diff options
author | Chris Robinson <[email protected]> | 2017-04-25 22:10:27 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-04-25 22:10:27 -0700 |
commit | ad782c00007ae7a39352bb649a3cfb957fa2135d (patch) | |
tree | 26b946de74d06672d543ce92fc38e111a61ed7b8 /Alc | |
parent | a0a41921fc28a1ff76a5850936cb32e912887735 (diff) |
Skip mixing the fade out step when starting silent
Unfortunately it can't skip mixing the fade in when going to silence because
the history needs to be up to date.
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/mixer.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index 2070f859..39def41f 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -507,25 +507,32 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei } else { - HrtfState backupstate = parms->Hrtf.State; ALfloat gain; /* The old coefficients need to fade to silence * completely since they'll be replaced after the mix. * So it needs to fade out over DstBufferSize instead * of Counter. + * + * Don't bother with the fade out when starting from + * silence. */ - hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Old.Coeffs); - hrtfparams.Delay[0] = parms->Hrtf.Old.Delay[0]; - hrtfparams.Delay[1] = parms->Hrtf.Old.Delay[1]; - hrtfparams.Gain = parms->Hrtf.Old.Gain; - hrtfparams.GainStep = -hrtfparams.Gain / - (ALfloat)DstBufferSize; - MixHrtfSamples( - voice->Direct.Buffer[lidx], voice->Direct.Buffer[ridx], - samples, voice->Offset, OutPos, IrSize, &hrtfparams, - &backupstate, DstBufferSize - ); + if(parms->Hrtf.Old.Gain > GAIN_SILENCE_THRESHOLD) + { + HrtfState backupstate = parms->Hrtf.State; + + hrtfparams.Coeffs = SAFE_CONST(ALfloat2*,parms->Hrtf.Old.Coeffs); + hrtfparams.Delay[0] = parms->Hrtf.Old.Delay[0]; + hrtfparams.Delay[1] = parms->Hrtf.Old.Delay[1]; + hrtfparams.Gain = parms->Hrtf.Old.Gain; + hrtfparams.GainStep = -hrtfparams.Gain / + (ALfloat)DstBufferSize; + MixHrtfSamples( + voice->Direct.Buffer[lidx], voice->Direct.Buffer[ridx], + samples, voice->Offset, OutPos, IrSize, &hrtfparams, + &backupstate, DstBufferSize + ); + } /* The new coefficients need to fade in completely * since they're replacing the old ones. To keep the |