Author: sagamusix
Date: Thu Jun 13 21:42:29 2024
New Revision: 21023
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21023
Log:
[Fix] XM: oggmod doesn't know what stereo samples are. As it is difficult (if possible at all) to reconstruct the waveform of the right channel, we restrict importing of those samples as mono samples instead of not importing them at all (which is what happened until now). The stereo sample path remains present as in theory someone could write a bugfixed oggmod tool that writes proper stereo samples.
Modified:
trunk/OpenMPT/soundlib/Load_xm.cpp
Modified: trunk/OpenMPT/soundlib/Load_xm.cpp
==============================================================================
--- trunk/OpenMPT/soundlib/Load_xm.cpp Thu Jun 13 20:04:02 2024 (r21022)
+++ trunk/OpenMPT/soundlib/Load_xm.cpp Thu Jun 13 21:42:29 2024 (r21023)
@@ -480,6 +480,13 @@
{
decodedSamples = ret;
LimitMax(decodedSamples, mpt::saturate_cast<long>(sample.nLength - offset));
+ if(offset == 0 && channels == 1 && sample.GetNumChannels() == 2)
+ {
+ // oggmod doesn't know what stereo samples are, so it treats them as mono samples, but doesn't clear the unknown stereo flag.
+ // We just take the left channel in this case, as it is difficult (if possible at all) to properly reconstruct the waveform of the right channel.
+ // Due to XM's delta-encoding and Vorbis being a lossless codec, samples could distort easily even when the delta encoding was off by a very small amount.
+ sample.uFlags.reset(CHN_STEREO);
+ }
if(decodedSamples > 0 && channels == sample.GetNumChannels())
{
if(sample.uFlags[CHN_16BIT])
|