DPF

DISTRHO Plugin Framework
Log | Files | Refs | Submodules | README | LICENSE

commit e69074ebfcb56aaf4e24fd672ab7a6b6581cec58
parent d164873893bb543535fe3638f2e5f59d07e8f4fb
Author: JP Cimalando <jp-dev@inbox.ru>
Date:   Sat, 28 Sep 2019 02:17:41 +0200

Fix setting the bypass parameter at init (#185)

* Fix setting the bypass parameter at init

* Rewrite the bypass patch with suggestions

Diffstat:
Mdistrho/src/DistrhoPluginLV2.cpp | 51+++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/distrho/src/DistrhoPluginLV2.cpp b/distrho/src/DistrhoPluginLV2.cpp @@ -166,6 +166,44 @@ public: // ------------------------------------------------------------------- + bool getPortControlValue(uint32_t index, float& value) const + { + if (const float* control = fPortControls[index]) + { + switch (fPlugin.getParameterDesignation(index)) + { + default: + value = *control; + break; + case kParameterDesignationBypass: + value = 1.0f - *control; + break; + } + + return true; + } + + return false; + } + + void setPortControlValue(uint32_t index, float value) + { + if (float* control = fPortControls[index]) + { + switch (fPlugin.getParameterDesignation(index)) + { + default: + *control = value; + break; + case kParameterDesignationBypass: + *control = 1.0f - value; + break; + } + } + } + + // ------------------------------------------------------------------- + void lv2_activate() { #if DISTRHO_PLUGIN_WANT_TIMEPOS @@ -514,18 +552,13 @@ public: for (uint32_t i=0, count=fPlugin.getParameterCount(); i < count; ++i) { - if (fPortControls[i] == nullptr) + if (!getPortControlValue(i, curValue)) continue; - curValue = *fPortControls[i]; - if (fPlugin.isParameterInput(i) && d_isNotEqual(fLastControlValues[i], curValue)) { fLastControlValues[i] = curValue; - if (fPlugin.getParameterDesignation(i) == kParameterDesignationBypass) - curValue = 1.0f - curValue; - fPlugin.setParameterValue(i, curValue); } } @@ -757,8 +790,7 @@ public: fLastControlValues[i] = fPlugin.getParameterValue(i); - if (fPortControls[i] != nullptr) - *fPortControls[i] = fLastControlValues[i]; + setPortControlValue(i, fLastControlValues[i]); } # if DISTRHO_PLUGIN_WANT_FULL_STATE @@ -1047,8 +1079,7 @@ private: { curValue = fLastControlValues[i] = fPlugin.getParameterValue(i); - if (fPortControls[i] != nullptr) - *fPortControls[i] = curValue; + setPortControlValue(i, curValue); } else if ((fPlugin.getParameterHints(i) & kParameterIsTrigger) == kParameterIsTrigger) {