Cant get the treestate to function

Hello,

I tried using the treestate to save and load the gain value, but the constructor says that the “juce::AudioProcessorValueTreeState does not have a default constructor.”

PluginProcessor.h (2.5 KB)
PluginEditor.cpp (4.7 KB)
PluginEditor.h (1.3 KB)
PluginProcessor.cpp (7.8 KB)

In the header, you declared a data member of type AudioProcessorValueTreeState, which doesn’t have a default constructor.

The quick fix would be to change the declaration to be a unique_ptr<AudioProcessorValueTreeState>.

A better fix would be to initialise state in the audioprocessor’s constructor initialiser list:

GainSliderAudioProcessor::GainSliderAudioProcessor()
    : AudioProcessor (...),
      state (*this, nullptr, "Parameters", createParameterLayout())
{
}

Hello,

I still have a problem with this line.

    state = std::make_unique<juce::AudioProcessorValueTreeState>(*this, nullptr, "Parameters", layout);

If you’re using the constructor initialiser list, then you don’t need that line at all.