Browse Source

Fix setting the bypass parameter at init (#185)

* Fix setting the bypass parameter at init

* Rewrite the bypass patch with suggestions
pull/189/head
JP Cimalando Filipe Coelho <falktx@falktx.com> 5 years ago
parent
commit
e69074ebfc
1 changed files with 41 additions and 10 deletions
  1. +41
    -10
      distrho/src/DistrhoPluginLV2.cpp

+ 41
- 10
distrho/src/DistrhoPluginLV2.cpp View File

@@ -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)
{


Loading…
Cancel
Save