Don't convert the HRTF decoder virtual speaker positions to radians
This commit is contained in:
parent
b785d80526
commit
3553ce1f67
18
Alc/hrtf.cpp
18
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;
|
||||
|
@ -79,8 +79,9 @@ void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth,
|
||||
* Produces HRTF filter coefficients for decoding B-Format, given a set of
|
||||
* virtual speaker positions, a matching decoding matrix, and per-order high-
|
||||
* frequency gains for the decoder. The calculated impulse responses are
|
||||
* ordered and scaled according to the matrix input.
|
||||
* ordered and scaled according to the matrix input. Note the specified virtual
|
||||
* positions should be in degrees, not radians!
|
||||
*/
|
||||
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);
|
||||
|
||||
#endif /* ALC_HRTF_H */
|
||||
|
@ -617,28 +617,28 @@ void InitHQPanning(ALCdevice *device, const AmbDecConf *conf, const ALsizei (&sp
|
||||
|
||||
void InitHrtfPanning(ALCdevice *device)
|
||||
{
|
||||
/* NOTE: azimuth goes clockwise. */
|
||||
/* NOTE: In degrees, and azimuth goes clockwise. */
|
||||
static constexpr AngularPoint AmbiPoints[]{
|
||||
{ DEG2RAD( 35.264390f), DEG2RAD( -45.000000f) },
|
||||
{ DEG2RAD( 35.264390f), DEG2RAD( 45.000000f) },
|
||||
{ DEG2RAD( 35.264390f), DEG2RAD( 135.000000f) },
|
||||
{ DEG2RAD( 35.264390f), DEG2RAD(-135.000000f) },
|
||||
{ DEG2RAD(-35.264390f), DEG2RAD( -45.000000f) },
|
||||
{ DEG2RAD(-35.264390f), DEG2RAD( 45.000000f) },
|
||||
{ DEG2RAD(-35.264390f), DEG2RAD( 135.000000f) },
|
||||
{ DEG2RAD(-35.264390f), DEG2RAD(-135.000000f) },
|
||||
{ DEG2RAD( 0.000000f), DEG2RAD( -20.905157f) },
|
||||
{ DEG2RAD( 0.000000f), DEG2RAD( 20.905157f) },
|
||||
{ DEG2RAD( 0.000000f), DEG2RAD( 159.094843f) },
|
||||
{ DEG2RAD( 0.000000f), DEG2RAD(-159.094843f) },
|
||||
{ DEG2RAD( 20.905157f), DEG2RAD( -90.000000f) },
|
||||
{ DEG2RAD(-20.905157f), DEG2RAD( -90.000000f) },
|
||||
{ DEG2RAD(-20.905157f), DEG2RAD( 90.000000f) },
|
||||
{ DEG2RAD( 20.905157f), DEG2RAD( 90.000000f) },
|
||||
{ DEG2RAD( 69.094843f), DEG2RAD( 0.000000f) },
|
||||
{ DEG2RAD(-69.094843f), DEG2RAD( 0.000000f) },
|
||||
{ DEG2RAD(-69.094843f), DEG2RAD( 180.000000f) },
|
||||
{ DEG2RAD( 69.094843f), DEG2RAD( 180.000000f) },
|
||||
{ 35.264390f, -45.000000f },
|
||||
{ 35.264390f, 45.000000f },
|
||||
{ 35.264390f, 135.000000f },
|
||||
{ 35.264390f, -135.000000f },
|
||||
{ -35.264390f, -45.000000f },
|
||||
{ -35.264390f, 45.000000f },
|
||||
{ -35.264390f, 135.000000f },
|
||||
{ -35.264390f, -135.000000f },
|
||||
{ 0.000000f, -20.905157f },
|
||||
{ 0.000000f, 20.905157f },
|
||||
{ 0.000000f, 159.094843f },
|
||||
{ 0.000000f, -159.094843f },
|
||||
{ 20.905157f, -90.000000f },
|
||||
{ -20.905157f, -90.000000f },
|
||||
{ -20.905157f, 90.000000f },
|
||||
{ 20.905157f, 90.000000f },
|
||||
{ 69.094843f, 0.000000f },
|
||||
{ -69.094843f, 0.000000f },
|
||||
{ -69.094843f, 180.000000f },
|
||||
{ 69.094843f, 180.000000f },
|
||||
};
|
||||
static constexpr ALfloat AmbiMatrix[][MAX_AMBI_COEFFS]{
|
||||
{ 5.00000000e-02f, 5.00000000e-02f, 5.00000000e-02f, 5.00000000e-02f, 6.45497224e-02f, 6.45497224e-02f, 0.00000000e+00f, 6.45497224e-02f, 0.00000000e+00f, 1.48264644e-02f, 6.33865691e-02f, 1.01126676e-01f, -7.36485380e-02f, -1.09260065e-02f, 7.08683387e-02f, -1.01622099e-01f },
|
||||
|
Loading…
x
Reference in New Issue
Block a user