AudioProcessorValueTree::SliderAttachment for 2 Parameters?


#1

I want to use the same slider to control 2 parameters based on the value of a another switch parameter, so if the switch is off, the slider shows/edits parameter A, and if the switch is on, the slider shows/edits parameter B.

There does’t seem any obvious way to do this.

Has anyone played around with anything like this?


#2

Easy way, just use the toggle state of the button as a flag.

void yourComponent::buttonStateChanged (Button* b)
{
    if (b->getToggleState();)
       slider.setValue (firstValue, dontSendNotifcation);
    else
       slider.setValue (secondValue, dontSendNotifcation);
}

void yourComponent::sliderValueChanged (Slider * s)
{
    if (controlButton.getToggleState())
        firstValue = slider.getValue();
    else
        secondValue = slider.getValue();
}

#3

Thanks but won’t the SliderAttachment interfere?


#4

Sure, you can also just use two sliders and use the button to change their visibility.


#5

Yeah, that’s the first thing I tried, but there’s a flicker. The value changing and the visibility changing are not synced.