aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h16
-rw-r--r--OpenAL32/Include/alu.h25
2 files changed, 34 insertions, 7 deletions
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 52296a15..12c4c610 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -509,8 +509,12 @@ struct ALCdevice_struct
struct {
/* Channel names for the dry buffer mix. */
enum Channel ChannelName[MAX_OUTPUT_CHANNELS];
- /* Ambisonic coefficients for mixing to the dry buffer. */
- ChannelConfig AmbiCoeffs[MAX_OUTPUT_CHANNELS];
+ union {
+ /* Ambisonic coefficients for mixing to the dry buffer. */
+ ChannelConfig Coeffs[MAX_OUTPUT_CHANNELS];
+ /* Coefficient channel mapping for mixing to the dry buffer. */
+ BFChannelConfig Map[MAX_OUTPUT_CHANNELS];
+ } Ambi;
/* Number of coefficients in each ChannelConfig to mix together (4 for
* first-order, 9 for second-order, etc).
*/
@@ -523,8 +527,12 @@ struct ALCdevice_struct
/* First-order ambisonics output, to be upsampled to the dry buffer if different. */
struct {
- /* Ambisonic coefficients for mixing. */
- ChannelConfig AmbiCoeffs[MAX_OUTPUT_CHANNELS];
+ union {
+ ChannelConfig Coeffs[MAX_OUTPUT_CHANNELS];
+ BFChannelConfig Map[MAX_OUTPUT_CHANNELS];
+ } Ambi;
+ /* Will only be 4 or 0. */
+ ALuint CoeffCount;
ALfloat (*Buffer)[BUFFERSIZE];
ALuint NumChannels;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 8b11bdd4..c6b5aba0 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -330,7 +330,14 @@ void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat coeffs[MAX_AMBI
*
* Computes channel gains for ambient, omni-directional sounds.
*/
-void ComputeAmbientGains(const ChannelConfig *chancoeffs, ALuint numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+#define ComputeAmbientGains(b, g, o) do { \
+ if((b).CoeffCount > 0) \
+ ComputeAmbientGainsMC((b).Ambi.Coeffs, (b).NumChannels, g, o); \
+ else \
+ ComputeAmbientGainsBF((b).Ambi.Map, (b).NumChannels, g, o); \
+} while (0)
+void ComputeAmbientGainsMC(const ChannelConfig *chancoeffs, ALuint numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void ComputeAmbientGainsBF(const BFChannelConfig *chanmap, ALuint numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputePanningGains
@@ -338,7 +345,13 @@ void ComputeAmbientGains(const ChannelConfig *chancoeffs, ALuint numchans, ALflo
* Computes panning gains using the given channel decoder coefficients and the
* pre-calculated direction or angle coefficients.
*/
-void ComputePanningGains(const ChannelConfig *chancoeffs, ALuint numchans, ALuint numcoeffs, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+#define ComputePanningGains(b, c, g, o) do { \
+ if((b).CoeffCount > 0) \
+ ComputePanningGainsMC((b).Ambi.Coeffs, (b).NumChannels, (b).CoeffCount, c, g, o);\
+ else \
+ ComputePanningGainsBF((b).Ambi.Map, (b).NumChannels, c, g, o); \
+} while (0)
+void ComputePanningGainsMC(const ChannelConfig *chancoeffs, ALuint numchans, ALuint numcoeffs, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALuint numchans, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
@@ -348,7 +361,13 @@ void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALuint numchans, cons
* a 1x4 'slice' of a transform matrix for the input channel, used to scale and
* orient the sound samples.
*/
-void ComputeFirstOrderGains(const ChannelConfig *chancoeffs, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+#define ComputeFirstOrderGains(b, m, g, o) do { \
+ if((b).CoeffCount > 0) \
+ ComputeFirstOrderGainsMC((b).Ambi.Coeffs, (b).NumChannels, m, g, o); \
+ else \
+ ComputeFirstOrderGainsBF((b).Ambi.Map, (b).NumChannels, m, g, o); \
+} while (0)
+void ComputeFirstOrderGainsMC(const ChannelConfig *chancoeffs, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
void ComputeFirstOrderGainsBF(const BFChannelConfig *chanmap, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);