diff options
author | Chris Robinson <[email protected]> | 2018-02-10 05:16:28 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-02-10 05:16:28 -0800 |
commit | ee3d53a67373cae7ec13c29a4e3842e732ec06cc (patch) | |
tree | 3adee7ad74d89e4c7571b2729ec15fc8b95ea0f1 /Alc/panning.c | |
parent | c346baff5b5e86e7e7982b5e644ecf756a040170 (diff) |
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.
Diffstat (limited to 'Alc/panning.c')
-rw-r--r-- | Alc/panning.c | 105 |
1 files changed, 63 insertions, 42 deletions
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); |