Updating multiple 'linked' controls

Hi,

I’m trying to update multiple ‘linked’ controls so they show/have the same value when one of them is changed. I have 2 sliders that can be linked so both should be updated when the other one is dragged.
I’m not sure how to do this correctly in iPlug2. What I do now is check for param changes in OnParamChangeUI. Then I set the linked control param to the same value as the other one:

SetParameterValue(kParamSlider1, value);
refSlider1->SetDirty(false); // only update ui, don't push

This seems to almost work. :slight_smile: Only, when automating the parameter in StudioOne 4 / Win, the automation randomly turns off like when changing a control manually that is being automated by the host.

What is the correct way of doing this?

Thanks,
PJ

1 Like

in iPlug2 controls linked to the same parameter (with same paramIdx set in CTOR) should both get updated when one changes, without you having to do anything special.

Not sure that answers your question.

There is a reasonably complex setup in this test/example which might be worth looking at:

Thanks!

In my case, the option to link the 2 controls is optional. So it cannot set both controls to the same paramIdx in the CTOR because it depends on the ‘link’ control in the plugin.
I see that in the example there’s a similar case so I checked setting both params in Control->SetActionFunction. This works, but not for automation that is coming from the host.

Kind regards,
PJ

you can use IControl::SetParamIdx() to change the parameter that a control is linked to, including kNoParameter (-1)

after doing that you’d need to call IEditorDelegate::SendCurrentParamValuesFromDelegate(), to update the control values

1 Like

Thanks, I ended up using SetParamIdx and SendParameterValueFromDelegate to update the specific control. Seems to work fine now!

I’m transitioning from wdl-ol to iplug2 and I’m trying to do exactly what you described, but I’m having some trouble. It’d be really helpful if you could show that part of the code!

Sorry for the noobness

If anyone is as helpless as me and reads this, you can do it without the SetParamIdx, like this:

  case kLVol:
  mLVol = GetParam(kLVol)->Value() / 100.;
    if (mSync) {
      GetParam(kRVol)->Set(GetParam(kLVol)->Value());
      mRVol = mLVol;
      SendCurrentParamValuesFromDelegate();
    }

Where mSync defines wether knobs are synced or not. LVol is the parameter being altered and RVol is copying LVol.