treeState constructor

I’m afraid this is simple but I have no idea how to correct this.
I’m trying to do the whole treestate parameter thing following the tutorial, also this video tutorial.

In plugin processors .h public section I have: AudioProcessorValueTreeState treeState; then in the initialisation list I have treeState(*this, nullptr), and thats it. I get an error: no default constructor exists for class "juce::AudioProcessorValueTreeState"
treestate only has one constructor with the 2 arguments, so yeah there isn’t a default constructor…

I’ve tried starting from a blank plugin project and adding these 2 lines in the same places and it all works fine. Does anyone have any idea why I’m getting an error with this? Thanks

1 Like

From the post alone it seems if you are doing everything right, but hard to say without seeing more source code. Can you post the code with a bit more context, i.e. the full constructor for example.

Sorry to drag this back to the top but I’m having exactly the same problem (following the same tutorial, using VS17)

adding the following statement to the public: section of my AudioProcessor (PluginProcessor.h)

AudioProcessorValueTreeState treeState;

and

in my AudioProcessor constructor

_myAudioProcessor::_myAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  AudioChannelSet::stereo(), true)
                      #endif
                       .withOutput ("Output", AudioChannelSet::stereo(), true)
                     #endif
                       ),
	treeState(*this, nullptr)
#endif
{
}

results is an error

‘juce::AudioProcessorValueTreeState’: no appropriate default constructor available

is it that

treeState(*this, nullptr)

is not constructing?

The constructor is inside the preprocessor macro…

I am not a fan of that makro mess, but probably you have a preferred configuration in the Projucer defined.
It can be done like that:

_myAudioProcessor::_myAudioProcessor()
#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  AudioChannelSet::stereo(), true)
                      #endif
                       .withOutput ("Output", AudioChannelSet::stereo(), true)
                     #endif
                       ),
#else
    :
#endif
	treeState(*this, nullptr)
{
}

(long version of @t0m’s answer :wink: )

1 Like

yes,

that’s where the tutorial says to add it, here’s a link to the point in the video tut

thanks @daniel

but even following your suggestion, it still gives a ‘no default constructor’ error.

thx for you efforts

Ah, those tutorials are not owned by the JUCE team.

That being said, the creator, @JoshuaHodge, is currently working with us.

thanks @tom - Joshua was following this JUCE tutorial (it’s linked in the OP)

it does seem to suggest this approach (although it use the name ‘parameters’)

TutorialProcessor()
    :   parameters (*this, nullptr)
{
    //...
}

If that is happening in XCode, sometimes it doesn’t clear error messages properly…
I would be very surprised. Also double-check, if you named the AudioProcessorValueTreeState the same way like the one quoted here, and that you didn’t accidently add two members of the type AudioProcessorValueTreeState…

But if you know, you won’t use the JucePlugin_PreferredChannelConfigurations makro, you can get rid of the whole block.

Good luck

1 Like

I’m working in VS17

I tried to delete it and I got exactly the same,

I think the problems is really that it can’t find the constructor of the class

image

image

solved - thanks

Could you elaborate on how it was solved?