# Why no logarithmic slider?

**URL:** <https://forum.juce.com/t/why-no-logarithmic-slider/43840>\
**Category:** General JUCE discussion\
**Created:** [January 15, 2021, 12:24pm UTC](https://forum.juce.com/t/why-no-logarithmic-slider/43840 "2021-01-15T12:24:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dubak](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dubak/32/9037_2.png) [@Dubak](https://forum.juce.com/u/Dubak)\
**Post date:** [January 15, 2021, 12:24pm UTC](https://forum.juce.com/t/why-no-logarithmic-slider/43840/1 "2021-01-15T12:24:43Z")

</div>

I thought I must have missed something (and maybe I did), but to me it looks like there is no quick way of setting a slider as logarithmic (I mean logarithmic translation between position and value).  
This is a functionality that has to be extremly common in audio applications when working with stuff like frequency or filter quality. Why is there no in-built solution for this in JUCE yet?

Just to clarify, I’m not looking for a solution on how to achieve this. I already have my LogSlider class working. I’m just baffled by a fact that to achieve this I had to write my own implementation instead of just “flicking a switch” somewhere or specifying it directly in the constructor.

---

<div class="post-metadata">

**Author:** ![kamedin](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kamedin/32/11711_2.png) [@kamedin](https://forum.juce.com/u/kamedin)\
**Post date:** [January 15, 2021, 11:42pm UTC](https://forum.juce.com/t/why-no-logarithmic-slider/43840/2 "2021-01-15T23:42:04Z")

</div>

You don’t need to subclass. Slider maps positions to values with a [NormalisableRange](https://docs.juce.com/master/classNormalisableRange.html). You can approximate a log mapping with the range’s skew, but for true log mapping you can [create a NormalisableRange](https://docs.juce.com/master/classNormalisableRange.html#ad8156ee5d7f2650156263a6f743f6886) supplying your [ValueRemapFunctions](https://docs.juce.com/master/classNormalisableRange.html#a413315ca8a7cb8b6d44e01f0d28bde13) for 0to1 and 1to0. Then you [set it](https://docs.juce.com/master/classSlider.html#a671aa56b17166c99b21715ce3d293bf2) to the Slider. If you connect a Slider to a processor parameter with a SliderAttachment, it will use the NormalisableRange set in the parameter’s constructor. For example, I create the ranges for my frequency parameters with

```auto
juce::NormalisableRange<float> freqRange (float min, float max)
{
    auto range{ std::log2 (max / min) };
    return { min, max,
        [=](float min, float, float v) { return std::exp2 (v * range) * min; },
        [=](float min, float, float v) { return std::log2 (v / min) / range; },
        [](float min, float max, float v) { return std::clamp (v, min, max); }
    };
}

```
