From 6ad252efdaf2f4a9ed569097c35b8b781f9f1d50 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 16 Nov 2019 14:07:31 -0800 Subject: Use wrappers to distinguish elevation and azimuth values --- alc/hrtf.cpp | 6 +++--- alc/hrtf.h | 6 ++++-- alc/panning.cpp | 52 ++++++++++++++++++++++++++-------------------------- 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/alc/hrtf.cpp b/alc/hrtf.cpp index 5df15859..2137723d 100644 --- a/alc/hrtf.cpp +++ b/alc/hrtf.cpp @@ -319,14 +319,14 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, auto &field = Hrtf->field[0]; /* Calculate the elevation indices. */ - const auto elev0 = CalcEvIndex(field.evCount, pt.Elev); + const auto elev0 = CalcEvIndex(field.evCount, pt.Elev.value); const ALsizei elev1_idx{mini(elev0.idx+1, field.evCount-1)}; const ALsizei ir0offset{Hrtf->elev[elev0.idx].irOffset}; const ALsizei ir1offset{Hrtf->elev[elev1_idx].irOffset}; /* Calculate azimuth indices. */ - const auto az0 = CalcAzIndex(Hrtf->elev[elev0.idx].azCount, pt.Azim); - const auto az1 = CalcAzIndex(Hrtf->elev[elev1_idx].azCount, pt.Azim); + const auto az0 = CalcAzIndex(Hrtf->elev[elev0.idx].azCount, pt.Azim.value); + const auto az1 = CalcAzIndex(Hrtf->elev[elev1_idx].azCount, pt.Azim.value); /* Calculate the HRIR indices to blend. */ const ALuint idx[4]{ diff --git a/alc/hrtf.h b/alc/hrtf.h index a81ebfed..98df801b 100644 --- a/alc/hrtf.h +++ b/alc/hrtf.h @@ -88,9 +88,11 @@ struct DirectHrtfState { DEF_FAM_NEWDEL(DirectHrtfState, Coeffs) }; +struct ElevRadius { float value; }; +struct AzimRadius { float value; }; struct AngularPoint { - ALfloat Elev; - ALfloat Azim; + ElevRadius Elev; + AzimRadius Azim; }; diff --git a/alc/panning.cpp b/alc/panning.cpp index 56b8cc77..b754d18b 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -525,32 +525,32 @@ void InitHrtfPanning(ALCdevice *device) constexpr float PI{al::MathDefs::Pi()}; const float CornerElev{static_cast(std::atan2(1.0, std::sqrt(2.0)))}; static const AngularPoint AmbiPoints[]{ - { 0.0f, 0.0f }, - { 0.0f, PI }, - { 0.0f, -PI/2.0f }, - { 0.0f, PI/2.0f }, - { PI/2.0f, 0.0f }, - { -PI/2.0f, 0.0f }, - { PI/4.0f, -PI/2.0f }, - { -PI/4.0f, -PI/2.0f }, - { PI/4.0f, PI/2.0f }, - { -PI/4.0f, PI/2.0f }, - { PI/4.0f, 0.0f }, - { -PI/4.0f, 0.0f }, - { PI/4.0f, PI }, - { -PI/4.0f, PI }, - { 0.0f, -PI/4.0f }, - { 0.0f, PI/4.0f }, - { 0.0f, -PI*3.0f/4.0f }, - { 0.0f, PI*3.0f/4.0f }, - { CornerElev, -PI/4.0f }, - { -CornerElev, -PI/4.0f }, - { CornerElev, PI/4.0f }, - { -CornerElev, PI/4.0f }, - { CornerElev, -PI*3.0f/4.0f }, - { -CornerElev, -PI*3.0f/4.0f }, - { CornerElev, PI*3.0f/4.0f }, - { -CornerElev, PI*3.0f/4.0f }, + { ElevRadius{ 0.0f}, AzimRadius{ 0.0f} }, + { ElevRadius{ 0.0f}, AzimRadius{ PI} }, + { ElevRadius{ 0.0f}, AzimRadius{ -PI/2.0f} }, + { ElevRadius{ 0.0f}, AzimRadius{ PI/2.0f} }, + { ElevRadius{ PI/2.0f}, AzimRadius{ 0.0f} }, + { ElevRadius{ -PI/2.0f}, AzimRadius{ 0.0f} }, + { ElevRadius{ PI/4.0f}, AzimRadius{ -PI/2.0f} }, + { ElevRadius{ -PI/4.0f}, AzimRadius{ -PI/2.0f} }, + { ElevRadius{ PI/4.0f}, AzimRadius{ PI/2.0f} }, + { ElevRadius{ -PI/4.0f}, AzimRadius{ PI/2.0f} }, + { ElevRadius{ PI/4.0f}, AzimRadius{ 0.0f} }, + { ElevRadius{ -PI/4.0f}, AzimRadius{ 0.0f} }, + { ElevRadius{ PI/4.0f}, AzimRadius{ PI} }, + { ElevRadius{ -PI/4.0f}, AzimRadius{ PI} }, + { ElevRadius{ 0.0f}, AzimRadius{ -PI/4.0f} }, + { ElevRadius{ 0.0f}, AzimRadius{ PI/4.0f} }, + { ElevRadius{ 0.0f}, AzimRadius{-PI*3.0f/4.0f} }, + { ElevRadius{ 0.0f}, AzimRadius{ PI*3.0f/4.0f} }, + { ElevRadius{ CornerElev}, AzimRadius{ -PI/4.0f} }, + { ElevRadius{-CornerElev}, AzimRadius{ -PI/4.0f} }, + { ElevRadius{ CornerElev}, AzimRadius{ PI/4.0f} }, + { ElevRadius{-CornerElev}, AzimRadius{ PI/4.0f} }, + { ElevRadius{ CornerElev}, AzimRadius{-PI*3.0f/4.0f} }, + { ElevRadius{-CornerElev}, AzimRadius{-PI*3.0f/4.0f} }, + { ElevRadius{ CornerElev}, AzimRadius{ PI*3.0f/4.0f} }, + { ElevRadius{-CornerElev}, AzimRadius{ PI*3.0f/4.0f} }, }; static const float AmbiMatrix[][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 }, -- cgit v1.2.3