From 59768674f1764706a2e59c4c314f80eca3b5de9d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 13 Feb 2018 03:03:26 -0800 Subject: Use an alternate ambisonic HRTF decode layout Similar to the previous, but includes the top and bottom HRTF responses. The higher-order decode (for the "basic" HRTF output) also now uses 2H1P mixed- order instead of 2H1V, which seems more stable. --- Alc/panning.c | 115 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 48 deletions(-) (limited to 'Alc/panning.c') diff --git a/Alc/panning.c b/Alc/panning.c index b90652a3..6baff75f 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -649,6 +649,8 @@ static void InitPanning(ALCdevice *device) } else { + ALfloat w_scale=1.0f, xyz_scale=1.0f; + /* FOA output is always ACN+N3D for higher-order ambisonic output. * The upsampler expects this and will convert it for output. */ @@ -661,7 +663,17 @@ static void InitPanning(ALCdevice *device) device->FOAOut.CoeffCount = 0; device->FOAOut.NumChannels = 4; - ambiup_reset(device->AmbiUp, device); + if(device->AmbiOrder >= 3) + { + w_scale = W_SCALE_3H3P; + xyz_scale = XYZ_SCALE_3H3P; + } + else + { + w_scale = W_SCALE_2H2P; + xyz_scale = XYZ_SCALE_2H2P; + } + ambiup_reset(device->AmbiUp, device, w_scale, xyz_scale); } if(ConfigValueFloat(devname, "decoder", "nfc-ref-delay", &nfc_delay) && nfc_delay > 0.0f) @@ -870,62 +882,68 @@ static void InitHrtfPanning(ALCdevice *device) { /* NOTE: azimuth goes clockwise. */ static const ALfloat AmbiPoints[][2] = { - { 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( 45.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( -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(-135.0f) }, - { DEG2RAD(-35.0f), DEG2RAD( 135.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( 135.0f) }, + { DEG2RAD(-35.0f), DEG2RAD(-135.0f) }, + { DEG2RAD(-35.0f), DEG2RAD( -45.0f) }, + { DEG2RAD(-90.0f), DEG2RAD( 0.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 }, + { 5.55555556e-02f, 0.00000000e+00f, 1.23717915e-01f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f }, + { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f }, + { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f }, + { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f }, + { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.66025404e-02f }, + { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f }, + { 5.55555556e-02f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f }, + { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.66025404e-02f }, + { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f }, + { 5.55555556e-02f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f }, + { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f }, + { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f }, + { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f }, + { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f }, + { 5.55555556e-02f, 0.00000000e+00f, -1.23717915e-01f, 0.00000000e+00f }, }, 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 }, + { 5.55555556e-02f, 0.00000000e+00f, 1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 1.29099445e-01f }, + { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -1.29099445e-01f }, + { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, 6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 1.29099445e-01f }, + { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 8.66025404e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -1.29099445e-01f }, + { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, 6.83467648e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, + { 5.55555556e-02f, 0.00000000e+00f, -1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f }, }; static const ALfloat AmbiOrderHFGainFOA[MAX_AMBI_ORDER+1] = { - 2.82842712e+00, 1.63299316e+00 + 3.00000000e+00f, 1.73205081e+00f }, AmbiOrderHFGainHOA[MAX_AMBI_ORDER+1] = { - 2.15665546e+00, 1.67053814e+00, 8.62662186e-01 + 2.40192231e+00f, 1.86052102e+00f, 9.60768923e-01f }; const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS] = AmbiMatrixFOA; const ALfloat *restrict AmbiOrderHFGain = AmbiOrderHFGainFOA; @@ -964,7 +982,8 @@ static void InitHrtfPanning(ALCdevice *device) device->FOAOut.CoeffCount = 0; device->FOAOut.NumChannels = 4; - ambiup_reset(device->AmbiUp, device); + ambiup_reset(device->AmbiUp, device, AmbiOrderHFGainFOA[0] / AmbiOrderHFGain[0], + AmbiOrderHFGainFOA[1] / AmbiOrderHFGain[1]); } else { -- cgit v1.2.3