aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c36
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h2
-rw-r--r--OpenAL32/alAuxEffectSlot.c2
3 files changed, 17 insertions, 23 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 7bf6f2ff..d7a8a89b 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -348,16 +348,16 @@ static ALboolean CalcEffectSlotParams(ALeffectslot *slot, ALCdevice *device)
slot->Params.RoomRolloff = props->Props.Reverb.RoomRolloffFactor;
slot->Params.DecayTime = props->Props.Reverb.DecayTime;
slot->Params.DecayHFRatio = props->Props.Reverb.DecayHFRatio;
- slot->Params.AirAbsorptionGainHF = props->Props.Reverb.AirAbsorptionGainHF;
slot->Params.DecayHFLimit = props->Props.Reverb.DecayHFLimit;
+ slot->Params.AirAbsorptionGainHF = props->Props.Reverb.AirAbsorptionGainHF;
}
else
{
slot->Params.RoomRolloff = 0.0f;
slot->Params.DecayTime = 0.0f;
slot->Params.DecayHFRatio = 0.0f;
- slot->Params.AirAbsorptionGainHF = 1.0f;
slot->Params.DecayHFLimit = AL_FALSE;
+ slot->Params.AirAbsorptionGainHF = 1.0f;
}
/* Swap effect states. No need to play with the ref counts since they keep
@@ -1079,7 +1079,6 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
const ALsizei NumSends = Device->NumAuxSends;
aluVector Position, Velocity, Direction, SourceToListener;
ALfloat Distance, ClampedDist, DopplerFactor;
- ALfloat RoomAirAbsorption[MAX_SENDS];
ALeffectslot *SendSlots[MAX_SENDS];
ALfloat RoomRolloff[MAX_SENDS];
ALfloat DecayDistance[MAX_SENDS];
@@ -1108,20 +1107,20 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
RoomRolloff[i] = 0.0f;
DecayDistance[i] = 0.0f;
DecayHFDistance[i] = 0.0f;
- RoomAirAbsorption[i] = 1.0f;
}
else if(SendSlots[i]->Params.AuxSendAuto)
{
RoomRolloff[i] = SendSlots[i]->Params.RoomRolloff + props->RoomRolloffFactor;
DecayDistance[i] = SendSlots[i]->Params.DecayTime * SPEEDOFSOUNDMETRESPERSEC;
DecayHFDistance[i] = DecayDistance[i] * SendSlots[i]->Params.DecayHFRatio;
- RoomAirAbsorption[i] = SendSlots[i]->Params.AirAbsorptionGainHF;
- if(SendSlots[i]->Params.DecayHFLimit && RoomAirAbsorption[i] < 1.0f)
+ if(SendSlots[i]->Params.DecayHFLimit)
{
- ALfloat limitRatio = log10f(REVERB_DECAY_GAIN) /
- (log10f(RoomAirAbsorption[i]) * DecayDistance[i]);
- limitRatio = minf(limitRatio, SendSlots[i]->Params.DecayHFRatio);
- DecayHFDistance[i] = minf(DecayHFDistance[i], limitRatio*DecayDistance[i]);
+ ALfloat airAbsorption = SendSlots[i]->Params.AirAbsorptionGainHF;
+ if(airAbsorption < 1.0f)
+ {
+ ALfloat limitRatio = log10f(REVERB_DECAY_GAIN) / log10f(airAbsorption);
+ DecayHFDistance[i] = minf(limitRatio, DecayHFDistance[i]);
+ }
}
}
else
@@ -1131,7 +1130,6 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
RoomRolloff[i] = props->RolloffFactor;
DecayDistance[i] = 0.0f;
DecayHFDistance[i] = 0.0f;
- RoomAirAbsorption[i] = AIRABSORBGAINHF;
}
if(!SendSlots[i])
@@ -1249,24 +1247,20 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
}
/* Distance-based air absorption */
- if(ClampedDist > props->RefDistance)
+ if(ClampedDist > props->RefDistance && props->RolloffFactor > 0.0f)
{
- ALfloat meters_base = (ClampedDist-props->RefDistance) * Listener->Params.MetersPerUnit;
+ ALfloat meters_base = (ClampedDist-props->RefDistance) * props->RolloffFactor *
+ Listener->Params.MetersPerUnit;
if(props->AirAbsorptionFactor > 0.0f)
{
- ALfloat absorb = props->AirAbsorptionFactor * meters_base;
- DryGainHF *= powf(AIRABSORBGAINHF, absorb*props->RolloffFactor);
+ ALfloat hfattn = powf(AIRABSORBGAINHF, meters_base * props->AirAbsorptionFactor);
+ DryGainHF *= hfattn;
for(i = 0;i < NumSends;i++)
- {
- if(RoomRolloff[i] > 0.0f)
- WetGainHF[i] *= powf(AIRABSORBGAINHF, absorb*RoomRolloff[i]);
- }
+ WetGainHF[i] *= hfattn;
}
if(props->WetGainAuto)
{
- meters_base *= props->RolloffFactor;
-
/* Apply a decay-time transformation to the wet path, based on the
* source distance in meters. The initial decay of the reverb
* effect is calculated and applied to the wet path.
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 7126f8f5..5be9ae7a 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -122,8 +122,8 @@ typedef struct ALeffectslot {
ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */
ALfloat DecayTime;
ALfloat DecayHFRatio;
- ALfloat AirAbsorptionGainHF;
ALboolean DecayHFLimit;
+ ALfloat AirAbsorptionGainHF;
} Params;
/* Self ID */
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index 8a990584..cd2c1e09 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -616,8 +616,8 @@ ALenum InitEffectSlot(ALeffectslot *slot)
slot->Params.RoomRolloff = 0.0f;
slot->Params.DecayTime = 0.0f;
slot->Params.DecayHFRatio = 0.0f;
- slot->Params.AirAbsorptionGainHF = 1.0f;
slot->Params.DecayHFLimit = AL_FALSE;
+ slot->Params.AirAbsorptionGainHF = 1.0f;
return AL_NO_ERROR;
}