# \[SOLVED\] Plugin params only loaded with GUI

**URL:** <https://forum.juce.com/t/solved-plugin-params-only-loaded-with-gui/35865>\
**Category:** General JUCE discussion\
**Created:** [October 25, 2019, 9:17am UTC](https://forum.juce.com/t/solved-plugin-params-only-loaded-with-gui/35865 "2019-10-25T09:17:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [October 25, 2019, 9:17am UTC](https://forum.juce.com/t/solved-plugin-params-only-loaded-with-gui/35865/1 "2019-10-25T09:17:52Z")

</div>

After saving a project in the DAW and loading it again, my plugin will only restore its internal state after I open the GUI. Before it behaves like it was initialized.  
I set the state in `setStateInformation()` like so:

```auto
  std::unique_ptr<XmlElement> xmlState(getXmlFromBinary(data, sizeInBytes));
  if (xmlState.get() != nullptr) {
    if (xmlState->hasTagName(m_value_tree.state.getType()))
      m_value_tree.replaceState(ValueTree::fromXml(*xmlState));
  }

```

I’m using listeners to the audiotree to set values in my DSP code, but my guess is that `replacestate()` will not notify the listeners.

Is there a way to notify the listeners, or maybe even make every single parameter act like it was changed, even though it wasn’t?

---

<div class="post-metadata">

**Author:** ![Achder](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/achder/32/5897_2.png) [@Achder](https://forum.juce.com/u/Achder)\
**Post date:** [October 25, 2019, 10:00am UTC](https://forum.juce.com/t/solved-plugin-params-only-loaded-with-gui/35865/2 "2019-10-25T10:00:31Z")

</div>

There is ValueTree::sendPropertyChangeMessage():  
[https://docs.juce.com/master/classValueTree.html#a164ff183e358b982b1a1f5dd1176ab88](https://docs.juce.com/master/classValueTree.html#a164ff183e358b982b1a1f5dd1176ab88)

---

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [October 26, 2019, 2:21pm UTC](https://forum.juce.com/t/solved-plugin-params-only-loaded-with-gui/35865/3 "2019-10-26T14:21:52Z")

</div>

Thanks for your answer! The proposed solution works just fine for everything that is not an audioparameter. However, I found that triggering audioparameters on the ValueTree (not on AudioProcessorValueTreeState) doesn’t retrigger the parameter listeners. The problem here might be that I don’t know how the parameters are even stored on the ValueTree. For example, calling

```auto
m_value_tree.state.getNumProperties();

```

returns 0, so it seems to me the audio params are stored in a different way.  
I also tried to set the values manually by calling

```auto
m_value_tree.getParameter(name)->setValueNotifyingHost(m_value_tree.getParameterAsValue(name).getValue());

```

but weirdly, this sets the value to either end of the parameter range.

---

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [October 26, 2019, 5:28pm UTC](https://forum.juce.com/t/solved-plugin-params-only-loaded-with-gui/35865/4 "2019-10-26T17:28:49Z")

</div>

Ok I got it working. The values were set to the limits because I forgot use the conversion function. The working solution is:

```auto
m_value_tree.getParameter(name)->setValueNotifyingHost(m_value_tree.getParameter(name)->convertTo0to1(m_value_tree.getParameterAsValue(name).getValue()));

```
