diff options
author | Chris Robinson <[email protected]> | 2017-09-22 05:42:04 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-09-22 05:42:04 -0700 |
commit | 369f52a0d76e1be1407441ca0bb67343cffa95f3 (patch) | |
tree | ab40abba1c463603f9401a7dc08cf207379b9794 /Alc | |
parent | 9007b7735519b049668ccd0c787ef52a00934386 (diff) |
Add an option to ignore the app's speed of sound for reverb decay
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 5 | ||||
-rw-r--r-- | Alc/ALu.c | 12 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 4 |
3 files changed, 17 insertions, 4 deletions
@@ -885,6 +885,10 @@ static void alc_init(void) if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) ZScale *= -1.0f; + str = getenv("__ALSOFT_REVERB_IGNORES_SOUND_SPEED"); + if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) + OverrideReverbSpeedOfSound = AL_TRUE; + ret = altss_create(&LocalContext, ReleaseThreadCtx); assert(ret == althrd_success); @@ -2540,6 +2544,7 @@ static ALvoid InitContext(ALCcontext *Context) listener->Params.MetersPerUnit = listener->MetersPerUnit; listener->Params.DopplerFactor = 1.0f; listener->Params.SpeedOfSound = SPEEDOFSOUNDMETRESPERSEC; + listener->Params.ReverbSpeedOfSound = SPEEDOFSOUNDMETRESPERSEC; ATOMIC_INIT(&listener->Update, NULL); ATOMIC_INIT(&listener->FreeList, NULL); @@ -89,6 +89,9 @@ ALfloat ConeScale = 1.0f; /* Localized Z scalar for mono sources */ ALfloat ZScale = 1.0f; +/* Force default speed of sound for distance-related reverb decay. */ +ALboolean OverrideReverbSpeedOfSound = AL_FALSE; + const aluMatrixf IdentityMatrixf = {{ { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -312,6 +315,11 @@ static ALboolean CalcListenerParams(ALCcontext *Context) Listener->Params.DopplerFactor = props->DopplerFactor; Listener->Params.SpeedOfSound = props->SpeedOfSound * props->DopplerVelocity; + if(OverrideReverbSpeedOfSound) + Listener->Params.ReverbSpeedOfSound = SPEEDOFSOUNDMETRESPERSEC; + else + Listener->Params.ReverbSpeedOfSound = Listener->Params.SpeedOfSound * + Listener->Params.MetersPerUnit; Listener->Params.SourceDistanceModel = props->SourceDistanceModel; Listener->Params.DistanceModel = props->DistanceModel; @@ -1105,8 +1113,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 * Listener->Params.SpeedOfSound * - Listener->Params.MetersPerUnit; + DecayDistance[i] = SendSlots[i]->Params.DecayTime * + Listener->Params.ReverbSpeedOfSound; 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 455a433a..ee7954c4 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -1362,8 +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, Listener->Params.SpeedOfSound * - Listener->Params.MetersPerUnit); + props->Reverb.DecayTime, Listener->Params.ReverbSpeedOfSound + ); /* Calculate the LF/HF decay times. */ lfDecayTime = clampf(props->Reverb.DecayTime * props->Reverb.DecayLFRatio, |