20 #define HRTF_HISTORY_BITS (6)
21 #define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
22 #define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
25 #define HRIR_LENGTH (1<<HRIR_BITS)
26 #define HRIR_MASK (HRIR_LENGTH-1)
39 /* NOTE: Fields are stored *backwards*. field[0] is the farthest field, and
40 * field[fdCount-1] is the nearest.
50 const ALfloat (*coeffs
)[2];
51 const ALubyte (*delays
)[2];
59 struct EnumeratedHrtf
{
66 using float2
= std::array
<float,2>;
67 using HrirArray
= std::array
<float2
,HRIR_LENGTH
>;
70 alignas(16) std::array
<ALfloat
,HRTF_HISTORY_LENGTH
> History
;
71 alignas(16) HrirArray Values
;
75 alignas(16) HrirArray Coeffs
;
80 struct DirectHrtfState
{
81 /* HRTF filter state for dry buffer content */
83 alignas(16) HrirArray Values
{};
84 al::FlexArray
<HrirArray
,16> Coeffs
;
86 DirectHrtfState(size_t numchans
) : Coeffs
{numchans
} { }
88 static std::unique_ptr
<DirectHrtfState
> Create(size_t num_chans
);
90 DEF_FAM_NEWDEL(DirectHrtfState
, Coeffs
)
99 al::vector
<EnumeratedHrtf
> EnumerateHrtf(const char *devname
);
100 HrtfEntry
*GetLoadedHrtf(HrtfHandle
*handle
);
102 void GetHrtfCoeffs(const HrtfEntry
*Hrtf
, ALfloat elevation
, ALfloat azimuth
, ALfloat distance
,
103 ALfloat spread
, HrirArray
&coeffs
, ALsizei (&delays
)[2]);
106 * Produces HRTF filter coefficients for decoding B-Format, given a set of
107 * virtual speaker positions, a matching decoding matrix, and per-order high-
108 * frequency gains for the decoder. The calculated impulse responses are
109 * ordered and scaled according to the matrix input.
111 void BuildBFormatHrtf(const HrtfEntry
*Hrtf
, DirectHrtfState
*state
,
112 const al::span
<const AngularPoint
> AmbiPoints
, const ALfloat (*AmbiMatrix
)[MAX_AMBI_CHANNELS
],
113 const ALfloat
*AmbiOrderHFGain
);
115 #endif /* ALC_HRTF_H */