summaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-07-20 19:57:24 -0700
committerChris Robinson <[email protected]>2011-07-20 19:57:24 -0700
commit9723c553b67d2113d17881d77ec2c2d44b818238 (patch)
tree8185c49845874dd6102acf5e221cd220eaaa1702 /Alc
parent6bfb0371eb8dd7e3d18ff0225bebadf261de6b65 (diff)
Scale reverb output based on the number of channels
A scale of sqrt(2/numchannels) is used so the perceived volume matches as if it was stereo output, which seems to match other implementations.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alcReverb.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c
index 27caad6f..38586357 100644
--- a/Alc/alcReverb.c
+++ b/Alc/alcReverb.c
@@ -596,11 +596,15 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1],
LateReverbPan[2] };
const ALfloat *speakerGain;
+ ALfloat ambientGain;
ALfloat dirGain;
ALfloat length;
ALuint index;
ALint pos;
+ // Attenuate non-directional reverb according to the number of channels
+ ambientGain = aluSqrt(2.0f/Device->NumChan);
+
// Calculate the 3D-panning gains for the early reflections and late
// reverb.
length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2];
@@ -635,7 +639,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
for(index = 0;index < Device->NumChan;index++)
{
enum Channel chan = Device->Speaker2Chan[index];
- State->Early.PanGain[chan] = lerp(1.0, speakerGain[chan], dirGain) * Gain;
+ State->Early.PanGain[chan] = lerp(ambientGain, speakerGain[chan], dirGain) * Gain;
}
@@ -648,7 +652,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
for(index = 0;index < Device->NumChan;index++)
{
enum Channel chan = Device->Speaker2Chan[index];
- State->Late.PanGain[chan] = lerp(1.0, speakerGain[chan], dirGain) * Gain;
+ State->Late.PanGain[chan] = lerp(ambientGain, speakerGain[chan], dirGain) * Gain;
}
}
@@ -1102,6 +1106,7 @@ static ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeff
// Update channel gains
gain = Slot->Gain;
+ gain *= aluSqrt(2.0/Device->NumChan);
for(index = 0;index < MAXCHANNELS;index++)
State->Gain[index] = 0.0f;
for(index = 0;index < Device->NumChan;index++)