aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2018-01-11 03:45:23 -0800
committerChris Robinson <[email protected]>2018-01-11 03:45:23 -0800
commit15f9d15ba006fab67a3ace8b2560c3397e75b1aa (patch)
treeb65235f68b7b76ca1943ce2442d79ef972f2cfc0
parent279799ad7020360e59763cbd80af82e202357c51 (diff)
Avoid using macros to access anonymous structures
-rw-r--r--Alc/ALc.c1
-rw-r--r--Alc/ALu.c34
-rw-r--r--Alc/bformatdec.c2
-rw-r--r--Alc/effects/chorus.c4
-rw-r--r--Alc/effects/compressor.c2
-rw-r--r--Alc/effects/dedicated.c6
-rw-r--r--Alc/effects/distortion.c2
-rw-r--r--Alc/effects/echo.c4
-rw-r--r--Alc/effects/equalizer.c2
-rw-r--r--Alc/effects/modulator.c2
-rw-r--r--Alc/effects/reverb.c6
-rw-r--r--Alc/mixer.c4
-rw-r--r--Alc/panning.c29
-rw-r--r--OpenAL32/Include/alMain.h73
-rw-r--r--OpenAL32/Include/alu.h55
15 files changed, 122 insertions, 104 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index a5bf731b..cca88a8f 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -1637,6 +1637,7 @@ void SetDefaultChannelOrder(ALCdevice *device)
}
extern inline ALint GetChannelIndex(const enum Channel names[MAX_OUTPUT_CHANNELS], enum Channel chan);
+extern inline ALint GetChannelIdxByName(const RealMixParams *real, enum Channel chan);
/* ALCcontext_DeferUpdates
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 25aa5c03..a4e9c1a4 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -520,8 +520,8 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
CalcDirectionCoeffs(Dir, Spread, coeffs);
/* NOTE: W needs to be scaled by sqrt(2) due to FuMa normalization. */
- ComputePanningGains(Device->Dry, coeffs, DryGain*1.414213562f,
- voice->Direct.Params[0].Gains.Target);
+ ComputeDryPanGains(&Device->Dry, coeffs, DryGain*1.414213562f,
+ voice->Direct.Params[0].Gains.Target);
for(c = 1;c < num_channels;c++)
{
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
@@ -602,7 +602,7 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
voice->Direct.Buffer = Device->FOAOut.Buffer;
voice->Direct.Channels = Device->FOAOut.NumChannels;
for(c = 0;c < num_channels;c++)
- ComputeFirstOrderGains(Device->FOAOut, matrix.m[c], DryGain,
+ ComputeFirstOrderGains(&Device->FOAOut, matrix.m[c], DryGain,
voice->Direct.Params[c].Gains.Target);
for(i = 0;i < NumSends;i++)
{
@@ -636,7 +636,7 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
int idx;
for(j = 0;j < MAX_OUTPUT_CHANNELS;j++)
voice->Direct.Params[c].Gains.Target[j] = 0.0f;
- if((idx=GetChannelIdxByName(Device->RealOut, chans[c].channel)) != -1)
+ if((idx=GetChannelIdxByName(&Device->RealOut, chans[c].channel)) != -1)
voice->Direct.Params[c].Gains.Target[idx] = DryGain;
}
@@ -830,13 +830,13 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
voice->Direct.Params[c].Gains.Target[j] = 0.0f;
if(Device->Dry.Buffer == Device->RealOut.Buffer)
{
- int idx = GetChannelIdxByName(Device->RealOut, chans[c].channel);
+ int idx = GetChannelIdxByName(&Device->RealOut, chans[c].channel);
if(idx != -1) voice->Direct.Params[c].Gains.Target[idx] = DryGain;
}
continue;
}
- ComputePanningGains(Device->Dry,
+ ComputeDryPanGains(&Device->Dry,
coeffs, DryGain * downmix_gain, voice->Direct.Params[c].Gains.Target
);
}
@@ -902,7 +902,7 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
voice->Direct.Params[c].Gains.Target[j] = 0.0f;
if(Device->Dry.Buffer == Device->RealOut.Buffer)
{
- int idx = GetChannelIdxByName(Device->RealOut, chans[c].channel);
+ int idx = GetChannelIdxByName(&Device->RealOut, chans[c].channel);
if(idx != -1) voice->Direct.Params[c].Gains.Target[idx] = DryGain;
}
@@ -918,7 +918,7 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
CalcAnglePairwiseCoeffs(chans[c].angle, chans[c].elevation, Spread, coeffs);
else
CalcAngleCoeffs(chans[c].angle, chans[c].elevation, Spread, coeffs);
- ComputePanningGains(Device->Dry,
+ ComputeDryPanGains(&Device->Dry,
coeffs, DryGain, voice->Direct.Params[c].Gains.Target
);
@@ -1725,8 +1725,8 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
SAFE_CONST(ALfloatBUFFERSIZE*,device->FOAOut.Buffer), SamplesToDo
);
- lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
- ridx = GetChannelIdxByName(device->RealOut, FrontRight);
+ lidx = GetChannelIdxByName(&device->RealOut, FrontLeft);
+ ridx = GetChannelIdxByName(&device->RealOut, FrontRight);
assert(lidx != -1 && ridx != -1);
state = device->Hrtf;
@@ -1761,8 +1761,8 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
}
else if(device->Uhj_Encoder)
{
- int lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
- int ridx = GetChannelIdxByName(device->RealOut, FrontRight);
+ int lidx = GetChannelIdxByName(&device->RealOut, FrontLeft);
+ int ridx = GetChannelIdxByName(&device->RealOut, FrontRight);
if(lidx != -1 && ridx != -1)
{
/* Encode to stereo-compatible 2-channel UHJ output. */
@@ -1774,8 +1774,8 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
}
else if(device->Bs2b)
{
- int lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
- int ridx = GetChannelIdxByName(device->RealOut, FrontRight);
+ int lidx = GetChannelIdxByName(&device->RealOut, FrontLeft);
+ int ridx = GetChannelIdxByName(&device->RealOut, FrontRight);
if(lidx != -1 && ridx != -1)
{
/* Apply binaural/crossfeed filter */
@@ -1791,9 +1791,9 @@ void aluMixData(ALCdevice *device, ALvoid *OutBuffer, ALsizei NumSamples)
if(device->Stablizer)
{
- int lidx = GetChannelIdxByName(device->RealOut, FrontLeft);
- int ridx = GetChannelIdxByName(device->RealOut, FrontRight);
- int cidx = GetChannelIdxByName(device->RealOut, FrontCenter);
+ int lidx = GetChannelIdxByName(&device->RealOut, FrontLeft);
+ int ridx = GetChannelIdxByName(&device->RealOut, FrontRight);
+ int cidx = GetChannelIdxByName(&device->RealOut, FrontCenter);
assert(lidx >= 0 && ridx >= 0 && cidx >= 0);
ApplyStablizer(device->Stablizer, Buffer, lidx, ridx, cidx,
diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c
index ba6daac5..3efdfba9 100644
--- a/Alc/bformatdec.c
+++ b/Alc/bformatdec.c
@@ -549,7 +549,7 @@ void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device)
{
ALfloat coeffs[MAX_AMBI_COEFFS] = { 0.0f };
CalcDirectionCoeffs(Ambi3DPoints[i], 0.0f, coeffs);
- ComputePanningGains(device->Dry, coeffs, 1.0f, encgains[i]);
+ ComputeDryPanGains(&device->Dry, coeffs, 1.0f, encgains[i]);
}
/* Combine the matrices that do the in->virt and virt->out conversions
diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c
index 65d2225b..9be69f92 100644
--- a/Alc/effects/chorus.c
+++ b/Alc/effects/chorus.c
@@ -148,9 +148,9 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCcontext *Conte
/* Gains for left and right sides */
CalcAngleCoeffs(-F_PI_2, 0.0f, 0.0f, coeffs);
- ComputePanningGains(device->Dry, coeffs, Slot->Params.Gain, state->Gains[0].Target);
+ ComputeDryPanGains(&device->Dry, coeffs, Slot->Params.Gain, state->Gains[0].Target);
CalcAngleCoeffs( F_PI_2, 0.0f, 0.0f, coeffs);
- ComputePanningGains(device->Dry, coeffs, Slot->Params.Gain, state->Gains[1].Target);
+ ComputeDryPanGains(&device->Dry, coeffs, Slot->Params.Gain, state->Gains[1].Target);
phase = props->Chorus.Phase;
rate = props->Chorus.Rate;
diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c
index 81f3c31b..4ae2acdb 100644
--- a/Alc/effects/compressor.c
+++ b/Alc/effects/compressor.c
@@ -86,7 +86,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCcontex
STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels;
for(i = 0;i < 4;i++)
- ComputeFirstOrderGains(device->FOAOut, IdentityMatrixf.m[i],
+ ComputeFirstOrderGains(&device->FOAOut, IdentityMatrixf.m[i],
slot->Params.Gain, state->Gain[i]);
}
diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c
index 32e5b49e..af8dc954 100644
--- a/Alc/effects/dedicated.c
+++ b/Alc/effects/dedicated.c
@@ -78,7 +78,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCcontext
if(slot->Params.EffectType == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT)
{
int idx;
- if((idx=GetChannelIdxByName(device->RealOut, LFE)) != -1)
+ if((idx=GetChannelIdxByName(&device->RealOut, LFE)) != -1)
{
STATIC_CAST(ALeffectState,state)->OutBuffer = device->RealOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->RealOut.NumChannels;
@@ -90,7 +90,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCcontext
int idx;
/* Dialog goes to the front-center speaker if it exists, otherwise it
* plays from the front-center location. */
- if((idx=GetChannelIdxByName(device->RealOut, FrontCenter)) != -1)
+ if((idx=GetChannelIdxByName(&device->RealOut, FrontCenter)) != -1)
{
STATIC_CAST(ALeffectState,state)->OutBuffer = device->RealOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->RealOut.NumChannels;
@@ -103,7 +103,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCcontext
STATIC_CAST(ALeffectState,state)->OutBuffer = device->Dry.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->Dry.NumChannels;
- ComputePanningGains(device->Dry, coeffs, Gain, state->gains);
+ ComputeDryPanGains(&device->Dry, coeffs, Gain, state->gains);
}
}
}
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c
index 546750d2..56931646 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.c
@@ -104,7 +104,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCcontex
cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth)
);
- ComputeAmbientGains(device->Dry, slot->Params.Gain, state->Gain);
+ ComputeAmbientGains(&device->Dry, slot->Params.Gain, state->Gain);
}
static ALvoid ALdistortionState_process(ALdistortionState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c
index 97a70eea..3d538d9d 100644
--- a/Alc/effects/echo.c
+++ b/Alc/effects/echo.c
@@ -139,11 +139,11 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCcontext *context,
/* First tap panning */
CalcAngleCoeffs(-F_PI_2*lrpan, 0.0f, spread, coeffs);
- ComputePanningGains(device->Dry, coeffs, slot->Params.Gain, state->Gains[0].Target);
+ ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gains[0].Target);
/* Second tap panning */
CalcAngleCoeffs( F_PI_2*lrpan, 0.0f, spread, coeffs);
- ComputePanningGains(device->Dry, coeffs, slot->Params.Gain, state->Gains[1].Target);
+ ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gains[1].Target);
}
static ALvoid ALechoState_process(ALechoState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels)
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c
index f2428e95..8be689d2 100644
--- a/Alc/effects/equalizer.c
+++ b/Alc/effects/equalizer.c
@@ -132,7 +132,7 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCcontext
STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels;
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
- ComputeFirstOrderGains(device->FOAOut, IdentityMatrixf.m[i],
+ ComputeFirstOrderGains(&device->FOAOut, IdentityMatrixf.m[i],
slot->Params.Gain, state->Gain[i]);
/* Calculate coefficients for the each type of filter. Note that the shelf
diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c
index af64448d..70751d87 100644
--- a/Alc/effects/modulator.c
+++ b/Alc/effects/modulator.c
@@ -148,7 +148,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCcontext
STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer;
STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels;
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
- ComputeFirstOrderGains(device->FOAOut, IdentityMatrixf.m[i],
+ ComputeFirstOrderGains(&device->FOAOut, IdentityMatrixf.m[i],
slot->Params.Gain, state->Gain[i]);
}
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c
index 711b4372..f6cd2b04 100644
--- a/Alc/effects/reverb.c
+++ b/Alc/effects/reverb.c
@@ -1264,13 +1264,15 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection
MATRIX_MULT(transform, rot, A2B);
memset(&State->Early.PanGain, 0, sizeof(State->Early.PanGain));
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
- ComputeFirstOrderGains(Device->FOAOut, transform.m[i], gain*earlyGain, State->Early.PanGain[i]);
+ ComputeFirstOrderGains(&Device->FOAOut, transform.m[i], gain*earlyGain,
+ State->Early.PanGain[i]);
rot = GetTransformFromVector(LateReverbPan);
MATRIX_MULT(transform, rot, A2B);
memset(&State->Late.PanGain, 0, sizeof(State->Late.PanGain));
for(i = 0;i < MAX_EFFECT_CHANNELS;i++)
- ComputeFirstOrderGains(Device->FOAOut, transform.m[i], gain*lateGain, State->Late.PanGain[i]);
+ ComputeFirstOrderGains(&Device->FOAOut, transform.m[i], gain*lateGain,
+ State->Late.PanGain[i]);
#undef MATRIX_MULT
}
diff --git a/Alc/mixer.c b/Alc/mixer.c
index 01586f7c..d99a4a8f 100644
--- a/Alc/mixer.c
+++ b/Alc/mixer.c
@@ -548,8 +548,8 @@ ALboolean MixSource(ALvoice *voice, ALsource *Source, ALCdevice *Device, ALsizei
ALsizei fademix = 0;
int lidx, ridx;
- lidx = GetChannelIdxByName(Device->RealOut, FrontLeft);
- ridx = GetChannelIdxByName(Device->RealOut, FrontRight);
+ lidx = GetChannelIdxByName(&Device->RealOut, FrontLeft);
+ ridx = GetChannelIdxByName(&Device->RealOut, FrontRight);
assert(lidx != -1 && ridx != -1);
if(!Counter)
diff --git a/Alc/panning.c b/Alc/panning.c
index aaae6bbd..37bf3ac9 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -37,6 +37,9 @@
extern inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
+extern inline void ComputeAmbientGains(const DryMixParams *dry, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+extern inline void ComputeDryPanGains(const DryMixParams *dry, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+extern inline void ComputeFirstOrderGains(const BFMixParams *foa, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
static const ALsizei FuMa2ACN[MAX_AMBI_COEFFS] = {
@@ -382,41 +385,41 @@ static bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALsizei sp
* and vice-versa.
*/
if(alstr_cmp_cstr(conf->Speakers[i].Name, "LF") == 0)
- c = GetChannelIdxByName(device->RealOut, FrontLeft);
+ c = GetChannelIdxByName(&device->RealOut, FrontLeft);
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "RF") == 0)
- c = GetChannelIdxByName(device->RealOut, FrontRight);
+ c = GetChannelIdxByName(&device->RealOut, FrontRight);
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "CE") == 0)
- c = GetChannelIdxByName(device->RealOut, FrontCenter);
+ c = GetChannelIdxByName(&device->RealOut, FrontCenter);
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "LS") == 0)
{
if(device->FmtChans == DevFmtX51Rear)
- c = GetChannelIdxByName(device->RealOut, BackLeft);
+ c = GetChannelIdxByName(&device->RealOut, BackLeft);
else
- c = GetChannelIdxByName(device->RealOut, SideLeft);
+ c = GetChannelIdxByName(&device->RealOut, SideLeft);
}
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "RS") == 0)
{
if(device->FmtChans == DevFmtX51Rear)
- c = GetChannelIdxByName(device->RealOut, BackRight);
+ c = GetChannelIdxByName(&device->RealOut, BackRight);
else
- c = GetChannelIdxByName(device->RealOut, SideRight);
+ c = GetChannelIdxByName(&device->RealOut, SideRight);
}
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "LB") == 0)
{
if(device->FmtChans == DevFmtX51)
- c = GetChannelIdxByName(device->RealOut, SideLeft);
+ c = GetChannelIdxByName(&device->RealOut, SideLeft);
else
- c = GetChannelIdxByName(device->RealOut, BackLeft);
+ c = GetChannelIdxByName(&device->RealOut, BackLeft);
}
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "RB") == 0)
{
if(device->FmtChans == DevFmtX51)
- c = GetChannelIdxByName(device->RealOut, SideRight);
+ c = GetChannelIdxByName(&device->RealOut, SideRight);
else
- c = GetChannelIdxByName(device->RealOut, BackRight);
+ c = GetChannelIdxByName(&device->RealOut, BackRight);
}
else if(alstr_cmp_cstr(conf->Speakers[i].Name, "CB") == 0)
- c = GetChannelIdxByName(device->RealOut, BackCenter);
+ c = GetChannelIdxByName(&device->RealOut, BackCenter);
else
{
const char *name = alstr_get_cstr(conf->Speakers[i].Name);
@@ -424,7 +427,7 @@ static bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALsizei sp
char ch;
if(sscanf(name, "AUX%u%c", &n, &ch) == 1 && n < 16)
- c = GetChannelIdxByName(device->RealOut, Aux0+n);
+ c = GetChannelIdxByName(&device->RealOut, Aux0+n);
else
{
ERR("AmbDec speaker label \"%s\" not recognized\n", name);
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 74b01b09..52f409ac 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -678,6 +678,35 @@ typedef struct DistanceComp {
*/
#define BUFFERSIZE 2048
+typedef struct DryMixParams {
+ AmbiConfig Ambi;
+ /* Number of coefficients in each Ambi.Coeffs to mix together (4 for first-
+ * order, 9 for second-order, etc). If the count is 0, Ambi.Map is used
+ * instead to map each output to a coefficient index.
+ */
+ ALsizei CoeffCount;
+
+ ALfloat (*Buffer)[BUFFERSIZE];
+ ALsizei NumChannels;
+ ALsizei NumChannelsPerOrder[MAX_AMBI_ORDER+1];
+} DryMixParams;
+
+typedef struct BFMixParams {
+ AmbiConfig Ambi;
+ /* Will only be 4 or 0. */
+ ALsizei CoeffCount;
+
+ ALfloat (*Buffer)[BUFFERSIZE];
+ ALsizei NumChannels;
+} BFMixParams;
+
+typedef struct RealMixParams {
+ enum Channel ChannelName[MAX_OUTPUT_CHANNELS];
+
+ ALfloat (*Buffer)[BUFFERSIZE];
+ ALsizei NumChannels;
+} RealMixParams;
+
struct ALCdevice_struct
{
RefCount ref;
@@ -752,38 +781,15 @@ struct ALCdevice_struct
alignas(16) ALfloat TempBuffer[4][BUFFERSIZE];
/* The "dry" path corresponds to the main output. */
- struct {
- AmbiConfig Ambi;
- /* Number of coefficients in each Ambi.Coeffs to mix together (4 for
- * first-order, 9 for second-order, etc). If the count is 0, Ambi.Map
- * is used instead to map each output to a coefficient index.
- */
- ALsizei CoeffCount;
-
- ALfloat (*Buffer)[BUFFERSIZE];
- ALsizei NumChannels;
- ALsizei NumChannelsPerOrder[MAX_AMBI_ORDER+1];
- } Dry;
+ DryMixParams Dry;
/* First-order ambisonics output, to be upsampled to the dry buffer if different. */
- struct {
- AmbiConfig Ambi;
- /* Will only be 4 or 0. */
- ALsizei CoeffCount;
-
- ALfloat (*Buffer)[BUFFERSIZE];
- ALsizei NumChannels;
- } FOAOut;
+ BFMixParams FOAOut;
/* "Real" output, which will be written to the device buffer. May alias the
* dry buffer.
*/
- struct {
- enum Channel ChannelName[MAX_OUTPUT_CHANNELS];
-
- ALfloat (*Buffer)[BUFFERSIZE];
- ALsizei NumChannels;
- } RealOut;
+ RealMixParams RealOut;
struct FrontStablizer *Stablizer;
@@ -984,12 +990,6 @@ void SetDefaultWFXChannelOrder(ALCdevice *device);
const ALCchar *DevFmtTypeString(enum DevFmtType type);
const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans);
-/**
- * GetChannelIdxByName
- *
- * Returns the index for the given channel name (e.g. FrontCenter), or -1 if it
- * doesn't exist.
- */
inline ALint GetChannelIndex(const enum Channel names[MAX_OUTPUT_CHANNELS], enum Channel chan)
{
ALint i;
@@ -1000,7 +1000,14 @@ inline ALint GetChannelIndex(const enum Channel names[MAX_OUTPUT_CHANNELS], enum
}
return -1;
}
-#define GetChannelIdxByName(x, c) GetChannelIndex((x).ChannelName, (c))
+/**
+ * GetChannelIdxByName
+ *
+ * Returns the index for the given channel name (e.g. FrontCenter), or -1 if it
+ * doesn't exist.
+ */
+inline ALint GetChannelIdxByName(const RealMixParams *real, enum Channel chan)
+{ return GetChannelIndex(real->ChannelName, chan); }
extern FILE *LogFile;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 6600e4e9..e450d68e 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -459,35 +459,41 @@ inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread,
*/
void CalcAnglePairwiseCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
+void ComputeAmbientGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void ComputeAmbientGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputeAmbientGains
*
* Computes channel gains for ambient, omni-directional sounds.
*/
-#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, ALsizei numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
-void ComputeAmbientGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+inline void ComputeAmbientGains(const DryMixParams *dry, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
+{
+ if(dry->CoeffCount > 0)
+ ComputeAmbientGainsMC(dry->Ambi.Coeffs, dry->NumChannels, ingain, gains);
+ else
+ ComputeAmbientGainsBF(dry->Ambi.Map, dry->NumChannels, ingain, gains);
+}
+
+void ComputePanningGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, ALsizei numcoeffs, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
- * ComputePanningGains
+ * ComputeDryPanGains
*
* Computes panning gains using the given channel decoder coefficients and the
* pre-calculated direction or angle coefficients.
*/
-#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, ALsizei numchans, ALsizei numcoeffs, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
-void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+inline void ComputeDryPanGains(const DryMixParams *dry, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
+{
+ if(dry->CoeffCount > 0)
+ ComputePanningGainsMC(dry->Ambi.Coeffs, dry->NumChannels, dry->CoeffCount,
+ coeffs, ingain, gains);
+ else
+ ComputePanningGainsBF(dry->Ambi.Map, dry->NumChannels, coeffs, ingain, gains);
+}
+void ComputeFirstOrderGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+void ComputeFirstOrderGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
/**
* ComputeFirstOrderGains
*
@@ -495,14 +501,13 @@ void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, con
* a 1x4 'slice' of a transform matrix for the input channel, used to scale and
* orient the sound samples.
*/
-#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, ALsizei numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
-void ComputeFirstOrderGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
+inline void ComputeFirstOrderGains(const BFMixParams *foa, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
+{
+ if(foa->CoeffCount > 0)
+ ComputeFirstOrderGainsMC(foa->Ambi.Coeffs, foa->NumChannels, mtx, ingain, gains);
+ else
+ ComputeFirstOrderGainsBF(foa->Ambi.Map, foa->NumChannels, mtx, ingain, gains);
+}
ALboolean MixSource(struct ALvoice *voice, struct ALsource *Source, ALCdevice *Device, ALsizei SamplesToDo);