aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-11-26 00:24:54 -0800
committerChris Robinson <[email protected]>2010-11-26 00:24:54 -0800
commit98d78f7ff9a3636567273e4384731debca2ec79f (patch)
tree00ac934d2223bd64d07467966d0c4c06ae548838
parent3d1eb7dcadb7642320506bfc94a539f0afe25c9c (diff)
Slightly improve channel gain calculations
-rw-r--r--Alc/ALu.c4
-rw-r--r--Alc/alcReverb.c13
2 files changed, 8 insertions, 9 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 78f18782..b7471132 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -620,13 +620,13 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
DirGain = aluSqrt(Position[0]*Position[0] + Position[2]*Position[2]);
// elevation adjustment for directional gain. this sucks, but
// has low complexity
- AmbientGain = 1.0/aluSqrt(Device->NumChan) * (1.0-DirGain);
+ AmbientGain = aluSqrt(1.0/Device->NumChan);
for(s = 0;s < OUTPUTCHANNELS;s++)
ALSource->Params.DryGains[s] = 0.0f;
for(s = 0;s < (ALsizei)Device->NumChan;s++)
{
Channel chan = Device->Speaker2Chan[s];
- ALfloat gain = SpeakerGain[chan]*DirGain + AmbientGain;
+ ALfloat gain = AmbientGain + (SpeakerGain[chan]-AmbientGain)*DirGain;
ALSource->Params.DryGains[chan] = DryGain * gain;
}
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c
index e1f6df45..02f07f9a 100644
--- a/Alc/alcReverb.c
+++ b/Alc/alcReverb.c
@@ -596,7 +596,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1],
LateReverbPan[2] };
const ALfloat *speakerGain;
- ALfloat dirGain, ambientGain;
+ ALfloat dirGain;
ALfloat length;
ALuint index;
ALint pos;
@@ -629,27 +629,26 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
pos = aluCart2LUTpos(earlyPan[2], earlyPan[0]);
speakerGain = &Device->PanningLUT[OUTPUTCHANNELS * pos];
dirGain = aluSqrt((earlyPan[0] * earlyPan[0]) + (earlyPan[2] * earlyPan[2]));
- ambientGain = (1.0 - dirGain);
+
for(index = 0;index < OUTPUTCHANNELS;index++)
State->Early.PanGain[index] = 0.0f;
for(index = 0;index < Device->NumChan;index++)
{
Channel chan = Device->Speaker2Chan[index];
- State->Early.PanGain[chan] = speakerGain[chan]*dirGain +
- ambientGain;
+ State->Early.PanGain[chan] = 1.0 + (speakerGain[chan]-1.0)*dirGain;
}
+
pos = aluCart2LUTpos(latePan[2], latePan[0]);
speakerGain = &Device->PanningLUT[OUTPUTCHANNELS * pos];
dirGain = aluSqrt((latePan[0] * latePan[0]) + (latePan[2] * latePan[2]));
- ambientGain = (1.0 - dirGain);
+
for(index = 0;index < OUTPUTCHANNELS;index++)
State->Late.PanGain[index] = 0.0f;
for(index = 0;index < Device->NumChan;index++)
{
Channel chan = Device->Speaker2Chan[index];
- State->Late.PanGain[chan] = speakerGain[chan]*dirGain +
- ambientGain;
+ State->Late.PanGain[chan] = 1.0 + (speakerGain[chan]-1.0)*dirGain;
}
}