How do I add my custom parameters to the ValueTree?

I have my own graphic component that works with doubles, but I don’t know how to add it to the tree correctly.

currently I add each parameter with createAndAddParameter, even if I don’t need the values used by sliders. I just need the ID and the value. Also I am forced to convert it to float.

i think i would just need something like this

> double value = 1.0;
> tree.createAndAddParameter ("param", value);

and get it back

> std::atomic<double>* value = tree.getRawParameterValue ("param");

from what I have seen it only allows to add float or int

valueTreeState.createAndAddParameter(std::make_unique< AudioParameterFloat > (id, name, min,max, value));

Am I the only one in the whole world who would like to add doubles?

  • You’re talking about AudioProcessorValueTreeState, not ValueTree. APVTS is used to manage an AudioProcessor state (aka its parameters), and it contains a ValueTree.
  • Creating parameters using that version of APVTS::createAndAddParameter is deprecated. The standard way now is using APVTS constructor with a ParameterLayout.
  • AudioProcessorParameter's values are floats normalized to 0…1. There are subclasses for bool, float, int and “choice” parameters, but the underlying value is a normalized float for all of them.