From 923af8c3a6626a43f7564afe0de61fcd55f2fce1 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 26 May 2009 09:23:49 -0700 Subject: Don't update the source's gains in the sample mixing loop Update copies stored on the stack instead, then update the source after mixing --- Alc/ALu.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'Alc/ALu.c') diff --git a/Alc/ALu.c b/Alc/ALu.c index a875e204..f00fdafa 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -852,12 +852,10 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma static float DummyBuffer[BUFFERSIZE]; ALfloat *WetBuffer[MAX_SENDS]; ALfloat (*Matrix)[OUTPUTCHANNELS] = ALContext->ChannelMatrix; - ALfloat newDrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; - ALfloat newWetSend[MAX_SENDS]; + ALfloat DrySend[OUTPUTCHANNELS] = { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; + ALfloat WetSend[MAX_SENDS]; ALfloat DryGainHF = 0.0f; ALfloat WetGainHF[MAX_SENDS]; - ALfloat *DrySend; - ALfloat *WetSend; ALuint rampLength; ALfloat dryGainStep[OUTPUTCHANNELS]; ALfloat wetGainStep[MAX_SENDS]; @@ -958,12 +956,10 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma ALSource->Send[i].Slot->WetBuffer : DummyBuffer); } - DrySend = ALSource->DryGains; - WetSend = ALSource->WetGains; CalcSourceParams(ALContext, ALSource, (Channels==1) ? AL_TRUE : AL_FALSE, - newDrySend, newWetSend, &Pitch, + DrySend, WetSend, &Pitch, &DryGainHF, WetGainHF); Pitch = (Pitch*Frequency) / ALContext->Frequency; @@ -1029,22 +1025,22 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma if(ALSource->FirstStart && DataPosInt == 0 && DataPosFrac == 0) { for(i = 0;i < OUTPUTCHANNELS;i++) - { - DrySend[i] = newDrySend[i]; dryGainStep[i] = 0; - } for(i = 0;i < MAX_SENDS;i++) - { - WetSend[i] = newWetSend[i]; wetGainStep[i] = 0; - } } else { for(i = 0;i < OUTPUTCHANNELS;i++) - dryGainStep[i] = (newDrySend[i]-DrySend[i]) / rampLength; + { + dryGainStep[i] = (DrySend[i]-ALSource->DryGains[i]) / rampLength; + DrySend[i] = ALSource->DryGains[i]; + } for(i = 0;i < MAX_SENDS;i++) - wetGainStep[i] = (newWetSend[i]-WetSend[i]) / rampLength; + { + wetGainStep[i] = (WetSend[i]-ALSource->WetGains[i]) / rampLength; + WetSend[i] = ALSource->WetGains[i]; + } } ALSource->FirstStart = AL_FALSE; @@ -1233,6 +1229,10 @@ ALvoid aluMixData(ALCcontext *ALContext,ALvoid *buffer,ALsizei size,ALenum forma //Update source info ALSource->position = DataPosInt; ALSource->position_fraction = DataPosFrac; + for(i = 0;i < OUTPUTCHANNELS;i++) + ALSource->DryGains[i] = DrySend[i]; + for(i = 0;i < MAX_SENDS;i++) + ALSource->WetGains[i] = WetSend[i]; skipmix: ; } -- cgit v1.2.3