Solved How to Save a Preset?
-
I realise this may be obvious, but I can't seem to save a preset. I simply have this statement in my code…
Engine.saveUserPreset("Test Preset");
…but no file is written. (I'm expecting a file to be created with component values I've set the save-in-preset flag to, and addModuleStateToUserPreset data.)
What am I missing?
Thank you.
-
@clevername27 This function saves onto a currently loaded file. This means the file has to exist first.
-
@ustk Thank you for your reply. If Engine.saveUserPreset doesn't create a file, then how does it get created?
-
File/FileSystem API
inline function savePresetAs() { FileSystem.browse(FileSystem.getFolder(FileSystem.UserPresets), true, "*.preset", function(f) { var filePath = f.toString(File.FullPath); var parentDirectory = f.getParentDirectory().toString(File.FullPath); var userPresetsDirectory = FileSystem.getFolder(FileSystem.UserPresets).toString(File.FullPath); if (parentDirectory == userPresetsDirectory) return Engine.showMessageBox("Invalid Location", "Please choose a sub folder to store the preset.", 0); if (!filePath.contains(userPresetsDirectory)) return Engine.showMessageBox("Invalid Location", "Please save the preset within the User Presets folder.", 0); Engine.saveUserPreset(f.toString(File.FullPath).replace(".preset")); }); }
-
@d-healey I don't care if you are using HISE to make "virtual instruments" (as if that's a real thing). You're alright.
-