aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-12-19 13:49:49 -0800
committerChris Robinson <[email protected]>2017-12-19 13:52:05 -0800
commit52569ef56268a47b1c993f56faf057673135ec36 (patch)
tree6ef36b6221649ad810d3e7775b9a3e3df7bfe63b
parent661bd054aa94a5ce99433cf6fd4b8f99ed77f87e (diff)
Fade gains in the chorus and flanger output
-rw-r--r--Alc/effects/chorus.c18
-rw-r--r--Alc/effects/flanger.c18
2 files changed, 20 insertions, 16 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;
}
diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c
index bbd16059..75b72dec 100644
--- a/Alc/effects/flanger.c
+++ b/Alc/effects/flanger.c
@@ -48,7 +48,10 @@ typedef struct ALflangerState {
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 FlangerWaveForm waveform;
@@ -90,7 +93,6 @@ static ALvoid ALflangerState_Destruct(ALflangerState *state)
static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *Device)
{
ALsizei maxlen;
- ALsizei it;
maxlen = fastf2i(AL_FLANGER_MAX_DELAY * 2.0f * Device->Frequency) + 1;
maxlen = NextPowerOf2(maxlen);
@@ -106,8 +108,8 @@ static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *D
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 ALflangerState_update(ALflangerState *state, const ALCcontext *con
/* 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->Flanger.Phase;
rate = props->Flanger.Rate;
@@ -270,8 +272,8 @@ static ALvoid ALflangerState_process(ALflangerState *state, ALsizei SamplesToDo,
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, 0, base, todo);
base += todo;
}