Non-linear slider values


I’m a minor contributor to the JuceOPLVSTi and I’m trying to help create custom GUI elements. Right now I’m more involved in the front-end and GUI which is the simpler part relatively speaking. The dev working on it is doing it as a side-project, so I want to help where I can and minimize his work.

I’m not much of a C++ programmer (though I have coded a bit in the past) but an issue I’m having is how to create non-linear slider values for the FM-synth.

Currently, there is a drop-down list for setting the base frequency multiplier, but I want it to be a slider element. Unfortunately, because it is based on an existing hardware (OPL2/3 architecture) there is a fixed but slightly irregular table for frequency multiples.

[0.5x, 1x, 2x, 3x, 4x, 5x, 6x, 7x, 8x, 9x, 10x, 12x, 15x]

The issue is the extreme ends as I basically want 13 equidistant ticks corresponding to the frequency table.

I’ve read the JUCE slider values tutorial and JUCE Slider class reference, in particular the stuff about setRange, interval, and so on but it seems like it has to be a set interval or a basic log formula.

Any assistance in the form of tutorials, links, tips would be appreciated. Thank you very much!


Why not just put these values into an array and then use the current value of the slider as the index for the array. Or am I missing something?


Thank you for the response. I’ll give that a try. It’s been some time since I’ve coded, so even getting things up and running again in JUCE with demo projects took me a bit.