Add an option to ignore the app's speed of sound for reverb decay
This commit is contained in:
parent
9007b77355
commit
369f52a0d7
@ -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);
|
||||
|
12
Alc/ALu.c
12
Alc/ALu.c
@ -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)
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -50,7 +50,8 @@ typedef struct ALlistener {
|
||||
ALfloat MetersPerUnit;
|
||||
|
||||
ALfloat DopplerFactor;
|
||||
ALfloat SpeedOfSound;
|
||||
ALfloat SpeedOfSound; /* in units per sec! */
|
||||
ALfloat ReverbSpeedOfSound; /* in meters per sec! */
|
||||
|
||||
ALboolean SourceDistanceModel;
|
||||
enum DistanceModel DistanceModel;
|
||||
|
@ -516,6 +516,7 @@ void aluHandleDisconnect(ALCdevice *device);
|
||||
|
||||
extern ALfloat ConeScale;
|
||||
extern ALfloat ZScale;
|
||||
extern ALboolean OverrideReverbSpeedOfSound;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -79,3 +79,13 @@ which some applications make use of to protect against partial updates. In an
|
||||
attempt to standardize on that behavior, OpenAL Soft has changed those methods
|
||||
accordingly. Setting this to "ignore" restores the previous no-op behavior for
|
||||
applications that interact poorly with the new behavior.
|
||||
|
||||
__ALSOFT_REVERB_IGNORES_SOUND_SPEED
|
||||
Older versions of OpenAL Soft ignored the app-specified speed of sound when
|
||||
calculating distance-related reverb decays and always assumed the default
|
||||
343.3m/s. Now, both of the AL_SPEED_OF_SOUND and AL_METERS_PER_UNIT properties
|
||||
are taken into account for speed of sound adjustments to have an appropriate
|
||||
affect on the reverb decay. Consequently, applications that use reverb but
|
||||
don't set these properties properly may find the reverb decay too strong.
|
||||
Setting this to "true" or "1" will revert to the old behavior for those apps
|
||||
and assume the default speed of sound for reverb.
|
||||
|
Loading…
x
Reference in New Issue
Block a user