# NormalisableRange suggestions

**URL:** <https://forum.juce.com/t/normalisablerange-suggestions/19514>\
**Category:** Audio Plugins\
**Created:** [October 17, 2016, 12:25pm UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514 "2016-10-17T12:25:04Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [October 17, 2016, 12:25pm UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/1 "2016-10-17T12:25:04Z")

</div>

NormalisableRange needs an option to store a normalized logharitmic value (e.g. for Frequencies)

Here is some sample conversion code from my internal library to store frequencies in a normalized range between 0.f and 1.f

```
class LogFrequency_normalized
{
public:
    LogFrequency_normalized(double minFrequency_, double maxFrequency_)
    {
        setMinMaxHz(minFrequency_, maxFrequency_);
    };
    
    void setMinMaxHz(double minFrequency_, double maxFrequency_)
    {
        minFrequency=minFrequency_;
        maxFrequency=maxFrequency_;
        minFrequencyLog=log(minFrequency_);
        maxFrequencyLog=log(maxFrequency_);
    };
    
    double getFrequency(double normalizedLog)
    {
        return exp((normalizedLog*(maxFrequencyLog-minFrequencyLog))+minFrequencyLog);
    };
    
    double getNormalizedLog(double frequency)
    {
        if (frequency<=minFrequency)
        {
            return 0.;
        } else
            if (frequency>=maxFrequency)
            {
                return 1.;
            } else
            {
                return (log(frequency)-minFrequencyLog)/(maxFrequencyLog-minFrequencyLog);
            };
    };
private:
    double minFrequency, maxFrequency;
    double minFrequencyLog, maxFrequencyLog;
          
};
```

---

<div class="post-metadata">

**Author:** ![ed95](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ed95/32/7635_2.png) [@ed95](https://forum.juce.com/u/ed95)\
**Post date:** [October 18, 2016, 9:48am UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/2 "2016-10-18T09:48:07Z")

</div>

Hi chkn,

The NormalisableRange class is designed to be used in an arbitrary manner with templated values and leaves the implementation of specifics, such as logarithmic values, up to the user. Thanks for the suggestion though!

Ed

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [October 18, 2016, 10:30am UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/3 "2016-10-18T10:30:37Z")

</div>

Sorry not sure if you really understand the usecase?

If i look into NormalisableRange it seems the value is transformed into some kind of polynomial(?) (fixed exponent) way (when using skew Factor), which is transformed into a normalized range, but for frequencies we usually need to transform the frequency into a logarithmic (fixed base) way, so that e.g. every octave has the same distance

An example, we want to store a frequency which we know is always between  
between is 100Hz and 3,2KhZ.

the normalized logarithmic representation would be

0=100Hz  
0,2=200Hz  
0,4=400Hz  
0,6=800Hz  
0,8=1.6 kHZ  
1,0=3.2 kHz

How to achieve something like that with NormalisableRange?

---

<div class="post-metadata">

**Author:** ![Achder](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/achder/32/5897_2.png) [@Achder](https://forum.juce.com/u/Achder)\
**Post date:** [October 19, 2016, 9:02pm UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/4 "2016-10-19T21:02:32Z")

</div>

I don’t think it’s possible. You can get the center frequency right, but the rest is still off. I really liked the suggestion made by Anthony\_Nicholls here: [Suggestion: Replace skew with lambdas](https://forum.juce.com/t/suggestion-replace-skew-with-lambdas/18653)  
Lambdas would be great. I know, it’s a problem with backwards compability. But I liked the JUCE\_COMPILER\_SUPPORTS\_LAMBDAS solution.

---

<div class="post-metadata">

**Author:** ![cocell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cocell/32/643_2.png) [@cocell](https://forum.juce.com/u/cocell)\
**Post date:** [October 19, 2016, 9:29pm UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/5 "2016-10-19T21:29:17Z")

</div>

Try  
y=mx+b  
equation

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [October 20, 2016, 8:47am UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/6 "2016-10-20T08:47:52Z")

</div>

Well the math is not the problem, in the first post there is the solution. I thought this is just missing in the NormalisableRange. I already use custom classes for parameter storing, but for the long way I may switch to AudioProcpsserparametetValueTree so I think this could be a nice addition.

---

<div class="post-metadata">

**Author:** ![chkn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/chkn/32/3862_2.png) [@chkn](https://forum.juce.com/u/chkn)\
**Post date:** [December 9, 2016, 11:48am UTC](https://forum.juce.com/t/normalisablerange-suggestions/19514/7 "2016-12-09T11:48:34Z")

</div>

bump, bump, bump… and bump
