Why aren't the NormalisableRange conversions functions public?


#1

Hi,

I need to convert a NormalisableRange <float> to a NormalisableRange <double>.
I thought to just make a new NormalisableRange <double> object where I pass all variables from the float one to the new one with float to double conversions.
Unfortunately, the lambda’s convertFrom0To1Function, convertTo0To1Function and snapToLegalValueFunction are not public, so I cannot get them from the float version.

If there is another solution, please let me know, but I prefer to have these functions public.

Thanks
Jelle


#2

I don’t think you can use the same lambdas. They have the wrong signature since they are using floats and not doubles as parameter and return types.


#3

Essentially what @Achder said, you’d have to set the conversion lambdas for the double by just wrapping calls to the original, float range. SliderAttachment does something like that… inversed, of course :slight_smile:


#4

Thank you. I was indeed thinking about that the parameter system uses float while the slider uses doubles. There is no chance that the slider will use floats in the future?


#5

I think it would rather be the opposite way, since floats are a subset of doubles. But the AudioParameters using float comes from the various plugin APIs. If that will change, we can only guess. On the other hand it makes sense to use float parameters, when the audio processing runs in float as well. Sure there is double precision processing…


#6

Yes, I see. Double audio would then be better.
Because, I also found out that the NormalisableRange loses the double functionality if it is constructed from the conversion system in AudioProcessorValueTreeState that TonyAtHarrison mentioned.
For example, Slider::getValue() will sometimes return values like -0.0999994 because the NormalisableRange::snapToLegalValue is not so precise anymore.