Refactor Effect processing (#7484)

* Move common effect processing code to wrapper method

- Introduce `processImpl` and `sleepImpl` methods, and adapt each effect
plugin to use them
- Use double for RMS out sum in Compressor and LOMM
- Run `checkGate` for GranularPitchShifterEffect
- Minor changes to LadspaEffect
- Remove dynamic allocations and VLAs from VstEffect's process method
- Some minor style/formatting fixes

* Fix VstEffect regression

* GranularPitchShifterEffect should not call `checkGate`

* Apply suggestions from code review

Co-authored-by: saker <sakertooth@gmail.com>

* Follow naming convention for local variables

* Add `MAXIMUM_BUFFER_SIZE` and use it in VstEffect

* Revert "GranularPitchShifterEffect should not call `checkGate`"

This reverts commit 67526f0ffe.

* VstEffect: Simplify setting "Don't Run" state

* Rename `sleepImpl` to `processBypassedImpl`

* Use `MAXIMUM_BUFFER_SIZE` in SetupDialog

* Pass `outSum` as out parameter; Fix LadspaEffect mutex

* Move outSum calculations to wrapper method

* Fix Linux build

* Oops

* Apply suggestions from code review

Co-authored-by: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: saker <sakertooth@gmail.com>

---------

Co-authored-by: saker <sakertooth@gmail.com>
Co-authored-by: Johannes Lorenz <1042576+JohannesLorenz@users.noreply.github.com>
This commit is contained in:
Dalton Messmer
2024-09-20 20:00:36 -04:00
committed by GitHub
parent 1d7ed16dc9
commit 18252088ba
53 changed files with 290 additions and 407 deletions

View File

@@ -91,15 +91,8 @@ inline void DynProcEffect::calcRelease()
}
bool DynProcEffect::processAudioBuffer( SampleFrame* _buf,
const fpp_t _frames )
Effect::ProcessStatus DynProcEffect::processImpl(SampleFrame* buf, const fpp_t frames)
{
if( !isEnabled() || !isRunning () )
{
//apparently we can't keep running after the decay value runs out so we'll just set the peaks to zero
m_currentPeak[0] = m_currentPeak[1] = DYN_NOISE_FLOOR;
return( false );
}
//qDebug( "%f %f", m_currentPeak[0], m_currentPeak[1] );
// variables for effect
@@ -107,7 +100,6 @@ bool DynProcEffect::processAudioBuffer( SampleFrame* _buf,
auto sm_peak = std::array{0.0f, 0.0f};
double out_sum = 0.0;
const float d = dryLevel();
const float w = wetLevel();
@@ -140,9 +132,9 @@ bool DynProcEffect::processAudioBuffer( SampleFrame* _buf,
}
}
for( fpp_t f = 0; f < _frames; ++f )
for (fpp_t f = 0; f < frames; ++f)
{
auto s = std::array{_buf[f][0], _buf[f][1]};
auto s = std::array{buf[f][0], buf[f][1]};
// apply input gain
s[0] *= inputGain;
@@ -210,17 +202,18 @@ bool DynProcEffect::processAudioBuffer( SampleFrame* _buf,
s[1] *= outputGain;
// mix wet/dry signals
_buf[f][0] = d * _buf[f][0] + w * s[0];
_buf[f][1] = d * _buf[f][1] + w * s[1];
out_sum += _buf[f][0] * _buf[f][0] + _buf[f][1] * _buf[f][1];
buf[f][0] = d * buf[f][0] + w * s[0];
buf[f][1] = d * buf[f][1] + w * s[1];
}
checkGate( out_sum / _frames );
return( isRunning() );
return ProcessStatus::ContinueIfNotQuiet;
}
void DynProcEffect::processBypassedImpl()
{
// Apparently we can't keep running after the decay value runs out so we'll just set the peaks to zero
m_currentPeak[0] = m_currentPeak[1] = DYN_NOISE_FLOOR;
}