# This strange behavior in Ableton occurs when restoring state (and default state)?

**URL:** <https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832>\
**Category:** General JUCE discussion\
**Created:** [September 12, 2023, 5:33pm UTC](https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832 "2023-09-12T17:33:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ian-SAfc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ian-safc/32/17877_2.png) [@Ian-SAfc](https://forum.juce.com/u/Ian-SAfc)\
**Post date:** [September 12, 2023, 5:33pm UTC](https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832/1 "2023-09-12T17:33:38Z")

</div>

I’m testing out my plugin. Works fine in Reaper but in Ableton something strange happened.

One of my sliders did not restore properly. The default value of the slider parameter is 0.5f (in a range 0.0f to 1.0f). If I set the slider to the default value, when I exit Ableton and relaunch it, the state is restored and the slider value changed to 0.0f!

Has anyone experienced similar strange behavior from Ableton? I upgraded to Ableton Lite latest version just now and that seemed to fix the issue. But one issue remains, - I insert my plugin on a different track in Ableton and it does not set the all plugin sliders to their default values!

In Reaper, all this works fine. Has anyone else had similar experiences with Ableton, or any insights to share?

---

<div class="post-metadata">

**Author:** ![duvrin](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@duvrin](https://forum.juce.com/u/duvrin)\
**Post date:** [September 12, 2023, 6:10pm UTC](https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832/2 "2023-09-12T18:10:42Z")

</div>

Just because your plugin works fine in one host, doesn’t mean that it’s bullet-proof in all hosts. Different DAWs have different ways of initializing plugins and they behave differently when you minimize/maximize the GUI and/or restore state. Use the debugger to walk through the functions calls (constructors, getStateInforamtion, setStateInformation, prepareToPlay), expect them to be in different order with different hosts. Get yourself familiar with Pluginval to make sure you are also covered with the hosts you don’t work with.

---

<div class="post-metadata">

**Author:** ![zsliu98](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/zsliu98/32/22502_2.png) [@zsliu98](https://forum.juce.com/u/zsliu98)\
**Post date:** [September 12, 2023, 10:38pm UTC](https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832/3 "2023-09-12T22:38:25Z")

</div>

As duvrin already mentioned, testing the plugin with validators like pluginval is a good idea. I would also suggest replacing your editor with `juce::GenericAudioProcessorEditor` to see whether the problem still exists.

> If I set the slider to the default value, when I exit Ableton and relaunch it, the state is restored and the slider value changed to 0.0f!

You talked a lot about the default values. FYI, if a parameter in APVTS isn’t changed by `replaceState()`, a `parameterChanged()` with this parameter will not get called.

---

<div class="post-metadata">

**Author:** ![Ian-SAfc](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/ian-safc/32/17877_2.png) [@Ian-SAfc](https://forum.juce.com/u/Ian-SAfc)\
**Post date:** [September 13, 2023, 12:48pm UTC](https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832/4 "2023-09-13T12:48:03Z")

</div>

@zsliu98 @duvrin  
I downloaded pluginval and my plugin “all tests passed” at levels 5 and 10; thats a useful tool I didn’t know about.  
I think I have to scrutinize my `createparameterlayout()` and constructor to see how the defaults are set etc. and discover how Ableton might take a different road.

---

<div class="post-metadata">

**Author:** ![duvrin](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@duvrin](https://forum.juce.com/u/duvrin)\
**Post date:** [September 13, 2023, 6:11pm UTC](https://forum.juce.com/t/this-strange-behavior-in-ableton-occurs-when-restoring-state-and-default-state/57832/5 "2023-09-13T18:11:14Z")

</div>

I think that in your case you need to focus on `setStateInformation`. use `ValueTree::toXmlString` to print your `apvts.state` tree and if nothing is wrong there, add your processor as a listener to one of the parameters that doesn’t restore properly and trace back any actions that trigger changes. For example you might find out that when you initialize your GUI you are doing something wrong.

If `setStateInformation` will print the wrong values to begin with, head over to `getStateInformation` and see if the values are being saved to your plugin state properly (again by using `ValueTree::toXmlString`).

Note that `getState` and `setState` are being called by the host whenever it decides to (and different hosts will use them in different ways), so they are the immediate suspects whenever the plugin state is not restored correctly.
