Export - import of modulator data through exportState / restoreState (scriptnode branch)
I´m trying to use the
restoreStateto export and import all settings for a modulator on a sampler´s release-time modulator setting.
(so from one to another, like presets for a modulator)
Exporting is easy as pie, eihter via the built in function that you get in the edit menu of the object when clicking on the modulator, or via scripting, like so:
- click on modulator
- choose "edit name of modulator" -> "Create Base64 encoded state"
onInitin the interface script I put:
Content.makeFrontInterface(633, 400); const var Modulator1 = Synth.getModulator("Global Static Time Variant Modulator1"); const var export1 = Modulator1.exportState(); Console.print(export1); // this outputs fine, same base64 string as the menu option.
So far so good, I get the base64 code no matter which option I choose, but I cannot in any situation I´ve tried get the new modulator restored with the
Modulator. This is my coding attempt:
Content.makeFrontInterface(633, 400); const var Modulator1 = Synth.getModulator("Global Static Time Variant Modulator1"); const var export1 = Modulator1.exportState(); const var modulator3 = Synth.getModulator("modulator3"); modulator3.restoreState(export1);
I get nothing imported except for the state of the "UseTable" knob set to "on", that one is the same way it was saved. The state of the table is empty, default linear. None of my entered points in the "graph/table" view is correct.
Is this a known bug? Or am I having to expand on the specificity of
(specs: macos 10.13, hise scriptnode 2020-08 ish.)
Ok, found the solution! I was treating all things in the modulator as data exportable by
exportState(), but that one does not export or include table data, regardless of the modulator, it seems. So this one is the appending solution of for the table data of the "Global Static Time Variant Modulator", that has both buttons and table data:
Content.makeFrontInterface(633, 400); // Prepping for export, original modulator const var Modulator1 = Synth.getModulator("Global Static Time Variant Modulator1"); const var mod1Table = Modulator1.asTableProcessor(); // asTableProcessor, was the missing piece. // Export the table (only one so index is 0) const var export1 = mod1Table.exportAsBase64(0); Console.print("export1: " + export1); // Prepping for import, next modulator const var Modulator3 = Synth.getModulator("modulator3"); const var mod3Table = Modulator3.asTableProcessor(); // Use the previous export1 as the data input for table index 0. mod3Table.restoreFromBase64(0, export1);