aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/hrtf.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-05-03 03:15:28 -0700
committerChris Robinson <[email protected]>2011-05-03 03:15:28 -0700
commit48def2fecb3e3ff0e8500e3cec3bdc0639580e72 (patch)
tree550edc904d903a57c8eec854619a0d08d2129fd2 /Alc/hrtf.c
parentba236ad1084ffc99890f0301f444ddc7d63a64e1 (diff)
Properly handle elevations that don't have angles up to 180
Diffstat (limited to 'Alc/hrtf.c')
-rw-r--r--Alc/hrtf.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index 6972ec27..09747209 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -27,6 +27,7 @@
typedef struct {
ALsizei num_angles;
+ ALsizei max_angle;
ALshort coeffs[][2][HRTF_LENGTH];
} HrtfFilterCoeffs;
@@ -36,15 +37,17 @@ static void get_angle_coeffs(const HrtfFilterCoeffs *elev, ALfloat angle, const
{
if(angle < 0)
{
- int idx = ((angle > -180.0) ? (int)(angle*(elev->num_angles-1)/-180.0 + 0.5) :
- (elev->num_angles-1));
+ int idx = ((angle > -elev->max_angle) ?
+ (int)(angle*(elev->num_angles-1)/-elev->max_angle + 0.5) :
+ (elev->num_angles-1));
*left = elev->coeffs[idx][1];
*right = elev->coeffs[idx][0];
}
else
{
- int idx = ((angle < 180.0) ? (int)(angle*(elev->num_angles-1)/180.0 + 0.5) :
- (elev->num_angles-1));
+ int idx = ((angle < elev->max_angle) ?
+ (int)(angle*(elev->num_angles-1)/elev->max_angle + 0.5) :
+ (elev->num_angles-1));
*left = elev->coeffs[idx][0];
*right = elev->coeffs[idx][1];
}