aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-03-11 22:40:08 -0700
committerChris Robinson <[email protected]>2018-03-11 22:40:08 -0700
commit8eb7a94e1c07a8b3d74f84886c493d1a7dada7de (patch)
treefa0d499201c0486b2b4da7c20abbf02443f98a98
parent6b35a4534f1047c8e6ec630cbae89ea3e25e5d74 (diff)
Apply a distance decay on the source send for the reverb's DecayLFRatio
-rw-r--r--Alc/ALu.c12
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h1
-rw-r--r--OpenAL32/alAuxEffectSlot.c1
3 files changed, 12 insertions, 2 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 12708cc5..1aa35cb7 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -457,6 +457,7 @@ static bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool f
{
slot->Params.RoomRolloff = props->Props.Reverb.RoomRolloffFactor;
slot->Params.DecayTime = props->Props.Reverb.DecayTime;
+ slot->Params.DecayLFRatio = props->Props.Reverb.DecayLFRatio;
slot->Params.DecayHFRatio = props->Props.Reverb.DecayHFRatio;
slot->Params.DecayHFLimit = props->Props.Reverb.DecayHFLimit;
slot->Params.AirAbsorptionGainHF = props->Props.Reverb.AirAbsorptionGainHF;
@@ -465,6 +466,7 @@ static bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool f
{
slot->Params.RoomRolloff = 0.0f;
slot->Params.DecayTime = 0.0f;
+ slot->Params.DecayLFRatio = 0.0f;
slot->Params.DecayHFRatio = 0.0f;
slot->Params.DecayHFLimit = AL_FALSE;
slot->Params.AirAbsorptionGainHF = 1.0f;
@@ -1186,6 +1188,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
ALeffectslot *SendSlots[MAX_SENDS];
ALfloat RoomRolloff[MAX_SENDS];
ALfloat DecayDistance[MAX_SENDS];
+ ALfloat DecayLFDistance[MAX_SENDS];
ALfloat DecayHFDistance[MAX_SENDS];
ALfloat DryGain, DryGainHF, DryGainLF;
ALfloat WetGain[MAX_SENDS];
@@ -1210,6 +1213,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
SendSlots[i] = NULL;
RoomRolloff[i] = 0.0f;
DecayDistance[i] = 0.0f;
+ DecayLFDistance[i] = 0.0f;
DecayHFDistance[i] = 0.0f;
}
else if(SendSlots[i]->Params.AuxSendAuto)
@@ -1220,6 +1224,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
*/
DecayDistance[i] = SendSlots[i]->Params.DecayTime *
Listener->Params.ReverbSpeedOfSound;
+ DecayLFDistance[i] = DecayDistance[i] * SendSlots[i]->Params.DecayLFRatio;
DecayHFDistance[i] = DecayDistance[i] * SendSlots[i]->Params.DecayHFRatio;
if(SendSlots[i]->Params.DecayHFLimit)
{
@@ -1242,6 +1247,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
* effect slot is the same as the dry path, sans filter effects */
RoomRolloff[i] = props->RolloffFactor;
DecayDistance[i] = 0.0f;
+ DecayLFDistance[i] = 0.0f;
DecayHFDistance[i] = 0.0f;
}
@@ -1386,7 +1392,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
*/
for(i = 0;i < NumSends;i++)
{
- ALfloat gain;
+ ALfloat gain, gainhf, gainlf;
if(!(DecayDistance[i] > 0.0f))
continue;
@@ -1398,8 +1404,10 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop
*/
if(gain > 0.0f)
{
- ALfloat gainhf = powf(REVERB_DECAY_GAIN, meters_base/DecayHFDistance[i]);
+ gainhf = powf(REVERB_DECAY_GAIN, meters_base/DecayHFDistance[i]);
WetGainHF[i] *= minf(gainhf / gain, 1.0f);
+ gainlf = powf(REVERB_DECAY_GAIN, meters_base/DecayLFDistance[i]);
+ WetGainLF[i] *= minf(gainlf / gain, 1.0f);
}
}
}
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index 36f09782..61c72153 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -127,6 +127,7 @@ typedef struct ALeffectslot {
ALfloat RoomRolloff; /* Added to the source's room rolloff, not multiplied. */
ALfloat DecayTime;
+ ALfloat DecayLFRatio;
ALfloat DecayHFRatio;
ALboolean DecayHFLimit;
ALfloat AirAbsorptionGainHF;
diff --git a/OpenAL32/alAuxEffectSlot.c b/OpenAL32/alAuxEffectSlot.c
index d4e6bf75..301244a0 100644
--- a/OpenAL32/alAuxEffectSlot.c
+++ b/OpenAL32/alAuxEffectSlot.c
@@ -686,6 +686,7 @@ ALenum InitEffectSlot(ALeffectslot *slot)
slot->Params.EffectState = slot->Effect.State;
slot->Params.RoomRolloff = 0.0f;
slot->Params.DecayTime = 0.0f;
+ slot->Params.DecayLFRatio = 0.0f;
slot->Params.DecayHFRatio = 0.0f;
slot->Params.DecayHFLimit = AL_FALSE;
slot->Params.AirAbsorptionGainHF = 1.0f;