diff options
author | Chris Robinson <[email protected]> | 2017-09-21 10:20:59 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-09-21 10:20:59 -0700 |
commit | fc9cb2fbd8b96fd4bddf3123b5c5479bec089d7f (patch) | |
tree | 9891d7339ffb5246680a989aa1b0bcf8cfbabf79 | |
parent | 90cedbea49e9756d97033962f6c1145991bc7095 (diff) |
Use the app-specified speed of sound for reverb decay
Specifically, the initial reverb decay as determined by the source distance,
and the reverb decayhf limit from air absorption.
-rw-r--r-- | Alc/ALu.c | 3 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 11 |
2 files changed, 9 insertions, 5 deletions
@@ -1105,7 +1105,8 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALvoiceProps *prop else if(SendSlots[i]->Params.AuxSendAuto) { RoomRolloff[i] = SendSlots[i]->Params.RoomRolloff + props->RoomRolloffFactor; - DecayDistance[i] = SendSlots[i]->Params.DecayTime * SPEEDOFSOUNDMETRESPERSEC; + DecayDistance[i] = SendSlots[i]->Params.DecayTime * Listener->Params.SpeedOfSound * + Listener->Params.MetersPerUnit; DecayHFDistance[i] = DecayDistance[i] * SendSlots[i]->Params.DecayHFRatio; if(SendSlots[i]->Params.DecayHFLimit) { diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 75790eae..455a433a 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -29,6 +29,7 @@ #include "alAuxEffectSlot.h" #include "alEffect.h" #include "alFilter.h" +#include "alListener.h" #include "alError.h" #include "mixer_defs.h" @@ -694,7 +695,7 @@ static inline ALvoid CalcMatrixCoeffs(const ALfloat diffusion, ALfloat *x, ALflo * filters. */ static ALfloat CalcLimitedHfRatio(const ALfloat hfRatio, const ALfloat airAbsorptionGainHF, - const ALfloat decayTime) + const ALfloat decayTime, const ALfloat SpeedOfSound) { ALfloat limitRatio; @@ -703,8 +704,8 @@ static ALfloat CalcLimitedHfRatio(const ALfloat hfRatio, const ALfloat airAbsorp * equation, solve for HF ratio. The delay length is cancelled out of * the equation, so it can be calculated once for all lines. */ - limitRatio = 1.0f / (CalcDecayLength(airAbsorptionGainHF, decayTime) * - SPEEDOFSOUNDMETRESPERSEC); + limitRatio = 1.0f / (CalcDecayLength(airAbsorptionGainHF, decayTime) * SpeedOfSound); + /* Using the limit calculated above, apply the upper bound to the HF * ratio. Also need to limit the result to a minimum of 0.1, just like * the HF ratio parameter. @@ -1310,6 +1311,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection static ALvoid ALreverbState_update(ALreverbState *State, const ALCcontext *Context, const ALeffectslot *Slot, const ALeffectProps *props) { const ALCdevice *Device = Context->Device; + const ALlistener *Listener = Context->Listener; ALuint frequency = Device->Frequency; ALfloat lfScale, hfScale, hfRatio; ALfloat lfDecayTime, hfDecayTime; @@ -1360,7 +1362,8 @@ static ALvoid ALreverbState_update(ALreverbState *State, const ALCcontext *Conte hfRatio = props->Reverb.DecayHFRatio; if(props->Reverb.DecayHFLimit && props->Reverb.AirAbsorptionGainHF < 1.0f) hfRatio = CalcLimitedHfRatio(hfRatio, props->Reverb.AirAbsorptionGainHF, - props->Reverb.DecayTime); + props->Reverb.DecayTime, Listener->Params.SpeedOfSound * + Listener->Params.MetersPerUnit); /* Calculate the LF/HF decay times. */ lfDecayTime = clampf(props->Reverb.DecayTime * props->Reverb.DecayLFRatio, |