How to set a parameter version hint?

Hello,

I am following along with the arpeggiator tutorial and I am running into an error that requires the version hint for my speed parameter to be some integer above 0.

I am struggling with my syntax in the documentation for AudioProcessorParameter at this link:
https://docs.juce.com/master/classAudioProcessorParameter.html#a7022e0d84cfc013effd47f70cb3e7975

How do I set the version hint for a parameter?

You can pass a ParameterID { "id", versionHint } as the first argument of a parameter constructor.

There’s an example in the AudioPluginDemo project:

5 Likes

Wouldn’t it be a good idea to demonstrate this concept here? : JUCE: Tutorial: Adding plug-in parameters

Of course it’s easy to check the demo code, but that’s not where noobs will start. (I’m far from noob, but my first place to check was the tutorial, next was the forum; demo code is usually my last port of call.)

6 Likes

+1 for updating the tutorial docs. I was scratching my head on this for a while (as I am a newbie), but figured out that with the Juce upgrade, they must have added a new assert to check for the version number to be non zero. Declaring the ParameterID with its constructor lets us set the version number.

addParameter (mDryWetParameter = new juce::AudioParameterFloat(juce::ParameterID(“drywet”, 1), “Dry Wet”, 0.0, 1.0, 0.2));

6 Likes

Excuse me. It seems that this doesn’t work with unique_ptr.
It says:

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk/usr/include/c++/v1/__memory/unique_ptr.h:686:30 Call to deleted constructor of 'juce::AudioParameterFloat'

Am I supposed to give up using juce::AudioProcessorValueTreeState::ParameterLayout?

Yes, in templates the compiler cannot deduce the type. You need to give it a hint, like the snippet reuk linked above:

std::make_unique<AudioParameterFloat> (ParameterID { "gain",  1 }, "Gain",           NormalisableRange<float> (0.0f, 1.0f), 0.9f)

Only providing curly brackets doesn’t work in the templated make_unique function.

1 Like