HISE Logo Forum
    • Categories
    • Register
    • Login

    Load / Get Audio Files From Folder?

    Scheduled Pinned Locked Moved Solved General Questions
    7 Posts 2 Posters 116 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.
    • griffinboyG
      griffinboy
      last edited by griffinboy

      						FileSystem.browseForDirectory(FileSystem.getFolder(FileSystem.Downloads), function(folder)
      		{
      			if (!isDefined(folder))
      				return;
      				
      
      			
      		//	var fileList = Engine.getSampleFilesFromDirectory( file.toString(file.FullPath), false);
      			
      			Console.print("Confirmed");
      			
      		//	Console.print(fileList);
      			
      		});
      		
      		
      };
      Content.getComponent("btn_LoadFolder").setControlCallback(onbtn_LoadFolderControl);
      
      

      What's the proper way to get a folder in Hise, and get the audio files from it? I'd like to get the paths.
      Thanks

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

        @griffinboy

        You can get a reference to a predefined folder using FileSystem.getFolder(locationType)

        Here's a partial list of the location types - there are more than this though which will show up in the autocomplete.

        For example to get the downloads folder you would use local downloadsFolder = FileSystem.getFolder(FileSystem.Downloads);

        If you want to get a subfolder there you could then use downloadsFolder.getChildFile("MySubfolder")

        If you want to get that folder, and create it if it doesn't already exist you would replace getChildFile with createDirectory

        To check if a file object is a directory you would use myObj.isDirectory() - check the API docs for all the available functions.

        To get the files within a folder you use FileSystem.findFiles()

        You might find this video helpful

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

        griffinboyG 2 Replies Last reply Reply Quote 2
        • griffinboyG
          griffinboy @d.healey
          last edited by griffinboy

          @d-healey
          To the rescue once again, thank you!
          I was looking for a way to get a list of the paths of all audiofiles inside of a folder (user selects a folder, I extract the audio file locations from inside it). I'm sure that your video will likely have what I need.

          griffinboyG 1 Reply Last reply Reply Quote 0
          • griffinboyG
            griffinboy @d.healey
            last edited by griffinboy

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • griffinboyG griffinboy marked this topic as a question on
            • griffinboyG griffinboy has marked this topic as solved on
            • griffinboyG
              griffinboy @griffinboy
              last edited by griffinboy

              @griffinboy

              The answer:

              inline function onbtn_LoadFolderControl(component, value)
              {
                  if (!value)
                      return;
              
                  FileSystem.browseForDirectory(FileSystem.getFolder(FileSystem.Downloads), function(dir)
                  {
                      if (!isDefined(dir) || !dir.isDirectory())
                          return;
              
              		// Print folder name
                      Console.print(dir.toString(dir.FullPath));
              
              		// Find and print all file paths
                      var fls = FileSystem.findFiles(dir, "*.wav", true);
                      for (var i = 0; i < fls.length; ++i)
                          Console.print(fls[i].toString(fls[i].FullPath));
                  });
              };
              Content.getComponent("btn_LoadFolder").setControlCallback(onbtn_LoadFolderControl);
              
              

              My button is called:
              btn_LoadFolder

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

                @griffinboy said in Load / Get Audio Files From Folder?:

                for (var i = 0; i

                You don't need the var here - this isn't JavaScript 🤪

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

                griffinboyG 1 Reply Last reply Reply Quote 1
                • griffinboyG
                  griffinboy @d.healey
                  last edited by

                  @d-healey

                  Lol, thanks. I'm definitely still not used to it!

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

                  46

                  Online

                  1.7k

                  Users

                  11.7k

                  Topics

                  101.8k

                  Posts