Save and load text file
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.
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…
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.
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...
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.
For the record, the API calls are merged into one method.