diff options
author | Chris Robinson <[email protected]> | 2010-08-09 06:12:00 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-08-09 06:12:00 -0700 |
commit | 2d1988bb6ffaec62de849cce694a5fec30188997 (patch) | |
tree | bf69bfe8f1a537bc9fc7f7a6cd3f05d57f329169 /Alc/alcModulator.c | |
parent | e007dc36140a0359b9ae1e1bf495c2afa5ab70f8 (diff) |
Output on available channels only, for the echo and modulator effects
Diffstat (limited to 'Alc/alcModulator.c')
-rw-r--r-- | Alc/alcModulator.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index 0578ee1c..19944fa3 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -43,7 +43,7 @@ typedef struct ALmodulatorState { ALuint index; ALuint step; - ALfloat Scale; + ALfloat Gain[OUTPUTCHANNELS]; FILTER iirFilter; ALfloat history[1]; @@ -90,8 +90,15 @@ static ALvoid ModulatorDestroy(ALeffectState *effect) static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device) { ALmodulatorState *state = (ALmodulatorState*)effect; + ALuint index; - state->Scale = aluSqrt(Device->NumChan / 8.0f); + for(index = 0;index < OUTPUTCHANNELS;index++) + state->Gain[index] = 0.0f; + for(index = 0;index < Device->NumChan;index++) + { + Channel chan = Device->Speaker2Chan[index]; + state->Gain[chan] = 1.0f; + } return AL_TRUE; } @@ -121,7 +128,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 * state->Scale; + const ALfloat gain = Slot->Gain; const ALuint step = state->step; ALuint index = state->index; ALfloat samp; @@ -144,14 +151,14 @@ static ALvoid ModulatorProcess(ALeffectState *effect, const ALeffectslot *Slot, /* Apply slot gain */ \ samp *= gain; \ \ - SamplesOut[i][FRONT_LEFT] += samp; \ - SamplesOut[i][FRONT_RIGHT] += samp; \ - SamplesOut[i][FRONT_CENTER] += samp; \ - SamplesOut[i][SIDE_LEFT] += samp; \ - SamplesOut[i][SIDE_RIGHT] += samp; \ - SamplesOut[i][BACK_LEFT] += samp; \ - SamplesOut[i][BACK_RIGHT] += samp; \ - SamplesOut[i][BACK_CENTER] += samp; \ + SamplesOut[i][FRONT_LEFT] += state->Gain[FRONT_LEFT] * samp; \ + SamplesOut[i][FRONT_RIGHT] += state->Gain[FRONT_RIGHT] * samp; \ + SamplesOut[i][FRONT_CENTER] += state->Gain[FRONT_CENTER] * samp; \ + SamplesOut[i][SIDE_LEFT] += state->Gain[SIDE_LEFT] * samp; \ + SamplesOut[i][SIDE_RIGHT] += state->Gain[SIDE_RIGHT] * samp; \ + SamplesOut[i][BACK_LEFT] += state->Gain[BACK_LEFT] * samp; \ + SamplesOut[i][BACK_RIGHT] += state->Gain[BACK_RIGHT] * samp; \ + SamplesOut[i][BACK_CENTER] += state->Gain[BACK_CENTER] * samp; \ } while(0) FILTER_OUT(sin_func); } @@ -191,8 +198,6 @@ 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; |