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"


#ifndef JucePlugin_PreferredChannelConfigurations
     : AudioProcessor (BusesProperties()
                     #if ! JucePlugin_IsMidiEffect
                      #if ! JucePlugin_IsSynth
                       .withInput  ("Input",  juce::AudioChannelSet::stereo(), true)
                       .withOutput ("Output", juce::AudioChannelSet::stereo(), true)
    apvts(*this, nullptr, "Parameters", createParameterLayout())
    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

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


    AudioProcessorValueTreeState apvts;
    //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