diff options
author | Max Horn | 2002-11-19 01:50:15 +0000 |
---|---|---|
committer | Max Horn | 2002-11-19 01:50:15 +0000 |
commit | 49d6b10fc39708d45c2057ec9e1150f00b2e033f (patch) | |
tree | 19ce0cf057d818d9ec18b7df17504d43b491b797 | |
parent | 24a1a2a369a1c74e143e3c2ee500d645d6fa6457 (diff) | |
download | scummvm-rg350-49d6b10fc39708d45c2057ec9e1150f00b2e033f.tar.gz scummvm-rg350-49d6b10fc39708d45c2057ec9e1150f00b2e033f.tar.bz2 scummvm-rg350-49d6b10fc39708d45c2057ec9e1150f00b2e033f.zip |
Patch #639931: ALL: Fix for possible mixer distortion
svn-id: r5602
-rw-r--r-- | sound/mixer.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index fe69e8aee1..9f6ec44b24 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -837,8 +837,10 @@ void SoundMixer::ChannelMP3::mix(int16 * data, uint len) { while ((_posInFrame < _synth.pcm.length) && (len > 0)) { int16 sample = (int16)((scale_sample(*ch) * volume) / 32); - *data++ += sample; - *data++ += sample; + *data = clamped_add_16(*data, sample); + data++; + *data = clamped_add_16(*data, sample); + data++; len--; ch++; _posInFrame++; @@ -957,8 +959,10 @@ void SoundMixer::ChannelMP3CDMusic::mix(int16 * data, uint len) { ch = _synth.pcm.samples[0] + _posInFrame; while ((_posInFrame < _synth.pcm.length) && (len > 0)) { int16 sample = (int16)((scale_sample(*ch++) * volume) / 32); - *data++ += sample; - *data++ += sample; + *data = clamped_add_16(*data, sample); + data++; + *data = clamped_add_16(*data, sample); + data++; len--; _posInFrame++; } @@ -1083,10 +1087,12 @@ void SoundMixer::ChannelVorbis::mix(int16 * data, uint len) { // Mix the samples in for (uint i = 0; i < len; i++) { int16 sample = (int16) ((int32) samples[i * channels] * volume / 256); - *data++ += sample; + *data = clamped_add_16(*data, sample); + data++; if (channels > 1) sample = (int16) ((int32) samples[i * channels + 1] * volume / 256); - *data++ += sample; + *data = clamped_add_16(*data, sample); + data++; } delete [] samples; |