aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/hrtf.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-12-21 08:55:22 -0800
committerChris Robinson <[email protected]>2018-12-21 08:55:22 -0800
commit3553ce1f67d46573e338ff6e53a31d60a722d5c6 (patch)
treeb574ab621a47ee6163ef73e6c93af8f9a2e760dc /Alc/hrtf.cpp
parentb785d805263c9517c1523785b2da39f9a47b6002 (diff)
Don't convert the HRTF decoder virtual speaker positions to radians
Diffstat (limited to 'Alc/hrtf.cpp')
-rw-r--r--Alc/hrtf.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp
index 5cc1e8b4..ab202e53 100644
--- a/Alc/hrtf.cpp
+++ b/Alc/hrtf.cpp
@@ -275,7 +275,7 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth,
}
-void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const struct AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_COEFFS], ALsizei AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain)
+void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, const ALsizei NumChannels, const AngularPoint *AmbiPoints, const ALfloat (*RESTRICT AmbiMatrix)[MAX_AMBI_COEFFS], const ALsizei AmbiCount, const ALfloat *RESTRICT AmbiOrderHFGain)
{
/* Set this to 2 for dual-band HRTF processing. May require a higher quality
* band-splitter, or better calculation of the new IR length to deal with the
@@ -287,19 +287,17 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N
al::vector<ALsizei> idx(AmbiCount);
for(ALsizei c{0};c < AmbiCount;c++)
{
- ALuint evidx, azidx;
- ALuint evoffset;
- ALuint azcount;
-
/* Calculate elevation index. */
- evidx = (ALsizei)((F_PI_2+AmbiPoints[c].Elev) * (Hrtf->evCount-1) / F_PI + 0.5f);
- evidx = clampi(evidx, 0, Hrtf->evCount-1);
+ const auto evidx = clampi(
+ static_cast<ALsizei>((90.0f+AmbiPoints[c].Elev)*(Hrtf->evCount-1)/180.0f + 0.5f),
+ 0, Hrtf->evCount-1);
- azcount = Hrtf->azCount[evidx];
- evoffset = Hrtf->evOffset[evidx];
+ const ALsizei azcount{Hrtf->azCount[evidx]};
+ const ALsizei evoffset{Hrtf->evOffset[evidx]};
/* Calculate azimuth index for this elevation. */
- azidx = (ALsizei)((F_TAU+AmbiPoints[c].Azim) * azcount / F_TAU + 0.5f) % azcount;
+ const auto azidx = static_cast<ALsizei>(
+ (360.0f+AmbiPoints[c].Azim)*azcount/360.0f + 0.5f) % azcount;
/* Calculate indices for left and right channels. */
idx[c] = evoffset + azidx;