Manipulating Sliders textbox value


I am working on a audio application wherein I have equalizer band.
Each equalizer has slider for frequency and gain and a combobox for equalizer type(PEQ, HighShelf and LowShelf).

Each slider displays a different value and sends another value.

Frequency Slider:

  • For PEQ: display value-> 20Hz to 20000Hz, Slider Range: 20 Hz to 20000 Hz
  • For HighShelf: display value-> 1000Hz to 20000Hz, Slider Range: 1000 Hz to 20000 Hz
  • For LowShelf: display value-> 20 Hz to 1000Hz, Slider Range: 20 Hz to 1000 Hz

I have written a custom slider and overriden ‘getTextFromValue()’ method for display purpose. It’s working fine for frequency.

Question: The values in the frequency slider needs to change logarithmically rather than the default linear. How can we vary a slider logaritmically?

Gain Slider:

Display value -> -12 to +12 and slider range: 0 to 24.
Here also, I am using the ‘getTextFromValue()’ method for display purpose and subtract 12 from the slider value for display, so that if slider is a bottom with value as 0, it will display (-12) in the textbox. This is perfect.

Question: The slider’s textbox is editable, so when user enter’s zero in the textbox considering that it will display him zero in the texbox, it represents (-12) in the textbox which is not the user wanted. How can I handle this situation?

Slider Range: 0-24
Display Range: -12 to +12
textbox Range: -12 to +12 ( currently, it displays the value based on slider range and subtracting 12 from it).

Any ideas/ solution is welcome.

You can solve both problems with the same technique you’re using - just override juce::Slider::getValueFromText() and juce::Slider::getTextFromValue to convert between your display value and the actual units of the slider.

What this means is that you need internal units - the actual double value of the slider - and external units - the display value of the slider.

Let’s look at the second case. You have half the answer, you also need to override getValueFromText() which will convert the string to a double and then add 12 to the value…

Thanks Tom!
I have been able to use the juce::Slider::getValueFromText() method and display the value entered in the textbox and send a different value.
However, still unable to get to change frequency slider to vary logarithmically.
I think one possibility will be to set the slider’s skew factor to 0.5. Is this correct?