Author: sagamusix
Date: Sat Mar 16 23:54:24 2024
New Revision: 20385
URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=20385
Log:
[Mod] Compressor DMO: Similar to Chorus / Flanger, avoid chance of reading from the wrong buffer offset at extremely high sample rates. In this particular case, the mix rate needs to be above 500 kHz before the overflow would occur.
Modified:
trunk/OpenMPT/soundlib/plugins/dmo/Compressor.cpp
Modified: trunk/OpenMPT/soundlib/plugins/dmo/Compressor.cpp
==============================================================================
--- trunk/OpenMPT/soundlib/plugins/dmo/Compressor.cpp Sat Mar 16 23:00:16 2024 (r20384)
+++ trunk/OpenMPT/soundlib/plugins/dmo/Compressor.cpp Sat Mar 16 23:54:24 2024 (r20385)
@@ -88,10 +88,10 @@
}
compGainPow >>= (31 - compGainInt);
- int32 readOffset = m_predelay + m_bufPos * 4096 + m_bufSize - 1;
+ int32 readOffset = m_predelay + m_bufSize - 1;
readOffset /= 4096;
- readOffset %= m_bufSize;
-
+ readOffset = (readOffset + m_bufPos) % m_bufSize;
+
float outGain = (static_cast<float>(compGainPow) * (1.0f / 2147483648.0f)) * m_gain;
*(out[0])++ = m_buffer[readOffset * 2] * outGain;
*(out[1])++ = m_buffer[readOffset * 2 + 1] * outGain;
|