HISE Logo Forum
    • Categories
    • Register
    • Login

    Method for detecting whether the samples were found

    Scheduled Pinned Locked Moved Scripting
    10 Posts 4 Posters 470 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      aaronventure
      last edited by aaronventure

      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.

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by

        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

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        A 1 Reply Last reply Reply Quote 0
        • A
          aaronventure @d.healey
          last edited by

          @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.

          d.healeyD 1 Reply Last reply Reply Quote 2
          • d.healeyD
            d.healey @aaronventure
            last edited by

            @aaronventure oh cool, I'll check this out

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            A 1 Reply Last reply Reply Quote 0
            • A
              aaronventure @d.healey
              last edited by aaronventure

              @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.

              A 1 Reply Last reply Reply Quote 0
              • A
                aaronventure @aaronventure
                last edited by

                @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
                					}
                				}, {});
                				
                			});
                		}
                	};
                
                LindonL 1 Reply Last reply Reply Quote 1
                • LindonL
                  Lindon @aaronventure
                  last edited by Lindon

                  Whilst we are here - I think it would be nice to have the partner of

                  Settings.setSampleFolder()

                  so

                  reg myString = Settings.getSampleFolder();

                  HISE Development for hire.
                  www.channelrobot.com

                  d.healeyD Christoph HartC 2 Replies Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Lindon
                    last edited by d.healey

                    @Lindon You can do that already. FileSystem.getFolder(FileSystem.Samples).toString(0);

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    LindonL 1 Reply Last reply Reply Quote 0
                    • Christoph HartC
                      Christoph Hart @Lindon
                      last edited by Christoph Hart

                      @Lindon What's wrong with FileSystem.getFolder(FileSystem.Samples)?

                      Damnit David!!!

                      1 Reply Last reply Reply Quote 1
                      • LindonL
                        Lindon @d.healey
                        last edited by

                        @d-healey @Christoph-Hart

                        -- well whats wrong with it is that it just didnt occur to me.....;-) So ignore me..

                        HISE Development for hire.
                        www.channelrobot.com

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        32

                        Online

                        1.7k

                        Users

                        11.7k

                        Topics

                        102.0k

                        Posts