aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-05-20 07:58:05 -0700
committerChris Robinson <[email protected]>2011-05-20 07:58:05 -0700
commitcbbb04eb409c9e9f675974a7a45ae28b93c3ec1f (patch)
treeb50934fece62d6d896af10f755f8dac1be2ae884 /Alc/ALu.c
parent7396aaf2c28ef4e16c3f27d0cc3c06cc09134d41 (diff)
Always fully normalize the position when using HRTF
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index ce68cdf9..45caad16 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -656,19 +656,19 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
// Use energy-preserving panning algorithm for multi-speaker playback
- length = __max(OrigDist, MinDist);
- if(length > 0.0f)
- {
- ALfloat invlen = 1.0f/length;
- Position[0] *= invlen;
- Position[1] *= invlen;
- Position[2] *= invlen;
- }
-
if((Device->Flags&DEVICE_USE_HRTF))
{
const ALshort *hrtf_left, *hrtf_right;
+ length = OrigDist;
+ if(length > 0.0f)
+ {
+ ALfloat invlen = 1.0f/length;
+ Position[0] *= invlen;
+ Position[1] *= invlen;
+ Position[2] *= invlen;
+ }
+
GetHrtfCoeffs(asin(Position[1]) * (180.0/M_PI),
atan2(Position[0], -Position[2]*ZScale) * (180.0/M_PI),
&hrtf_left, &hrtf_right);
@@ -682,6 +682,15 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
}
else
{
+ length = __max(OrigDist, MinDist);
+ if(length > 0.0f)
+ {
+ ALfloat invlen = 1.0f/length;
+ Position[0] *= invlen;
+ Position[1] *= invlen;
+ Position[2] *= invlen;
+ }
+
pos = aluCart2LUTpos(-Position[2]*ZScale, Position[0]);
SpeakerGain = &Device->PanningLUT[MAXCHANNELS * pos];