From 4742dedb4504f1d9925101a3aa7e5db27fc8370f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 16 Jan 2008 13:00:35 -0800 Subject: [PATCH] Don't clamp wet gain if there's no send slot, and move slot gain calculation To remove an extra if check --- Alc/ALu.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Alc/ALu.c b/Alc/ALu.c index 0c02b778..df5ad6b0 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -366,18 +366,19 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, break; } - // Source Gain + Attenuation + // Source Gain + Attenuation and clamp to Min/Max Gain DryMix = SourceVolume * flAttenuation; + DryMix = __min(DryMix,MaxVolume); + DryMix = __max(DryMix,MinVolume); if(ALSource->Send[0].Slot) + { WetMix = SourceVolume * ((ALSource->WetGainAuto && ALSource->Send[0].Slot->AuxSendAuto) ? RoomAttenuation : 1.0f); + WetMix = __min(WetMix,MaxVolume); + WetMix = __max(WetMix,MinVolume); + } - // Clamp to Min/Max Gain - DryMix = __min(DryMix,MaxVolume); - DryMix = __max(DryMix,MinVolume); - WetMix = __min(WetMix,MaxVolume); - WetMix = __max(WetMix,MinVolume); //3. Apply directional soundcones SourceToListener[0] = -Position[0]; SourceToListener[1] = -Position[1]; @@ -471,9 +472,6 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, DryGainHF *= pow(ALSource->AirAbsorptionFactor * AIRABSORBGAINHF, Distance * MetersPerUnit); - if(ALSource->Send[0].Slot) - WetMix *= ALSource->Send[0].Slot->Gain; - //7. Convert normalized position into pannings, then into channel volumes aluNormalize(Position); switch(aluChannelsFromFormat(OutputFormat)) @@ -483,6 +481,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(1.0f); //Direct if(ALSource->Send[0].Slot) { + WetMix *= ALSource->Send[0].Slot->Gain; wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt(1.0f); //Room wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(1.0f); //Room } @@ -499,6 +498,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[FRONT_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt( PanningLR); //R Direct if(ALSource->Send[0].Slot) { + WetMix *= ALSource->Send[0].Slot->Gain; wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt(1.0f-PanningLR); //L Room wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt( PanningLR); //R Room } @@ -525,6 +525,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[BACK_RIGHT] = ConeVolume * ListenerGain * DryMix * aluSqrt(( PanningLR)*( PanningFB)); if(ALSource->Send[0].Slot) { + WetMix *= ALSource->Send[0].Slot->Gain; wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); wetsend[BACK_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB)); @@ -557,6 +558,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[FRONT_RIGHT] = 0.0f; if(ALSource->Send[0].Slot) { + WetMix *= ALSource->Send[0].Slot->Gain; wetsend[BACK_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[BACK_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); wetsend[SIDE_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB)); @@ -585,6 +587,7 @@ static ALvoid CalcSourceParams(ALCcontext *ALContext, ALsource *ALSource, drysend[BACK_RIGHT] = 0.0f; if(ALSource->Send[0].Slot) { + WetMix *= ALSource->Send[0].Slot->Gain; wetsend[FRONT_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*(1.0f-PanningFB)); wetsend[FRONT_RIGHT] = ListenerGain * WetMix * aluSqrt(( PanningLR)*(1.0f-PanningFB)); wetsend[SIDE_LEFT] = ListenerGain * WetMix * aluSqrt((1.0f-PanningLR)*( PanningFB)); -- 2.11.4.GIT