aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects/compressor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'alc/effects/compressor.cpp')
-rw-r--r--alc/effects/compressor.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp
index 6202e58e..a4333539 100644
--- a/alc/effects/compressor.cpp
+++ b/alc/effects/compressor.cpp
@@ -64,7 +64,10 @@ namespace {
struct CompressorState final : public EffectState {
/* Effect gains for each channel */
- float mGain[MaxAmbiChannels][MaxAmbiChannels]{};
+ struct {
+ uint mTarget{INVALID_CHANNEL_INDEX};
+ float mGain{1.0f};
+ } mChans[MaxAmbiChannels];
/* Effect parameters */
bool mEnabled{true};
@@ -103,9 +106,12 @@ void CompressorState::update(const ContextBase*, const EffectSlot *slot,
mEnabled = props->Compressor.OnOff;
mOutTarget = target.Main->Buffer;
- auto set_gains = [slot,target](auto &gains, al::span<const float,MaxAmbiChannels> coeffs)
- { ComputePanGains(target.Main, coeffs.data(), slot->Gain, gains); };
- SetAmbiPanIdentity(std::begin(mGain), slot->Wet.Buffer.size(), set_gains);
+ auto set_channel = [this](size_t idx, uint target, float gain)
+ {
+ mChans[idx].mTarget = target;
+ mChans[idx].mGain = gain;
+ };
+ target.Main->setAmbiMixParams(slot->Wet, slot->Gain, set_channel);
}
void CompressorState::process(const size_t samplesToDo,
@@ -158,19 +164,22 @@ void CompressorState::process(const size_t samplesToDo,
mEnvFollower = env;
/* Now compress the signal amplitude to output. */
- auto changains = std::addressof(mGain[0]);
+ auto chan = std::cbegin(mChans);
for(const auto &input : samplesIn)
{
- const float *outgains{*(changains++)};
- for(FloatBufferLine &output : samplesOut)
+ const size_t outidx{chan->mTarget};
+ if(outidx != INVALID_CHANNEL_INDEX)
{
- const float gain{*(outgains++)};
+ const float *RESTRICT src{input.data() + base};
+ float *RESTRICT dst{samplesOut[outidx].data() + base};
+ const float gain{chan->mGain};
if(!(std::fabs(gain) > GainSilenceThreshold))
- continue;
-
- for(size_t i{0u};i < td;i++)
- output[base+i] += input[base+i] * gains[i] * gain;
+ {
+ for(size_t i{0u};i < td;i++)
+ dst[i] += src[i] * gains[i] * gain;
+ }
}
+ ++chan;
}
base += td;