aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcEcho.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-07-16 03:35:51 -0700
committerChris Robinson <[email protected]>2011-07-16 03:35:51 -0700
commitce6db53e5f63c5445e5884ac91d4ce4030be4198 (patch)
tree223e23c82c50bc8ea194e20b471a149e920ee105 /Alc/alcEcho.c
parent292ea0607ddd3df4edced130cc041ba2de13cf27 (diff)
Apply the slot gain during the effect update method
Diffstat (limited to 'Alc/alcEcho.c')
-rw-r--r--Alc/alcEcho.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c
index f60290f9..b62c124a 100644
--- a/Alc/alcEcho.c
+++ b/Alc/alcEcho.c
@@ -90,22 +90,16 @@ static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
for(i = 0;i < state->BufferLength;i++)
state->SampleBuffer[i] = 0.0f;
- for(i = 0;i < MAXCHANNELS;i++)
- state->Gain[i] = 0.0f;
- for(i = 0;i < Device->NumChan;i++)
- {
- enum Channel chan = Device->Speaker2Chan[i];
- state->Gain[chan] = 1.0f;
- }
-
return AL_TRUE;
}
static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)
{
ALechoState *state = (ALechoState*)effect;
- ALuint frequency = Context->Device->Frequency;
- ALfloat lrpan, cw, g;
+ ALCdevice *Device = Context->Device;
+ ALuint frequency = Device->Frequency;
+ ALfloat lrpan, cw, g, gain;
+ ALuint i;
state->Tap[0].delay = (ALuint)(Slot->effect.Params.Echo.Delay * frequency) + 1;
state->Tap[1].delay = (ALuint)(Slot->effect.Params.Echo.LRDelay * frequency);
@@ -120,6 +114,15 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeff
cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency);
g = 1.0f - Slot->effect.Params.Echo.Damping;
state->iirFilter.coeff = lpCoeffCalc(g, cw);
+
+ gain = Slot->Gain;
+ for(i = 0;i < MAXCHANNELS;i++)
+ state->Gain[i] = 0.0f;
+ for(i = 0;i < Device->NumChan;i++)
+ {
+ enum Channel chan = Device->Speaker2Chan[i];
+ state->Gain[chan] = gain;
+ }
}
static ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])
@@ -129,9 +132,9 @@ static ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuin
const ALuint tap1 = state->Tap[0].delay;
const ALuint tap2 = state->Tap[1].delay;
ALuint offset = state->Offset;
- const ALfloat gain = Slot->Gain;
ALfloat samp[2], smp;
ALuint i;
+ (void)Slot;
for(i = 0;i < SamplesToDo;i++,offset++)
{
@@ -149,10 +152,6 @@ static ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuin
smp = lpFilter2P(&state->iirFilter, 0, smp+SamplesIn[i]);
state->SampleBuffer[offset&mask] = smp * state->FeedGain;
- // Apply slot gain
- samp[0] *= gain;
- samp[1] *= gain;
-
SamplesOut[i][FRONT_LEFT] += state->Gain[FRONT_LEFT] * samp[0];
SamplesOut[i][FRONT_RIGHT] += state->Gain[FRONT_RIGHT] * samp[1];
SamplesOut[i][SIDE_LEFT] += state->Gain[SIDE_LEFT] * samp[0];