diff options
Diffstat (limited to 'Alc/alcEcho.c')
-rw-r--r-- | Alc/alcEcho.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index d6f7fbb3..e6ecac5c 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -49,7 +49,7 @@ typedef struct ALechoState { ALfloat FeedGain; - ALfloat Scale; + ALfloat Gain[OUTPUTCHANNELS]; FILTER iirFilter; ALfloat history[2]; @@ -90,8 +90,13 @@ static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device) for(i = 0;i < state->BufferLength;i++) state->SampleBuffer[i] = 0.0f; - state->Scale = aluSqrt(Device->NumChan / 6.0f); - state->Scale = __min(state->Scale, 1.0f); + for(i = 0;i < OUTPUTCHANNELS;i++) + state->Gain[i] = 0.0f; + for(i = 0;i < Device->NumChan;i++) + { + Channel chan = Device->Speaker2Chan[i]; + state->Gain[chan] = 1.0f; + } return AL_TRUE; } @@ -127,7 +132,7 @@ 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 * state->Scale; + const ALfloat gain = Slot->Gain; ALfloat samp[2], smp; ALuint i; @@ -151,12 +156,12 @@ static ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuin samp[0] *= gain; samp[1] *= gain; - SamplesOut[i][FRONT_LEFT] += samp[0]; - SamplesOut[i][FRONT_RIGHT] += samp[1]; - SamplesOut[i][SIDE_LEFT] += samp[0]; - SamplesOut[i][SIDE_RIGHT] += samp[1]; - SamplesOut[i][BACK_LEFT] += samp[0]; - SamplesOut[i][BACK_RIGHT] += samp[1]; + 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]; + SamplesOut[i][SIDE_RIGHT] += state->Gain[SIDE_RIGHT] * samp[1]; + SamplesOut[i][BACK_LEFT] += state->Gain[BACK_LEFT] * samp[0]; + SamplesOut[i][BACK_RIGHT] += state->Gain[BACK_RIGHT] * samp[1]; } state->Offset = offset; } @@ -183,8 +188,6 @@ ALeffectState *EchoCreate(void) state->GainL = 0.0f; state->GainR = 0.0f; - state->Scale = 1.0f; - state->iirFilter.coeff = 0.0f; state->iirFilter.history[0] = 0.0f; state->iirFilter.history[1] = 0.0f; |