Use a multi-dimensional array for the panning LUT

This commit is contained in:
Chris Robinson
2011-05-21 17:45:54 -07:00
parent 5cdf774ea7
commit a9d9553fff
5 changed files with 16 additions and 17 deletions
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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++)
+9 -10
View File
@@ -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);
}
}
}
+1 -1
View File
@@ -489,7 +489,7 @@ struct ALCdevice_struct
ALuint DevChannels[MAXCHANNELS];
Channel Speaker2Chan[MAXCHANNELS];
ALfloat PanningLUT[MAXCHANNELS * LUT_NUM];
ALfloat PanningLUT[LUT_NUM][MAXCHANNELS];
ALuint NumChan;
ALfloat ClickRemoval[MAXCHANNELS];