Home to Foleys Finest Audio

Confusion saving and loading state


I’ve been using Faust and PGM for the last few months without any issues - it’s very easy and the integration between Faust and Juce and PGM is great. I am however confused about saving and loading presets. Is it supposed to work right out of the box or do I have to write some code to manage the saving and loading of parameters? It seems to save a preset but when the same preset is loaded the plugin just reloads to its default state. Also the contents of the preset file don’t look the same as the presets created by the example projects - there are no line breaks separating the values.

Hi @derryn and welcome,

The PGM takes care of loading and restoring the parameter values as well as values in the persistent ValueTree accessed as magicState.getPropertyAsValue(const juce::String&).
That is as long as your processor doesn’t override the setStateInformation() and getStateInformation(). The default juce plugin boilerplate will contain those two methods, so you need to remove them if you want PGM to take care of saving and loading the state. You are free to use your own save and load methods, but then it’s up to you what you want to store in what format.

There is nothing for presets though. The FoleysSynth has some example code that you can copy if you want to show how you can retrieve the current parameter values and restore them later. It also shows the configuration file, that PGM allows to store settings in a file to make them available to all plugin instances (and update them live once the file changes).

This method is only inside your plugin, it doesn’t follow the presets used in the host. AFAIK there is no common format that works cross platform. You can try to write such thing, but currently it is beyont the scope of PGM. I agree, it would be a nice addition though.

Hope that helps a bit further, let me know if you have further questions

I guess I am confused about this menu - it doesn’t work on my plugin but it works on all the examples. I am sure that I could implement my own preset system like the example but I would also like the built in state saving to work. I think the faust2juce script implemented its own state saving methods that are overridden by PGM. Do I need to setup my own ValueTree?

That menu is brought to you by the JUCE standalone wrapper. It simply calls the setStateInformation and getStateInformation.
This will work for a PGM plugin, if it inherits from foleys::MagicProcessor and if it’s not overriding setStateInformation and getStateInformation in your plugin (i.e. remove those two functions from the generated code).

Did you see and follow this posting?

Yes I have read that post. setStateInformation and getStateInformation are left out with preprocessor defines in the latest faust2juce script if PLUGIN_MAGIC is enabled. My plugin seems to be saving corrupt files that won’t reload the state when selected.

Ah I see. Unfortunately I am not a faust user, so I didn’t check that addition too deeply.
Maybe @Digital_Larry can chime in, he contributed that code to faust.

If you have your project or a demo project that exposes the problem somewhere public I can have a look too.

I found the solution in this thread:

The Faust controls don’t update the ValueTree - this caused the saved state to always have the default values. Syncing the controls fixed host saving and internal xml saving.

Copyright © 2020-2021 Foleys Finest Audio UG. All rights reserved.