From 2dc8e1f59f6e0cfa1735438fbcca7c1956b6eaad Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Fri, 7 Mar 2003 19:28:34 +0000 Subject: [PATCH] Try mixing differently; this might help sound quality for people using the fallback sound drivers. --- stepmania/src/RageSoundManager.cpp | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/stepmania/src/RageSoundManager.cpp b/stepmania/src/RageSoundManager.cpp index 5ff8e3605a..d4c04336b8 100644 --- a/stepmania/src/RageSoundManager.cpp +++ b/stepmania/src/RageSoundManager.cpp @@ -306,32 +306,13 @@ void SoundMixBuffer::write(const Sint16 *buf, unsigned size) } for(unsigned pos = 0; pos < size; ++pos) - { - Sint32 samp = buf[pos] * 32768; - - /* Scale volume: */ - samp = Sint32(samp * vol); - - /* Add and clip. Can't use clamp() here--we're clamping to - * the min and max of Sint32. */ - if(samp > 0 && mixbuf[pos] + samp < mixbuf[pos]) - mixbuf[pos] = INT_MAX; - else if(samp < 0 && mixbuf[pos] + samp > mixbuf[pos]) - mixbuf[pos] = INT_MIN; - else - mixbuf[pos] = mixbuf[pos] + samp; - } + mixbuf[pos] += buf[pos]; } void SoundMixBuffer::read(Sint16 *buf) { for(unsigned pos = 0; pos < mixbuf.size(); ++pos) - { - /* XXX: dither */ - Sint32 out = (mixbuf[pos]) / 32768; - out = clamp(out, -32768, 32767); - buf[pos] = Sint16(out); - } + buf[pos] = (Sint16) clamp(mixbuf[pos], -32768, 32767); mixbuf.erase(); }