How to make it
-
@Jay build your own preset browser using panels and their associated paint callbacks...
-
@Jay using panels and filesystem API. this was the starting point for this preset browser.
Custom Mini Preset Browser Example using FileSystem API:
Hey folks!
This seems to be a hot topic with the new FileSystem API, so for those who need a starting place for building a custom mini-preset browser in HiseScript, here's a simple snippet showing how to achieve the most basic steps for:
- Loading presets from the user preset directory
- Saving a set of controls to a file in the user preset directory with user input for the preset name
- Fetching all preset names in a given directory and displaying them in a viewport
- Showing the preset directory
HiseSnippet 2295.3ocsZ0ziaabFd3tKCrjsRrcC5odfXOoscqhVWmzFajZ48q1MwqWUK6Ew0wMlhbzpIhhi.GpcsRvhZfdnWxk.zS8TAxgh.TTTzeAEnsW5ugV.+SH28A224CRNbHor1EwBvFly7Ny6y6Gyy7Ny3tQTOLiQiPV0t+rIXj0kr6MKLd3VCcIgn81FYcA6tQXFNFs4rItLF1GYYs7uf2qUsUPhee6s1zMvMzCm0DBcHk3guCYLINq0tc9HRPvtt936SFqI806rmGMbKZ.cJfjksail35Mx8H7cc4hsjMx5M1wmDSi5E6FiYHqU1j5Oq2P5IgR4OjvH8Cv7O1.0ClHYy6RC74Hl2JZqgj.+tIVLCAyR2L6eYo8+116S7Iosm4GtrnCmrQn6OrVZdvaCc30dwgmkF7VQBuqX2yKhLINqGN1tn8dgw3nAtPHPGVRYQKc5aYuEEjHLt0X2Q3cifORGQy2qc60cd21sW6lMp2n967NNbYinALmXpSerCy8XruCIzYhHQnQcHVwhcN1MxoW.waD7W93HmOvIQGGgi2hNdBMD9n4pZxrJWEYidSr6zXxfoAaNMNlFV4LXH2pRfJf513AjPLywMHvwKA1tg9NdPK8gjHly.ZjB4N8inmvvQMpGB4ULHGC6HSt2T1gyWzntC7KChxtuCA9rJzkIh.X7wm0TKFWVAt1Rgnlzvr9U8kLPS0ySgjBKRUliS1PvTnX1Q4.xTpWErfLBo3UCnTQxfRZSU.hz9WX0evjXBz7BfBkjoforY69j3.7BLWB4JYlj8x4rtOkK8qHkISvUmmkdvn4BoCF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OFvd4i4Zmiw7SNGi45miw7tmiw7dmiw7SOGi4mM2wv+u4vsmFSGKWl.MzcGww2sr1IjWomHiD8+gi7rcn
Hope this is helpful!
A few extra things to consider:
- This example saves the preset files in a certain format (key-value pairs), but it's up to you to choose how you'll save your controls and load them from your custom preset files.
- This is completely separate from the built-in preset browser, so proceed with caution. The actual HISE user presets are formatted differently.
- This doesn't include any protections for overwriting files or checks for invalid files / objects loaded.
-
@pluginboi is giving me some errors and is quitting HISE
-
@Jay Oh weird, I havent opened that snippet in like a year. but I just got to my computer and heres the base script for the presetbrowser in the pic above
HiseSnippet 1540.3ocsW80aaaCDWJMpnwacXEXOOP3mjWScs655FRQwRqSbavVRMpSSKPVQAiDsEWjHEDoZpQQ9Zrua6s8QXeC1tSjxRx1Ks0.SOjXd+m+tiGONJSFvTJYli6VGOKk439kdimIzQChnbgyA6439UdGRUZVFwP5IyRoJEKzw08ZOEI3t0lNEe+8O+DZLUDvpH43bhjGv9UdBWWQczt+BONdHMjcLOolz2e2CBjhAxXYNDOWyqmSJM3b5T1QTTrM7bbu99gbsLarlpYJPlmHCmMNRdgvH+IbE+rXFtnuyXvPFxNCh3wgiJ2qJGG2MGUsyulYm+MdGxC4yoWg.ecACRkF0w.2MtpPp+mQH4VKj1zDR2xabPFOUWwAimuv6.AjPlPAntdnXj0Yi+7FdCjfDBc2D54rgYvh4Z3+fd81l.+oyCa0Bfakl7NZF4n8e0nGeD4QjRMmxzCjIoRArvusgcaTGAjLTPhgA.BSwzOiJBigxiOzh.e28tDLaoHxIDcDijVHCYhLNjkoJDAcmg7PCUvqm1dHM.PwYs2lz9kJVV62.txZvg4h.MWJ.CRASwzAQfCLlPQljISHThJkEvmvYgVeUnLWDyELxjRCTnqIrU.rjXB.eiFcraA7KVFPisVZDUGAg3PdLa7L3jPBhMVMqQDiZqo6TfdXBF4WZ9Gtf0K2.ML8DtnPIkekyAH465ZjFfGcVN6+vVFjGPy2TwehLi3OArH.FktD1o00naZtJpPltZ4XcFWL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sLeD2+BYtF5XdHEZbBkydGkmLFdUW.C7t.J3UX9dC7fkYcObMh.iYhvhE+C7YY1GW6ZY1ujoSBMHS9VaeO7AT2nfBDShh2KtE7vUXMouSQSDPOudc64j.uk6sAA31+NvY8Uqy8VCc990Pm6uF57CqgNOXMz4GWCc9oqTG7YzONWKSLGG.Bi1unapq69BJTYUTE57u.WHz88C
-
@pluginboi when opening the snippet is giving me this error
-
@Jay Do you have different sub Preset folders set up in your Userpreset project folder? and then edit this line to be the names of each folder
var presetFolders = ["Factory", "User"]; // update this with your actual folder names
-
@pluginboi Thanks a lot.
-
@pluginboi what to add, to make it show the selected preset on a label?
-
@Jay I figure it out
-
@pluginboi I was wondering if you know how to save a preset to a file because I'm using this and is not working
inline function onsaveOkControl(component, value)
{
Engine.saveUserPreset(presetNametoSave);
};
Content.getComponent("saveOk").setControlCallback(onsaveOkControl);any idea why?
Thanks in advance!!!
-
@Jay this is how i save them to the 'user' sub folder but you could get rid of the child folder to make it general. I found this in an old thread I think @Dan-Korneff posted about out so he may have more info if you're doing more customization
var pre_folder = FileSystem.getFolder(FileSystem.UserPresets).getChildFile("User"); function save(file) { Engine.saveUserPreset(file); } //// Save as Button inline function onSaveasBTNControl(component, value) { if (value) FileSystem.browse(pre_folder, true, "*.preset", save); PresetHandler.init(); populatePanel1(); UpdatePresetLabel(); }; Content.getComponent("SaveasBTN").setControlCallback(onSaveasBTNControl);
-
@pluginboi T h a n k Y o u
-
This is always showing one preset name behind it. Do you think you can help me with this?
note: it's doing it in both examplesnamespace UserPresetWidgets { inline function createPresetButton(name, x, y, up) { local widget = Content.addPanel(name, x, y); Content.setPropertiesFromJSON(name, { "width": 10, "height": 15, "saveInPreset": false, "allowCallbacks": "Clicks & Hover" }); widget.data.up = up; widget.setPaintRoutine(function(g) { g.setColour(this.data.hover ? 0xFF65B17c : 0xFF2C4433); g.fillTriangle([0, 0, this.getWidth(), this.getHeight()], this.data.up ? Math.PI/2 : 1.5 * Math.PI); }); widget.setMouseCallback(function(event) { this.data.hover = event.hover; if(event.clicked) { if(this.data.up) { convoLbl1.set("text", Engine.getCurrentUserPresetName()); Engine.loadNextUserPreset(true); } else { convoLbl1.set("text", Engine.getCurrentUserPresetName()); Engine.loadPreviousUserPreset(true); } } this.repaint(); }); return widget; }; } const var UpButton = UserPresetWidgets.createPresetButton("UpButton", 749, 10, true); const var DownButton = UserPresetWidgets.createPresetButton("DownButton", 736, 10, false); // ============== second attemp // next inline function onnextBtnControl(component, value) { convoLbl1.set("text", Engine.getCurrentUserPresetName()); Engine.loadNextUserPreset(true); }; Content.getComponent("nextBtn").setControlCallback(onnextBtnControl); // prev inline function onprevBtnControl(component, value) { convoLbl1.set("text", Engine.getCurrentUserPresetName()); Engine.loadPreviousUserPreset(true); }; Content.getComponent("prevBtn").setControlCallback(onprevBtnControl);
-
@Jay You have to load the preset first, then get the name, you have it the other way around
if(this.data.up) { // First load the preset Engine.loadNextUserPreset(true); // Then get the loaded preset name convoLbl1.set("text", Engine.getCurrentUserPresetName()); }
-
@ulrik Thank you so much, you're right