Using Slider as a kind of Rotary Switch?


#1

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:

Freq:
32 to 1.6
32==0x00
in steps of 8 until
40==0x01
in steps of ten until
100=0x07
in steps of 25 until
250=0x0d
in steps of 50 until
500=0x12
in steps of 100 until
800=0x15
in steps of 50 until
1.1k=0x1a
in steps of 100 until
1.6k=0x1f

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
Bollie


#2

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


#3

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.

Cheers
Bollie