diff options
author | Chris Robinson <[email protected]> | 2014-11-22 04:20:17 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-11-22 04:20:17 -0800 |
commit | a27e5e16523e1f6f166410e9992fc40886064eca (patch) | |
tree | a53e47af1b8afb1afa6c497247c9c462889d9067 /OpenAL32/Include/alMain.h | |
parent | 38383671d7d2a4f143f0ac84b48e8a02b91a1ba2 (diff) |
Use a different method for HRTF mixing
This new method mixes sources normally into a 14-channel buffer with the
channels placed all around the listener. HRTF is then applied to the channels
given their positions and written to a 2-channel buffer, which gets written out
to the device.
This method has the benefit that HRTF processing becomes more scalable. The
costly HRTF filters are applied to the 14-channel buffer after the mix is done,
turning it into a post-process with a fixed overhead. Mixing sources is done
with normal non-HRTF methods, so increasing the number of playing sources only
incurs normal mixing costs.
Another benefit is that it improves B-Format playback since the soundfield gets
mixed into speakers covering all three dimensions, which then get filtered
based on their locations.
The main downside to this is that the spatial resolution of the HRTF dataset
does not play a big role anymore. However, the hope is that with ambisonics-
based panning, the perceptual position of panned sounds will still be good. It
is also an option to increase the number of virtual channels for systems that
can handle it, or maybe even decrease it for weaker systems.
Diffstat (limited to 'OpenAL32/Include/alMain.h')
-rw-r--r-- | OpenAL32/Include/alMain.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 083d2613..bcb278dd 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -37,6 +37,8 @@ #include "vector.h" #include "alstring.h" +#include "hrtf.h" + #ifndef ALC_SOFT_HRTF #define ALC_SOFT_HRTF 1 #define ALC_HRTF_SOFT 0x1992 @@ -528,6 +530,17 @@ enum Channel { SideLeft, SideRight, + TopCenter, + BottomCenter, + TopFrontLeft, + TopFrontRight, + TopBackLeft, + TopBackRight, + BottomFrontLeft, + BottomFrontRight, + BottomBackLeft, + BottomBackRight, + InvalidChannel }; @@ -557,7 +570,7 @@ enum DevFmtChannels { DevFmtChannelsDefault = DevFmtStereo }; -#define MAX_OUTPUT_CHANNELS (8) +#define MAX_OUTPUT_CHANNELS (14) ALuint BytesFromDevFmt(enum DevFmtType type) DECL_CONST; ALuint ChannelsFromDevFmt(enum DevFmtChannels chans) DECL_CONST; @@ -593,6 +606,21 @@ typedef struct ChannelConfig { } ChannelConfig; +#define HRTF_HISTORY_BITS (6) +#define HRTF_HISTORY_LENGTH (1<<HRTF_HISTORY_BITS) +#define HRTF_HISTORY_MASK (HRTF_HISTORY_LENGTH-1) + +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]; + ALuint Delay[2]; +} HrtfParams; + + /* Size for temporary storage of buffer data, in ALfloats. Larger values need * more memory, while smaller values may need more iterations. The value needs * to be a sensible size, however, as it constrains the max stepping value used @@ -652,6 +680,9 @@ struct ALCdevice_struct /* HRTF filter tables */ const struct Hrtf *Hrtf; + HrtfState Hrtf_State[MAX_OUTPUT_CHANNELS]; + HrtfParams Hrtf_Params[MAX_OUTPUT_CHANNELS]; + ALuint Hrtf_Offset; // Stereo-to-binaural filter struct bs2b *Bs2b; |