aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-16 13:00:35 -0800
committerChris Robinson <[email protected]>2008-01-16 13:00:35 -0800
commit4742dedb4504f1d9925101a3aa7e5db27fc8370f (patch)
treeea8c3ebb67a7f62a95ec7cd3764a3126c6c5b64a
parent10a9bc62bf859ad3b97be9bda36fb0a737175774 (diff)
Don't clamp wet gain if there's no send slot, and move slot gain calculation
To remove an extra if check
-rw-r--r--Alc/ALu.c21
1 files 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));