Parse getUserPresetList() output into 2d array
-
Is there something other than getCurrentUserPresetName() that will return the full path of the current preset not just the name? If there is then I can compare it against the output of getUserPresetList() to get an index for the current preset and then select that index in the combo box.
-
Never mind. I figured it out.
-
@d-healey This is super helpful thank you so much, I already had a one-dropdown version made but this allows to have the entire tree of plugins. Brilliant! Is there a simple solution to have the current preset stored when the plugin opens? It makes no sense storing the combo boxes value in a preset, so I wonder if there is another way to save what preset is currently loaded and have that open in the preset browser from the start
-
@Morphoice said in Parse getUserPresetList() output into 2d array:
@d-healey This is super helpful thank you so much, I already had a one-dropdown version made but this allows to have the entire tree of plugins. Brilliant! Is there a simple solution to have the current preset stored when the plugin opens? It makes no sense storing the combo boxes value in a preset, so I wonder if there is another way to save what preset is currently loaded and have that open in the preset browser from the start
put the name of the preset you have loaded in a text box, and have the text box's callback do the loading, and have the text box saveInPreset. Now cover the text box with a combo box, use LAF to make its default state transparent - so now you see the text box - showing you the name of the preset, and when you click on it the combobox Dave has created shows up, you select a preset and the combobox callback changes the value in the text box and calls the textbox's changed() functionality to load the actual preset.
Added functionality here is you can change the order add and remove presets in the combobox list and your existing presets all still work/load fine.
eg.
HiseSnippet 1132.3ocsV0saiSDEdbZc0FWVztRbMZH2fqnp+sKKHsphzlefHR6FQJq3tUiGOIYnimwxdRaiP8AfK4Yg2.DOPbC2R4LicrcZCo6FI5EQ8767cNymOmYPhhxRSUIHm5WLKlgb9H2gyj5IslP3RTu1HmO18LRplkfyTc5rXRZJKD43rw2ZT3TeSj8u+5aNkHHRJqTEB8VEmx5yi35RsCZ98bgnKIjcAOph2urYOpR1RITSA7rg6AnXB8RxX14Dia0bQNa0IjqUIC0DMKE74TU3rgSTWKy7+s7TdffYDNDMDRTlZTqIbQ3f40ZJB4r4fxJeirJ+SbOiGxKzW1Adl0.tLhp8.mZqBRG9A.ImJPZyLH8b2gzDdrtzhAOa61SBWHiHPqtJTx7EU6O1vskB7Pp2KhbIqaBHTDg+qN3fcwvO67ZOOOnempwWQRv8IALwg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-
@Lindon ingenious thank you!
-
@Morphoice no problem - works for all cases where you have a combobox and you may at some point want to add to, or reorder or remove any elements...
-
@Lindon how do you get the full path of the preset to load from the label1 value? I only have the
I don't have that inside the label oncontrol only the displayed name. I only have the full path it in the combobox oncontrol. If I understand correctly the loading of the preset should be handled by the Label1
-
@Morphoice Use the user preset handler.
Then in the post load callback you can store the reference to the preset file
reg currentPresetFile; uph.setPostCallback(function(presetFile) { currentPresetFile = presetFile; });
-
@d-healey what is uph?
I loaded the preset like this inside the combobox callback
but that doesnt work for the labelEngine.loadUserPreset(Engine.getUserPresetList()[value - 1]+".preset");
-
@Morphoice said in Parse getUserPresetList() output into 2d array:
uph
Reference to a user preset handler.
const uph = Engine.createUserPresetHandler();
https://docs.hise.audio/scripting/scripting-api/userpresethandler/index.html
@Morphoice said in Parse getUserPresetList() output into 2d array:
I loaded the preset like this inside the combobox callback
but that doesnt work for the labelWhat do you mean it doesn't work for the label?
-
@d-healey I'm wrong somewhere
inline function onLabel1Control(component, value) { Engine.loadUserPreset(Engine.getUserPresetList()[value - 1]+".preset"); }; Label1.setControlCallback(onLabel1Control);
Interface: Factory Presets/Plucks/Echoes Interface: loading preset Echoes Interface:! presethandler.js (51): '-' is not allowed on the String type
-
@Morphoice said in Parse getUserPresetList() output into 2d array:
Engine.loadUserPreset(Engine.getUserPresetList()[value - 1]+".preset");
This is only going to work in the combo box's callback. In a label's callback the value will be the label's text.
-
@d-healey exactly, hence my question how I can get to load it in the label :) don't I need to do that there instead of in the combo? Or am I missing the point?
-
@Morphoice If I'm understanding correctly you have the preset name in the label's text/value, so what about
Engine.loadUserPreset(value);
-
@d-healey just the preset name, not the full path to the preset, it needs the full path to load
-
@Morphoice Isn't it a hidden label and meant to store the full path?
-
@d-healey if I understood lindon's approach correctly, the combo box is what's hidden, the label displays the name, at least that's what I got from his snippet
-
@Morphoice Then I defer to Lindon.
-
@Lindon @d-healey I guess the text label could also be invisible and the combobox visible so I get the full path in the label callback
but if I call loadUserPreset there it just runs into a loop loading the preset and outputting hundreds of console messages until HISE crashes after a minute or so
const var Presets = Content.getComponent("Presets"); // The Combobox const var CurrentPreset = Content.getComponent("CurrentPreset"); // The Label inline function onPresetsControl(component, value) { if (!value) return; local presetPath = Engine.getUserPresetList()[value - 1]; CurrentPreset.set("text", presetPath); CurrentPreset.changed(); } Presets.setControlCallback(onPresetsControl); inline function onCurrentPresetControl(component, value) { Engine.loadUserPreset(value+".preset"); Console.print(value); }; CurrentPreset.setControlCallback(onCurrentPresetControl);
if I put the loadUserPreset into the combobox callback it hangs compiling and crashes after a while too
-
@Morphoice You need to disable saveInPreset for the component that is loading the preset, otherwise you get an infinite loop.