Using Slider as a kind of Rotary Switch?


Hello there,
I’m quite new to JUCE and I’m working on a small app controlling the DSP mixer of my Tascam audio interface.

Right now I’m trying to create some EQ controls. I tried using a rotary slider as Frequency-Selector for the 4 band EQ. However, the frequencies aren’t linear. So here’s the example:

32 to 1.6
in steps of 8 until
in steps of ten until
in steps of 25 until
in steps of 50 until
in steps of 100 until
in steps of 50 until
in steps of 100 until

Now it seems that this would fit more a rotary switch rather than a slider. However, is there a way to use the slider for this?

Best regards


Well you could just set the interval in Slider::setRange and do some kind of conversion yourself in the Slider::Listener callback.


Hey there,

thanks for the reply.

I ended up making a class “FreqSlider”, that inherits from Slider. I overrode the constructor to accept an array of possible values. It also sets the range from 0 to size_of_array-1. I also overrode getValue to return the corresponding value from the array. setValue does the same in the opposite direction. And in order to have the TextBox show the corresponding values from the array.

I hope my approach makes nobody cringe. :wink: Haven’t written a single line of C++ code in 15 years.