diff options
author | Chris Robinson <[email protected]> | 2022-12-19 00:24:39 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2022-12-19 00:24:39 -0800 |
commit | bbc35ffd4c3614ba978276dff3f855b3ed68910f (patch) | |
tree | eddb4ab4d6c6cbd4545252ce4b5f2c83d3815b64 | |
parent | 775d9ac314cbecde3aa6ed3b59a9aaad971bbe0b (diff) |
Turn a static member function into a lambda where it's used
And clean up some parameters
-rw-r--r-- | alc/effects/reverb.cpp | 60 |
1 files changed, 29 insertions, 31 deletions
diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 80ea9b74..4939cb31 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -389,7 +389,7 @@ struct LateReverb { const float mfDecayTime, const float hfDecayTime, const float lf0norm, const float hf0norm, const float frequency); - void clear() + void clear() noexcept { for(auto &filter : T60) filter.clear(); @@ -429,8 +429,7 @@ struct ReverbPipeline { void updateDelayLine(const float earlyDelay, const float lateDelay, const float density_mult, const float decayTime, const float frequency); void update3DPanning(const float *ReflectionsPan, const float *LateReverbPan, - const float earlyGain, const float lateGain, const bool doUpmix, - const EffectTarget &target); + const float earlyGain, const float lateGain, const bool doUpmix, const MixParams *mainMix); void processEarly(size_t offset, const size_t samplesToDo, const al::span<ReverbUpdateLine,NUM_LINES> tempSamples, @@ -439,7 +438,7 @@ struct ReverbPipeline { const al::span<ReverbUpdateLine,NUM_LINES> tempSamples, const al::span<FloatBufferLine,NUM_LINES> outSamples); - void clear() + void clear() noexcept { for(auto &filter : mFilter) { @@ -504,27 +503,6 @@ struct ReverbState final : public EffectState { bool mUpmixOutput{false}; - static void DoMixRow(const al::span<float> OutBuffer, const al::span<const float,4> Gains, - const float *InSamples, const size_t InStride) - { - std::fill(OutBuffer.begin(), OutBuffer.end(), 0.0f); - for(const float gain : Gains) - { - const float *RESTRICT input{al::assume_aligned<16>(InSamples)}; - InSamples += InStride; - - if(!(std::fabs(gain) > GainSilenceThreshold)) - continue; - - for(float &sample : OutBuffer) - { - sample += *input * gain; - ++input; - } - } - } - - void MixOutPlain(ReverbPipeline &pipeline, const al::span<FloatBufferLine> samplesOut, const size_t todo) { @@ -552,6 +530,25 @@ struct ReverbState final : public EffectState { { ASSUME(todo > 0); + auto DoMixRow = [](const al::span<float> OutBuffer, const al::span<const float,4> Gains, + const float *InSamples, const size_t InStride) + { + std::fill(OutBuffer.begin(), OutBuffer.end(), 0.0f); + for(const float gain : Gains) + { + const float *RESTRICT input{al::assume_aligned<16>(InSamples)}; + InSamples += InStride; + + if(!(std::fabs(gain) > GainSilenceThreshold)) + continue; + + auto mix_sample = [gain](const float sample, const float input) noexcept -> float + { return sample + input*gain; }; + std::transform(OutBuffer.begin(), OutBuffer.end(), input, OutBuffer.begin(), + mix_sample); + } + }; + /* When upsampling, the B-Format conversion needs to be done separately * so the proper HF scaling can be applied to each B-Format channel. * The panning gains then pan and upsample the B-Format channels. @@ -1034,7 +1031,7 @@ std::array<std::array<float,4>,4> GetTransformFromVector(const float *vec) /* Update the early and late 3D panning gains. */ void ReverbPipeline::update3DPanning(const float *ReflectionsPan, const float *LateReverbPan, - const float earlyGain, const float lateGain, const bool doUpmix, const EffectTarget &target) + const float earlyGain, const float lateGain, const bool doUpmix, const MixParams *mainMix) { /* Create matrices that transform a B-Format signal according to the * panning vectors. @@ -1071,9 +1068,9 @@ void ReverbPipeline::update3DPanning(const float *ReflectionsPan, const float *L auto latecoeffs = mult_matrix(latemat); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(target.Main, earlycoeffs[i].data(), earlyGain, mEarly.PanGain[i]); + ComputePanGains(mainMix, earlycoeffs[i].data(), earlyGain, mEarly.PanGain[i]); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(target.Main, latecoeffs[i].data(), lateGain, mLate.PanGain[i]); + ComputePanGains(mainMix, latecoeffs[i].data(), lateGain, mLate.PanGain[i]); } else { @@ -1103,9 +1100,9 @@ void ReverbPipeline::update3DPanning(const float *ReflectionsPan, const float *L auto latecoeffs = mult_matrix(LateA2B, latemat); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(target.Main, earlycoeffs[i].data(), earlyGain, mEarly.PanGain[i]); + ComputePanGains(mainMix, earlycoeffs[i].data(), earlyGain, mEarly.PanGain[i]); for(size_t i{0u};i < NUM_LINES;i++) - ComputePanGains(target.Main, latecoeffs[i].data(), lateGain, mLate.PanGain[i]); + ComputePanGains(mainMix, latecoeffs[i].data(), lateGain, mLate.PanGain[i]); } } @@ -1171,7 +1168,8 @@ void ReverbState::update(const ContextBase *Context, const EffectSlot *Slot, mOutTarget = target.Main->Buffer; const float gain{props->Reverb.Gain * Slot->Gain * ReverbBoost}; pipeline.update3DPanning(props->Reverb.ReflectionsPan, props->Reverb.LateReverbPan, - props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain, mUpmixOutput, target); + props->Reverb.ReflectionsGain*gain, props->Reverb.LateReverbGain*gain, mUpmixOutput, + target.Main); if(!fullUpdate) { |