From 1db83923446bde61b9c5cce7a6cb9c4da56269c9 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 25 Nov 2014 22:24:29 -0800 Subject: [PATCH] Improve ambient gain calculations --- Alc/effects/reverb.c | 8 ++++---- Alc/panning.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 896dbaef..9170e1c9 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -1038,7 +1038,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection ALfloat length, invlen; ALuint i; - ComputeAmbientGains(Device, 1.0f, AmbientGains); + ComputeAmbientGains(Device, 1.4142f, AmbientGains); length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2]; if(!(length > FLT_EPSILON)) @@ -1054,7 +1054,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection earlyPan[2] *= invlen; length = minf(length, 1.0f); - ComputeDirectionalGains(Device, earlyPan, 1.0f, DirGains); + ComputeDirectionalGains(Device, earlyPan, 1.4142f, DirGains); for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) State->Early.PanGain[i] = lerp(AmbientGains[i], DirGains[i], length) * Gain; } @@ -1073,7 +1073,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection latePan[2] *= invlen; length = minf(length, 1.0f); - ComputeDirectionalGains(Device, latePan, 1.0f, DirGains); + ComputeDirectionalGains(Device, latePan, 1.4142f, DirGains); for(i = 0;i < MAX_OUTPUT_CHANNELS;i++) State->Late.PanGain[i] = lerp(AmbientGains[i], DirGains[i], length) * Gain; } @@ -1167,7 +1167,7 @@ static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, cons else { /* Update channel gains */ - ComputeAmbientGains(Device, Slot->Gain*2.0f, State->Gain); + ComputeAmbientGains(Device, Slot->Gain*1.4142f, State->Gain); } } diff --git a/Alc/panning.c b/Alc/panning.c index a9d0f5cb..4a3541c2 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -92,7 +92,7 @@ void ComputeAmbientGains(const ALCdevice *device, ALfloat ingain, ALfloat gains[ // scaling the W channel input by sqrt(0.5). The square root of the // base average provides for a more perceptual average volume, better // suited to non-directional gains. - gains[i] = sqrtf(device->Channel[i].HOACoeff[0]/1.4142f)*1.4142f * ingain; + gains[i] = sqrtf(device->Channel[i].HOACoeff[0]/1.4142f) * ingain; } } -- 2.11.4.GIT