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 | |
parent | e007dc36140a0359b9ae1e1bf495c2afa5ab70f8 (diff) |
Output on available channels only, for the echo and modulator effects
-rw-r--r-- | Alc/alcEcho.c | 27 | ||||
-rw-r--r-- | Alc/alcModulator.c | 31 |
2 files changed, 33 insertions, 25 deletions
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index d6f7fbb3..e6ecac5c 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -49,7 +49,7 @@ typedef struct ALechoState { ALfloat FeedGain; - ALfloat Scale; + ALfloat Gain[OUTPUTCHANNELS]; FILTER iirFilter; ALfloat history[2]; @@ -90,8 +90,13 @@ 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); + for(i = 0;i < OUTPUTCHANNELS;i++) + state->Gain[i] = 0.0f; + for(i = 0;i < Device->NumChan;i++) + { + Channel chan = Device->Speaker2Chan[i]; + state->Gain[chan] = 1.0f; + } return AL_TRUE; } @@ -127,7 +132,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 * state->Scale; + const ALfloat gain = Slot->Gain; ALfloat samp[2], smp; ALuint i; @@ -151,12 +156,12 @@ static ALvoid EchoProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuin samp[0] *= gain; samp[1] *= gain; - SamplesOut[i][FRONT_LEFT] += samp[0]; - SamplesOut[i][FRONT_RIGHT] += samp[1]; - SamplesOut[i][SIDE_LEFT] += samp[0]; - SamplesOut[i][SIDE_RIGHT] += samp[1]; - SamplesOut[i][BACK_LEFT] += samp[0]; - SamplesOut[i][BACK_RIGHT] += samp[1]; + SamplesOut[i][FRONT_LEFT] += state->Gain[FRONT_LEFT] * samp[0]; + SamplesOut[i][FRONT_RIGHT] += state->Gain[FRONT_RIGHT] * samp[1]; + SamplesOut[i][SIDE_LEFT] += state->Gain[SIDE_LEFT] * samp[0]; + SamplesOut[i][SIDE_RIGHT] += state->Gain[SIDE_RIGHT] * samp[1]; + SamplesOut[i][BACK_LEFT] += state->Gain[BACK_LEFT] * samp[0]; + SamplesOut[i][BACK_RIGHT] += state->Gain[BACK_RIGHT] * samp[1]; } state->Offset = offset; } @@ -183,8 +188,6 @@ 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; 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; |