# Manipulating Sliders textbox value

**URL:** <https://forum.juce.com/t/manipulating-sliders-textbox-value/7157>\
**Category:** General JUCE discussion\
**Created:** [July 12, 2011, 6:33pm UTC](https://forum.juce.com/t/manipulating-sliders-textbox-value/7157 "2011-07-12T18:33:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![praghu](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@praghu](https://forum.juce.com/u/praghu)\
**Post date:** [July 12, 2011, 6:33pm UTC](https://forum.juce.com/t/manipulating-sliders-textbox-value/7157/1 "2011-07-12T18:33:15Z")

</div>

Hi,

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.

---

<div class="post-metadata">

**Author:** ![tomswirly](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/tomswirly/32/236_2.png) [@tomswirly](https://forum.juce.com/u/tomswirly)\
**Post date:** [July 12, 2011, 6:44pm UTC](https://forum.juce.com/t/manipulating-sliders-textbox-value/7157/2 "2011-07-12T18:44:05Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![praghu](https://avatars.discourse-cdn.com/v4/letter/p/b3f665/32.png) [@praghu](https://forum.juce.com/u/praghu)\
**Post date:** [July 14, 2011, 1:47pm UTC](https://forum.juce.com/t/manipulating-sliders-textbox-value/7157/3 "2011-07-14T13:47:24Z")

</div>

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?
