# Why can't I get Slider NormalisableRange?

**URL:** <https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594>\
**Category:** General JUCE discussion\
**Created:** [June 9, 2023, 6:22pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594 "2023-06-09T18:22:51Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [June 9, 2023, 6:22pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/1 "2023-06-09T18:22:51Z")

</div>

Hello,  
there are methods:  
`Slider::setRange()`  
`Slider::setNormalisableRange()`  
and:  
`Slider::getRange()`

But I wonder where the hell is `Slider::getNormalisableRange()`. I am pretty sure there is some good reason for that, but I can’t find that reason and that’s why missing `Slider::getNormalisableRange()` frustrates me very hard.

For any help great thanks in advance.  
Best Regards.

---

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [June 9, 2023, 6:44pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/2 "2023-06-09T18:44:09Z")

</div>

And there is also related question (at least in my case related). To `Slider::valueFromTextFunction` I can pass parameter `String` as a number with unit and I am interpreting that properly, and if I get `String` just as a number and without unit I can also interprate that but I need to update my value text box to show the lacking unit. And that is done automaticaly when `Slider::setValue()` is called. But only if I call it with new value. But if old value is passed to `setValue()` then slider will not call any listeners because there is no changes so in the value box I get not updated value (without unit).

So I need to check by myself in the `valueFromTextFunction` if ongoing value is actually new value and if not then I need to update my value box by myself. But to make appropriate comparison I need to have access to sliders `NormalisableRange` and I don’t have that access.

So maybe there is any other method to check if passed value to `Slider::setValue()` will cause ane changes or not?

For any help great thanks in advance.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [June 10, 2023, 7:12pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/3 "2023-06-10T19:12:55Z")

</div>

you could just get these things from the processor parameter directly

---

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [June 11, 2023, 11:37am UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/4 "2023-06-11T11:37:51Z")

</div>

Thenks for your help. But let’s assume I don’t link my slider to any processor parameter?

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [June 11, 2023, 2:17pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/5 "2023-06-11T14:17:44Z")

</div>

> [@pajczur](#):
>
> But I wonder where the hell is `Slider::getNormalisableRange()`. I am pretty sure there is some good reason for that, but I can’t find that reason and that’s why missing `Slider::getNormalisableRange()` frustrates me very hard.

I think it is a simple oversight. As a workaround you can keep the NormalisableRange as member yourself whenever you set it. But it is not ideal of course.  
It would be nice if that getter could be added.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [June 11, 2023, 2:49pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/6 "2023-06-11T14:49:04Z")

</div>

in that case I’d agree with daniel that a getter would indeed be a nice thing to have, but keeping a member of it yourself somewhere the current workaround

---

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [June 11, 2023, 5:10pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/7 "2023-06-11T17:10:53Z")

</div>

Hello, thanks for all you reply. And for advices. But it is still interesting why there isn’t such NormalisableRange getter for Slider. I suppose there is some good reason, and it is interesting for me what the reason it is?

---

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [June 11, 2023, 9:12pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/8 "2023-06-11T21:12:07Z")

</div>

By the way I also found out it would be very handy if `Slider::setValue()` would return some `bool` which could tell if any changes was done. Of course it’s just my opinion, but I found many cases when I would love to have such info.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [June 11, 2023, 9:33pm UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/9 "2023-06-11T21:33:36Z")

</div>

You can easily achieve that:

```auto
if (slider.getValue() != newValue)
{
    slider.setValue (newValue);
    // and do what you needed the bool for
}

```

---

<div class="post-metadata">

**Author:** ![pajczur](https://avatars.discourse-cdn.com/v4/letter/p/e9a140/32.png) [@pajczur](https://forum.juce.com/u/pajczur)\
**Post date:** [June 13, 2023, 1:04am UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/10 "2023-06-13T01:04:04Z")

</div>

Hello Daniel, thanks but that doesn’t work because `newValue` often can be value which is not snapped to legal value. So to snap it by myself I need `NormalisableRage`.

---

<div class="post-metadata">

**Author:** ![Mrugalla](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/mrugalla/32/13092_2.png) [@Mrugalla](https://forum.juce.com/u/Mrugalla)\
**Post date:** [June 13, 2023, 8:28am UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/11 "2023-06-13T08:28:26Z")

</div>

it sounds like you basically want to instantiate a parameter, but instead of this parameter being owned by the processor, it’s just some parameter in the GUI. is that true? in that case you could just take juce::RangedAudioParameter and use it in the GUI. might not be the most intended way of using it, but I think it would work and you can let the attachment handle all the slider stuff. don’t make it complicated and modify all these Slider-functions when you don’t have to

---

<div class="post-metadata">

**Author:** ![Marcusonic](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Marcusonic](https://forum.juce.com/u/Marcusonic)\
**Post date:** [June 13, 2023, 9:25am UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/12 "2023-06-13T09:25:17Z")

</div>

you can use getInterval or getSkew separately.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [June 13, 2023, 9:37am UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/13 "2023-06-13T09:37:24Z")

</div>

Then you still miss the snap function or individual mapping function that the NormalisableRange may have…  
But good point

I think it is a totally valid request to getNormalisableRange(), somebody at the juce team just needs to find the time to add those 5 lines.

---

<div class="post-metadata">

**Author:** ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)\
**Post date:** [June 15, 2023, 11:01am UTC](https://forum.juce.com/t/why-cant-i-get-slider-normalisablerange/56594/14 "2023-06-15T11:01:15Z")

</div>

Thanks for reporting, seemed a nice easy one to drop in at the end of a working day.

> <https://github.com/juce-framework/JUCE/commit/b09b4c3bc0c8888130c4cca5a1754d38d0a154e9>
