aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-05-16 03:54:16 -0700
committerChris Robinson <[email protected]>2009-05-16 03:54:16 -0700
commitc447eeb2c77d91d11750270aaed36a2354069095 (patch)
tree1a3a7e4d5153ca8e73ac6daac6b25c87313b3b9b /Alc/ALu.c
parentad19cea6e014b7a3bee0b098d5e3e58def631a49 (diff)
Use the source reference distance to specify full panning magnitude
Sources that are closer than the specified reference distance will not pan to full magnitude, thus providing a smoother transition as it moves around near the listener
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 1d1878af..78c936cc 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -572,6 +572,7 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext,
ALfloat RoomRolloff[MAX_SENDS];
ALfloat DryGainHF = 1.0f;
ALfloat DirGain, AmbientGain;
+ ALfloat length;
const ALfloat *SpeakerGain;
ALint NumSends;
ALint pos, s, i;
@@ -855,7 +856,16 @@ static ALvoid CalcSourceParams(const ALCcontext *ALContext,
DryMix *= ListenerGain;
// Use energy-preserving panning algorithm for multi-speaker playback
- aluNormalize(Position);
+ length = aluSqrt(Position[0]*Position[0] + Position[1]*Position[1] +
+ Position[2]*Position[2]);
+ length = __max(length, MinDist);
+ if(length > 0.0f)
+ {
+ ALfloat invlen = 1.0f/length;
+ Position[0] *= invlen;
+ Position[1] *= invlen;
+ Position[2] *= invlen;
+ }
pos = aluCart2LUTpos(-Position[2], Position[0]);
SpeakerGain = &ALContext->PanningLUT[OUTPUTCHANNELS * pos];