aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/alcEcho.c
diff options
context:
space:
mode:
Diffstat (limited to 'Alc/alcEcho.c')
-rw-r--r--Alc/alcEcho.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c
index d9700527..d6f7fbb3 100644
--- a/Alc/alcEcho.c
+++ b/Alc/alcEcho.c
@@ -49,6 +49,8 @@ typedef struct ALechoState {
ALfloat FeedGain;
+ ALfloat Scale;
+
FILTER iirFilter;
ALfloat history[2];
} ALechoState;
@@ -88,6 +90,9 @@ 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);
+
return AL_TRUE;
}
@@ -122,7 +127,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;
+ const ALfloat gain = Slot->Gain * state->Scale;
ALfloat samp[2], smp;
ALuint i;
@@ -178,6 +183,8 @@ 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;