diff options
author | Chris Robinson <[email protected]> | 2010-04-08 16:34:51 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-04-08 16:34:51 -0700 |
commit | 704b386cc54c2ae5ac46d2400e8e75762c6d46f0 (patch) | |
tree | 5fac8921bf30524e3e133be3cacfebe715a3cf98 | |
parent | aace50ebf4c97f62adceef88e42babf524ff2e28 (diff) |
Scale the ring modulator's mono input when expanding to multi-channel
-rw-r--r-- | Alc/alcModulator.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/Alc/alcModulator.c b/Alc/alcModulator.c index 3547e504..c6891282 100644 --- a/Alc/alcModulator.c +++ b/Alc/alcModulator.c @@ -40,6 +40,8 @@ typedef struct ALmodulatorState { SQUARE } Waveform; + ALfloat scalar; + ALuint index; ALuint step; @@ -87,9 +89,11 @@ static ALvoid ModulatorDestroy(ALeffectState *effect) static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device) { + ALmodulatorState *state = (ALmodulatorState*)effect; + + state->scalar = aluSqrt(1.0f/Device->NumChan); + 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->scalar; const ALuint step = state->step; ALuint index = state->index; ALfloat samp; @@ -140,12 +144,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][SIDE_LEFT] += samp; \ - SamplesOut[i][SIDE_RIGHT] += samp; \ - SamplesOut[i][BACK_LEFT] += samp; \ - SamplesOut[i][BACK_RIGHT] += samp; \ + 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; \ } while(0) FILTER_OUT(sin_func); } |