Can anyone give me an overview of what NormalizableRange is all about? I am trying to set up an AudioParameterFloat parameter for my plugin so that I can at least display a value outside the range [0,1]. For example, a percent reverb parameter in the range [0,100] or a room area parameter in the range [1000,10000] (sq. ft.). I have constructed my plugin by starting with the NoiseGate example, which has two parameters in the range [0,1] and uses the GenericEditor, and modifying it to support my five parameters and use my own brand of signal processing. Works fine if all parameters range from 0 to 1. I only modified the processor code, using the editor code as is. But when I tried to change my percent reverb parameter from [0,1] with initial value 0.5 to [0,100] with initial value 50, it behaved in a way I could not understand. Here is a sample of my code:
OK. I think I understand the NormalisableRange class now and can use it to go back and forth between a [0,1] range and an [A,B] range. My remaining problem is that I cannot see what is happening between my slider values and the corresponding parameter values. I assume that the slider value is unnormalised and needs to be normalized in the editor, but I am not sure how or where to do this.
Unfortunately dealing with the parameter ranges (and skews) and sliders tends to be a bit tricky, but I am sure you will eventually find out some solution that works for you.
I now have further insight into what is going on. The (AudioParameterFloat) parameter methods getValue and setValue (and one or two other methods) apply conversions to and from the [0,1] domain. This is only apparent if you look at the code for these methods. I tried, without success, to undo the conversions in my code so that “percent reverb” came back to my processor in the range [0,100]. What finally worked was to change the JUCE code for getValue and setValue to eliminate the conversions. I guess the idea behind the audio parameters and normalization is to make sure that sliders are always in the range [0,1] even if the parameters they control are not. This is more or less the opposite of what I want to do.
Aha!! I tried an approach based on the AudioProcessorValueTreeState tutorial and it works just fine without the need to hack any JUCE code. My five sliders all display the ranges I like and the parameters appear to arrive in the processor intact. No need for slider listeners or worrying about what to do when the slider value changes (or is in the process of changing). I’ve learned a lot from this exercise. Next project: make the GUI look sexier!
Thanks, I thought it was some other tutorial. I tried this one without success. Can you point me in the right direction?. I have some like this gainSlider.setRange(0.0, 1.0);
and inputGainParam = std::make_unique<AudioParameterFloat>(GAIN_ID, GAIN_NAME, NormalisableRange< float >(0.0f, 2.0f), 0.5f);
My output in the parameter is just from 0.0 to 1.0 as the gain range. I want it to be mapped to the range 0.0 to 2.0.
Thanks for your help
you should check out josh’s video on the valueTreeState object. it’s very recent as you can see so it’s pretty much what is being done nowadays. https://www.youtube.com/watch?v=HrRghlZHJvE&t=2s
the only thing missing in his video is the xml stuff and the stuff with the atomic< float >* but you already have that from the text tutorial