aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-02-17 22:12:54 -0800
committerChris Robinson <[email protected]>2018-02-18 23:56:51 -0800
commit6ff50558a04c9d59f0f9bd45d4588095b95c8ec5 (patch)
treecd486900b7089bf643c17ed92244592fb2a7a1a9 /Alc
parentfa9ab9af7cb559ff9ecc1846f2996265bfbea1ec (diff)
Use a proper struct for specifying angular points
Diffstat (limited to 'Alc')
-rw-r--r--Alc/hrtf.c8
-rw-r--r--Alc/hrtf.h7
-rw-r--r--Alc/panning.c2
3 files changed, 11 insertions, 6 deletions
diff --git a/Alc/hrtf.c b/Alc/hrtf.c
index b5d23a7c..e0323146 100644
--- a/Alc/hrtf.c
+++ b/Alc/hrtf.c
@@ -194,7 +194,7 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth,
}
-void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS], ALsizei AmbiCount, const ALfloat *restrict AmbiOrderHFGain)
+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)
{
/* 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
@@ -216,15 +216,15 @@ void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei N
ALuint azcount;
/* Calculate elevation index. */
- evidx = (ALsizei)floorf((F_PI_2 + AmbiPoints[c][0]) *
+ evidx = (ALsizei)floorf((F_PI_2 + AmbiPoints[c].Elev) *
(Hrtf->evCount-1)/F_PI + 0.5f);
- evidx = mini(evidx, Hrtf->evCount-1);
+ evidx = clampi(evidx, 0, Hrtf->evCount-1);
azcount = Hrtf->azCount[evidx];
evoffset = Hrtf->evOffset[evidx];
/* Calculate azimuth index for this elevation. */
- azidx = (ALsizei)floorf((F_TAU+AmbiPoints[c][1]) *
+ azidx = (ALsizei)floorf((F_TAU+AmbiPoints[c].Azim) *
azcount/F_TAU + 0.5f) % azcount;
/* Calculate indices for left and right channels. */
diff --git a/Alc/hrtf.h b/Alc/hrtf.h
index 60842e8d..cb6dfddc 100644
--- a/Alc/hrtf.h
+++ b/Alc/hrtf.h
@@ -63,6 +63,11 @@ typedef struct DirectHrtfState {
} Chan[];
} DirectHrtfState;
+struct AngularPoint {
+ ALfloat Elev;
+ ALfloat Azim;
+};
+
void FreeHrtfs(void);
@@ -79,6 +84,6 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth,
* virtual speaker positions and HF/LF matrices for decoding to them. The
* returned coefficients are ordered and scaled according to the matrices.
*/
-void BuildBFormatHrtf(const struct Hrtf *Hrtf, DirectHrtfState *state, ALsizei NumChannels, const ALfloat (*restrict AmbiPoints)[2], const ALfloat (*restrict AmbiMatrix)[MAX_AMBI_COEFFS], ALsizei AmbiCount, const ALfloat *restrict AmbiOrderHFGain);
+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);
#endif /* ALC_HRTF_H */
diff --git a/Alc/panning.c b/Alc/panning.c
index 08651736..37802791 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -810,7 +810,7 @@ static void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsiz
static void InitHrtfPanning(ALCdevice *device)
{
/* NOTE: azimuth goes clockwise. */
- static const ALfloat AmbiPoints[][2] = {
+ static const struct AngularPoint AmbiPoints[] = {
{ DEG2RAD( 90.0f), DEG2RAD( 0.0f) },
{ DEG2RAD( 35.0f), DEG2RAD( 45.0f) },
{ DEG2RAD( 35.0f), DEG2RAD( 135.0f) },