aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/panning.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-21 06:32:18 -0800
committerChris Robinson <[email protected]>2018-12-21 06:32:18 -0800
commitb785d805263c9517c1523785b2da39f9a47b6002 (patch)
tree5f5e3174483af7265bfd55b737bd5ee112d23f34 /Alc/panning.cpp
parent7744e4ff72def926a26feca391170d25df39c469 (diff)
Use a dodecahedron for the ambisonic HRTF decode
Also uses full second-order for "basic" HRTF rendering. Note that the supplied matrix is full third-order, but only the first- and second-order coefficients are used. The base matrices are the identical, only differing by the high- frequency scalars.
Diffstat (limited to 'Alc/panning.cpp')
-rw-r--r--Alc/panning.cpp119
1 files changed, 51 insertions, 68 deletions
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index 783fe480..9c3be106 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -618,78 +618,62 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp
void InitHrtfPanning(ALCdevice *device)
{
/* NOTE: azimuth goes clockwise. */
- static constexpr AngularPoint AmbiPoints[] = {
- { DEG2RAD( 90.0f), DEG2RAD( 0.0f) },
- { DEG2RAD( 35.2643897f), DEG2RAD( 45.0f) },
- { DEG2RAD( 35.2643897f), DEG2RAD( 135.0f) },
- { DEG2RAD( 35.2643897f), DEG2RAD(-135.0f) },
- { DEG2RAD( 35.2643897f), 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.2643897f), DEG2RAD( 45.0f) },
- { DEG2RAD(-35.2643897f), DEG2RAD( 135.0f) },
- { DEG2RAD(-35.2643897f), DEG2RAD(-135.0f) },
- { DEG2RAD(-35.2643897f), DEG2RAD( -45.0f) },
- { DEG2RAD(-90.0f), DEG2RAD( 0.0f) },
+ static constexpr AngularPoint AmbiPoints[]{
+ { DEG2RAD( 35.264390f), DEG2RAD( -45.000000f) },
+ { DEG2RAD( 35.264390f), DEG2RAD( 45.000000f) },
+ { DEG2RAD( 35.264390f), DEG2RAD( 135.000000f) },
+ { DEG2RAD( 35.264390f), DEG2RAD(-135.000000f) },
+ { DEG2RAD(-35.264390f), DEG2RAD( -45.000000f) },
+ { DEG2RAD(-35.264390f), DEG2RAD( 45.000000f) },
+ { DEG2RAD(-35.264390f), DEG2RAD( 135.000000f) },
+ { DEG2RAD(-35.264390f), DEG2RAD(-135.000000f) },
+ { DEG2RAD( 0.000000f), DEG2RAD( -20.905157f) },
+ { DEG2RAD( 0.000000f), DEG2RAD( 20.905157f) },
+ { DEG2RAD( 0.000000f), DEG2RAD( 159.094843f) },
+ { DEG2RAD( 0.000000f), DEG2RAD(-159.094843f) },
+ { DEG2RAD( 20.905157f), DEG2RAD( -90.000000f) },
+ { DEG2RAD(-20.905157f), DEG2RAD( -90.000000f) },
+ { DEG2RAD(-20.905157f), DEG2RAD( 90.000000f) },
+ { DEG2RAD( 20.905157f), DEG2RAD( 90.000000f) },
+ { DEG2RAD( 69.094843f), DEG2RAD( 0.000000f) },
+ { DEG2RAD(-69.094843f), DEG2RAD( 0.000000f) },
+ { DEG2RAD(-69.094843f), DEG2RAD( 180.000000f) },
+ { DEG2RAD( 69.094843f), DEG2RAD( 180.000000f) },
};
- static constexpr ALfloat AmbiMatrixFOA[][MAX_AMBI_COEFFS] = {
- { 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] = {
- { 5.55555556e-02f, 0.00000000e+00f, 1.23717915e-01f, 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 },
- { 5.55555556e-02f, -5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 5.00000000e-02f, 7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, 8.66025404e-02f, 0.00000000e+00f, 1.29099445e-01f },
- { 5.55555556e-02f, -6.12372435e-02f, 0.00000000e+00f, 6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, -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 },
- { 5.55555556e-02f, 0.00000000e+00f, 0.00000000e+00f, -8.66025404e-02f, 0.00000000e+00f, 1.29099445e-01f },
- { 5.55555556e-02f, 6.12372435e-02f, 0.00000000e+00f, -6.12372435e-02f, -6.83467648e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 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 },
- { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, -5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, -5.00000000e-02f, -4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 5.00000000e-02f, -7.14285715e-02f, 5.00000000e-02f, 4.55645099e-02f, 0.00000000e+00f },
- { 5.55555556e-02f, 0.00000000e+00f, -1.23717915e-01f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f },
+ static constexpr ALfloat AmbiMatrix[][MAX_AMBI_COEFFS]{
+ { 5.00000000e-02f, 5.00000000e-02f, 5.00000000e-02f, 5.00000000e-02f, 6.45497224e-02f, 6.45497224e-02f, 0.00000000e+00f, 6.45497224e-02f, 0.00000000e+00f, 1.48264644e-02f, 6.33865691e-02f, 1.01126676e-01f, -7.36485380e-02f, -1.09260065e-02f, 7.08683387e-02f, -1.01622099e-01f },
+ { 5.00000000e-02f, -5.00000000e-02f, 5.00000000e-02f, 5.00000000e-02f, -6.45497224e-02f, -6.45497224e-02f, 0.00000000e+00f, 6.45497224e-02f, 0.00000000e+00f, -1.48264644e-02f, -6.33865691e-02f, -1.01126676e-01f, -7.36485380e-02f, -1.09260065e-02f, 7.08683387e-02f, -1.01622099e-01f },
+ { 5.00000000e-02f, -5.00000000e-02f, 5.00000000e-02f, -5.00000000e-02f, 6.45497224e-02f, -6.45497224e-02f, 0.00000000e+00f, -6.45497224e-02f, 0.00000000e+00f, -1.48264644e-02f, 6.33865691e-02f, -1.01126676e-01f, -7.36485380e-02f, 1.09260065e-02f, 7.08683387e-02f, 1.01622099e-01f },
+ { 5.00000000e-02f, 5.00000000e-02f, 5.00000000e-02f, -5.00000000e-02f, -6.45497224e-02f, 6.45497224e-02f, 0.00000000e+00f, -6.45497224e-02f, 0.00000000e+00f, 1.48264644e-02f, -6.33865691e-02f, 1.01126676e-01f, -7.36485380e-02f, 1.09260065e-02f, 7.08683387e-02f, 1.01622099e-01f },
+ { 5.00000000e-02f, 5.00000000e-02f, -5.00000000e-02f, 5.00000000e-02f, 6.45497224e-02f, -6.45497224e-02f, 0.00000000e+00f, -6.45497224e-02f, 0.00000000e+00f, 1.48264644e-02f, -6.33865691e-02f, 1.01126676e-01f, 7.36485380e-02f, -1.09260065e-02f, -7.08683387e-02f, -1.01622099e-01f },
+ { 5.00000000e-02f, -5.00000000e-02f, -5.00000000e-02f, 5.00000000e-02f, -6.45497224e-02f, 6.45497224e-02f, 0.00000000e+00f, -6.45497224e-02f, 0.00000000e+00f, -1.48264644e-02f, 6.33865691e-02f, -1.01126676e-01f, 7.36485380e-02f, -1.09260065e-02f, -7.08683387e-02f, -1.01622099e-01f },
+ { 5.00000000e-02f, -5.00000000e-02f, -5.00000000e-02f, -5.00000000e-02f, 6.45497224e-02f, 6.45497224e-02f, 0.00000000e+00f, 6.45497224e-02f, 0.00000000e+00f, -1.48264644e-02f, -6.33865691e-02f, -1.01126676e-01f, 7.36485380e-02f, 1.09260065e-02f, -7.08683387e-02f, 1.01622099e-01f },
+ { 5.00000000e-02f, 5.00000000e-02f, -5.00000000e-02f, -5.00000000e-02f, -6.45497224e-02f, -6.45497224e-02f, 0.00000000e+00f, 6.45497224e-02f, 0.00000000e+00f, 1.48264644e-02f, 6.33865691e-02f, 1.01126676e-01f, 7.36485380e-02f, 1.09260065e-02f, -7.08683387e-02f, 1.01622099e-01f },
+ { 5.00000000e-02f, 3.09016994e-02f, 0.00000000e+00f, 8.09016994e-02f, 6.45497224e-02f, 0.00000000e+00f, -5.59016994e-02f, 0.00000000e+00f, 7.21687836e-02f, 7.76323754e-02f, 0.00000000e+00f, -1.49775925e-01f, 0.00000000e+00f, -2.95083663e-02f, 0.00000000e+00f, 7.76323754e-02f },
+ { 5.00000000e-02f, -3.09016994e-02f, 0.00000000e+00f, 8.09016994e-02f, -6.45497224e-02f, 0.00000000e+00f, -5.59016994e-02f, 0.00000000e+00f, 7.21687836e-02f, -7.76323754e-02f, 0.00000000e+00f, 1.49775925e-01f, 0.00000000e+00f, -2.95083663e-02f, 0.00000000e+00f, 7.76323754e-02f },
+ { 5.00000000e-02f, -3.09016994e-02f, 0.00000000e+00f, -8.09016994e-02f, 6.45497224e-02f, 0.00000000e+00f, -5.59016994e-02f, 0.00000000e+00f, 7.21687836e-02f, -7.76323754e-02f, 0.00000000e+00f, 1.49775925e-01f, 0.00000000e+00f, 2.95083663e-02f, 0.00000000e+00f, -7.76323754e-02f },
+ { 5.00000000e-02f, 3.09016994e-02f, 0.00000000e+00f, -8.09016994e-02f, -6.45497224e-02f, 0.00000000e+00f, -5.59016994e-02f, 0.00000000e+00f, 7.21687836e-02f, 7.76323754e-02f, 0.00000000e+00f, -1.49775925e-01f, 0.00000000e+00f, 2.95083663e-02f, 0.00000000e+00f, -7.76323754e-02f },
+ { 5.00000000e-02f, 8.09016994e-02f, 3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, 6.45497224e-02f, -3.45491503e-02f, 0.00000000e+00f, -8.44966837e-02f, -4.79794466e-02f, 0.00000000e+00f, -6.77901327e-02f, 3.03448665e-02f, 0.00000000e+00f, -1.65948192e-01f, 0.00000000e+00f },
+ { 5.00000000e-02f, 8.09016994e-02f, -3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, -6.45497224e-02f, -3.45491503e-02f, 0.00000000e+00f, -8.44966837e-02f, -4.79794466e-02f, 0.00000000e+00f, -6.77901327e-02f, -3.03448665e-02f, 0.00000000e+00f, 1.65948192e-01f, 0.00000000e+00f },
+ { 5.00000000e-02f, -8.09016994e-02f, -3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, 6.45497224e-02f, -3.45491503e-02f, 0.00000000e+00f, -8.44966837e-02f, 4.79794466e-02f, 0.00000000e+00f, 6.77901327e-02f, -3.03448665e-02f, 0.00000000e+00f, 1.65948192e-01f, 0.00000000e+00f },
+ { 5.00000000e-02f, -8.09016994e-02f, 3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, -6.45497224e-02f, -3.45491503e-02f, 0.00000000e+00f, -8.44966837e-02f, 4.79794466e-02f, 0.00000000e+00f, 6.77901327e-02f, 3.03448665e-02f, 0.00000000e+00f, -1.65948192e-01f, 0.00000000e+00f },
+ { 5.00000000e-02f, 0.00000000e+00f, 8.09016994e-02f, 3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, 9.04508497e-02f, 6.45497224e-02f, 1.23279000e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 7.94438918e-02f, 1.12611206e-01f, -2.42115150e-02f, 1.25611822e-01f },
+ { 5.00000000e-02f, 0.00000000e+00f, -8.09016994e-02f, 3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, 9.04508497e-02f, -6.45497224e-02f, 1.23279000e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -7.94438918e-02f, 1.12611206e-01f, 2.42115150e-02f, 1.25611822e-01f },
+ { 5.00000000e-02f, 0.00000000e+00f, -8.09016994e-02f, -3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, 9.04508497e-02f, 6.45497224e-02f, 1.23279000e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, -7.94438918e-02f, -1.12611206e-01f, 2.42115150e-02f, -1.25611822e-01f },
+ { 5.00000000e-02f, 0.00000000e+00f, 8.09016994e-02f, -3.09016994e-02f, 0.00000000e+00f, 0.00000000e+00f, 9.04508497e-02f, -6.45497224e-02f, 1.23279000e-02f, 0.00000000e+00f, 0.00000000e+00f, 0.00000000e+00f, 7.94438918e-02f, -1.12611206e-01f, -2.42115150e-02f, -1.25611822e-01f }
};
- static constexpr ALfloat AmbiOrderHFGainFOA[MAX_AMBI_ORDER+1] = {
- 3.00000000e+00f, 1.73205081e+00f
- }, AmbiOrderHFGainHOA[MAX_AMBI_ORDER+1] = {
- 2.40192231e+00f, 1.86052102e+00f, 9.60768923e-01f
+ static constexpr ALfloat AmbiOrderHFGainFOA[MAX_AMBI_ORDER+1]{
+ 3.16227766e+00f, 1.82574186e+00f
+ }, AmbiOrderHFGainHOA[MAX_AMBI_ORDER+1]{
+ 2.35702260e+00f, 1.82574186e+00f, 9.42809042e-01f
+ /* 1.86508671e+00f, 1.60609389e+00f, 1.14205530e+00f, 5.68379553e-01f */
};
- static constexpr ALsizei IndexMap[6] = { 0, 1, 2, 3, 4, 8 };
- static constexpr ALsizei ChansPerOrder[MAX_AMBI_ORDER+1] = { 1, 3, 2, 0 };
- const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_COEFFS] = AmbiMatrixFOA;
- const ALfloat *RESTRICT AmbiOrderHFGain = AmbiOrderHFGainFOA;
+ static constexpr ALsizei IndexMap[9]{ 0, 1, 2, 3, 4, 5, 6, 7, 8 };
+ static constexpr ALsizei ChansPerOrder[MAX_AMBI_ORDER+1]{ 1, 3, 5, 0 };
+ const ALfloat *AmbiOrderHFGain{AmbiOrderHFGainFOA};
ALsizei count{4};
- static_assert(COUNTOF(AmbiPoints) == COUNTOF(AmbiMatrixFOA), "FOA Ambisonic HRTF mismatch");
- static_assert(COUNTOF(AmbiPoints) == COUNTOF(AmbiMatrixHOA), "HOA Ambisonic HRTF mismatch");
+ static_assert(COUNTOF(AmbiPoints) == COUNTOF(AmbiMatrix), "Ambisonic HRTF mismatch");
/* Don't bother with HOA when using full HRTF rendering. Nothing needs it,
* and it eases the CPU/memory load.
@@ -698,7 +682,6 @@ void InitHrtfPanning(ALCdevice *device)
{
device->AmbiUp.reset(new AmbiUpsampler{});
- AmbiMatrix = AmbiMatrixHOA;
AmbiOrderHFGain = AmbiOrderHFGainHOA;
count = static_cast<ALsizei>(COUNTOF(IndexMap));
}