Thread: WDL-OL
View Single Post
Old 05-25-2012, 05:20 PM  
Human being with feelings
olilarkin's Avatar
Join Date: Apr 2009
Location: Huddersfield, UK
Posts: 1,111

Originally Posted by cerberus View Post
but we might wish to store/restore this kind of setting in the state chunk with the project file.
i hope this makes things clearer for you:

AU/VST3/RTAS Hosts don't support banks of presets and they don't call different plug-in methods when saving the project file or when saving preset files (e.g. .aupreset / .vstpreset) to disk - they just ask the plug-in for a chunk to represent the plug-in's current state. In my IPlug this entails calling SerializeState(). If you didn't decide to manually add stuff to the chunk yourself (#define PLUG_DOES_STATE_CHUNKS 0), you won't have implemented SerializeState() in your plugin class and IPlugBase::SerializeState() will get called, which will just call IPlugBase::SerializeParams() to serialize the values of all the regular IPlug parameters. If however you wanted to add a hidden parameter (i.e. not exposed to automation) or some arbitrary data (e.g a string for a filepath) you will set (#define PLUG_DOES_STATE_CHUNKS 1) and implement Un/SerializeState() in your plugin class. In your SerializeState() you pack all the extra data into the chunk and then finally call IPlugBase::SerializeParams() at the end to store all the regular parameters in the chunk after your custom ones.

VST2 plug-ins do support saving banks of presets (.fxb files) but also support saving individual presets (.fxp). Importantly though when you save the VST2 host's project file it will store the state of a bank in rather than just the current state - so this means that if you edited preset #1 and #2 and #3, when you reload your project and select preset #1,#2 or #3 you will get the modified preset, not the initial preset that you declared in the plugin constructor. When the host tries to save the state of the VST2 plugin to the project file or to an fxb file IPlugBase::SerializePresets() will be called. This method will stick all of the chunks from your individual presets into one big chunk and return that to the host.

If you like you can implement Un/SerializePresets() in your plugin class (calling IPlugBase::Un/SerializePresets() at the end) in order to store a "global" custom variable that will be the same for the entire bank (fxb or in host project). This might be appropriate for the kind of things that i think you are talking about I suppose, HOWEVER it will only work for VST2!

If you wish to store a skin/theme choice globally for instance, one idea might be to write it to a text file on disk somewhere - however this way the choice is not saved with the project - it is totally global across hosts.

As I previously mentioned you could implement your own preset system (storing presets in some location on the HD) and discourage the use of host presets. Your presets might not include the skin/theme choice, just the parameter states - the skin/theme choice could just be saved in the main plugin state.

Apart from that I don't know anything else to suggest. FWIW on a related topic i think i will avoid an in-plugin preset menu in future plugins I make, because the behaviour is not the same in VST2 as it is in Audiounit/VST3/RTAS - i.e. since these formats don't support/save banks , Un/SerializePresets() is not called and only the last preset you edit gets stored in the state chunk. If you try and recall other presets they will have the default values you specified for them in the constructor.
VirtualCZ | pMix | Endless Series | WDL-OL | Linkedin | Facebook
Available for Audio Dev tuition via Skype (IPlug/JUCE/C++)
olilarkin is offline   Reply With Quote