No default constructor exists for class "juce::AudioProcessorValueTreeState"

Heya, I’ve been trying to make a VST plugin and recently tried to implement preset management, but my plugin will no longer build because of the error
no default constructor exists for class "juce::AudioProcessorValueTreeState"

I’m not really sure where I’m going wrong and the other answers on the forums weren’t working. Here’s the chunk of my code where the error comes from.


#include "PluginProcessor.h"
#include "PluginEditor.h"

//==============================================================================
Hot_PotatoAudioProcessor::Hot_PotatoAudioProcessor()

#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  juce::AudioChannelSet::stereo(), true)
                      #endif
                       .withOutput ("Output", juce::AudioChannelSet::stereo(), true)
                     #endif
                    ),
    apvts(*this, nullptr, "Parameters", createParameterLayout())
#endif
{
    apvts.state.setProperty(Service::PresetManager::presetNameProperty, "", nullptr);
    apvts.state.setProperty("version", ProjectInfo::versionString, nullptr);

    presetManager = std::make_unique<Service::PresetManager>(apvts);
};

Hopefully I can get this fixed lol :confused:

Are you sure JucePlugin_PreferredChannelConfigurations is defined in this project?

Looks like you’ve added the initialisation of your apvts within the #ifndef JucePlugin_PreferredChannelConfigurations scope, so I’m guessing that macro is in fact defined as so that section of code won’t be compiled.

Move the initialisation to be after the #endif and you should be good.

I actually managed to fix this without doing that, In my PluginProcessor.h I changed the lines

Note: they are shortened

public:
    juce::AudioProcessorValueTreeState apvts;
private:
    AudioProcessorValueTreeState apvts;
    std::unique_ptr<Service::PresetManager> presetManager;

to

public:
    AudioProcessorValueTreeState apvts;
private:
    //AudioProcessorValueTreeState apvts;
    std::unique_ptr<Service::PresetManager> presetManager;

I think one of the issues was that i defined apvts twice, along with some other typos. Thanks for the help though!

1 Like