diff options
author | Chris Robinson <[email protected]> | 2014-10-02 18:05:42 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-10-02 18:05:42 -0700 |
commit | 95ba18cf4e52c439b85ece2daf0b404fa69c7b70 (patch) | |
tree | 2367b5d69488633fb8d596cf3e3b328d81b2753f /Alc/effects/reverb.c | |
parent | 9377d0f23730ff0d42a870627ea9a75059c481f4 (diff) |
Make ComputeAngleGains use ComputeDirectionalGains
Diffstat (limited to 'Alc/effects/reverb.c')
-rw-r--r-- | Alc/effects/reverb.c | 62 |
1 files changed, 36 insertions, 26 deletions
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 1e9cd550..8c17076a 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -1031,44 +1031,54 @@ static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoT // Update the early and late 3D panning gains. static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, ALfloat Gain, ALreverbState *State) { - ALfloat earlyPan[3] = { ReflectionsPan[0], ReflectionsPan[1], - ReflectionsPan[2] }; - ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1], - LateReverbPan[2] }; + ALfloat earlyPan[3] = { ReflectionsPan[0], ReflectionsPan[1], ReflectionsPan[2] }; + ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1], LateReverbPan[2] }; + ALfloat earlyLen = 0.0f; + ALfloat lateLen = 0.0f; + ALfloat length, invlen; ALfloat ambientGain; - ALfloat dirGain; - ALfloat length; + ALuint i; Gain *= ReverbBoost; - /* Attenuate reverb according to its coverage (dirGain=0 will give - * Gain*ambientGain, and dirGain=1 will give Gain). */ - ambientGain = minf(sqrtf(2.0f/Device->NumSpeakers), 1.0f); + /* Attenuate reverb according to its coverage (len=0 will give + * ambientGain, and len>=1 will be fully panned using Gain). */ + ambientGain = minf(sqrtf(2.0f/Device->NumSpeakers), 1.0f) * Gain; length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2]; - if(length > 1.0f) + if(length > FLT_EPSILON) { - length = 1.0f / sqrtf(length); - earlyPan[0] *= length; - earlyPan[1] *= length; - earlyPan[2] *= length; + length = sqrtf(length); + + invlen = 1.0f / length; + earlyPan[0] *= invlen; + earlyPan[1] *= invlen; + earlyPan[2] *= invlen; + + earlyLen = minf(1.0f, length); + ComputeDirectionalGains(Device, earlyPan, Gain, State->Early.PanGain); } + length = latePan[0]*latePan[0] + latePan[1]*latePan[1] + latePan[2]*latePan[2]; - if(length > 1.0f) + if(length > FLT_EPSILON) { - length = 1.0f / sqrtf(length); - latePan[0] *= length; - latePan[1] *= length; - latePan[2] *= length; - } + length = sqrtf(length); - dirGain = sqrtf(earlyPan[0]*earlyPan[0] + earlyPan[2]*earlyPan[2]); - ComputeAngleGains(Device, atan2f(earlyPan[0], earlyPan[2]), (1.0f-dirGain)*F_PI, - lerp(ambientGain, 1.0f, dirGain) * Gain, State->Early.PanGain); + invlen = 1.0f / length; + latePan[0] *= invlen; + latePan[1] *= invlen; + latePan[2] *= invlen; - dirGain = sqrtf(latePan[0]*latePan[0] + latePan[2]*latePan[2]); - ComputeAngleGains(Device, atan2f(latePan[0], latePan[2]), (1.0f-dirGain)*F_PI, - lerp(ambientGain, 1.0f, dirGain) * Gain, State->Late.PanGain); + lateLen = minf(1.0f, length); + ComputeDirectionalGains(Device, latePan, Gain, State->Late.PanGain); + } + + for(i = 0;i < Device->NumSpeakers;i++) + { + enum Channel chan = Device->Speaker[i].ChanName; + State->Early.PanGain[chan] = lerp(ambientGain, State->Early.PanGain[chan], earlyLen); + State->Late.PanGain[chan] = lerp(ambientGain, State->Late.PanGain[chan], lateLen); + } } static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, const ALeffectslot *Slot) |