aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-12-09 16:37:23 -0800
committerChris Robinson <[email protected]>2010-12-09 16:37:23 -0800
commitc3cd4c80b2a248918da9d049487213c4cc8c128f (patch)
treee27b6f1f5061b1e4065a796378ffe6e794f67d7e /Alc/ALu.c
parentbe3f3c4bf03dd5800e25f0d3144f2e122bac2f94 (diff)
Use a matrix when rendering to the dry buffer
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c106
1 files changed, 78 insertions, 28 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index e0fd5c9f..d831e9ca 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -150,15 +150,23 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
break;
}
- if(Channels == FmtStereo)
+ for(i = 0;i < MAXCHANNELS;i++)
{
- for(i = 0;i < MAXCHANNELS;i++)
- ALSource->Params.DryGains[i] = 0.0f;
+ ALuint i2;
+ for(i2 = 0;i2 < MAXCHANNELS;i2++)
+ ALSource->Params.DryGains[i][i2] = 0.0f;
+ }
+ switch(Channels)
+ {
+ case FmtMono:
+ ALSource->Params.DryGains[0][FRONT_CENTER] = DryGain * ListenerGain;
+ break;
+ case FmtStereo:
if(DupStereo == AL_FALSE)
{
- ALSource->Params.DryGains[FRONT_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
}
else
{
@@ -166,43 +174,81 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
case DevFmtMono:
case DevFmtStereo:
- ALSource->Params.DryGains[FRONT_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
break;
case DevFmtQuad:
case DevFmtX51:
DryGain *= aluSqrt(2.0f/4.0f);
- ALSource->Params.DryGains[FRONT_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[FRONT_RIGHT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[BACK_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[BACK_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][BACK_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][BACK_RIGHT] = DryGain * ListenerGain;
break;
case DevFmtX61:
DryGain *= aluSqrt(2.0f/4.0f);
- ALSource->Params.DryGains[FRONT_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[FRONT_RIGHT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[SIDE_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[SIDE_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][SIDE_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][SIDE_RIGHT] = DryGain * ListenerGain;
break;
case DevFmtX71:
DryGain *= aluSqrt(2.0f/6.0f);
- ALSource->Params.DryGains[FRONT_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[FRONT_RIGHT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[BACK_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[BACK_RIGHT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[SIDE_LEFT] = DryGain * ListenerGain;
- ALSource->Params.DryGains[SIDE_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][BACK_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][BACK_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[0][SIDE_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][SIDE_RIGHT] = DryGain * ListenerGain;
break;
}
}
- }
- else
- {
- for(i = 0;i < MAXCHANNELS;i++)
- ALSource->Params.DryGains[i] = DryGain * ListenerGain;
+ break;
+
+ case FmtRear:
+ ALSource->Params.DryGains[0][BACK_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][BACK_RIGHT] = DryGain * ListenerGain;
+ break;
+
+ case FmtQuad:
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[2][BACK_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[3][BACK_RIGHT] = DryGain * ListenerGain;
+ break;
+
+ case FmtX51:
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[2][FRONT_CENTER] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[3][LFE] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[4][BACK_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[5][BACK_RIGHT] = DryGain * ListenerGain;
+ break;
+
+ case FmtX61:
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[2][FRONT_CENTER] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[3][LFE] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[4][BACK_CENTER] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[5][SIDE_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[6][SIDE_RIGHT] = DryGain * ListenerGain;
+ break;
+
+ case FmtX71:
+ ALSource->Params.DryGains[0][FRONT_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[1][FRONT_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[2][FRONT_CENTER] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[3][LFE] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[4][BACK_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[5][BACK_RIGHT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[6][SIDE_LEFT] = DryGain * ListenerGain;
+ ALSource->Params.DryGains[7][SIDE_RIGHT] = DryGain * ListenerGain;
+ break;
}
for(i = 0;i < NumSends;i++)
@@ -615,12 +661,16 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
// has low complexity
AmbientGain = aluSqrt(1.0/Device->NumChan);
for(s = 0;s < MAXCHANNELS;s++)
- ALSource->Params.DryGains[s] = 0.0f;
+ {
+ ALuint s2;
+ for(s2 = 0;s2 < MAXCHANNELS;s2++)
+ ALSource->Params.DryGains[s][s2] = 0.0f;
+ }
for(s = 0;s < (ALsizei)Device->NumChan;s++)
{
Channel chan = Device->Speaker2Chan[s];
ALfloat gain = AmbientGain + (SpeakerGain[chan]-AmbientGain)*DirGain;
- ALSource->Params.DryGains[chan] = DryGain * gain;
+ ALSource->Params.DryGains[0][chan] = DryGain * gain;
}
/* Update filter coefficients. */