From 044662e4b709e0c446e16a849088c418c91d205c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Fri, 6 Aug 2010 07:55:00 -0700 Subject: Calculate gain steps once during a source mix --- Alc/mixer.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'Alc') diff --git a/Alc/mixer.c b/Alc/mixer.c index 4907c72e..54ec28be 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -119,9 +119,6 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, DeviceFreq = ALContext->Device->Frequency; - rampLength = DeviceFreq * MIN_RAMP_LENGTH / 1000; - rampLength = max(rampLength, SamplesToDo); - /* Find buffer format */ Frequency = 0; Channels = 0; @@ -175,6 +172,17 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, WetSend[i] = ALSource->WetGains[i]; } + /* Compute the gain steps for each output channel */ + rampLength = DeviceFreq * MIN_RAMP_LENGTH / 1000; + rampLength = max(rampLength, SamplesToDo); + + for(i = 0;i < OUTPUTCHANNELS;i++) + dryGainStep[i] = (ALSource->Params.DryGains[i]-DrySend[i]) / + rampLength; + for(i = 0;i < MAX_SENDS;i++) + wetGainStep[i] = (ALSource->Params.WetGains[i]-WetSend[i]) / + rampLength; + DryFilter = &ALSource->Params.iirFilter; for(i = 0;i < MAX_SENDS;i++) { @@ -247,14 +255,6 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, else memset(&Data[DataSize*Channels], 0, (BUFFER_PADDING*Channels*Bytes)); - /* Compute the gain steps for each output channel */ - for(i = 0;i < OUTPUTCHANNELS;i++) - dryGainStep[i] = (ALSource->Params.DryGains[i]-DrySend[i]) / - rampLength; - for(i = 0;i < MAX_SENDS;i++) - wetGainStep[i] = (ALSource->Params.WetGains[i]-WetSend[i]) / - rampLength; - /* Figure out how many samples we can mix. */ DataSize64 = LoopEnd; DataSize64 <<= FRACTIONBITS; -- cgit v1.2.3