aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-11-16 14:07:31 -0800
committerChris Robinson <[email protected]>2019-11-16 14:07:31 -0800
commit6ad252efdaf2f4a9ed569097c35b8b781f9f1d50 (patch)
tree313561c05e9f1972f9b10881a44506e93814edaa
parentd120e1464f1760b5b231321c0e68963ad633133f (diff)
Use wrappers to distinguish elevation and azimuth values
-rw-r--r--alc/hrtf.cpp6
-rw-r--r--alc/hrtf.h6
-rw-r--r--alc/panning.cpp52
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<float>::Pi()};
const float CornerElev{static_cast<float>(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 },