From da4f0c65c303ac3cffb0fe4da240b7bec573009a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 4 Jan 2017 21:53:28 -0800 Subject: [PATCH] Update the B-Format HRTF coefficients to use the pseudo-inverse matrix It's hard to tell which is ultimately better, although this way does make the FOA output somewhat louder which will help when it's combined with direct HRTF rendering. --- Alc/hrtf.c | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/Alc/hrtf.c b/Alc/hrtf.c index b3b795ac..3249868d 100644 --- a/Alc/hrtf.c +++ b/Alc/hrtf.c @@ -158,23 +158,21 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ { DEG2RAD(-90.0f), DEG2RAD( 0.0f) }, }; static const ALfloat Ambi3DMatrix[14][2][MAX_AMBI_COEFFS] = { - { { 0.078851598f, 0.000000000f, 0.070561967f, 0.000000000f }, { 0.0714285714f, 0.0000000000f, 0.1237180798f, 0.0000000000f } }, - { { 0.124051278f, 0.059847972f, 0.059847972f, 0.059847972f }, { 0.0714285714f, 0.0714285714f, 0.0714285714f, 0.0714285714f } }, - { { 0.124051278f, -0.059847972f, 0.059847972f, 0.059847972f }, { 0.0714285714f, -0.0714285714f, 0.0714285714f, 0.0714285714f } }, - { { 0.124051278f, -0.059847972f, 0.059847972f, -0.059847972f }, { 0.0714285714f, -0.0714285714f, 0.0714285714f, -0.0714285714f } }, - { { 0.124051278f, 0.059847972f, 0.059847972f, -0.059847972f }, { 0.0714285714f, 0.0714285714f, 0.0714285714f, -0.0714285714f } }, - { { 0.078851598f, 0.000000000f, 0.000000000f, 0.070561967f }, { 0.0714285714f, 0.0000000000f, 0.0000000000f, 0.1237180798f } }, - { { 0.078851598f, -0.070561967f, 0.000000000f, 0.000000000f }, { 0.0714285714f, -0.1237180798f, 0.0000000000f, 0.0000000000f } }, - { { 0.078851598f, 0.000000000f, 0.000000000f, -0.070561967f }, { 0.0714285714f, 0.0000000000f, 0.0000000000f, -0.1237180798f } }, - { { 0.078851598f, 0.070561967f, 0.000000000f, 0.000000000f }, { 0.0714285714f, 0.1237180798f, 0.0000000000f, 0.0000000000f } }, - { { 0.124051278f, 0.059847972f, -0.059847972f, 0.059847972f }, { 0.0714285714f, 0.0714285714f, -0.0714285714f, 0.0714285714f } }, - { { 0.124051278f, -0.059847972f, -0.059847972f, 0.059847972f }, { 0.0714285714f, -0.0714285714f, -0.0714285714f, 0.0714285714f } }, - { { 0.124051278f, -0.059847972f, -0.059847972f, -0.059847972f }, { 0.0714285714f, -0.0714285714f, -0.0714285714f, -0.0714285714f } }, - { { 0.124051278f, 0.059847972f, -0.059847972f, -0.059847972f }, { 0.0714285714f, 0.0714285714f, -0.0714285714f, -0.0714285714f } }, - { { 0.078851598f, 0.000000000f, -0.070561967f, 0.000000000f }, { 0.0714285714f, 0.0000000000f, -0.1237180798f, 0.0000000000f } }, + { { 0.1889822365f, 0.0000000000f, 0.1889822365f, 0.0000000000f }, { 0.0714285714f, 0.0000000000f, 0.1237180798f, 0.0000000000f } }, + { { 0.1889822365f, 0.1091089451f, 0.1091089451f, 0.1091089451f }, { 0.0714285714f, 0.0714285714f, 0.0714285714f, 0.0714285714f } }, + { { 0.1889822365f, -0.1091089451f, 0.1091089451f, 0.1091089451f }, { 0.0714285714f, -0.0714285714f, 0.0714285714f, 0.0714285714f } }, + { { 0.1889822365f, -0.1091089451f, 0.1091089451f, -0.1091089451f }, { 0.0714285714f, -0.0714285714f, 0.0714285714f, -0.0714285714f } }, + { { 0.1889822365f, 0.1091089451f, 0.1091089451f, -0.1091089451f }, { 0.0714285714f, 0.0714285714f, 0.0714285714f, -0.0714285714f } }, + { { 0.1889822365f, 0.0000000000f, 0.0000000000f, 0.1889822365f }, { 0.0714285714f, 0.0000000000f, 0.0000000000f, 0.1237180798f } }, + { { 0.1889822365f, -0.1889822365f, 0.0000000000f, 0.0000000000f }, { 0.0714285714f, -0.1237180798f, 0.0000000000f, 0.0000000000f } }, + { { 0.1889822365f, 0.0000000000f, 0.0000000000f, -0.1889822365f }, { 0.0714285714f, 0.0000000000f, 0.0000000000f, -0.1237180798f } }, + { { 0.1889822365f, 0.1889822365f, 0.0000000000f, 0.0000000000f }, { 0.0714285714f, 0.1237180798f, 0.0000000000f, 0.0000000000f } }, + { { 0.1889822365f, 0.1091089451f, -0.1091089451f, 0.1091089451f }, { 0.0714285714f, 0.0714285714f, -0.0714285714f, 0.0714285714f } }, + { { 0.1889822365f, -0.1091089451f, -0.1091089451f, 0.1091089451f }, { 0.0714285714f, -0.0714285714f, -0.0714285714f, 0.0714285714f } }, + { { 0.1889822365f, -0.1091089451f, -0.1091089451f, -0.1091089451f }, { 0.0714285714f, -0.0714285714f, -0.0714285714f, -0.0714285714f } }, + { { 0.1889822365f, 0.1091089451f, -0.1091089451f, -0.1091089451f }, { 0.0714285714f, 0.0714285714f, -0.0714285714f, -0.0714285714f } }, + { { 0.1889822365f, 0.0000000000f, -0.1889822365f, 0.0000000000f }, { 0.0714285714f, 0.0000000000f, -0.1237180798f, 0.0000000000f } }, }; -#define AMBIHF_GAIN 1.0f -#define AMBILF_GAIN 0.553914423f /* -5.13dB */ /* Change this to 2 for dual-band HRTF processing. May require a higher quality * band-splitter, or better calculation of the new IR length to deal with the @@ -236,11 +234,6 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ for(i = 0;i < Hrtf->irSize;i++) temps[2][i] = fir[i] / 32767.0f; bandsplit_process(&splitter, temps[0], temps[1], temps[2], HRIR_LENGTH); - /* Scale the low and high frequency responses. */ - for(i = 0;i < HRIR_LENGTH;i++) - temps[0][i] *= AMBIHF_GAIN; - for(i = 0;i < HRIR_LENGTH;i++) - temps[1][i] *= AMBILF_GAIN; } /* Add to the left output coefficients with the specified delay. */ @@ -270,11 +263,6 @@ ALuint BuildBFormatHrtf(const struct Hrtf *Hrtf, ALfloat (*coeffs)[HRIR_LENGTH][ for(i = 0;i < Hrtf->irSize;i++) temps[2][i] = fir[i] / 32767.0f; bandsplit_process(&splitter, temps[0], temps[1], temps[2], HRIR_LENGTH); - /* Scale the low and high frequency responses. */ - for(i = 0;i < HRIR_LENGTH;i++) - temps[0][i] *= AMBIHF_GAIN; - for(i = 0;i < HRIR_LENGTH;i++) - temps[1][i] *= AMBILF_GAIN; } /* Add to the right output coefficients with the specified delay. */ -- 2.11.4.GIT