Help with createAndAddParameter

im new in juce and im trying to make the plugin tutorial 14 and 15 from youtube
i got success but im trying to make now tutorial 16 and implant this
treeState.createAndAddParameter(std::make_unique (GAIN_ID, GAIN_NAME, GAIN_NAME, gainRange,0.5f, nullptr, nullptr));

instead this one l

treeState.createAndAddParameter(GAIN_ID, GAIN_NAME, GAIN_NAME, gainRange,0.5f, nullptr, nullptr);

but build is failed
what im doing wrong ? tnx for any help.

A few things:

First of all, if you face a failing build, the exact error message your compiler gives you helps a lot to find out what went wrong even if they may look somewhat confusing for a newcomer, so it’s always a good idea to post your error message with such posts to help people helping you.

Second thing:

There are no official JUCE youtube tutorials so it’s not really clear what you mean by tutorial 14, 15 and 16, and you probably found some outdated non-official tutorial. This becomes especially evident as using the createAndAddParameter API is not the recommended state of the art approach with creating parameters anymore. That being said it still can be used, so although you might be learning an outdated approach here, this should not be the source of any build error.

Regarding this line of code you posted:

treeState.createAndAddParameter (std::make_unique (GAIN_ID, GAIN_NAME, GAIN_NAME, gainRange,0.5f, nullptr, nullptr));

You need to tell std::make_unique which type of object it should create. As std::make_unique is a function template, you do this by specifying the type of object to create as template parameter. As we want to create a std::unique_ptr holding an AudioProcessorValueTreeState::Parameter instance, you need to call

treeState.createAndAddParameter (std::make_unique<AudioProcessorValueTreeState::Parameter> (GAIN_ID, GAIN_NAME, GAIN_NAME, gainRange,0.5f, nullptr, nullptr));

In case the line you posted above was no copy & paste failure, this might probably be the reason for your error.

I am a beginner of JUCE who is not so much concerned with GUI making, so the following might be a newbie approach…

Using the class of “AudioParameterFloat”,

AudioParameterFloat *amp;

addParameter(amp= new AudioParameterFloat(“amp”,
// parameter ID
“amp”, // parameter name
0.f, // minimum value
1.f, // maximum value
.5f)); // default value

and turn off the function named “bool hasEditor()” in PluginProcessor.cpp, that is, “return false”. That’s it.
The parameter GUI will be provided by Host.

tnx for your answer sir
im a beginner so i guess i need to learn some more about the right way to implant in juce.
my experience is only arduino c. the videos on youtube is some guy tutorial and thats the only thing i can find for getting start. can you recommend me some basic reading or video of basics juce language? how to implant constructor right and so on?
thank you

thank you bijaganita
il try to implant this today step by step to understand it .
many thanks for you help ill let you know if i got successed.

When I got started a few years ago the official tutorials helped me a lot. That should of course not mean that the videos you found are bad only because an old API was used – changes in the framework happen from time to time and probably 95% of what you learned might still be correct. I just don’t know what you watched :wink: However, you can be sure that the official tutorials are updated if the framework gets updated.

One more thing as you mention

and as you mention that your

Both, JUCE and Arduino use the same language which is C++ and Arduino is a great experience to get started! As Arduino only uses a limited subset of the C++ syntax this might not become that obvious in the first place. So what I can recomend every newcomer is to learn pure basic C++ a bit before starting with a framework like JUCE that is written in C++. You will immediately get a better understanding of the syntax if you understood C++. The internet should be full of C++ tutorials, just have a look and try writing a few dumb command line applications – I’m sure that will help you moving forward with JUCE :slight_smile: