diff options
author | Chris Robinson <[email protected]> | 2017-12-19 13:49:49 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2017-12-19 13:52:05 -0800 |
commit | 52569ef56268a47b1c993f56faf057673135ec36 (patch) | |
tree | 6ef36b6221649ad810d3e7775b9a3e3df7bfe63b /Alc/effects/chorus.c | |
parent | 661bd054aa94a5ce99433cf6fd4b8f99ed77f87e (diff) |
Fade gains in the chorus and flanger output
Diffstat (limited to 'Alc/effects/chorus.c')
-rw-r--r-- | Alc/effects/chorus.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index fc49d170..25fa81ba 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -48,7 +48,10 @@ typedef struct ALchorusState { ALint lfo_disp; /* Gains for left and right sides */ - ALfloat Gain[2][MAX_OUTPUT_CHANNELS]; + struct { + ALfloat Current[MAX_OUTPUT_CHANNELS]; + ALfloat Target[MAX_OUTPUT_CHANNELS]; + } Gains[2]; /* effect parameters */ enum ChorusWaveForm waveform; @@ -90,7 +93,6 @@ static ALvoid ALchorusState_Destruct(ALchorusState *state) static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Device) { ALsizei maxlen; - ALsizei it; maxlen = fastf2i(AL_CHORUS_MAX_DELAY * 2.0f * Device->Frequency) + 1; maxlen = NextPowerOf2(maxlen); @@ -106,8 +108,8 @@ static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Dev state->BufferLength = maxlen; } - for(it = 0;it < state->BufferLength;it++) - state->SampleBuffer[it] = 0.0f; + memset(state->SampleBuffer, 0, state->BufferLength*sizeof(ALfloat)); + memset(state->Gains, 0, sizeof(state->Gains)); return AL_TRUE; } @@ -144,9 +146,9 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCcontext *Conte /* Gains for left and right sides */ CalcAngleCoeffs(-F_PI_2, 0.0f, 0.0f, coeffs); - ComputePanningGains(device->Dry, coeffs, Slot->Params.Gain, state->Gain[0]); + ComputePanningGains(device->Dry, coeffs, Slot->Params.Gain, state->Gains[0].Target); CalcAngleCoeffs( F_PI_2, 0.0f, 0.0f, coeffs); - ComputePanningGains(device->Dry, coeffs, Slot->Params.Gain, state->Gain[1]); + ComputePanningGains(device->Dry, coeffs, Slot->Params.Gain, state->Gains[1].Target); phase = props->Chorus.Phase; rate = props->Chorus.Rate; @@ -271,8 +273,8 @@ static ALvoid ALchorusState_process(ALchorusState *state, ALsizei SamplesToDo, c state->lfo_offset = (state->lfo_offset+todo) % state->lfo_range; for(c = 0;c < 2;c++) - MixSamples(temps[c], NumChannels, SamplesOut, state->Gain[c], state->Gain[c], - 0, base, todo); + MixSamples(temps[c], NumChannels, SamplesOut, state->Gains[c].Current, + state->Gains[c].Target, SamplesToDo-base, base, todo); base += todo; } |