From 7f15ccffb2cb74c493de8e20ec6a16cc350a1840 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 10 May 2017 09:03:17 +0000 Subject: [PATCH] Add some spaces for readability and update the position after forwarding to hopefully improve sound in GOB2. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4013 --- src/hardware/mixer.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/hardware/mixer.cpp b/src/hardware/mixer.cpp index 64d5707c..82e98a3e 100644 --- a/src/hardware/mixer.cpp +++ b/src/hardware/mixer.cpp @@ -299,21 +299,22 @@ inline void MixerChannel::AddSamples(Bitu len, const Type* data) { } void MixerChannel::AddStretched(Bitu len,Bit16s * data) { - if (done>=needed) { + if (done >= needed) { LOG_MSG("Can't add, buffer full"); return; } //Target samples this inputs gets stretched into - Bitu outlen=needed-done; + Bitu outlen = needed - done; Bitu index = 0; Bitu index_add = (len << FREQ_SHIFT)/outlen; - Bitu mixpos=mixer.pos+done; - done=needed; - Bitu pos=0; + Bitu mixpos = mixer.pos + done; + done = needed; + Bitu pos = 0; while (outlen--) { Bitu new_pos = index >> FREQ_SHIFT; if (pos != new_pos) { + pos = new_pos; //Forward the previous sample prevSample[0] = data[0]; data++; @@ -322,9 +323,9 @@ void MixerChannel::AddStretched(Bitu len,Bit16s * data) { Bits diff_mul = index & FREQ_MASK; index += index_add; mixpos &= MIXER_BUFMASK; - Bits sample = prevSample[0]+((diff*diff_mul) >> FREQ_SHIFT); - mixer.work[mixpos][0]+=sample*volmul[0]; - mixer.work[mixpos][1]+=sample*volmul[1]; + Bits sample = prevSample[0] + ((diff * diff_mul) >> FREQ_SHIFT); + mixer.work[mixpos][0] += sample * volmul[0]; + mixer.work[mixpos][1] += sample * volmul[1]; mixpos++; } }