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:
@@ -122,6 +122,41 @@ void Effect::loadSettings( const QDomElement & _this )
|
||||
|
||||
|
||||
|
||||
bool Effect::processAudioBuffer(SampleFrame* buf, const fpp_t frames)
|
||||
{
|
||||
if (!isOkay() || dontRun() || !isEnabled() || !isRunning())
|
||||
{
|
||||
processBypassedImpl();
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto status = processImpl(buf, frames);
|
||||
switch (status)
|
||||
{
|
||||
case ProcessStatus::Continue:
|
||||
break;
|
||||
case ProcessStatus::ContinueIfNotQuiet:
|
||||
{
|
||||
double outSum = 0.0;
|
||||
for (std::size_t idx = 0; idx < frames; ++idx)
|
||||
{
|
||||
outSum += buf[idx].sumOfSquaredAmplitudes();
|
||||
}
|
||||
|
||||
checkGate(outSum / frames);
|
||||
break;
|
||||
}
|
||||
case ProcessStatus::Sleep:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return isRunning();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Effect * Effect::instantiate( const QString& pluginName,
|
||||
Model * _parent,
|
||||
@@ -146,7 +181,7 @@ Effect * Effect::instantiate( const QString& pluginName,
|
||||
|
||||
|
||||
|
||||
void Effect::checkGate( double _out_sum )
|
||||
void Effect::checkGate(double outSum)
|
||||
{
|
||||
if( m_autoQuitDisabled )
|
||||
{
|
||||
@@ -155,7 +190,7 @@ void Effect::checkGate( double _out_sum )
|
||||
|
||||
// Check whether we need to continue processing input. Restart the
|
||||
// counter if the threshold has been exceeded.
|
||||
if (_out_sum - gate() <= F_EPSILON)
|
||||
if (outSum - gate() <= F_EPSILON)
|
||||
{
|
||||
incrementBufferCount();
|
||||
if( bufferCount() > timeout() )
|
||||
|
||||
@@ -564,7 +564,7 @@ SetupDialog::SetupDialog(ConfigTab tab_to_open) :
|
||||
QHBoxLayout * bufferSizeSubLayout = new QHBoxLayout();
|
||||
|
||||
m_bufferSizeSlider = new QSlider(Qt::Horizontal, bufferSizeBox);
|
||||
m_bufferSizeSlider->setRange(1, 128);
|
||||
m_bufferSizeSlider->setRange(1, MAXIMUM_BUFFER_SIZE / BUFFERSIZE_RESOLUTION);
|
||||
m_bufferSizeSlider->setTickInterval(8);
|
||||
m_bufferSizeSlider->setPageStep(8);
|
||||
m_bufferSizeSlider->setValue(m_bufferSize / BUFFERSIZE_RESOLUTION);
|
||||
|
||||
Reference in New Issue
Block a user