Module::onAdd and onSave for presets?

The methods Module::onAdd and Module ::onSave are only called on loading/saving a patch, but not on loading/saving a preset.

If I want to save e.g. a wave file within a preset, I could call Module::onSave from Module::dataToJson. But then every time the autosave thread runs, the wave file will also be saved.

Has anyone found a way to distinguish between Module::dataToJson called from saving a preset manually and called from the autosave thread?

1 Like

<bump> on this unanswered thread.

I’ve a use case where it’d be useful to display the name of the preset within a module. Is there a way to get the filename when a user loads a preset?

No, but you can put a text widget on the display that presents a name. This could be set in a menu, or even editable in-place. This text would of course be an entry in the json for the module, hence part of any preset that gets saved/loaded.

Good call, that seems like a fair way of going about it.

1 Like