diff options
author | Chris Robinson <[email protected]> | 2011-05-20 07:58:05 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-05-20 07:58:05 -0700 |
commit | cbbb04eb409c9e9f675974a7a45ae28b93c3ec1f (patch) | |
tree | b50934fece62d6d896af10f755f8dac1be2ae884 /Alc/ALu.c | |
parent | 7396aaf2c28ef4e16c3f27d0cc3c06cc09134d41 (diff) |
Always fully normalize the position when using HRTF
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r-- | Alc/ALu.c | 27 |
1 files changed, 18 insertions, 9 deletions
@@ -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]; |