aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2015-02-14 12:11:50 -0800
committerChris Robinson <[email protected]>2015-02-14 12:11:50 -0800
commitb4c9744d6ae8e768614ae911c69f49f7f341e94c (patch)
tree638ad6a664414393127e9664b35845b0085a5719 /Alc
parent18fed4e79ab8e3aa4455170b714f2c90c3ff4417 (diff)
Fix the HRTF B-Format decoder's W coefficient
And limit it to first-order again, since there will likely need to be extra scalings applied.
Diffstat (limited to 'Alc')
-rw-r--r--Alc/hrtf.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index c707b819..13aef6d6 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -312,14 +312,14 @@ ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat a
}
-/* Calculates HRTF coefficients for B-Format channels. */
+/* Calculates HRTF coefficients for B-Format channels (only up to first-order). */
void GetBFormatHrtfCoeffs(const struct Hrtf *Hrtf, const ALuint num_chans, ALfloat (**coeffs_list)[2], ALuint **delay_list)
{
ALuint elev_idx, azi_idx;
ALfloat scale;
ALuint i, c;
- assert(num_chans <= MAX_AMBI_COEFFS);
+ assert(num_chans <= 4);
for(c = 0;c < num_chans;c++)
{
@@ -352,10 +352,9 @@ void GetBFormatHrtfCoeffs(const struct Hrtf *Hrtf, const ALuint num_chans, ALflo
for(azi_idx = 0;azi_idx < azcount;azi_idx++)
{
ALuint lidx, ridx;
- ALfloat az;
- ALfloat ambi_coeffs[MAX_AMBI_COEFFS];
+ ALfloat ambi_coeffs[4];
+ ALfloat az, gain;
ALfloat x, y, z;
- ALfloat gain;
lidx = evoffset + azi_idx;
ridx = evoffset + ((azcount-azi_idx) % azcount);
@@ -367,22 +366,10 @@ void GetBFormatHrtfCoeffs(const struct Hrtf *Hrtf, const ALuint num_chans, ALflo
y = sinf(-az) * cosf(elev);
z = sinf(elev);
- ambi_coeffs[0] = 0.7071f; /* sqrt(1.0 / 2.0) */
+ ambi_coeffs[0] = 1.4142f;
ambi_coeffs[1] = x; /* X */
ambi_coeffs[2] = y; /* Y */
ambi_coeffs[3] = z; /* Z */
- ambi_coeffs[4] = 0.5f * (3.0f*z*z - 1.0f); /* 0.5 * (3*Z*Z - 1) */
- ambi_coeffs[5] = 2.0f * z * x; /* 2*Z*X */
- ambi_coeffs[6] = 2.0f * y * z; /* 2*Y*Z */
- ambi_coeffs[7] = x*x - y*y; /* X*X - Y*Y */
- ambi_coeffs[8] = 2.0f * x * y; /* 2*X*Y */
- ambi_coeffs[9] = 0.5f * z * (5.0f*z*z - 3.0f); /* 0.5 * Z * (5*Z*Z - 3) */
- ambi_coeffs[10] = 0.7262f * x * (5.0f*z*z - 1.0f); /* sqrt(135.0 / 256.0) * X * (5*Z*Z - 1) */
- ambi_coeffs[11] = 0.7262f * y * (5.0f*z*z - 1.0f); /* sqrt(135.0 / 256.0) * Y * (5*Z*Z - 1) */
- ambi_coeffs[12] = 2.5981f * z * (x*x - y*y); /* sqrt(27.0 / 4.0) * Z * (X*X - Y*Y) */
- ambi_coeffs[13] = 5.1962f * x * y * z; /* sqrt(27) * X * Y * Z */
- ambi_coeffs[14] = x * (x*x - 3.0f*y*y); /* X * (X*X - 3*Y*Y) */
- ambi_coeffs[15] = y * (3.0f*x*x - y*y); /* Y * (3*X*X - Y*Y) */
for(c = 0;c < num_chans;c++)
{