From a9d9553fff7f3ec571770a9b4a22c5a46f91780f Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 21 May 2011 17:45:54 -0700 Subject: Use a multi-dimensional array for the panning LUT --- Alc/ALu.c | 6 +++--- Alc/alcDedicated.c | 2 +- Alc/alcReverb.c | 4 ++-- Alc/panning.c | 19 +++++++++---------- 4 files changed, 15 insertions(+), 16 deletions(-) (limited to 'Alc') diff --git a/Alc/ALu.c b/Alc/ALu.c index cd0c2177..b387d7e1 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -188,7 +188,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) { pos = aluCart2LUTpos(cos(angles_StereoDup[c] * (M_PI/180.0)), sin(angles_StereoDup[c] * (M_PI/180.0))); - SpeakerGain = &Device->PanningLUT[MAXCHANNELS * pos]; + SpeakerGain = Device->PanningLUT[pos]; for(i = 0;i < (ALint)Device->NumChan;i++) { @@ -266,7 +266,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) } pos = aluCart2LUTpos(cos(angles[c] * (M_PI/180.0)), sin(angles[c] * (M_PI/180.0))); - SpeakerGain = &Device->PanningLUT[MAXCHANNELS * pos]; + SpeakerGain = Device->PanningLUT[pos]; for(i = 0;i < (ALint)Device->NumChan;i++) { @@ -692,7 +692,7 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) } pos = aluCart2LUTpos(-Position[2]*ZScale, Position[0]); - SpeakerGain = &Device->PanningLUT[MAXCHANNELS * pos]; + SpeakerGain = Device->PanningLUT[pos]; DirGain = aluSqrt(Position[0]*Position[0] + Position[2]*Position[2]); // elevation adjustment for directional gain. this sucks, but diff --git a/Alc/alcDedicated.c b/Alc/alcDedicated.c index 0b9d8419..6bab83e5 100644 --- a/Alc/alcDedicated.c +++ b/Alc/alcDedicated.c @@ -59,7 +59,7 @@ static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, con ALsizei s; pos = aluCart2LUTpos(1.0f, 0.0f); - SpeakerGain = &device->PanningLUT[MAXCHANNELS * pos]; + SpeakerGain = device->PanningLUT[pos]; for(s = 0;s < MAXCHANNELS;s++) state->gains[s] = SpeakerGain[s] * Effect->Params.Dedicated.Gain; diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 4ecf615e..20638710 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -627,7 +627,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection * panning direction. */ pos = aluCart2LUTpos(earlyPan[2], earlyPan[0]); - speakerGain = &Device->PanningLUT[MAXCHANNELS * pos]; + speakerGain = Device->PanningLUT[pos]; dirGain = aluSqrt((earlyPan[0] * earlyPan[0]) + (earlyPan[2] * earlyPan[2])); for(index = 0;index < MAXCHANNELS;index++) @@ -640,7 +640,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection pos = aluCart2LUTpos(latePan[2], latePan[0]); - speakerGain = &Device->PanningLUT[MAXCHANNELS * pos]; + speakerGain = Device->PanningLUT[pos]; dirGain = aluSqrt((latePan[0] * latePan[0]) + (latePan[2] * latePan[2])); for(index = 0;index < MAXCHANNELS;index++) diff --git a/Alc/panning.c b/Alc/panning.c index b5352e2b..a5a92298 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -168,8 +168,7 @@ ALvoid aluInitPanning(ALCdevice *Device) ALfloat SpeakerAngle[MAXCHANNELS]; Channel *Speaker2Chan; ALfloat Alpha, Theta; - ALfloat *PanningLUT; - ALint pos, offset; + ALint pos; ALuint s; Speaker2Chan = Device->Speaker2Chan; @@ -255,17 +254,17 @@ ALvoid aluInitPanning(ALCdevice *Device) break; } - PanningLUT = Device->PanningLUT; for(pos = 0; pos < LUT_NUM; pos++) { + ALfloat *PanningLUT = Device->PanningLUT[pos]; + /* clear all values */ - offset = MAXCHANNELS * pos; for(s = 0; s < MAXCHANNELS; s++) - PanningLUT[offset+s] = 0.0f; + PanningLUT[s] = 0.0f; if(Device->NumChan == 1) { - PanningLUT[offset + Speaker2Chan[0]] = 1.0f; + PanningLUT[Speaker2Chan[0]] = 1.0f; continue; } @@ -280,8 +279,8 @@ ALvoid aluInitPanning(ALCdevice *Device) /* source between speaker s and speaker s+1 */ Alpha = M_PI_2 * (Theta-SpeakerAngle[s]) / (SpeakerAngle[s+1]-SpeakerAngle[s]); - PanningLUT[offset + Speaker2Chan[s]] = cos(Alpha); - PanningLUT[offset + Speaker2Chan[s+1]] = sin(Alpha); + PanningLUT[Speaker2Chan[s]] = cos(Alpha); + PanningLUT[Speaker2Chan[s+1]] = sin(Alpha); break; } } @@ -292,8 +291,8 @@ ALvoid aluInitPanning(ALCdevice *Device) Theta += 2.0f * M_PI; Alpha = M_PI_2 * (Theta-SpeakerAngle[s]) / (2.0f * M_PI + SpeakerAngle[0]-SpeakerAngle[s]); - PanningLUT[offset + Speaker2Chan[s]] = cos(Alpha); - PanningLUT[offset + Speaker2Chan[0]] = sin(Alpha); + PanningLUT[Speaker2Chan[s]] = cos(Alpha); + PanningLUT[Speaker2Chan[0]] = sin(Alpha); } } } -- cgit v1.2.3