I want to display the .vstpreset file name a preset was loaded from (using the host’s load preset feature) in the GUI of my plugin. I managed to do this when saving a .vstpreset file by retrieving the file name in the processor’s setState method. I used a IAttributeList instance to do this. The IAttributeList::getString method retrieves a valid file name when a preset was loaded from a .vstpreset file.
Now I want to do the same for presets that the user saves in a .vstpreset file (using the host’s save preset feature). However, the “state” stream that is passed to the processor’s getState method doesn’t give me a file name. The IAttributeList::getString method doesn’t retrieve a valid file name when used in the getState method. Maybe this is because the “state” stream doesn’t know the name of the file that it’s going to be saved to at the time when it reads the preset data from the processor.
Is there any way to retrieve the .vstpreset file name when saving a preset in a similar way as it is possible when loading it from a .vstpreset file? Any help would be appreciated.
If you are talking about Cubase/Nuendo DAWs, you could check the kFilePathStringType and kFileName of IAttributeList ( VST 3 Interfaces: Predefined Preset Attributes) , these attributes are available for saving (getState) and loading (setState).
I’m already using the kFilePathStringType and kFileName constants in the IAttributeList::getString method. They work for loading (in the processor’s setState method), but not for saving. However, I do not own a Steinberg host except the VST3PluginTestHost, where retrieving the filename also only works for loading, not for saving. Besides that, I’m looking for a way to retrieve the filename that works in any DAW. Right now, retrieving the filename when loading works in Studio One/Studio Pro, Samplitude, Bitwig, Ableton and others.
I assume that retrieving the filename doesn’t work when saving because the plugin doesn’t know the filename at the moment when the host reads its preset data (in the getState method). It looks as if the filename is assigned to the stream after the setState method has finished. If yes, is there any other method that is called right after a file has been saved?
Which host are you talking about ? VST3PluginTestHost ?
if yes this is a bug in VST3PluginTestHost… normally the host should ask for the state after knowing what will be the filename and use this attributeList or getFileName( VST 3 Interfaces: IStreamAttributes Class Reference)
else there is no other way to get the filename…
I’m talking about any DAW I have for testing. As mentioned these are Studio One/Studio Pro (Presonus/Fender), Samplitude ProX (Magix/BorisFX), Bitwig and Ableton. I also have some other VST hosts I randomly use, such as Magix Music Maker or Cantabile. All behave the same: they provide the filename when loading a preset, but not when saving.
Maybe this is important: if the user wants to save a preset (in VST3PluginTestHost), he is first prompted to provide a target file name. After closing the save dialog, the getState method is called. So as you mentioned, VST3PluginTestHost should know the file name before it calls the getState method. After the getState method is finished, the user is prompted again to provide some additional info for the preset. Is this a special behaviour of VST3PluginTestHost or is any host supposed to save a preset in this order?
no this is specific to VST3PluginTestHost, normally the getState should happen at the end after everything else is set (path, media attributes …). With VST3PluginTestHost it should not be possible to change the preset after getState is called… (see it as a bug)
If you check with Cubase getState is called after the preset name is entered.
You need to inform the host developers that you’d like them to implement this feature in their hosts. There’s no other API available to retrieve the filename.