Inform effects about changes in enabled model (#7237)

Add the virtual method `Effect::onEnabledChanged` which can be overridden by effects so that they can react to state changes with regards to being enabled or bypassed. The call of this methods is connected to state changes of the enabled model in the constructor of `Effect`.

Implement the method in `DualFilterEffect` by resetting the history of the two filters. This is done to prevent pops that have been reported in #4612.
This commit is contained in:
Michael Gregorius
2024-05-05 10:05:22 +02:00
committed by GitHub
parent d5f5d00a6f
commit 9bdc8adf33
4 changed files with 13 additions and 0 deletions

View File

@@ -208,6 +208,8 @@ protected:
}
void reinitSRC();
virtual void onEnabledChanged() {}
private:
EffectChain * m_parent;

View File

@@ -218,6 +218,11 @@ bool DualFilterEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames
return isRunning();
}
void DualFilterEffect::onEnabledChanged()
{
m_filter1->clearHistory();
m_filter2->clearHistory();
}

View File

@@ -47,6 +47,8 @@ public:
return &m_dfControls;
}
protected:
void onEnabledChanged() override;
private:
DualFilterControls m_dfControls;

View File

@@ -61,6 +61,10 @@ Effect::Effect( const Plugin::Descriptor * _desc,
{
m_autoQuitDisabled = true;
}
// Call the virtual method onEnabledChanged so that effects can react to changes,
// e.g. by resetting state.
connect(&m_enabledModel, &BoolModel::dataChanged, [this] { onEnabledChanged(); });
}