From e3a70e50216850aff2721ce3cc4a3e1c2cee311f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 12 May 2010 04:56:03 -0700 Subject: Scale output of effects to compensate for device down-mixing --- Alc/alcModulator.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Alc/alcModulator.c') diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index cabbaeb6..0578ee1c 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -43,6 +43,8 @@ typedef struct ALmodulatorState { ALuint index; ALuint step; + ALfloat Scale; + FILTER iirFilter; ALfloat history[1]; } ALmodulatorState; @@ -87,9 +89,11 @@ static ALvoid ModulatorDestroy(ALeffectState *effect) static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device) { + ALmodulatorState *state = (ALmodulatorState*)effect; + + state->Scale = aluSqrt(Device->NumChan / 8.0f); + return AL_TRUE; - (void)effect; - (void)Device; } static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect) @@ -117,7 +121,7 @@ static ALvoid ModulatorUpdate(ALeffectState *effect, ALCcontext *Context, const static ALvoid ModulatorProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[OUTPUTCHANNELS]) { ALmodulatorState *state = (ALmodulatorState*)effect; - const ALfloat gain = Slot->Gain; + const ALfloat gain = Slot->Gain * state->Scale; const ALuint step = state->step; ALuint index = state->index; ALfloat samp; @@ -187,6 +191,8 @@ ALeffectState *ModulatorCreate(void) state->index = 0.0f; state->step = 1.0f; + state->Scale = 1.0f; + state->iirFilter.coeff = 0.0f; state->iirFilter.history[0] = 0.0f; -- cgit v1.2.3