aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/reverb.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-09-21 10:20:59 -0700
committerChris Robinson <[email protected]>2017-09-21 10:20:59 -0700
commitfc9cb2fbd8b96fd4bddf3123b5c5479bec089d7f (patch)
tree9891d7339ffb5246680a989aa1b0bcf8cfbabf79 /Alc/effects/reverb.c
parent90cedbea49e9756d97033962f6c1145991bc7095 (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.
Diffstat (limited to 'Alc/effects/reverb.c')
-rw-r--r--Alc/effects/reverb.c11
1 files changed, 7 insertions, 4 deletions
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,