save start and end positions in preset
-
Hi there, my own "Save Preset" button I've placed on the main interface (to save presets more quickly) does not save the start and end positions I set in my audio loop player.
Is there something specific I need to add? Because when I save a preset via the preset browser, the start and end positions are saved in the preset.Thanks
-
@treynterrio Are you using the
Engine.saveUserPreset()function?https://docs.hise.dev/scripting/scripting-api/engine/index.html#saveuserpreset
Or have you made your own custom solution? If so, post your button's click callback function.
-
const var BtnSavePreset = Content.getComponent("BtnSavePreset"); reg currentPreset; inline function saveNextPresetAuto() { local presetRoot = FileSystem.getFolder(FileSystem.UserPresets); local userFolder = presetRoot.createDirectory("user"); local i = 1; local f; while (true) { f = userFolder.getChildFile("preset-" + i + ".preset"); if (!f.isFile()) break; i++; } currentPreset = f; Engine.saveUserPreset(f); updatePresetDisplay(); } inline function onBtnSavePresetControl(component, value) { if (value) saveNextPresetAuto(); } BtnSavePreset.setControlCallback(onBtnSavePresetControl); -
@treynterrio if you add the module to the preset like this:
Engine.addModuleStateToUserPreset("Audio Loop Player1");it will be saved with the preset

-
@treynterrio
Was the code created with AI?while(true)should create an infinite loop, shouldn't it?As ulrik writes,
Engine.addModuleStateToUserPresetshould be sufficient to save the values in the user preset. :-) -
@Oli-Ullmann The
while(true)does indeed create an infinite loop, but there's abreakin there which exits the loop when the condition is satisfied.It's just used to find the next available preset number for saving incremental preset names.
Start with filename "preset-1.preset" Does that file exist? If yes, then try preset-2.preset If no, then use that filename to the save the preset Repeat from file exists? -
@ulrik Nice

-
@dannytaurus
Oh yes, of course! I overlooked that... Thanks! :-) -
@ulrik I just tried this but I get this error:
Script Processor1:! Line 84, column 34: Can't store modules with child modules {U2NyaXB0IFByb2Nlc3NvcjF8b25Jbml0KCl8Mjg3MXw4NHwzNA==} exporter:! Line 84, column 34: Can't store modules with child modules {U -
I just found out it saves the start and end position in HISE but not in the exported version in my DAW. I can see this in my AudioWaveform I've displayed.
-
@treynterrio What's in your preset XML?
-
I just managed to fix it. There was something in the script before I had to swap. so I don't needed this Engine.addModuleStateToUserPreset