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.
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 https://github.com/pongasoft/jamba/blob/v1.0.0/src/cpp/pongasoft/VST/RT/RTState.cpp#L52
Example of code using data.outputParameterChanges https://github.com/pongasoft/jamba/blob/v1.0.0/src/cpp/pongasoft/VST/RT/RTParameter.cpp#L29
There may be another solution using a sub controller but I have never used it.
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 https://github.com/pongasoft/jamba-sample-gain/blob/v1.0.1/src/cpp/GUI/LinkedSliderView.cpp (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(!fLink.exists() || !fSlider.exists() || !fLinkedSlider.exists())
if(fLinkedSlider.getParamID() == iParamID)
if(fLink && fSlider != fLinkedSlider)
if(fLink.getParamID() == iParamID)
if(fLink && fSlider.getValue() < fLinkedSlider.getValue())
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).