Use ComputeAngleGains for the echo and dedicated effects

This commit is contained in:
Chris Robinson 2012-04-28 08:24:09 -07:00
parent 611bd0b2d3
commit c34d78f417
2 changed files with 5 additions and 29 deletions

View File

@ -53,9 +53,7 @@ static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
static ALvoid DedicatedUpdate(ALeffectState *effect, ALCdevice *device, const ALeffectslot *Slot)
{
ALdedicatedState *state = (ALdedicatedState*)effect;
const ALfloat *ChannelGain;
ALfloat Gain;
ALint pos;
ALsizei s;
Gain = Slot->Gain * Slot->effect.Dedicated.Gain;
@ -63,13 +61,7 @@ static ALvoid DedicatedUpdate(ALeffectState *effect, ALCdevice *device, const AL
state->gains[s] = 0.0f;
if(Slot->effect.type == AL_EFFECT_DEDICATED_DIALOGUE)
{
pos = aluCart2LUTpos(0.0f, 1.0f);
ChannelGain = device->PanningLUT[pos];
for(s = 0;s < MAXCHANNELS;s++)
state->gains[s] = ChannelGain[s] * Gain;
}
ComputeAngleGains(device, aluAtan2(0.0f, 1.0f), 0.0f, Gain, state->gains);
else if(Slot->effect.type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
state->gains[LFE] = Gain;
}

View File

@ -94,10 +94,9 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffec
{
ALechoState *state = (ALechoState*)effect;
ALuint frequency = Device->Frequency;
ALfloat dirGain, ambientGain;
const ALfloat *ChannelGain;
ALfloat lrpan, cw, g, gain;
ALuint i, pos;
ALfloat dirGain;
ALuint i;
state->Tap[0].delay = fastf2u(Slot->effect.Echo.Delay * frequency) + 1;
state->Tap[1].delay = fastf2u(Slot->effect.Echo.LRDelay * frequency);
@ -118,28 +117,13 @@ static ALvoid EchoUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffec
state->Gain[1][i] = 0.0f;
}
ambientGain = aluSqrt(1.0f/Device->NumChan);
dirGain = aluFabs(lrpan);
/* First tap panning */
pos = aluCart2LUTpos(((lrpan>0.0f)?-1.0f:1.0f), 0.0f);
ChannelGain = Device->PanningLUT[pos];
for(i = 0;i < Device->NumChan;i++)
{
enum Channel chan = Device->Speaker2Chan[i];
state->Gain[0][chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * gain;
}
ComputeAngleGains(Device, aluAtan2(-lrpan, 0.0f), (1.0f-dirGain)*F_PI, gain, state->Gain[0]);
/* Second tap panning */
pos = aluCart2LUTpos(((lrpan>0.0f)?1.0f:-1.0f), 0.0f);
ChannelGain = Device->PanningLUT[pos];
for(i = 0;i < Device->NumChan;i++)
{
enum Channel chan = Device->Speaker2Chan[i];
state->Gain[1][chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * gain;
}
ComputeAngleGains(Device, aluAtan2(+lrpan, 0.0f), (1.0f-dirGain)*F_PI, gain, state->Gain[1]);
}
static ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])