diff options
author | Chris Robinson <[email protected]> | 2010-05-12 04:56:03 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-05-12 04:56:03 -0700 |
commit | e3a70e50216850aff2721ce3cc4a3e1c2cee311f (patch) | |
tree | bb9a7f3bbd9ff90903f14360ab127eb1b6275ce2 /Alc/alcEcho.c | |
parent | af4faaf6660d02ce593e07b97d05020b44ed06e4 (diff) |
Scale output of effects to compensate for device down-mixing
Diffstat (limited to 'Alc/alcEcho.c')
-rw-r--r-- | Alc/alcEcho.c | 9 |
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; |