aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-11-30 18:42:04 -0800
committerChris Robinson <[email protected]>2019-11-30 18:42:04 -0800
commit9559f7bfc29350ffb71cbd4c14f11c6de927c781 (patch)
treebcce4340af48a436fd0d0303410bd6d84514e2c9 /alc
parentfcf03705e69f545972fa4e2b8d1f6a820f7ff784 (diff)
Update the second-order decoder for HRTF
This uses fewer virtual speakers to help with clarity. The fewer speakers used for the response, the less destructive phase interference there should be.
Diffstat (limited to 'alc')
-rw-r--r--alc/panning.cpp102
1 files changed, 45 insertions, 57 deletions
diff --git a/alc/panning.cpp b/alc/panning.cpp
index 38674f5e..1a06c264 100644
--- a/alc/panning.cpp
+++ b/alc/panning.cpp
@@ -523,10 +523,10 @@ void InitCustomPanning(ALCdevice *device, bool hqdec, const AmbDecConf *conf,
void InitHrtfPanning(ALCdevice *device)
{
constexpr float PI{al::MathDefs<float>::Pi()};
- constexpr float PI_2{al::MathDefs<float>::Pi() / 2.0f};
- constexpr float PI_4{al::MathDefs<float>::Pi() / 4.0f};
- constexpr float PI3_4{al::MathDefs<float>::Pi() * 3.0f / 4.0f};
- const float CornerElev{static_cast<float>(std::atan2(1.0, std::sqrt(2.0)))};
+ constexpr float PI_2{PI / 2.0f};
+ constexpr float PI_4{PI_2 / 2.0f};
+ constexpr float PI3_4{PI_4 * 3.0f};
+ static const float CornerElev{static_cast<float>(std::atan2(1.0, std::sqrt(2.0)))};
static const AngularPoint AmbiPoints1O[]{
{ ElevRadius{ CornerElev}, AzimRadius{ -PI_4} },
{ ElevRadius{ CornerElev}, AzimRadius{-PI3_4} },
@@ -537,32 +537,26 @@ void InitHrtfPanning(ALCdevice *device)
{ ElevRadius{-CornerElev}, AzimRadius{ PI_4} },
{ ElevRadius{-CornerElev}, AzimRadius{ PI3_4} },
}, AmbiPoints2O[]{
- { ElevRadius{ 0.0f}, AzimRadius{ 0.0f} },
- { ElevRadius{ 0.0f}, AzimRadius{ PI} },
- { ElevRadius{ 0.0f}, AzimRadius{ -PI_2} },
- { ElevRadius{ 0.0f}, AzimRadius{ PI_2} },
- { ElevRadius{ PI_2}, AzimRadius{ 0.0f} },
- { ElevRadius{ -PI_2}, AzimRadius{ 0.0f} },
- { ElevRadius{ PI_4}, AzimRadius{ -PI_2} },
- { ElevRadius{ PI_4}, AzimRadius{ PI_2} },
- { ElevRadius{ -PI_4}, AzimRadius{ -PI_2} },
- { ElevRadius{ -PI_4}, AzimRadius{ PI_2} },
- { ElevRadius{ PI_4}, AzimRadius{ 0.0f} },
- { ElevRadius{ PI_4}, AzimRadius{ PI} },
- { ElevRadius{ -PI_4}, AzimRadius{ 0.0f} },
- { ElevRadius{ -PI_4}, AzimRadius{ PI} },
- { ElevRadius{ 0.0f}, AzimRadius{ -PI_4} },
- { ElevRadius{ 0.0f}, AzimRadius{-PI3_4} },
- { ElevRadius{ 0.0f}, AzimRadius{ PI_4} },
- { ElevRadius{ 0.0f}, AzimRadius{ PI3_4} },
- { ElevRadius{ CornerElev}, AzimRadius{ -PI_4} },
- { ElevRadius{ CornerElev}, AzimRadius{-PI3_4} },
- { ElevRadius{ CornerElev}, AzimRadius{ PI_4} },
- { ElevRadius{ CornerElev}, AzimRadius{ PI3_4} },
- { ElevRadius{-CornerElev}, AzimRadius{ -PI_4} },
- { ElevRadius{-CornerElev}, AzimRadius{-PI3_4} },
- { ElevRadius{-CornerElev}, AzimRadius{ PI_4} },
- { ElevRadius{-CornerElev}, AzimRadius{ PI3_4} },
+ { ElevRadius{ -CornerElev}, AzimRadius{ -PI_4} },
+ { ElevRadius{ -CornerElev}, AzimRadius{ -PI3_4} },
+ { ElevRadius{ CornerElev}, AzimRadius{ -PI3_4} },
+ { ElevRadius{ CornerElev}, AzimRadius{ PI3_4} },
+ { ElevRadius{ CornerElev}, AzimRadius{ PI_4} },
+ { ElevRadius{ -CornerElev}, AzimRadius{ PI_4} },
+ { ElevRadius{ -CornerElev}, AzimRadius{ PI3_4} },
+ { ElevRadius{ CornerElev}, AzimRadius{ -PI_4} },
+ { ElevRadius{-1.205932499e+00f}, AzimRadius{ -PI_2} },
+ { ElevRadius{ 1.205932499e+00f}, AzimRadius{ PI_2} },
+ { ElevRadius{-1.205932499e+00f}, AzimRadius{ PI_2} },
+ { ElevRadius{ 1.205932499e+00f}, AzimRadius{ -PI_2} },
+ { ElevRadius{ 0.0f}, AzimRadius{-1.205932499e+00f} },
+ { ElevRadius{ 0.0f}, AzimRadius{-1.935660155e+00f} },
+ { ElevRadius{ 0.0f}, AzimRadius{ 1.205932499e+00f} },
+ { ElevRadius{ 0.0f}, AzimRadius{ 1.935660155e+00f} },
+ { ElevRadius{-3.648638281e-01f}, AzimRadius{ PI} },
+ { ElevRadius{ 3.648638281e-01f}, AzimRadius{ PI} },
+ { ElevRadius{ 3.648638281e-01f}, AzimRadius{ 0.0f} },
+ { ElevRadius{-3.648638281e-01f}, AzimRadius{ 0.0f} },
};
static const float AmbiMatrix1O[][MAX_AMBI_CHANNELS]{
{ 1.250000000e-01f, 1.250000000e-01f, 1.250000000e-01f, 1.250000000e-01f },
@@ -574,37 +568,31 @@ void InitHrtfPanning(ALCdevice *device)
{ 1.250000000e-01f, -1.250000000e-01f, -1.250000000e-01f, 1.250000000e-01f },
{ 1.250000000e-01f, -1.250000000e-01f, -1.250000000e-01f, -1.250000000e-01f },
}, AmbiMatrix2O[][MAX_AMBI_CHANNELS]{
- { 3.846153846e-02f, 0.000000000e+00f, 0.000000000e+00f, 6.661733875e-02f, 0.000000000e+00f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, 8.606629658e-02f },
- { 3.846153846e-02f, 0.000000000e+00f, 0.000000000e+00f, -6.661733875e-02f, 0.000000000e+00f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, 8.606629658e-02f },
- { 3.846153846e-02f, 6.661733875e-02f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, -8.606629658e-02f },
- { 3.846153846e-02f, -6.661733875e-02f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, -8.606629658e-02f },
- { 3.846153846e-02f, 0.000000000e+00f, 6.661733875e-02f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 9.938079900e-02f, 0.000000000e+00f, 0.000000000e+00f },
- { 3.846153846e-02f, 0.000000000e+00f, -6.661733875e-02f, 0.000000000e+00f, 0.000000000e+00f, 0.000000000e+00f, 9.938079900e-02f, 0.000000000e+00f, 0.000000000e+00f },
- { 3.846153846e-02f, 4.710557198e-02f, 4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, 6.834676493e-02f, 2.484519975e-02f, 0.000000000e+00f, -4.303314829e-02f },
- { 3.846153846e-02f, -4.710557198e-02f, 4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, -6.834676493e-02f, 2.484519975e-02f, 0.000000000e+00f, -4.303314829e-02f },
- { 3.846153846e-02f, 4.710557198e-02f, -4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, -6.834676493e-02f, 2.484519975e-02f, 0.000000000e+00f, -4.303314829e-02f },
- { 3.846153846e-02f, -4.710557198e-02f, -4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, 6.834676493e-02f, 2.484519975e-02f, 0.000000000e+00f, -4.303314829e-02f },
- { 3.846153846e-02f, 0.000000000e+00f, 4.710557198e-02f, 4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, 2.484519975e-02f, 6.834676493e-02f, 4.303314829e-02f },
- { 3.846153846e-02f, 0.000000000e+00f, 4.710557198e-02f, -4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, 2.484519975e-02f, -6.834676493e-02f, 4.303314829e-02f },
- { 3.846153846e-02f, 0.000000000e+00f, -4.710557198e-02f, 4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, 2.484519975e-02f, -6.834676493e-02f, 4.303314829e-02f },
- { 3.846153846e-02f, 0.000000000e+00f, -4.710557198e-02f, -4.710557198e-02f, 0.000000000e+00f, 0.000000000e+00f, 2.484519975e-02f, 6.834676493e-02f, 4.303314829e-02f },
- { 3.846153846e-02f, 4.710557198e-02f, 0.000000000e+00f, 4.710557198e-02f, 6.834676493e-02f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, 0.000000000e+00f },
- { 3.846153846e-02f, 4.710557198e-02f, 0.000000000e+00f, -4.710557198e-02f, -6.834676493e-02f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, 0.000000000e+00f },
- { 3.846153846e-02f, -4.710557198e-02f, 0.000000000e+00f, 4.710557198e-02f, -6.834676493e-02f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, 0.000000000e+00f },
- { 3.846153846e-02f, -4.710557198e-02f, 0.000000000e+00f, -4.710557198e-02f, 6.834676493e-02f, 0.000000000e+00f, -4.969039950e-02f, 0.000000000e+00f, 0.000000000e+00f },
- { 3.846153846e-02f, 3.846153846e-02f, 3.846153846e-02f, 3.846153846e-02f, 4.556450996e-02f, 4.556450996e-02f, 0.000000000e+00f, 4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, 3.846153846e-02f, 3.846153846e-02f, -3.846153846e-02f, -4.556450996e-02f, 4.556450996e-02f, 0.000000000e+00f, -4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, -3.846153846e-02f, 3.846153846e-02f, 3.846153846e-02f, -4.556450996e-02f, -4.556450996e-02f, 0.000000000e+00f, 4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, -3.846153846e-02f, 3.846153846e-02f, -3.846153846e-02f, 4.556450996e-02f, -4.556450996e-02f, 0.000000000e+00f, -4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, 3.846153846e-02f, -3.846153846e-02f, 3.846153846e-02f, 4.556450996e-02f, -4.556450996e-02f, 0.000000000e+00f, -4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, 3.846153846e-02f, -3.846153846e-02f, -3.846153846e-02f, -4.556450996e-02f, -4.556450996e-02f, 0.000000000e+00f, 4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, -3.846153846e-02f, -3.846153846e-02f, 3.846153846e-02f, -4.556450996e-02f, 4.556450996e-02f, 0.000000000e+00f, -4.556450996e-02f, 0.000000000e+00f },
- { 3.846153846e-02f, -3.846153846e-02f, -3.846153846e-02f, -3.846153846e-02f, 4.556450996e-02f, 4.556450996e-02f, 0.000000000e+00f, 4.556450996e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, 5.000000000e-02f, -5.000000000e-02f, 5.000000000e-02f, 6.454972244e-02f, -6.454972244e-02f, 0.000000000e+00f, -6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, 5.000000000e-02f, -5.000000000e-02f, -5.000000000e-02f, -6.454972244e-02f, -6.454972244e-02f, 0.000000000e+00f, 6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, 5.000000000e-02f, 5.000000000e-02f, -5.000000000e-02f, -6.454972244e-02f, 6.454972244e-02f, 0.000000000e+00f, -6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, -5.000000000e-02f, 5.000000000e-02f, -5.000000000e-02f, 6.454972244e-02f, -6.454972244e-02f, 0.000000000e+00f, -6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, -5.000000000e-02f, 5.000000000e-02f, 5.000000000e-02f, -6.454972244e-02f, -6.454972244e-02f, 0.000000000e+00f, 6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, -5.000000000e-02f, -5.000000000e-02f, 5.000000000e-02f, -6.454972244e-02f, 6.454972244e-02f, 0.000000000e+00f, -6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, -5.000000000e-02f, -5.000000000e-02f, -5.000000000e-02f, 6.454972244e-02f, 6.454972244e-02f, 0.000000000e+00f, 6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, 5.000000000e-02f, 5.000000000e-02f, 5.000000000e-02f, 6.454972244e-02f, 6.454972244e-02f, 0.000000000e+00f, 6.454972244e-02f, 0.000000000e+00f },
+ { 5.000000000e-02f, 3.090169944e-02f, -8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, -6.454972244e-02f, 9.045084972e-02f, 0.000000000e+00f, -1.232790000e-02f },
+ { 5.000000000e-02f, -3.090169944e-02f, 8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, -6.454972244e-02f, 9.045084972e-02f, 0.000000000e+00f, -1.232790000e-02f },
+ { 5.000000000e-02f, -3.090169944e-02f, -8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, 6.454972244e-02f, 9.045084972e-02f, 0.000000000e+00f, -1.232790000e-02f },
+ { 5.000000000e-02f, 3.090169944e-02f, 8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, 6.454972244e-02f, 9.045084972e-02f, 0.000000000e+00f, -1.232790000e-02f },
+ { 5.000000000e-02f, 8.090169944e-02f, 0.000000000e+00f, 3.090169944e-02f, 6.454972244e-02f, 0.000000000e+00f, -5.590169944e-02f, 0.000000000e+00f, -7.216878365e-02f },
+ { 5.000000000e-02f, 8.090169944e-02f, 0.000000000e+00f, -3.090169944e-02f, -6.454972244e-02f, 0.000000000e+00f, -5.590169944e-02f, 0.000000000e+00f, -7.216878365e-02f },
+ { 5.000000000e-02f, -8.090169944e-02f, 0.000000000e+00f, 3.090169944e-02f, -6.454972244e-02f, 0.000000000e+00f, -5.590169944e-02f, 0.000000000e+00f, -7.216878365e-02f },
+ { 5.000000000e-02f, -8.090169944e-02f, 0.000000000e+00f, -3.090169944e-02f, 6.454972244e-02f, 0.000000000e+00f, -5.590169944e-02f, 0.000000000e+00f, -7.216878365e-02f },
+ { 5.000000000e-02f, 0.000000000e+00f, -3.090169944e-02f, -8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, -3.454915028e-02f, 6.454972244e-02f, 8.449668365e-02f },
+ { 5.000000000e-02f, 0.000000000e+00f, 3.090169944e-02f, -8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, -3.454915028e-02f, -6.454972244e-02f, 8.449668365e-02f },
+ { 5.000000000e-02f, 0.000000000e+00f, 3.090169944e-02f, 8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, -3.454915028e-02f, 6.454972244e-02f, 8.449668365e-02f },
+ { 5.000000000e-02f, 0.000000000e+00f, -3.090169944e-02f, 8.090169944e-02f, 0.000000000e+00f, 0.000000000e+00f, -3.454915028e-02f, -6.454972244e-02f, 8.449668365e-02f },
};
static const float AmbiOrderHFGain1O[MAX_AMBI_ORDER+1]{
2.000000000e+00f, 1.154700538e+00f
}, AmbiOrderHFGain2O[MAX_AMBI_ORDER+1]{
- 2.687419249e+00f, 2.081665999e+00f, 1.074967700e+00f
+ 2.357022604e+00f, 1.825741858e+00f, 9.428090416e-01f
};
static const ALuint ChansPerOrder[MAX_AMBI_ORDER+1]{ 1, 3, 5, 7 };