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/alcModulator.c | |
parent | af4faaf6660d02ce593e07b97d05020b44ed06e4 (diff) |
Scale output of effects to compensate for device down-mixing
Diffstat (limited to 'Alc/alcModulator.c')
-rw-r--r-- | Alc/alcModulator.c | 12 |
1 files changed, 9 insertions, 3 deletions
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; |