HISE Logo Forum
    • Categories
    • Register
    • Login

    Export - import of modulator data through exportState / restoreState (scriptnode branch)

    Scheduled Pinned Locked Moved Scripting
    2 Posts 1 Posters 229 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      andioak
      last edited by andioak

      I´m trying to use the exportState and restoreState to 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:

      Menu option:

      1. click on modulator
      2. choose "edit name of modulator" -> "Create Base64 encoded state"

      HISE-script option:

      In the onInit in 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 .restoreState of 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 restoreState?

      (specs: macos 10.13, hise scriptnode 2020-08 ish.)

      1 Reply Last reply Reply Quote 0
      • A
        andioak
        last edited by andioak

        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); 
        
        
        1 Reply Last reply Reply Quote 1
        • First post
          Last post

        51

        Online

        1.7k

        Users

        11.7k

        Topics

        102.1k

        Posts