HISE Logo Forum
    • Categories
    • Register
    • Login

    Save and load text file

    Scheduled Pinned Locked Moved Feature Requests
    6 Posts 2 Posters 1.6k 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.
    • C
      channelrobot
      last edited by

      We are going to need to be able to load and save data (say sequencer patterns) to some external file , like load_array and save_array in KSP. Again i cant see this in the documentation anywhere, please correct me if I'm wrong.

      1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart
        last edited by

        You can already include external javascript files:

        viewtopic.php?f=5&t=16

        This way you could define JSON objects which contain your sequencer patterns and they will be parsed when the script is compiled, but for on the fly changes as well as exporting data into a file I would need to add some more API calls.

        I would suggest these two methods:

        Engine.dumpAsJson(object, fileName); // saves a object as JSON file
        var loadedObject = Engine.loadFromJSON(); // loads a JSON file into an object.
        
        

        You obviously can't load them in an undefered callback (no file I/O in the audio thread), but for control callbacks it should be fine.

        I am not sure how to handle the file management - for now I would simply put them all into the scripts directory,
        but for HISE Player libraries the directory of the library should be used…

        1 Reply Last reply Reply Quote 0
        • C
          channelrobot
          last edited by

          I'm not sure this solves the problem., could be wrong. We need a way to hold preset data to load it dynamically and save it dynamically.

          USE CASE
          I have an instrument with several effects. I can change the effect parameters. I now need a button the user can press to start a file save dialog, so they can save these parameters to some folder and file name combination of their choosing. I also need a load button that opens a file load dialog so the user can load a set of parameters (a preset) from a set of files they previously saved.

          dumpAsJson and loadFromJson assumes I know ahead of time what the file is called… I dont...

          1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart
            last edited by

            Alright, I'll add these methods:

            var fileName = Engine.openFileLoadBrowser();
            var fileName = Engine.openFileSaveBrowser();
            
            

            You can use the return value as argument for the JSON dump methods.

            1 Reply Last reply Reply Quote 0
            • C
              channelrobot
              last edited by

              ..perfect.

              1 Reply Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart
                last edited by

                For the record, the API calls are merged into one method.

                Engine.browseForFile(bool browseForFileToSave);
                
                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                18

                Online

                1.7k

                Users

                11.8k

                Topics

                102.6k

                Posts