Method for detecting whether the samples were found
-
I'd like to roll my own overlay for not detecting any samples.
I can't find any way to do this in the API. Basically I want the same return bool that the internal method for checking the samples provides which then results in the built-in overlay for locating the samples popping up.
If I'm not just being blind and failing to see it, I'd kindly request that method be exposed to us. So a simple call that returns 0 if the samples for any of the sample maps weren't found at the given LinkOS path or if the LinkOS file doesn't exist.
-
I want the same thing. The error handler should be able to do this, but it's broken - https://forum.hise.audio/topic/7058/custom-error-messages/13
-
@d-healey I'm getting to this now, and have been able to get the error handler working for detecting samples.
const var errorHandler = Engine.createErrorHandler(); errorHandler.setErrorCallback(function(state, message) { ErrorHandler.errorLabel.set("text", errorHandler.getNumActiveErrors() + " " + errorHandler.getCurrentErrorLevel() + " " + state + " " + message); if (state == 9) // if samples not detected { // show your own overlay here } });
inline function onlocateSamplesButtonControl(component, value) { if (canExecute.locateButton) // prevent execution on init { FileSystem.browseForDirectory(FileSystem.UserHome, function(result) { Settings.setSampleFolder(result); // remove overlay Engine.reloadAllSamples(); }); } else canExecute.locateButton = true; }; Content.getComponent("locateSamplesButton").setControlCallback(onlocateSamplesButtonControl);
If the user pointed to the wrong folder, the error will trigger again after attempting to reload all samples.
-
@aaronventure oh cool, I'll check this out
-
@d-healey So it's 9 in case the link file isn't found, and 10 if it exists the samples are not found in the specified directory.
-
@aaronventure Found a better solution
inline function onlocateSamplesButtonControl(component, value) { if (errorHandler.getCurrentErrorLevel() == 9 || errorHandler.getCurrentErrorLevel() == 10) // prevent execution on init { FileSystem.browseForDirectory(FileSystem.UserHome, function(result) { errorHandler.clearAllErrors(); Settings.setSampleFolder(result); Engine.reloadAllSamples(); // this seems to be synchronous and freezes the entire script execution // the browse callback will execute in entirety before the error handler reevaluates the situation // so we delay enough for it to throw another error if the directory is wrong and prevent overlay removal Content.callAfterDelay(250, function() { if (errorHandler.getCurrentErrorLevel() == -1) { // if samples found } }, {}); }); } };
-
Whilst we are here - I think it would be nice to have the partner of
Settings.setSampleFolder()
so
reg myString = Settings.getSampleFolder();
-
@Lindon You can do that already.
FileSystem.getFolder(FileSystem.Samples).toString(0);
-
@Lindon What's wrong with
FileSystem.getFolder(FileSystem.Samples)
?Damnit David!!!
-
-- well whats wrong with it is that it just didnt occur to me.....;-) So ignore me..