Make a DirectHrtfState constructor to try appeasing MSVC
[openal-soft.git] / Alc / hrtf.h
blobcbec2fc7086977d577eeb83fe89bb499d5653ac3
1 #ifndef ALC_HRTF_H
2 #define ALC_HRTF_H
4 #include "AL/al.h"
5 #include "AL/alc.h"
7 #include "alMain.h"
8 #include "atomic.h"
9 #include "vector.h"
10 #include "almalloc.h"
13 #define HRTF_HISTORY_BITS (6)
14 #define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
15 #define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
17 #define HRIR_BITS (7)
18 #define HRIR_LENGTH (1<<HRIR_BITS)
19 #define HRIR_MASK (HRIR_LENGTH-1)
22 struct HrtfEntry;
24 struct Hrtf {
25 RefCount ref;
27 ALuint sampleRate;
28 ALsizei irSize;
30 ALfloat distance;
31 ALubyte evCount;
33 const ALubyte *azCount;
34 const ALushort *evOffset;
35 const ALfloat (*coeffs)[2];
36 const ALubyte (*delays)[2];
40 struct HrtfState {
41 alignas(16) ALfloat History[HRTF_HISTORY_LENGTH];
42 alignas(16) ALfloat Values[HRIR_LENGTH][2];
45 struct HrtfParams {
46 alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
47 ALsizei Delay[2];
48 ALfloat Gain;
51 struct DirectHrtfState {
52 /* HRTF filter state for dry buffer content */
53 ALsizei Offset{0};
54 ALsizei IrSize{0};
55 struct {
56 alignas(16) ALfloat Values[HRIR_LENGTH][2];
57 alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
58 } Chan[];
60 DirectHrtfState() noexcept { }
62 DEF_PLACE_NEWDEL()
65 struct AngularPoint {
66 ALfloat Elev;
67 ALfloat Azim;
71 void FreeHrtfs(void);
73 al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname);
74 struct Hrtf *GetLoadedHrtf(struct HrtfEntry *entry);
75 void Hrtf_IncRef(struct Hrtf *hrtf);
76 void Hrtf_DecRef(struct Hrtf *hrtf);
78 void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat (*RESTRICT coeffs)[2], ALsizei *delays);
80 /**
81 * Produces HRTF filter coefficients for decoding B-Format, given a set of
82 * virtual speaker positions, a matching decoding matrix, and per-order high-
83 * frequency gains for the decoder. The calculated impulse responses are
84 * ordered and scaled according to the matrix input.
86 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);
88 #endif /* ALC_HRTF_H */