Linked parameters

Hi everyone!

Please advise me how to do that. There are two parameters in my plugin, named “Left” and “Right”. Also I have a “Link” button. I want to change these two parameters simultaneously when the “Link” button is pressed. I.e. when I move the “Left” slider, the “Right” slider have to move simultaneously with the “Left” slider or vice versa.

Thanks.

I am not sure if this is the best way or if there is better solution but something which should work:

  • in the processing code, you keep track of the link state (you use data.inputParameterChanges to keep track of this state when it changes)
  • you also detect using data.inputParameterChanges that the left or right control parameter has changed
  • when you detect that one of them has changed and the link flag is true, then you change the other one by writing it to data.outputParameterChanges

Example of code using data.inputParameterChanges jamba/RTState.cpp at v1.0.0 · pongasoft/jamba · GitHub

Example of code using data.outputParameterChanges jamba/RTParameter.cpp at v1.0.0 · pongasoft/jamba · GitHub

There may be another solution using a sub controller but I have never used it.

Yan

I wanted to add to this topic since I last posed: when you asked your question I was working on the Jamba framework code example and this gave me the idea to extend the example to have 2 separate gain sliders (instead of 1) that would be linked via a Link toggle:

Implementing it with Jamba turned out to be straightforward (and a validation that the concepts in the framework were reasonable). You can find the actual code here jamba-sample-gain/LinkedSliderView.cpp at v1.0.1 · pongasoft/jamba-sample-gain · GitHub (the code is heavily documented because it serves as an example so this is why it relatively “big”)

The “generic” version (which only uses tags) is implemented in the same file (line 153) and the main logic demonstrates that it is rather straightforward.

void GenericLinkedSliderView::onParameterChange(ParamID iParamID)
{
  // Note: fLink is the toggle, fSlider is "this" slider, fLinkedSlider is the other slider
#if EDITOR_MODE
  if(!fLink.exists() || !fSlider.exists() || !fLinkedSlider.exists())
    return;
#endif

  if(fLinkedSlider.getParamID() == iParamID)
  {
    if(fLink && fSlider != fLinkedSlider)
      fSlider.copyValueFrom(fLinkedSlider);
    return;
  }

  if(fLink.getParamID() == iParamID)
  {
    if(fLink && fSlider.getValue() < fLinkedSlider.getValue())
      fSlider.copyValueFrom(fLinkedSlider);
    return;
  }
}

Unlike what I stated in my previous post, the logic is purely UI. The Real Time code doesn’t even know about the link concept and always get a left gain and a right gain (which happens to be the same when link is enabled).

Yan