Clear reverb gain coefficients when doing a device update

This commit is contained in:
Chris Robinson 2018-09-23 02:22:23 -07:00
parent 800326d37a
commit db6905bf57

View File

@ -554,6 +554,7 @@ static ALboolean ReverbState_deviceUpdate(ReverbState *State, ALCdevice *Device)
{
ALuint frequency = Device->Frequency;
ALfloat multiplier;
ALsizei i, j;
/* Allocate the delay lines. */
if(!AllocLines(frequency, State))
@ -566,6 +567,54 @@ static ALboolean ReverbState_deviceUpdate(ReverbState *State, ALCdevice *Device)
EARLY_TAP_LENGTHS[NUM_LINES-1]*multiplier) *
frequency);
/* Clear filters and gain coefficients since the delay lines were all just
* cleared (if not reallocated).
*/
for(i = 0;i < NUM_LINES;i++)
{
BiquadFilter_clear(&State->Filter[i].Lp);
BiquadFilter_clear(&State->Filter[i].Hp);
}
for(i = 0;i < NUM_LINES;i++)
{
State->EarlyDelayCoeff[i][0] = 0.0f;
State->EarlyDelayCoeff[i][1] = 0.0f;
}
for(i = 0;i < NUM_LINES;i++)
{
State->Early.Coeff[i][0] = 0.0f;
State->Early.Coeff[i][1] = 0.0f;
}
State->Late.DensityGain[0] = 0.0f;
State->Late.DensityGain[1] = 0.0f;
for(i = 0;i < NUM_LINES;i++)
{
State->Late.T60[i].MidGain[0] = 0.0f;
State->Late.T60[i].MidGain[1] = 0.0f;
BiquadFilter_clear(&State->Late.T60[i].HFFilter);
BiquadFilter_clear(&State->Late.T60[i].LFFilter);
}
for(i = 0;i < NUM_LINES;i++)
{
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
{
State->Early.CurrentGain[i][j] = 0.0f;
State->Early.PanGain[i][j] = 0.0f;
State->Late.CurrentGain[i][j] = 0.0f;
State->Late.PanGain[i][j] = 0.0f;
}
}
/* Reset counters and offset base. */
State->FadeCount = 0;
State->MaxUpdate[0] = MAX_UPDATE_SAMPLES;
State->MaxUpdate[1] = MAX_UPDATE_SAMPLES;
State->Offset = 0;
return AL_TRUE;
}