aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2012-04-29 05:04:46 -0700
committerChris Robinson <[email protected]>2012-04-29 05:04:46 -0700
commitaed35fd811f7aa5f1a9d2edb499e43d490ede96e (patch)
tree4c7cb8ae07dcb21975538a0a042d96b5e6d0f427
parent8d9838012d5d073cf0bcdc917634b69e77fbaf71 (diff)
Use ComputeAngleGains for multi-channel sources and remove the unused lookup table stuff
-rw-r--r--Alc/ALu.c14
-rw-r--r--Alc/panning.c70
-rw-r--r--OpenAL32/Include/alMain.h1
-rw-r--r--OpenAL32/Include/alu.h4
4 files changed, 4 insertions, 85 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 915c06e9..2777b0fe 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -115,14 +115,12 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALfloat WetGain[MAX_SENDS];
ALfloat WetGainHF[MAX_SENDS];
ALint NumSends, Frequency;
- const ALfloat *ChannelGain;
const struct ChanMap *chans = NULL;
enum Resampler Resampler;
ALint num_channels = 0;
ALboolean DirectChannels;
ALfloat Pitch;
ALfloat cw;
- ALuint pos;
ALint i, c;
/* Get device properties */
@@ -281,17 +279,11 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
/* Special-case LFE */
if(chans[c].channel == LFE)
{
- SrcMatrix[c][LFE] += DryGain;
+ SrcMatrix[c][chans[c].channel] = DryGain;
continue;
}
- pos = aluCart2LUTpos(aluSin(chans[c].angle), aluCos(chans[c].angle));
- ChannelGain = Device->PanningLUT[pos];
-
- for(i = 0;i < (ALint)Device->NumChan;i++)
- {
- enum Channel chan = Device->Speaker2Chan[i];
- SrcMatrix[c][chan] += DryGain * ChannelGain[chan];
- }
+ ComputeAngleGains(Device, chans[c].angle, 0.0f, DryGain,
+ SrcMatrix[c]);
}
}
for(i = 0;i < NumSends;i++)
diff --git a/Alc/panning.c b/Alc/panning.c
index 288f44d1..d6d4bc21 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -139,30 +139,6 @@ static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHAN
}
}
-static ALfloat aluLUTpos2Angle(ALint pos)
-{
- if(pos < QUADRANT_NUM)
- return aluAtan((ALfloat)pos / (ALfloat)(QUADRANT_NUM - pos));
- if(pos < 2 * QUADRANT_NUM)
- return F_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos));
- if(pos < 3 * QUADRANT_NUM)
- return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - F_PI;
- return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - F_PI_2;
-}
-
-ALint aluCart2LUTpos(ALfloat im, ALfloat re)
-{
- ALint pos = 0;
- ALfloat denom = aluFabs(im) + aluFabs(re);
- if(denom > 0.0f)
- pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5);
-
- if(re < 0.0f)
- pos = 2 * QUADRANT_NUM - pos;
- if(im < 0.0f)
- pos = LUT_NUM - pos;
- return pos%LUT_NUM;
-}
/**
* ComputeAngleGains
@@ -357,14 +333,12 @@ ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth,
}
}
+
ALvoid aluInitPanning(ALCdevice *Device)
{
const char *layoutname = NULL;
enum Channel *Speaker2Chan;
ALfloat *SpeakerAngle;
- ALfloat Alpha, Theta;
- ALint pos;
- ALuint s;
Speaker2Chan = Device->Speaker2Chan;
SpeakerAngle = Device->SpeakerAngle;
@@ -467,46 +441,4 @@ ALvoid aluInitPanning(ALCdevice *Device)
}
if(layoutname && Device->Type != Loopback)
SetSpeakerArrangement(layoutname, SpeakerAngle, Speaker2Chan, Device->NumChan);
-
- for(pos = 0; pos < LUT_NUM; pos++)
- {
- ALfloat *PanningLUT = Device->PanningLUT[pos];
-
- /* clear all values */
- for(s = 0; s < MAXCHANNELS; s++)
- PanningLUT[s] = 0.0f;
-
- if(Device->NumChan == 1)
- {
- PanningLUT[Speaker2Chan[0]] = 1.0f;
- continue;
- }
-
- /* source angle */
- Theta = aluLUTpos2Angle(pos);
-
- /* set panning values */
- for(s = 0; s < Device->NumChan - 1; s++)
- {
- if(Theta >= SpeakerAngle[s] && Theta < SpeakerAngle[s+1])
- {
- /* source between speaker s and speaker s+1 */
- Alpha = (Theta-SpeakerAngle[s]) /
- (SpeakerAngle[s+1]-SpeakerAngle[s]);
- PanningLUT[Speaker2Chan[s]] = aluSqrt(1.0f-Alpha);
- PanningLUT[Speaker2Chan[s+1]] = aluSqrt( Alpha);
- break;
- }
- }
- if(s == Device->NumChan - 1)
- {
- /* source between last and first speaker */
- if(Theta < SpeakerAngle[0])
- Theta += F_PI*2.0f;
- Alpha = (Theta-SpeakerAngle[s]) /
- (F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[s]);
- PanningLUT[Speaker2Chan[s]] = aluSqrt(1.0f-Alpha);
- PanningLUT[Speaker2Chan[0]] = aluSqrt( Alpha);
- }
- }
}
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 54fbcdf5..76a0bfbc 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -579,7 +579,6 @@ struct ALCdevice_struct
enum Channel Speaker2Chan[MAXCHANNELS];
ALfloat SpeakerAngle[MAXCHANNELS];
- ALfloat PanningLUT[LUT_NUM][MAXCHANNELS];
ALuint NumChan;
ALfloat ClickRemoval[MAXCHANNELS];
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index ff5601e5..ccc18746 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -110,9 +110,6 @@ _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _controlfp (unsigned int unNew, uns
#define aluFloor(x) ((ALfloat)floor((double)(x)))
#endif
-#define QUADRANT_NUM 128
-#define LUT_NUM (4 * QUADRANT_NUM)
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -296,7 +293,6 @@ static __inline void aluNormalize(ALfloat *inVector)
ALvoid aluInitPanning(ALCdevice *Device);
-ALint aluCart2LUTpos(ALfloat im, ALfloat re);
ALvoid ComputeAngleGains(const ALCdevice *device, ALfloat angle, ALfloat hwidth, ALfloat ingain, ALfloat *gains);