Custom Mini Preset Browser Example using FileSystem API
-
@BWSounds Have you tried this:
FileSystem.browse(FileSystem.Desktop, true, "*.mid", function(f) { MIDIPlayer1.saveAsMidiFile(f.toString(0), 1); });
Track indexes are not zero-based (super confusing, but it's the MIDI standard) and you need to convert the file object that is passed into the result function to a String containing the full path.
-
@musictop I think that would be precisely the use case for this kinda thing! This will work best for smaller sub-presets within a larger plugin.
-
@Christoph-Hart
Legend -
@Lunacy-Audio great! Thank you.
-
Nice one, this will be useful. thanks for sharing. :)
-
@Christoph-Hart said in Custom Mini Preset Browser Example using FileSystem API:
@BWSounds Have you tried this:
FileSystem.browse(FileSystem.Desktop, true, "*.mid", function(f) { MIDIPlayer1.saveAsMidiFile(f.toString(0), 1); });
Track indexes are not zero-based (super confusing, but it's the MIDI standard) and you need to convert the file object that is passed into the result function to a String containing the full path.
@Christoph-Hart I have a project that allows users to drag/drop midi files onto the interface and the plugin plays the files. This looks like what I need to actually save those MIDI files so that when the user saves their project in the DAW and re-opens the project, those MIDI files are still available. Currently, the files disappear on reload of the plugin unless they were compiled with the plugin.
Could this be used to save and recall multiple user MIDI files? Then, to recall multiple midi files on init, could setFile be used?
-
No if you want a midi player to be restored with the user preset you will have to connect it like a EQ with this:
https://docs.hise.audio/scripting/scripting-api/engine/index.html#addmodulestatetouserpreset
-
@Christoph-Hart So I've built two mini-preset browsers (thanks @Lunacy-Audio!) within the same plug in. I'm basically trying to save an LFO shape using one of the browsers, and then load it into a second LFO using the second browser.
Everything works, except that when I save a new .preset file in one browser, and then go into the second browser to load it into the other LFO table, the preset list has not updated to include the new .preset file.
So basically I'm looking for a callback function that will fetch all the relevant preset names to populate the list. I'm pretty sure its all in this script, but when I try and load bits into a button callback, I get errors.
-
You'll need a timer for this sort of thing where it repopulates the list every so often, like every 2000 ms or something. You could also add a refresh button like the one you describe for which you'll just need to add a button callback and then add the function
populatePresetList()
to that callback from the original snippet above.The timer approach will require some more testing. I tried this in one of my projects and it would occasionally crash the plugin, but worth a shot!
-
@Lunacy-Audio Yeah I looked at a timer but then realised a callback would be perfect. I tried to use populatePresetList() but kept getting errors.... said it wasn't a function.
inline function onLOAD_LFO1Control(component, value) { TABLEBROWSER1.showControl(1); LFOCLOSE1.showControl(1); populatePresetList(); }; Content.getComponent("LOAD_LFO1").setControlCallback(onLOAD_LFO1Control);
This is the callback on the button which brings up one of the browsers. If it refreshes the list at the same time that solves my problem. It felt a bit crude just sticking in populatePresetList(); and looks like it was :face_with_tears_of_joy:
Interface:! Line 386, column 20: This expression is not a function! {SW50ZXJmYWNlfHwxMjQwOXwzODZ8MjA=}
-
Ah, I forgot to mention you just need to include the namespace that encapsulates the function, so
PresetBrowser.populatePresetList();
. Anything outside the PresetBrowser namespace doesn't know what that function is. -
@Lunacy-Audio Brilliant thank you!