Rotary Slider: setting range to only output odd numbers

Hi,
I am in the middle of making a MIDI only plug in that will control a hardware equalizer.

Because of how they originally coded the hardware, it requires I use odd numbers for most all functions, whether it is a frequency setting or a Q width setting. There is also the filter section, which has the value of zero as OFF, and then goes up to 1, then odd numbers across it’s 19 steps of frequency selections.

So, how can I make a slider output 0, then only odd numbers until it’s maximum, which is an odd number?

Thanks.

You could inherit from Slider and override snapValue().
Then you can determine what values are valid for your slider:

https://docs.juce.com/master/classSlider.html#aa8ce89d390ea3de9ab58aae59db1d03b

Alternatively you can also have a look at AudioParameterFloat and set the snapToLegalValue lambda in the NormalisableRange:

https://docs.juce.com/master/classNormalisableRange.html#ad8156ee5d7f2650156263a6f743f6886

1 Like

Hi MArcel, thanks, I’ll try this and let you know if I got it working the way I need it to.