aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
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];