Display preset name and folder in label
-
Hi!
Just sat tinkering and was trying to have the preset name show in the preset browser together with the folder the preset is in. I already got the preset name, now I just need the folder.Was thinking like "ROCK - MALE 1", where "rock" is the folder and "male 1" is the preset.
Any clues to how this can be achieved?
-
@IsoWalle - print out the CurrentPreset name and you will see it include the full path, now use string manipulation to get what you want.
-
@Lindon Using Engine.getCurrentUserPreset only gives me the name. I've tried to go through the File API and FileSystem, though these are really not my friend. My approach was to find the file with the current presets name and then get the directory, but i can't seem to figure it out.
-
@IsoWalle can't you use
Engine.getUserPresetList()
and then, as Lindon says, use string manipulation to get the dir from the path?
-
-
@ulrik Thank you!
Though would this work if I had multiple presets with the same name in different folders?
Then I wouldn't be able to search for the correct one using getCurrentPresetName? -
@IsoWalle No it wouldn't, but you can get the path to the preset if you use the FileSystem functions
-
@ulrik But is it impossible then?
Since I can't get the (complete)path using the getCurrentUserPresetName, and I cant know which preset is active with using getUserPresetList. -
@IsoWalle I guess you can't use getCurrentUserPresetName if there are several presets with the same name, I think you need to build your own preset browser based on the FileSystem.
-
If you fancy playing with C++ this is the function and I don't think it would be difficult at all to modify.
String ScriptingApi::Engine::getCurrentUserPresetName() { return getProcessor()->getMainController()->getUserPresetHandler().getCurrentlyLoadedFile().getFileNameWithoutExtension(); }
What I think might be better is to add a function to the user preset handler that returns the current preset as a file object.