How to change the value of a AudioProcessorParameterWithID to user-readable value?

I have a need to modify the values of certain parameters, based on selections the user makes (picking a kind of “preset” from a list, with initial values that we want to then set as the values for the associated parameters). The problem is that I need those values to be in the normal user range, since they come from a user-editable XML file, not 0…1. But the function setValueNotifyingHost() calls setValue(), which calls convertFrom0to1() on the value, meaning it must be expecting a value in the range 0…1, not the user-readable value.

I have a pointer to a AudioProcessorParameterWithID, saved from when I created it via parameters.createAndAddParameter(). So, how do I set its value to a user-readable value? (Not sure what to call that. Plain? World? Unnormalized? Normalized?)

The only solution I can think of in the general case is to save the NormalisableRange objects that I create for each parameter, so that I can call the conversion routines for those.

But it would be a lot easier if there was a direct way to set the value for an AudioProcessorParameterWithID, or even a way to access its range object, so that I could make the same conversions anyplace I might need to, regardless of whether I had a SliderAttachment (or other attachment) connected to the parameter.

Your normalisable range should take care of that conversion, NormalisableRange<float>(user-readable-start, user-readable-end, ...). Depending on your conversion functions for the range you may have to map to or from 0.0 - 1.0 before returning to achieve what you want

AudioProcessorValueTreeState::getRange() should do the trick there :slight_smile:

1 Like

Actually, getParameterRange() is the function, but thanks! That’s exactly what I needed! :smiley:

1 Like