aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-07-04 07:14:45 -0700
committerChris Robinson <[email protected]>2011-07-04 07:20:38 -0700
commitd307ee8c2f0823f80b427766ace50243db0999d5 (patch)
tree7ffadef9d33578ebe3e5c0656d2aeac05de143cc /Alc/ALu.c
parent202f57552ad353912c54522605531e9737c790b0 (diff)
Implement a lerped lookup of the HRTF coefficients/delays
Code supplied by Christopher Fitzgerald
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c35
1 files changed, 10 insertions, 25 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index e7b53763..ebfd0817 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -269,8 +269,6 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
for(c = 0;c < num_channels;c++)
{
- const ALshort *hrtf_left, *hrtf_right;
-
if(chans[c] == LFE)
{
/* Skip LFE */
@@ -284,17 +282,10 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
continue;
}
- GetHrtfCoeffs(0.0, angles[c] * (M_PI/180.0),
- &hrtf_left, &hrtf_right,
- &ALSource->Params.HrtfDelay[c][0],
- &ALSource->Params.HrtfDelay[c][1]);
- for(i = 0;i < HRIR_LENGTH;i++)
- {
- ALSource->Params.HrtfCoeffs[c][i][0] =
- hrtf_left[i]*(1.0/32767.0)*DryGain*ListenerGain;
- ALSource->Params.HrtfCoeffs[c][i][1] =
- hrtf_right[i]*(1.0/32767.0)*DryGain*ListenerGain;
- }
+ GetLerpedHrtfCoeffs(0.0, angles[c] * (M_PI/180.0),
+ DryGain*ListenerGain,
+ ALSource->Params.HrtfCoeffs[c],
+ ALSource->Params.HrtfDelay[c]);
}
}
else
@@ -692,11 +683,9 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
BufferListItem = BufferListItem->next;
}
- // Use energy-preserving panning algorithm for multi-speaker playback
if((Device->Flags&DEVICE_USE_HRTF))
{
- const ALshort *hrtf_left, *hrtf_right;
-
+ // Use a binaural HRTF algorithm for stereo headphone playback
if(Distance > 0.0f)
{
ALfloat invlen = 1.0f/Distance;
@@ -705,18 +694,14 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
Position[2] *= invlen;
}
- GetHrtfCoeffs(asin(Position[1]), atan2(Position[0], -Position[2]*ZScale),
- &hrtf_left, &hrtf_right,
- &ALSource->Params.HrtfDelay[0][0],
- &ALSource->Params.HrtfDelay[0][1]);
- for(i = 0;i < HRIR_LENGTH;i++)
- {
- ALSource->Params.HrtfCoeffs[0][i][0] = hrtf_left[i]*(1.0/32767.0) * DryGain;
- ALSource->Params.HrtfCoeffs[0][i][1] = hrtf_right[i]*(1.0/32767.0) * DryGain;
- }
+ GetLerpedHrtfCoeffs(asin(Position[1]),
+ atan2(Position[0], -Position[2]*ZScale), DryGain,
+ ALSource->Params.HrtfCoeffs[0],
+ ALSource->Params.HrtfDelay[0]);
}
else
{
+ // Use energy-preserving panning algorithm for multi-speaker playback
ALfloat DirGain, AmbientGain;
const ALfloat *SpeakerGain;
ALfloat length;