GUI not reflecting parameters on load?

I have a VST/AU I’m developing, and if I have the plugin assigned to a track in ableton, I can close and reopen the plugin window and the GUI reflects param state, I can change the params via the Ableton controls and the GUI reflects the param state, but when I load a project fresh and open the plugin, the params are definitely set in the processor, and in the ableton plugin parameters, but my GUI isn’t reflecting the parameter values, just sitting at their defaults.

Any idea why this could be happening?

I have my sliders set up like:

dripAttachment.reset (new SliderAttachment (valueTreeState, "drip", dripSlider));

The param is set up like:

std::make_unique<juce::AudioParameterFloat> ("drip","Drip",0.0f,0.6f,0.0f)
dripParameter = parameters.getRawParameterValue("drip");

I’m kind of at a loss for figuring out how everything else works, but the initial load doesn’t trigger the correct gui state.

Just a sanity check: did you implement getStateInformation and setStateInformation?
And did you try to debug, if that is actually executed and restores the data correctly?

I implemented those like this:

**void** AudioProcessor::getStateInformation (juce::MemoryBlock& destData)


**auto** state = parameters.copyState();

std::unique_ptr<juce::XmlElement> xml (state.createXml());

copyXmlToBinary (*xml, destData);


**void** AudioProcessor::setStateInformation ( **const** **void** * data, **int** sizeInBytes)


std::unique_ptr<juce::XmlElement> xmlState (getXmlFromBinary (data, sizeInBytes));

**if** (xmlState.get() != **nullptr** )

**if** (xmlState->hasTagName (parameters.state.getType()))

parameters.replaceState (juce::ValueTree::fromXml (*xmlState));


In this app parameters is:

juce::AudioProcessorValueTreeState parameters;

and they are implemented as:

AudioProcessor::AudioProcessor() parameters (* **this** , **nullptr** , juce::Identifier (JucePlugin_Name), {
std::make_unique<juce::AudioParameterFloat> (...)
}) {
  myParameter = parameters.getRawParameterValue("myParam");

Well, thats unbelievably embarrassing :upside_down_face:

I hooked a debugger up to the AudioPluginHost and it looks like it never gets to replace state, bails on the xmlState condition. Not sure why.

Turns out it was a space in the plugin name. Wew.

Oh that’s a classic, happened to me as well.

The restrictions on type names and property names in XML are annoying.
Best to never use free text there, although I also often use that.
The plugin name is handy if you are creating presets, so maybe it’s best to add the plugin name as property to the state.

Glad you solved it.

Not very experienced but I hope i can help. I will assume that you have different AudioProcessor.cpp and AudioProcessorEditor.cpp files.

First what are you trying to assign to dripParameter? If you want to assign the value i guess you should go for:
dripParameter = *parameters.getRawParameterValue(“drip”);

or if dripParameter is a member of the Editor:
dripParameter = *audioProcessor.parameters.getRawParameterValue(“drip”);

Secondly what kind of object dripAttachment is??

Why don’t you declare:
std::unique_ptrjuce::AudioProcessorValueTreeState::SliderAttachment dripAttachment;

and then in your constructor initialise it with:
dripAttachment = std::make_uniquejuce::AudioProcessorValueTreeState::SliderAttachment(audioProcessor.valueTreeState, “drip”, dripSlider);

Some more info would help me understand more. Anyways, hope that helps!