aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/alu.cpp54
-rw-r--r--Alc/effects/autowah.cpp2
-rw-r--r--Alc/effects/compressor.cpp2
-rw-r--r--Alc/effects/equalizer.cpp4
-rw-r--r--Alc/effects/modulator.cpp4
-rw-r--r--Alc/panning.cpp25
-rw-r--r--OpenAL32/Include/alAuxEffectSlot.h6
-rw-r--r--OpenAL32/Include/alu.h8
8 files changed, 47 insertions, 58 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp
index 7216e18b..82eaa510 100644
--- a/Alc/alu.cpp
+++ b/Alc/alu.cpp
@@ -406,18 +406,9 @@ bool CalcEffectSlotParams(ALeffectslot *slot, ALCcontext *context, bool force)
AtomicReplaceHead(context->FreeEffectslotProps, props);
}
- MixParams params;
EffectTarget output;
if(ALeffectslot *target{slot->Params.Target})
- {
- auto iter = std::copy(std::begin(target->ChanMap), std::end(target->ChanMap),
- std::begin(params.AmbiMap));
- std::fill(iter, std::end(params.AmbiMap), BFChannelConfig{});
- params.Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(target->WetBuffer[0]);
- params.NumChannels = target->WetBuffer.size();
-
- output = EffectTarget{&params, nullptr};
- }
+ output = EffectTarget{&target->Wet, nullptr};
else
{
ALCdevice *device{context->Device};
@@ -628,8 +619,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
for(ALsizei i{0};i < NumSends;i++)
{
if(const ALeffectslot *Slot{SendSlots[i]})
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs,
- WetGain[i]*scale0, voice->mSend[i].Params[0].Gains.Target);
+ ComputePanGains(&Slot->Wet, coeffs, WetGain[i]*scale0,
+ voice->mSend[i].Params[0].Gains.Target);
}
}
else
@@ -689,8 +680,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
{
if(const ALeffectslot *Slot{SendSlots[i]})
for(ALsizei c{0};c < num_channels;c++)
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), matrix[c],
- WetGain[i], voice->mSend[i].Params[c].Gains.Target);
+ ComputePanGains(&Slot->Wet, matrix[c], WetGain[i],
+ voice->mSend[i].Params[c].Gains.Target);
}
}
}
@@ -719,8 +710,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
for(ALsizei i{0};i < NumSends;i++)
{
if(const ALeffectslot *Slot{SendSlots[i]})
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs,
- WetGain[i], voice->mSend[i].Params[c].Gains.Target);
+ ComputePanGains(&Slot->Wet, coeffs, WetGain[i],
+ voice->mSend[i].Params[c].Gains.Target);
}
}
}
@@ -770,8 +761,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
{
/* Skip LFE */
if(chans[c].channel != LFE)
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs,
- WetGain[i]*downmix_gain, voice->mSend[i].Params[c].Gains.Target);
+ ComputePanGains(&Slot->Wet, coeffs, WetGain[i] * downmix_gain,
+ voice->mSend[i].Params[c].Gains.Target);
}
}
}
@@ -803,8 +794,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
for(ALsizei i{0};i < NumSends;i++)
{
if(const ALeffectslot *Slot{SendSlots[i]})
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs,
- WetGain[i], voice->mSend[i].Params[c].Gains.Target);
+ ComputePanGains(&Slot->Wet, coeffs, WetGain[i],
+ voice->mSend[i].Params[c].Gains.Target);
}
}
}
@@ -879,8 +870,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
{
/* Skip LFE */
if(chans[c].channel != LFE)
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs,
- WetGain[i]*downmix_gain, voice->mSend[i].Params[c].Gains.Target);
+ ComputePanGains(&Slot->Wet, coeffs, WetGain[i] * downmix_gain,
+ voice->mSend[i].Params[c].Gains.Target);
}
}
}
@@ -929,8 +920,8 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo
for(ALsizei i{0};i < NumSends;i++)
{
if(const ALeffectslot *Slot{SendSlots[i]})
- ComputePanningGainsBF(Slot->ChanMap, Slot->WetBuffer.size(), coeffs,
- WetGain[i], voice->mSend[i].Params[c].Gains.Target);
+ ComputePanGains(&Slot->Wet, coeffs, WetGain[i],
+ voice->mSend[i].Params[c].Gains.Target);
}
}
}
@@ -1001,8 +992,8 @@ void CalcNonAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, cons
}
else
{
- voice->mSend[i].Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(SendSlots[i]->WetBuffer[0]);
- voice->mSend[i].Channels = SendSlots[i]->WetBuffer.size();
+ voice->mSend[i].Buffer = SendSlots[i]->Wet.Buffer;
+ voice->mSend[i].Channels = SendSlots[i]->Wet.NumChannels;
}
}
@@ -1109,8 +1100,8 @@ void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const A
}
else
{
- voice->mSend[i].Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(SendSlots[i]->WetBuffer[0]);
- voice->mSend[i].Channels = SendSlots[i]->WetBuffer.size();
+ voice->mSend[i].Buffer = SendSlots[i]->Wet.Buffer;
+ voice->mSend[i].Channels = SendSlots[i]->Wet.NumChannels;
}
}
@@ -1424,7 +1415,7 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
std::for_each(auxslots->begin(), auxslots->end(),
[SamplesToDo](ALeffectslot *slot) -> void
{
- for(auto &buffer : slot->WetBuffer)
+ for(auto &buffer : slot->MixBuffer)
std::fill_n(buffer.begin(), SamplesToDo, 0.0f);
}
);
@@ -1482,9 +1473,8 @@ void ProcessContext(ALCcontext *ctx, const ALsizei SamplesToDo)
[SamplesToDo](const ALeffectslot *slot) -> void
{
EffectState *state{slot->Params.mEffectState};
- state->process(SamplesToDo,
- &reinterpret_cast<const ALfloat(&)[BUFFERSIZE]>(slot->WetBuffer[0]),
- slot->WetBuffer.size(), state->mOutBuffer, state->mOutChannels);
+ state->process(SamplesToDo, slot->Wet.Buffer, slot->Wet.NumChannels,
+ state->mOutBuffer, state->mOutChannels);
}
);
}
diff --git a/Alc/effects/autowah.cpp b/Alc/effects/autowah.cpp
index 81c0c75c..0b12f68e 100644
--- a/Alc/effects/autowah.cpp
+++ b/Alc/effects/autowah.cpp
@@ -121,7 +121,7 @@ void ALautowahState::update(const ALCcontext *context, const ALeffectslot *slot,
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
- for(size_t i{0u};i < slot->WetBuffer.size();++i)
+ for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
diff --git a/Alc/effects/compressor.cpp b/Alc/effects/compressor.cpp
index 9e2ea376..6e5cea9d 100644
--- a/Alc/effects/compressor.cpp
+++ b/Alc/effects/compressor.cpp
@@ -80,7 +80,7 @@ void CompressorState::update(const ALCcontext* UNUSED(context), const ALeffectsl
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
- for(size_t i{0u};i < slot->WetBuffer.size();++i)
+ for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mGain[i]);
diff --git a/Alc/effects/equalizer.cpp b/Alc/effects/equalizer.cpp
index e9c75d53..441d8764 100644
--- a/Alc/effects/equalizer.cpp
+++ b/Alc/effects/equalizer.cpp
@@ -141,7 +141,7 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
calc_rcpQ_from_slope(gain, 0.75f));
/* Copy the filter coefficients for the other input channels. */
- for(size_t i{1u};i < slot->WetBuffer.size();++i)
+ for(ALsizei i{1};i < slot->Wet.NumChannels;++i)
{
mChans[i].filter[0].copyParamsFrom(mChans[0].filter[0]);
mChans[i].filter[1].copyParamsFrom(mChans[0].filter[1]);
@@ -151,7 +151,7 @@ void EqualizerState::update(const ALCcontext *context, const ALeffectslot *slot,
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
- for(size_t i{0u};i < slot->WetBuffer.size();++i)
+ for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
diff --git a/Alc/effects/modulator.cpp b/Alc/effects/modulator.cpp
index 46fe32a3..c2095192 100644
--- a/Alc/effects/modulator.cpp
+++ b/Alc/effects/modulator.cpp
@@ -129,12 +129,12 @@ void ModulatorState::update(const ALCcontext *context, const ALeffectslot *slot,
/* Bandwidth value is constant in octaves. */
mChans[0].Filter.setParams(BiquadType::HighPass, 1.0f, f0norm,
calc_rcpQ_from_bandwidth(f0norm, 0.75f));
- for(size_t i{1u};i < slot->WetBuffer.size();++i)
+ for(ALsizei i{1};i < slot->Wet.NumChannels;++i)
mChans[i].Filter.copyParamsFrom(mChans[0].Filter);
mOutBuffer = target.Main->Buffer;
mOutChannels = target.Main->NumChannels;
- for(size_t i{0u};i < slot->WetBuffer.size();++i)
+ for(ALsizei i{0};i < slot->Wet.NumChannels;++i)
{
auto coeffs = GetAmbiIdentityRow(i);
ComputePanGains(target.Main, coeffs.data(), slot->Params.Gain, mChans[i].TargetGains);
diff --git a/Alc/panning.cpp b/Alc/panning.cpp
index 209c650c..941e2a8b 100644
--- a/Alc/panning.cpp
+++ b/Alc/panning.cpp
@@ -740,11 +740,13 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf
}
}
-
-void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
+void ComputePanGains(const MixParams *mix, const ALfloat *RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
{
+ auto ambimap = mix->AmbiMap.cbegin();
+ const ALsizei numchans{mix->NumChannels};
+
ASSUME(numchans > 0);
- auto iter = std::transform(chanmap, chanmap+numchans, std::begin(gains),
+ auto iter = std::transform(ambimap, ambimap+numchans, std::begin(gains),
[coeffs,ingain](const BFChannelConfig &chanmap) noexcept -> ALfloat
{
ASSUME(chanmap.Index >= 0);
@@ -754,9 +756,6 @@ void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, con
std::fill(iter, std::end(gains), 0.0f);
}
-void ComputePanGains(const ALeffectslot *slot, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
-{ ComputePanningGainsBF(slot->ChanMap, slot->WetBuffer.size(), coeffs, ingain, gains); }
-
void aluInitRenderer(ALCdevice *device, ALint hrtf_id, HrtfRequestMode hrtf_appreq, HrtfRequestMode hrtf_userreq)
{
@@ -1015,11 +1014,15 @@ no_hrtf:
void aluInitEffectPanning(ALeffectslot *slot, ALCdevice *device)
{
const size_t count{AmbiChannelsFromOrder(device->mAmbiOrder)};
- slot->WetBuffer.resize(count);
- slot->WetBuffer.shrink_to_fit();
+ slot->MixBuffer.resize(count);
+ slot->MixBuffer.shrink_to_fit();
auto acnmap_end = AmbiIndex::From3D.begin() + count;
- auto iter = std::transform(AmbiIndex::From3D.begin(), acnmap_end, std::begin(slot->ChanMap),
- [](const ALsizei &acn) noexcept { return BFChannelConfig{1.0f, acn}; });
- std::fill(iter, std::end(slot->ChanMap), BFChannelConfig{});
+ auto iter = std::transform(AmbiIndex::From3D.begin(), acnmap_end, slot->Wet.AmbiMap.begin(),
+ [](const ALsizei &acn) noexcept -> BFChannelConfig
+ { return BFChannelConfig{1.0f, acn}; }
+ );
+ std::fill(iter, slot->Wet.AmbiMap.end(), BFChannelConfig{});
+ slot->Wet.Buffer = &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(slot->MixBuffer[0]);
+ slot->Wet.NumChannels = static_cast<ALsizei>(count);
}
diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h
index b3323578..c6f85a93 100644
--- a/OpenAL32/Include/alAuxEffectSlot.h
+++ b/OpenAL32/Include/alAuxEffectSlot.h
@@ -71,13 +71,15 @@ struct ALeffectslot {
/* Self ID */
ALuint id{};
+ /* Mixing buffer used by the Wet mix. */
+ al::vector<std::array<ALfloat,BUFFERSIZE>,16> MixBuffer;
+
/* Wet buffer configuration is ACN channel order with N3D scaling.
* Consequently, effects that only want to work with mono input can use
* channel 0 by itself. Effects that want multichannel can process the
* ambisonics signal and make a B-Format source pan.
*/
- al::vector<std::array<ALfloat,BUFFERSIZE>,16> WetBuffer;
- BFChannelConfig ChanMap[MAX_AMBI_CHANNELS];
+ MixParams Wet;
ALeffectslot() { PropsClean.test_and_set(std::memory_order_relaxed); }
ALeffectslot(const ALeffectslot&) = delete;
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index 952d1004..6cdd7d9f 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -421,8 +421,6 @@ inline float ScaleAzimuthFront(float azimuth, float scale)
}
-void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS]);
-
/**
* ComputePanGains
*
@@ -431,12 +429,8 @@ void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, con
* coeffs are a 'slice' of a transform matrix for the input channel, used to
* scale and orient the sound samples.
*/
-inline void ComputePanGains(const MixParams *dry, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS])
-{
- ComputePanningGainsBF(dry->AmbiMap.data(), dry->NumChannels, coeffs, ingain, gains);
-}
+void ComputePanGains(const MixParams *mix, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS]);
-void ComputePanGains(const ALeffectslot *slot, const ALfloat*RESTRICT coeffs, ALfloat ingain, ALfloat (&gains)[MAX_OUTPUT_CHANNELS]);
inline std::array<ALfloat,MAX_AMBI_CHANNELS> GetAmbiIdentityRow(size_t i) noexcept
{