Bool parameters With AudioProcessorValueTreeState


Hi ,
I am moving from AudioParameterFloat and AudioParameterBool to AudioProcessorValueTreeState.
But I don’t find informations about having an equivalent of a bool parameter with the createAndAddParameter method of the AudioProcessorValueTreeState.

So my question is can we emulate a bool behavior with a parameter created with the “createAndAddParameter()” method?

Thanks a lot,



Yes, absolutely. Here’s a template using lambdas for the valueToText and textToValue functions:

                            "Filter Mod",
                            NormalisableRange<float> (0.0f, 1.0f, 1.0f),
                            [](float value)
                                    return value < 0.5 ? "Off" : "On";
                            [](const String& text)
                                    if (text == "Off") return 0.0f;
	                                if (text == "On")  return 1.0f;
	                                return 0.0f;
				            false, true, true);


Thanks a lot, it is really helpfull!