HISE Logo Forum
    • Categories
    • Register
    • Login

    Encode Expansions except MIDI Folder

    Scheduled Pinned Locked Moved General Questions
    10 Posts 2 Posters 321 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.
    • S
      Soundavid
      last edited by

      Hi everyone, im building an instrument with a cool MIDI player but I want the chance to update and expand it with MIDI packs, with file based expansions is easy but with encoded expansions the plugin is reading only the embedded MIDI files even if I create the folder manually... Is there a way to encode the expansion without the MIDI folder or another solution to add MIDI packs in the future?

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

        @Soundavid Can you load the MIDI files through the File/File System APIs?

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

        S 1 Reply Last reply Reply Quote 0
        • S
          Soundavid @d.healey
          last edited by

          @d-healey Thanks for answer, Im using the expansion.getMidiFileList(); to populate a viewport and loading the files to the MIDIplayer from here, how can I return the Midi List array from the File System?

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

            @Soundavid Assuming the midi files are in the app data folder you can use FileSystem.getFolder(FileSystem.AppData).getChildFile("My Midi Files"); Then you'll want to perform a search in that folder for the midi files using findFiles

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

            S 1 Reply Last reply Reply Quote 1
            • S
              Soundavid @d.healey
              last edited by

              @d-healey Thanks David! the midi Files are in the Expansion Folder, so the way to go is Expansion.getRootFolder(); instead AppData right? Im going to try returning the MIDI list with findFiles.

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

                @Soundavid Yeah rootFolder would work. You can also get the expansions folder with FileSystem.Expansions - https://docs.hise.audio/scripting/scripting-api/filesystem/index.html

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

                S 1 Reply Last reply Reply Quote 0
                • S
                  Soundavid @d.healey
                  last edited by

                  @d-healey Ok Im using this code but now there's nothing loading in the Viewport and get an error in the MIDIPlayer.setFile Function, all of this are in the Expansion Callback.

                  reg rootFolder = e.getRootFolder();
                  reg midiFolder = rootFolder.getChildFile("MidiFiles");
                  reg MIDIList = FileSystem.findFiles(midiFolder, ".mid", true);
                  //reg MIDIList = e.getMidiFileList();
                  
                  //Load Midi Files to Viewport
                  MidiFileListViewPort.set("items", MIDIList.join("\n").replace(e.getWildcardReference("")).replace(".mid", ""));
                  
                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Soundavid
                    last edited by d.healey

                    @Soundavid Don't declare reg variables inside the expansion callback, use var. You're only providing the file extension as the wildcard, that means it will look for files called .mid. You need to use *.mid

                    You should add some validation at each stage.

                    if (isDefined(e)
                    {
                        var rootFolder = e.getRootFolder();
                    
                        if (isDefined(rootFolder) && rootFolder.isDirectory())
                        {
                            var midiFolder = rootFolder.createDirectory("MidiFiles"); // Use createDirectory here and it will create the folder if it doesn't already exist.
                            
                            var files = FileSystem.findFiles(midiFolder, "*.mid", true);
                    
                            if (files.length > 0)
                            {
                                var list = [];
                    
                                for (x in files)
                                {
                                    list.push(x.toString(x.FileName));
                                }
                                
                                MidiFileListViewPort.set("items", list.join("\n");
                            }
                        }
                    }

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

                    S 1 Reply Last reply Reply Quote 1
                    • S
                      Soundavid @d.healey
                      last edited by

                      @d-healey Thanks David!! I was registering that variables because I needed the same MIDIList to load the Midi files into the Player, your method returns the whole path as String so I guess I need to use the .replace() function for the viewport items and think how can I load these in the MIDI Player, you definitely put me in the right direction for this 👍

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

                        @Soundavid Declare the list variable as a const at the top of your namespace instead of the var, and use list.clear() before the loop that adds items to the list. Put your replace command in the list.push line.

                        Also declare the files variable as a reg at the top of your namespace instead of the var. Then you'll have access to the files outside of this function.

                        Another option entirely is to have two string arrays, one that contains the full paths and one that contains just the file names (for display). Then you can use the index of the name array to get the correct file path.

                        Lots of choices here!

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

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

                        19

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.4k

                        Posts