Parse getUserPresetList() output into 2d array
-
I am venturing down the seemingly much attempted and even more abandoned road of trying to roll your own custom preset browser in Hise.
I have the beginning of something but I'm stuck at the seemingly easier task of taking the output from Engine.getUserPresetList() and parsing it into a 2d array.
Engine.getUserPresetList() outputs an array that looks like this:
[ "Folder/presetname1", "Folder/presetname2", "Folder/presetname3", "Second Folder/presetname1", "Second Folder/presetname2", "Second Folder/blahblahblah", "XYZ/abc", "XYZ/abc2" ]
And I need to parse it into a 2d array like this:
"Folder": [ "presetname1", "presetname2", "presetname3" ], "Second Folder": [ "presetname1", "presetname2", "blahblahblah" ], "XYZ": [ "abc", "abc2" ]
I know that Hise does have a string split function but I'm falling down trying to build the 2d array.
Any resources anyone has that would help me on this path is greatly appreciated!
-
@whoopsydoodle your target isnt a 2D array - its 3 separate arrays in what looks like part of a json file
-
@Lindon yep, brain is mush. you're obviously correct. So then unfortunately I'm still stuck trying to parse that into a JSON block. I know there is the .parseAsJSON() function for strings.
-
@whoopsydoodle said in Parse getUserPresetList() output into 2d array:
custom preset browser in Hise
Why?
-
@d-healey I find the built in one to be very undesirable from a UX point of view and it seems to be very inflexible so that I can't customize it to fix what bothers me.
-
@whoopsydoodle What's it missing, perhaps we can add changes that will make it suitable? I'd always investigate this route before trying to roll a custom one of any complexity because, as you've found, it's not easy.
-
@d-healey The current preset browser UX only makes sense for large instruments. For FX it's completely wrong. As evidenced by the fact that pretty much every FX plugin out there uses a simple folder structure drill down expanding list.
A lot of them use a system menu (Fabfilter plugins are a good example of this done well). Which despite being skinned by the OS, honestly works great. Hise doesn't seem able to do such a thing. Which is fine. But my request would be a function that reads the folder structure and makes an expanding folder tree list like these.
Functions like delete, rename, overwrite don't need to be handled in the plugin. You can simply hand the user off to the OS filesystem with an "Open Preset Folder" button or menu item and let them organize as desired. All that's needed is a list of the contents from the User Presets folder and a "Save Preset" button.
-
@whoopsydoodle said in Parse getUserPresetList() output into 2d array:
Which is fine. But my request would be a function that reads the folder structure and makes an expanding folder tree list like these.
That should be pretty easy to script, maybe with a recursive function, but I try to avoid them if possible. Give me a little while, I'll see if I can come up with something.
-
It's nearly there. Just going to have a snack then I'll finish it off and post a snippet.
-
Here you go, you can use laf to change the appearance.
HiseSnippet 2542.3ocsZ0uaiiaDWN656p80BrGPe.3kBzls6GMxw6G0aOzM1I41zFuqwZeaZwgCGnkosYWYQAJp8R1hCnuF8O6qVeB5aP6P8QDkDIk1.T+GAQ72ONyvgyLhjhy3LORTDi6zo+hqCINc94cmecfX6jsXZfy4m3z4dcmwIQDwTRP7BRjvY70g3nHxJmNcty2HY0o2ccR98e9iiw93.ORQSNNuiQ8HWP2QEEsN6k+Ypu+Y3UjEzcJrG9xy8XASX9rXvhtS2CcBwduGug7Zrj1dccdENZqSmea2UtCcW+bO7Set6vAddCd9yF76elGAudM4otO4YCe95gqwdGNvoymc5JpfwmKvBRDHzwrUWOeK6GCRUv6nQzk9D4CtNyAMm1ryjsT+UyxcOQNNct6rBm0cRcV+xtSoqn2ztpSSBfJ5gpSqyd1LI2OASpihIc2TS5K6N2iSCEEHR64K5ddffvAWBojojx0Yueyc5NgALBDOdG98jy3vC2ziCd5gG9PD7m6+h98g4mHA5CXNxa2xzHiHzWix68FhXBaWHK.d3f8KnrOz2hmdbjjVffy7mf88WBSxGvBJvyvj5iF3SCHn0wAdBJK.og1Ad4Z7gfg4GSte++d+dz0nC9prG60iSDw7.Pd87YdXeDUP1sfbk.L8SC1.ZPZ4eaDgmJ5KnQhCt+2kzcziPteurmf5hX9jGGxovfKWBfQ9S86GxBi8goyLKSlrbfNyWKOo4V14bv9RwGs+CQ6K8b86slwQGbEhFXwbgwIHnrAHlygw1UONJzmBh62AhoWud2.KEOfu+9uneRqIxmBsb3KPTzeP18G6SB1H1BO+fGHcgRY2KoeO3qk3eG86kctWRyqk8VsaRulrWEcY+QiRzF3s5oNbwqVcNPIwgBiU.+mTlseMSPdSPpOBbznpPqWqEKKzvmv0BKK6vs0wCBh2sjvUCnjDgzrx4teV6xc8RSOTHxBN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DuW2orUxq4V4qDo7xhlA.6jnz8PTdWCChnhqUuLoeB2SxCsdOIaqI9kcmQEda0ai6owFcb9+hMlc6R+EcSOkoBC7tcO6ubauJoMn92xhEzfMSwBNUN2953cPHN2i.ZO.xFhjy26IuIZoOen7YoGXNIXUxC+W3WFnq74NYft4fPTiGm8Cdo2eM48W8mkzBXSAI2u2dcmJeF4V8Fq43rith9CddkEUsNN311witscb3ssiO411wmda63ytsc74M2Q4sc93XnBaZZiiyzYmlbCC6z4zjuoaRzpy+CbE2bo.
-
@d-healey this looks great. thank you.
One thing I can't seem to find. Does Hise have the ability to open a system window to a location? So I can let the user open to their presets folder.
FileSystem.browse seems to only be able to spawn a system save or open dialog, I'm looking to open the system finder / windows explorer.
-
@whoopsydoodle said in Parse getUserPresetList() output into 2d array:
so I can let the user open to their presets folder.
https://docs.hise.dev/scripting/scripting-api/file/index.html#show
-
@d-healey Perfect!
-
@d-healey the code you wrote is super helpful but I've run into an issue when the user saves a preset.
My thought was to call your populatePresetsMenu(); function again after the save dialog. This does reload the file structure and properly gets the new preset file. But for some reason the formatting gets lost. It all comes in as a single list with items displaying :: in their name after folder names.
I don't really follow why it would do that since the first thing that function does is wipe out the items and repopulate the same as it does onInit. Not sure why it would come back borked up a second time when the same function is fine the first time around.
The next thing I would like to do is have the newly saved preset selected in the combobox.
These two seem like they should be straight forward building off your script but I'm not having much luck.
-
@whoopsydoodle said in Parse getUserPresetList() output into 2d array:
But for some reason the formatting gets lost. It all comes in as a single list with items displaying :: in their name after folder names.
Which HISE build are you on ? This has been fixed in the develop branch.
-
@d-healey
Hey David,I wanted to script something like this for my new plug-in. Is it ok if I use your script as a starting point for my script?
It is not an open source plug-in but a commercial product.
All the best
Oli -
@Oli-Ullmann Go for it.
Unless I specifically say otherwise, any code I post directly on the forum can be used by anyone for any purpose.
-
@d-healey
That's great, thank you very much! :-) If you ever need anything (in the area of sound design, demo songs or similar), feel free to get in touch! :-) You are always a great help here! -
@Matt_SF said in Parse getUserPresetList() output into 2d array:
This has been fixed in the develop branch.
Yep. That was it. Thanks. All good now with current build.
Anyone have any suggestions on how to have the menu select the currently loaded preset from it's items?
-
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.