Avoid using ATOMIC macros
[openal-soft.git] / Alc / hrtf.h
bloba74df749c3ff5f8d3dcf3350c0c999f0819278a2
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"
12 #define HRTF_HISTORY_BITS (6)
13 #define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
14 #define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
16 #define HRIR_BITS (7)
17 #define HRIR_LENGTH (1<<HRIR_BITS)
18 #define HRIR_MASK (HRIR_LENGTH-1)
21 struct HrtfEntry;
23 struct Hrtf {
24 RefCount ref;
26 ALuint sampleRate;
27 ALsizei irSize;
29 ALfloat distance;
30 ALubyte evCount;
32 const ALubyte *azCount;
33 const ALushort *evOffset;
34 const ALfloat (*coeffs)[2];
35 const ALubyte (*delays)[2];
39 typedef struct HrtfState {
40 alignas(16) ALfloat History[HRTF_HISTORY_LENGTH];
41 alignas(16) ALfloat Values[HRIR_LENGTH][2];
42 } HrtfState;
44 typedef struct HrtfParams {
45 alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
46 ALsizei Delay[2];
47 ALfloat Gain;
48 } HrtfParams;
50 typedef struct DirectHrtfState {
51 /* HRTF filter state for dry buffer content */
52 ALsizei Offset;
53 ALsizei IrSize;
54 struct {
55 alignas(16) ALfloat Values[HRIR_LENGTH][2];
56 alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
57 } Chan[];
58 } DirectHrtfState;
60 struct AngularPoint {
61 ALfloat Elev;
62 ALfloat Azim;
66 void FreeHrtfs(void);
68 al::vector<EnumeratedHrtf> EnumerateHrtf(const char *devname);
69 struct Hrtf *GetLoadedHrtf(struct HrtfEntry *entry);
70 void Hrtf_IncRef(struct Hrtf *hrtf);
71 void Hrtf_DecRef(struct Hrtf *hrtf);
73 void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat (*RESTRICT coeffs)[2], ALsizei *delays);
75 /**
76 * Produces HRTF filter coefficients for decoding B-Format, given a set of
77 * virtual speaker positions, a matching decoding matrix, and per-order high-
78 * frequency gains for the decoder. The calculated impulse responses are
79 * ordered and scaled according to the matrix input.
81 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);
83 #endif /* ALC_HRTF_H */