gives me the float pointer. Is this the intended way? I don’t feel well comparing float values, why I chose int in the first place (although they seem to turn out “exact” after all)
Yeah as far as i know that’s just a quirk. I feel like they should have made some more functions to get as different types but you can just cast from float to whatever type you want. It’s a bit silly because eg. It starts as a int, you get as a float, then you cast back to int. But it works. As far as I know there’s no other way currently.
Most hosts will store internally a normalised float, that’s why this is exposed here.
But with the latest additions, you can use the RangedAudioParameter classes directly:
auto* selection = dynamic_cast<AudioParameterInt*> (apvts.getParameter ("foo"));
auto intValue = selection.get();
btw. best practice is to have the pointer looked up only once in the constructor and keep it as a member variable. That saves iterating through the parameters, and JUCE doesn’t allow adding and removing parameters after the constructor anyway. I am not sure, how slow the lookup is in practice, I seem to remember, that there is a map in place for fast lookup…
Following up on @daniel’s comment, but don’t quote me on this, using a float for all parameters means the API only has to deal with one data type, instead of having a more complex API that has different functions for each of the data types. And the beauty of using a value of 0.0-1.0 is that it’s super easy to convert to and from… myValue = (floatValue * myValueRange) + myValueBase and floatValue = (myValue - myValueBase) / myValueRange. I think I wrote those correctly… lol…