etlegacy-libs/openal/Alc/hrtf.h

85 lines
2.2 KiB
C
Raw Normal View History

2015-12-12 21:07:33 +00:00
#ifndef ALC_HRTF_H
#define ALC_HRTF_H
#include "AL/al.h"
#include "AL/alc.h"
2017-07-01 14:18:03 +00:00
#include "alMain.h"
2015-12-12 21:07:33 +00:00
#include "alstring.h"
2017-07-01 14:18:03 +00:00
#include "atomic.h"
2015-12-12 21:07:33 +00:00
2019-01-03 15:00:15 +00:00
#define HRTF_HISTORY_BITS (6)
#define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS)
#define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1)
#define HRIR_BITS (7)
#define HRIR_LENGTH (1<<HRIR_BITS)
#define HRIR_MASK (HRIR_LENGTH-1)
2017-07-01 14:18:03 +00:00
2015-12-12 21:07:33 +00:00
2017-07-01 14:18:03 +00:00
struct HrtfEntry;
2015-12-12 21:07:33 +00:00
2017-07-01 14:18:03 +00:00
struct Hrtf {
RefCount ref;
ALuint sampleRate;
ALsizei irSize;
2019-01-03 15:00:15 +00:00
ALfloat distance;
2017-07-01 14:18:03 +00:00
ALubyte evCount;
const ALubyte *azCount;
const ALushort *evOffset;
const ALfloat (*coeffs)[2];
const ALubyte (*delays)[2];
};
2019-01-03 15:00:15 +00:00
typedef struct HrtfState {
alignas(16) ALfloat History[HRTF_HISTORY_LENGTH];
alignas(16) ALfloat Values[HRIR_LENGTH][2];
} HrtfState;
typedef struct HrtfParams {
alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
ALsizei Delay[2];
ALfloat Gain;
} HrtfParams;
typedef struct DirectHrtfState {
/* HRTF filter state for dry buffer content */
ALsizei Offset;
ALsizei IrSize;
struct {
alignas(16) ALfloat Values[HRIR_LENGTH][2];
alignas(16) ALfloat Coeffs[HRIR_LENGTH][2];
} Chan[];
} DirectHrtfState;
struct AngularPoint {
ALfloat Elev;
ALfloat Azim;
};
2017-07-01 14:18:03 +00:00
void FreeHrtfs(void);
2015-12-12 21:07:33 +00:00
2017-07-01 14:18:03 +00:00
vector_EnumeratedHrtf EnumerateHrtf(const_al_string devname);
void FreeHrtfList(vector_EnumeratedHrtf *list);
struct Hrtf *GetLoadedHrtf(struct HrtfEntry *entry);
void Hrtf_IncRef(struct Hrtf *hrtf);
void Hrtf_DecRef(struct Hrtf *hrtf);
void GetHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat spread, ALfloat (*coeffs)[2], ALsizei *delays);
/**
* Produces HRTF filter coefficients for decoding B-Format, given a set of
2019-01-03 15:00:15 +00:00
* 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.
2017-07-01 14:18:03 +00:00
*/
2019-01-03 15:00:15 +00:00
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);
2015-12-12 21:07:33 +00:00
#endif /* ALC_HRTF_H */