# GUI not reflecting parameters on load?

**URL:** <https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874>\
**Category:** General JUCE discussion\
**Created:** [March 9, 2021, 4:51am UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874 "2021-03-09T04:51:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![thekenwheeler](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thekenwheeler](https://forum.juce.com/u/thekenwheeler)\
**Post date:** [March 9, 2021, 4:51am UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/1 "2021-03-09T04:51:41Z")

</div>

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:

```
addAndMakeVisible(dripSlider);
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.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 9, 2021, 1:21pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/2 "2021-03-09T13:21:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![thekenwheeler](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thekenwheeler](https://forum.juce.com/u/thekenwheeler)\
**Post date:** [March 9, 2021, 1:26pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/3 "2021-03-09T13:26:06Z")

</div>

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));

}
```

---

<div class="post-metadata">

**Author:** ![thekenwheeler](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thekenwheeler](https://forum.juce.com/u/thekenwheeler)\
**Post date:** [March 9, 2021, 1:30pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/4 "2021-03-09T13:30:57Z")

</div>

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");
}
```

---

<div class="post-metadata">

**Author:** ![thekenwheeler](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thekenwheeler](https://forum.juce.com/u/thekenwheeler)\
**Post date:** [March 9, 2021, 1:54pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/5 "2021-03-09T13:54:16Z")

</div>

Well, thats unbelievably embarrassing 🙃

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.

---

<div class="post-metadata">

**Author:** ![thekenwheeler](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thekenwheeler](https://forum.juce.com/u/thekenwheeler)\
**Post date:** [March 9, 2021, 2:02pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/6 "2021-03-09T14:02:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [March 9, 2021, 2:09pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/7 "2021-03-09T14:09:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![GKoulouris](https://avatars.discourse-cdn.com/v4/letter/g/e495f1/32.png) [@GKoulouris](https://forum.juce.com/u/GKoulouris)\
**Post date:** [March 9, 2021, 2:22pm UTC](https://forum.juce.com/t/gui-not-reflecting-parameters-on-load/44874/8 "2021-03-09T14:22:58Z")

</div>

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!
