From ee3d53a67373cae7ec13c29a4e3842e732ec06cc Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 10 Feb 2018 05:16:28 -0800 Subject: Use an alternate virtual layout for Ambisonic HRTF decoding This uses 16 channels, an 8-channel octagon + 8-channel cube, which should improve horizontal resolution without affecting vertical too much. --- Alc/hrtf.c | 17 +++++++--- Alc/hrtf.h | 2 +- Alc/panning.c | 105 +++++++++++++++++++++++++++++++++++----------------------- 3 files changed, 76 insertions(+), 48 deletions(-) diff --git a/Alc/hrtf.c b/Alc/hrtf.c index d1cfe6b0..cf211470 100644 --- a/Alc/hrtf.c +++ b/Alc/hrtf.c @@ -194,7 +194,7 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, } -void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[2][MAX_AMBI_COEFFS], ALsizei AmbiCount) +void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS], ALsizei AmbiCount, const ALfloat *restrict AmbiOrderHFGain) { /* Set 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 @@ -248,12 +248,13 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N { for(i = 0;i < NumChannels;++i) { + ALfloat hfgain = AmbiOrderHFGain[(ALsizei)floor(sqrt(i))]; ALsizei lidx = ldelay, ridx = rdelay; ALsizei j = 0; while(lidx < HRIR_LENGTH && ridx < HRIR_LENGTH && j < Hrtf->irSize) { - state->Chan[i].Coeffs[lidx++][0] += fir[j][0] * AmbiMatrix[c][0][i]; - state->Chan[i].Coeffs[ridx++][1] += fir[j][1] * AmbiMatrix[c][0][i]; + state->Chan[i].Coeffs[lidx++][0] += fir[j][0] * AmbiMatrix[c][i] * hfgain; + state->Chan[i].Coeffs[ridx++][1] += fir[j][1] * AmbiMatrix[c][i] * hfgain; j++; } } @@ -269,12 +270,15 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N /* Apply left ear response with delay. */ for(i = 0;i < NumChannels;++i) { + ALfloat hfgain = AmbiOrderHFGain[(ALsizei)floor(sqrt(i))]; for(b = 0;b < NUM_BANDS;b++) { ALsizei lidx = ldelay; ALsizei j = 0; while(lidx < HRIR_LENGTH) - state->Chan[i].Coeffs[lidx++][0] += temps[b][j++] * AmbiMatrix[c][b][i]; + state->Chan[i].Coeffs[lidx++][0] += temps[b][j++] * AmbiMatrix[c][i] * + hfgain; + hfgain = 1.0f; } } @@ -287,12 +291,15 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N /* Apply right ear response with delay. */ for(i = 0;i < NumChannels;++i) { + ALfloat hfgain = AmbiOrderHFGain[(ALsizei)floor(sqrt(i))]; for(b = 0;b < NUM_BANDS;b++) { ALsizei ridx = rdelay; ALsizei j = 0; while(ridx < HRIR_LENGTH) - state->Chan[i].Coeffs[ridx++][1] += temps[b][j++] * AmbiMatrix[c][b][i]; + state->Chan[i].Coeffs[ridx++][1] += temps[b][j++] * AmbiMatrix[c][i] * + hfgain; + hfgain = 1.0f; } } } diff --git a/Alc/hrtf.h b/Alc/hrtf.h index aaee4a8d..b041c911 100644 --- a/Alc/hrtf.h +++ b/Alc/hrtf.h @@ -79,6 +79,6 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, * virtual speaker positions and HF/LF matrices for decoding to them. The * returned coefficients are ordered and scaled according to the matrices. */ -void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[2][MAX_AMBI_COEFFS], ALsizei AmbiCount); +void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS], ALsizei AmbiCount, const ALfloat *restrict AmbiOrderHFGain); #endif /* ALC_HRTF_H */ diff --git a/Alc/panning.c b/Alc/panning.c index eaeb2646..e368c946 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -870,59 +870,79 @@ static void InitHrtfPanning(ALCdevice *device) { /* NOTE: azimuth goes clockwise. */ static const ALfloat AmbiPoints[][2] = { - { DEG2RAD( 90.0f), DEG2RAD( 0.0f) }, { DEG2RAD( 35.0f), DEG2RAD( -45.0f) }, - { DEG2RAD( 35.0f), DEG2RAD( 45.0f) }, - { DEG2RAD( 35.0f), DEG2RAD( 135.0f) }, { DEG2RAD( 35.0f), DEG2RAD(-135.0f) }, + { DEG2RAD( 35.0f), DEG2RAD( 135.0f) }, + { DEG2RAD( 35.0f), DEG2RAD( 45.0f) }, { DEG2RAD( 0.0f), DEG2RAD( 0.0f) }, - { DEG2RAD( 0.0f), DEG2RAD( 90.0f) }, - { DEG2RAD( 0.0f), DEG2RAD( 180.0f) }, + { DEG2RAD( 0.0f), DEG2RAD( -45.0f) }, { DEG2RAD( 0.0f), DEG2RAD( -90.0f) }, + { DEG2RAD( 0.0f), DEG2RAD(-135.0f) }, + { DEG2RAD( 0.0f), DEG2RAD( 180.0f) }, + { DEG2RAD( 0.0f), DEG2RAD( 135.0f) }, + { DEG2RAD( 0.0f), DEG2RAD( 90.0f) }, + { DEG2RAD( 0.0f), DEG2RAD( 45.0f) }, { DEG2RAD(-35.0f), DEG2RAD( -45.0f) }, - { DEG2RAD(-35.0f), DEG2RAD( 45.0f) }, - { DEG2RAD(-35.0f), DEG2RAD( 135.0f) }, { DEG2RAD(-35.0f), DEG2RAD(-135.0f) }, - { DEG2RAD(-90.0f), DEG2RAD( 0.0f) }, + { DEG2RAD(-35.0f), DEG2RAD( 135.0f) }, + { DEG2RAD(-35.0f), DEG2RAD( 45.0f) }, + }; + static const ALfloat AmbiMatrixFOA[][MAX_AMBI_COEFFS] = { + { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f }, + { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f }, + { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f }, + { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f }, + { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, 8.66025404e-002f }, + { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f }, + { 6.25000000e-002f, 8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f }, + { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f }, + { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, -8.66025404e-002f }, + { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f }, + { 6.25000000e-002f, -8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f }, + { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f }, + { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f }, + { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f }, + { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f }, + { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f }, + }, AmbiMatrixHOA[][MAX_AMBI_COEFFS] = { + { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f, 4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, 5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f, -4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, -5.00000000e-002f, 4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, -5.00000000e-002f, 1.25000000e-001f, 5.00000000e-002f, -4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, 8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.29099445e-001f }, + { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f, 6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f }, + { 6.25000000e-002f, 8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -1.29099445e-001f }, + { 6.25000000e-002f, 6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f, -6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f }, + { 6.25000000e-002f, 0.00000000e+000f, 0.00000000e+000f, -8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.29099445e-001f }, + { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, -6.12372435e-002f, 6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f }, + { 6.25000000e-002f, -8.66025404e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -1.29099445e-001f }, + { 6.25000000e-002f, -6.12372435e-002f, 0.00000000e+000f, 6.12372435e-002f, -6.83467648e-002f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f }, + { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f, 4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, 5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f, -4.55645099e-002f, -9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, -5.00000000e-002f, 4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, 9.68245837e-002f, 0.00000000e+000f }, + { 6.25000000e-002f, -5.00000000e-002f, -1.25000000e-001f, 5.00000000e-002f, -4.55645099e-002f, 9.68245837e-002f, 0.00000000e+000f, -9.68245837e-002f, 0.00000000e+000f }, }; - static const ALfloat AmbiMatrixFOA[][2][MAX_AMBI_COEFFS] = { - { { 1.88982237e-001f, 0.00000000e+000f, 1.90399923e-001f, 0.00000000e+000f }, { 7.14285714e-002f, 0.00000000e+000f, 1.24646009e-001f, 0.00000000e+000f } }, - { { 1.88982237e-001f, 1.09057783e-001f, 1.09208910e-001f, 1.09057783e-001f }, { 7.14285714e-002f, 7.13950780e-002f, 7.14940135e-002f, 7.13950780e-002f } }, - { { 1.88982237e-001f, -1.09057783e-001f, 1.09208910e-001f, 1.09057783e-001f }, { 7.14285714e-002f, -7.13950780e-002f, 7.14940135e-002f, 7.13950780e-002f } }, - { { 1.88982237e-001f, -1.09057783e-001f, 1.09208910e-001f, -1.09057783e-001f }, { 7.14285714e-002f, -7.13950780e-002f, 7.14940135e-002f, -7.13950780e-002f } }, - { { 1.88982237e-001f, 1.09057783e-001f, 1.09208910e-001f, -1.09057783e-001f }, { 7.14285714e-002f, 7.13950780e-002f, 7.14940135e-002f, -7.13950780e-002f } }, - { { 1.88982237e-001f, 0.00000000e+000f, 0.00000000e+000f, 1.88281281e-001f }, { 7.14285714e-002f, 0.00000000e+000f, 0.00000000e+000f, 1.23259031e-001f } }, - { { 1.88982237e-001f, -1.88281281e-001f, 0.00000000e+000f, 0.00000000e+000f }, { 7.14285714e-002f, -1.23259031e-001f, 0.00000000e+000f, 0.00000000e+000f } }, - { { 1.88982237e-001f, 0.00000000e+000f, 0.00000000e+000f, -1.88281281e-001f }, { 7.14285714e-002f, 0.00000000e+000f, 0.00000000e+000f, -1.23259031e-001f } }, - { { 1.88982237e-001f, 1.88281281e-001f, 0.00000000e+000f, 0.00000000e+000f }, { 7.14285714e-002f, 1.23259031e-001f, 0.00000000e+000f, 0.00000000e+000f } }, - { { 1.88982237e-001f, 1.09057783e-001f, -1.09208910e-001f, 1.09057783e-001f }, { 7.14285714e-002f, 7.13950780e-002f, -7.14940135e-002f, 7.13950780e-002f } }, - { { 1.88982237e-001f, -1.09057783e-001f, -1.09208910e-001f, 1.09057783e-001f }, { 7.14285714e-002f, -7.13950780e-002f, -7.14940135e-002f, 7.13950780e-002f } }, - { { 1.88982237e-001f, -1.09057783e-001f, -1.09208910e-001f, -1.09057783e-001f }, { 7.14285714e-002f, -7.13950780e-002f, -7.14940135e-002f, -7.13950780e-002f } }, - { { 1.88982237e-001f, 1.09057783e-001f, -1.09208910e-001f, -1.09057783e-001f }, { 7.14285714e-002f, 7.13950780e-002f, -7.14940135e-002f, -7.13950780e-002f } }, - { { 1.88982237e-001f, 0.00000000e+000f, -1.90399923e-001f, 0.00000000e+000f }, { 7.14285714e-002f, 0.00000000e+000f, -1.24646009e-001f, 0.00000000e+000f } } - }, AmbiMatrixHOA[][2][MAX_AMBI_COEFFS] = { - { { 1.43315266e-001f, 0.00000000e+000f, 1.90399923e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.18020996e-001f, 0.00000000e+000f, 0.00000000e+000f }, { 7.26741039e-002f, 0.00000000e+000f, 1.24646009e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.49618920e-001f, 0.00000000e+000f, 0.00000000e+000f } }, - { { 1.40852210e-001f, 1.09057783e-001f, 1.09208910e-001f, 1.09057783e-001f, 7.58818830e-002f, 7.66295578e-002f, -3.28314629e-004f, 7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, 7.13950780e-002f, 7.14940135e-002f, 7.13950780e-002f, 9.61978444e-002f, 9.71456952e-002f, -4.16214759e-004f, 9.71456952e-002f, 0.00000000e+000f } }, - { { 1.40852210e-001f, -1.09057783e-001f, 1.09208910e-001f, 1.09057783e-001f, -7.58818830e-002f, -7.66295578e-002f, -3.28314629e-004f, 7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, -7.13950780e-002f, 7.14940135e-002f, 7.13950780e-002f, -9.61978444e-002f, -9.71456952e-002f, -4.16214759e-004f, 9.71456952e-002f, 0.00000000e+000f } }, - { { 1.40852210e-001f, -1.09057783e-001f, 1.09208910e-001f, -1.09057783e-001f, 7.58818830e-002f, -7.66295578e-002f, -3.28314629e-004f, -7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, -7.13950780e-002f, 7.14940135e-002f, -7.13950780e-002f, 9.61978444e-002f, -9.71456952e-002f, -4.16214759e-004f, -9.71456952e-002f, 0.00000000e+000f } }, - { { 1.40852210e-001f, 1.09057783e-001f, 1.09208910e-001f, -1.09057783e-001f, -7.58818830e-002f, 7.66295578e-002f, -3.28314629e-004f, -7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, 7.13950780e-002f, 7.14940135e-002f, -7.13950780e-002f, -9.61978444e-002f, 9.71456952e-002f, -4.16214759e-004f, -9.71456952e-002f, 0.00000000e+000f } }, - { { 1.39644596e-001f, 0.00000000e+000f, 0.00000000e+000f, 1.88281281e-001f, 0.00000000e+000f, 0.00000000e+000f, -5.83538687e-002f, 0.00000000e+000f, 1.01835015e-001f }, { 7.08127349e-002f, 0.00000000e+000f, 0.00000000e+000f, 1.23259031e-001f, 0.00000000e+000f, 0.00000000e+000f, -7.39770307e-002f, 0.00000000e+000f, 1.29099445e-001f } }, - { { 1.39644596e-001f, -1.88281281e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -5.83538687e-002f, 0.00000000e+000f, -1.01835015e-001f }, { 7.08127349e-002f, -1.23259031e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -7.39770307e-002f, 0.00000000e+000f, -1.29099445e-001f } }, - { { 1.39644596e-001f, 0.00000000e+000f, 0.00000000e+000f, -1.88281281e-001f, 0.00000000e+000f, 0.00000000e+000f, -5.83538687e-002f, 0.00000000e+000f, 1.01835015e-001f }, { 7.08127349e-002f, 0.00000000e+000f, 0.00000000e+000f, -1.23259031e-001f, 0.00000000e+000f, 0.00000000e+000f, -7.39770307e-002f, 0.00000000e+000f, 1.29099445e-001f } }, - { { 1.39644596e-001f, 1.88281281e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -5.83538687e-002f, 0.00000000e+000f, -1.01835015e-001f }, { 7.08127349e-002f, 1.23259031e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, -7.39770307e-002f, 0.00000000e+000f, -1.29099445e-001f } }, - { { 1.40852210e-001f, 1.09057783e-001f, -1.09208910e-001f, 1.09057783e-001f, 7.58818830e-002f, -7.66295578e-002f, -3.28314629e-004f, -7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, 7.13950780e-002f, -7.14940135e-002f, 7.13950780e-002f, 9.61978444e-002f, -9.71456952e-002f, -4.16214759e-004f, -9.71456952e-002f, 0.00000000e+000f } }, - { { 1.40852210e-001f, -1.09057783e-001f, -1.09208910e-001f, 1.09057783e-001f, -7.58818830e-002f, 7.66295578e-002f, -3.28314629e-004f, -7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, -7.13950780e-002f, -7.14940135e-002f, 7.13950780e-002f, -9.61978444e-002f, 9.71456952e-002f, -4.16214759e-004f, -9.71456952e-002f, 0.00000000e+000f } }, - { { 1.40852210e-001f, -1.09057783e-001f, -1.09208910e-001f, -1.09057783e-001f, 7.58818830e-002f, 7.66295578e-002f, -3.28314629e-004f, 7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, -7.13950780e-002f, -7.14940135e-002f, -7.13950780e-002f, 9.61978444e-002f, 9.71456952e-002f, -4.16214759e-004f, 9.71456952e-002f, 0.00000000e+000f } }, - { { 1.40852210e-001f, 1.09057783e-001f, -1.09208910e-001f, -1.09057783e-001f, -7.58818830e-002f, -7.66295578e-002f, -3.28314629e-004f, 7.66295578e-002f, 0.00000000e+000f }, { 7.14251066e-002f, 7.13950780e-002f, -7.14940135e-002f, -7.13950780e-002f, -9.61978444e-002f, -9.71456952e-002f, -4.16214759e-004f, 9.71456952e-002f, 0.00000000e+000f } }, - { { 1.43315266e-001f, 0.00000000e+000f, -1.90399923e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.18020996e-001f, 0.00000000e+000f, 0.00000000e+000f }, { 7.26741039e-002f, 0.00000000e+000f, -1.24646009e-001f, 0.00000000e+000f, 0.00000000e+000f, 0.00000000e+000f, 1.49618920e-001f, 0.00000000e+000f, 0.00000000e+000f } }, + static const ALfloat AmbiOrderHFGainFOA[MAX_AMBI_ORDER+1] = { + 2.82842712e+00, 1.63299316e+00 + }, AmbiOrderHFGainHOA[MAX_AMBI_ORDER+1] = { + 2.15665546e+00, 1.67053814e+00, 8.62662186e-01 }; - const ALfloat (*AmbiMatrix)[2][MAX_AMBI_COEFFS] = device->AmbiUp ? AmbiMatrixHOA : - AmbiMatrixFOA; - ALsizei count = device->AmbiUp ? 9 : 4; + const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS] = AmbiMatrixFOA; + const ALfloat *restrict AmbiOrderHFGain = AmbiOrderHFGainFOA; + ALsizei count = 4; ALsizei i; + static_assert(COUNTOF(AmbiPoints) == COUNTOF(AmbiMatrixFOA), "FOA Ambisonic HRTF mismatch"); + static_assert(COUNTOF(AmbiPoints) == COUNTOF(AmbiMatrixHOA), "HOA Ambisonic HRTF mismatch"); static_assert(COUNTOF(AmbiPoints) <= HRTF_AMBI_MAX_CHANNELS, "HRTF_AMBI_MAX_CHANNELS is too small"); + if(device->AmbiUp) + { + AmbiMatrix = AmbiMatrixHOA; + AmbiOrderHFGain = AmbiOrderHFGainHOA; + count = 9; + } + device->Hrtf = al_calloc(16, FAM_SIZE(DirectHrtfState, Chan, count)); for(i = 0;i < count;i++) @@ -956,7 +976,8 @@ static void InitHrtfPanning(ALCdevice *device) device->RealOut.NumChannels = ChannelsFromDevFmt(device->FmtChans, device->AmbiOrder); BuildBFormatHrtf(device->HrtfHandle, - device->Hrtf, device->Dry.NumChannels, AmbiPoints, AmbiMatrix, COUNTOF(AmbiPoints) + device->Hrtf, device->Dry.NumChannels, AmbiPoints, AmbiMatrix, COUNTOF(AmbiPoints), + AmbiOrderHFGain ); InitNearFieldCtrl(device, device->HrtfHandle->distance, device->AmbiUp ? 2 : 1, true); -- cgit v1.2.3