How to handle slider value changes for twoValueHorizontal Slider Styles


#1

Hi Everyone!

I’m making my first plug-in following this tutorial (https://www.juce.com/doc/tutorial_audio_parameter)

I’m trying to make a Slider::TwoValueHorizontal SliderStyle respond to min/max value changes but I’m a little stuck!

Any tips on how I can modify this function? Right now I have a check in place to use different code for my Slider::TwoValueHorizontal slider, but my two value slider parameter keeps snapping back to its default value when I change it.

How can I specify below that (slider) is the minimum value/maximum value of the slider itself?

void sliderValueChanged (Slider* slider)
{
if (slider->getName() == “TwoValueSlider”) {

    if (AudioParameterFloat* paramMin = getParameterForSlider (slider))
        *paramMin = (float) slider->getMinValue();
    
    if (AudioParameterFloat* paramMax = getParameterForSlider (slider))
        *paramMax = (float) slider->getMaxValue();
}

else {

if (AudioParameterFloat* param = getParameterForSlider (slider))
    *param = (float) slider->getValue();
}

}