HISE Logo Forum
    • Categories
    • Register
    • Login

    AudioLoopPlayer load

    Scheduled Pinned Locked Moved General Questions
    51 Posts 6 Posters 2.7k 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.
    • MikeBM
      MikeB
      last edited by

      I have 9 folders with 40-50 samples each - all named differently.

      how do I get them into an array? and then I can load them into the AudioLoopPlayer - without having to make 500 array entries.

      "One hour of trial and error can save 10 minutes of reading the manual."
      "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
      HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

        You could use the file API - https://docs.hise.audio/scripting/scripting-api/filesystem/index.html#findfiles

        I actually think we are missing a function. For expansions we have getAudioFileList() but we don't have it for non-expansion projects.

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

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

          Oh actually, Engine.loadAudioFilesIntoPool(), returns a list as well so we don't need a new function.

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

          MikeBM 1 Reply Last reply Reply Quote 0
          • MikeBM
            MikeB @d.healey
            last edited by

            @d-healey

            This is my entry call.
            The samples are already all in the pool.

            But I still have to load them into the player.
            At the moment I do it like this - it works.
            Disadvantage. The number of samples in each folder (bass, kick, snare, etc.) must be the same.
            The samples are predefined with names in the array.

            But in the end I have a different number of samples with different names in the folders.

            Engine.loadAudioFilesIntoPool();
            var InstrumentID_S1;
            var VariationID_S1;
            const var Instrument_S1 = ["Bass", "Kick", "Snare", "HiHat", "Tom", "Cymbal", "Crash" ];
            const var Sample_S1 = ["sample1.wav","sample2.wav","sample3.wav","sample4.wav","sample5.wav","sample6.wav","sample7.wav", "sample8.wav", "sample9.wav", "sample10.wav", "sample11.wav", "sample12.wav", "sample13.wav", "sample14.wav", "sample15.wav", "sample16.wav", "sample17.wav", "sample18.wav", "sample19.wav", "sample20.wav", "sample21.wav", "sample22.wav", "sample23.wav", "sample24.wav", "sample25.wav", "sample26.wav", "sample27.wav", "sample28.wav", "sample29.wav", "sample30.wav", "sample31.wav", "sample32.wav", "sample33.wav", "sample34.wav", "sample35.wav", "sample36.wav", "sample37.wav", "sample38.wav", "sample39.wav", "sample40.wav", "sample41.wav", "sample42.wav", "sample43.wav", "sample44.wav", "sample45.wav", "sample46.wav", "sample47.wav", "sample48.wav"];
            //End ------------------
            
            
            //Start Knob-KitSelector----------------------------------------------------------------------------------------------------------------------
            inline function onKitSelector_Knob_S1Control(component, value){
            	InstrumentID_S1 = parseInt(value);	
            	Console.print("Instrument_S1" + "{PROJECT_FOLDER}"+Instrument_S1[InstrumentID_S1]+"/"+Sample_S1[VariationID_S1]);
            	Synth.getAudioSampleProcessor("Audio Loop Player_S1").setFile("{PROJECT_FOLDER}"+Instrument_S1[InstrumentID_S1]+"/"+Sample_S1[VariationID_S1]); 
            	knb_Root_S1.setValue(AudioLoopPlayer_S1.getAttribute(AudioLoopPlayer_S1.RootNote));
            	knb_Root_S1.changed();  
            	
            
            };
            

            "One hour of trial and error can save 10 minutes of reading the manual."
            "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
            HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

              @MikeB Change those vars in to reg.

              Engine.loadAudioFilesIntoPool() returns an array that contains the names of all of your audio files.

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

              MikeBM 1 Reply Last reply Reply Quote 0
              • MikeBM
                MikeB @d.healey
                last edited by MikeB

                @d-healey

                Change those vars in to reg.>

                I change WAS in vars reg?????

                Engine.loadAudioFilesIntoPool() returns an array that contains the names of all of your audio files.

                A little bit more info Dave - you know I'm not on your level :-)

                "One hour of trial and error can save 10 minutes of reading the manual."
                "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

                LindonL 1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @MikeB
                  last edited by

                  @MikeB said in AudioLoopPlayer load:

                  @d-healey

                  Change those vars in to reg.>

                  I change WAS in vars reg?????

                  Engine.loadAudioFilesIntoPool() returns an array that contains the names of all of your audio files.

                  A little bit more info Dave - you know I'm not on your level :-)

                  Do a little exploration work:

                  var myList = Engine.loadAudioFilesIntoPool();
                  Console.print(trace(myList));
                  
                  

                  HISE Development for hire.
                  www.channelrobot.com

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

                    @Lindon You're just pranking me now with that var. :p

                    Never use var unless you absolutely have to - paint routines, mouse callbacks, etc. Everywhere else either use const or reg, and if you're in an inline function or callback use local. var should always be your last choice.

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

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

                      @d-healey said in AudioLoopPlayer load:

                      @Lindon You're just pranking me now with that var. :p

                      Never use var unless you absolutely have to - paint routines, mouse callbacks, etc. Everywhere else either use const or reg, and if you're in an inline function or callback use local. var should always be your last choice.

                      --sorry it was just too easy

                      var AnnoyingDave = true;
                      

                      Actually tho there is a limit to the number of reg variables you can use I think...

                      HISE Development for hire.
                      www.channelrobot.com

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

                        @Lindon The limit is per namespace. So it's unlikely you'll hit that limit is most instances, if you do, then use var. In our current situation - loadAudioFilesIntoPool - it would make most sense to use a const.

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

                        1 Reply Last reply Reply Quote 0
                        • MikeBM
                          MikeB
                          last edited by

                          Ok you two Jedi Knights :-)
                          So now I have an array with 500 files.

                          As you can see there are folders - different folders Kick, Snare, etc.
                          In each folder there are samples with different long names (not like here in the excerpt).
                          I would like to select the folder (InstrumentID) via one knob and a sample (VariantionID) from this folder via another knob.

                           "{PROJECT_FOLDER}Kick/sample1.wav",
                            "{PROJECT_FOLDER}Kick/sample10.wav",
                            "{PROJECT_FOLDER}Kick/sample11.wav",
                            "{PROJECT_FOLDER}Kick/sample12.wav",
                            "{PROJECT_FOLDER}Kick/sample13.wav",
                            "{PROJECT_FOLDER}Kick/sample14.wav",
                            "{PROJECT_FOLDER}Kick/sample15.wav",
                            "{PROJECT_FOLDER}Kick/sample16.wav",
                            "{PROJECT_FOLDER}Kick/sample17.wav",
                            "{PROJECT_FOLDER}Kick/sample18.wav",
                            "{PROJECT_FOLDER}Kick/sample19.wav",
                          

                          "One hour of trial and error can save 10 minutes of reading the manual."
                          "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                          HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

                            @MikeB Everything you need is here - https://docs.hise.audio/scripting/scripting-api/string/index.html :) time to have a problem.

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

                            MikeBM 1 Reply Last reply Reply Quote 0
                            • MikeBM
                              MikeB @d.healey
                              last edited by

                              @d-healey Unfortunately this is of no use to me David - but thanks for your support.

                              "One hour of trial and error can save 10 minutes of reading the manual."
                              "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                              HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

                                @MikeB

                                Unfortunately this is of no use to me

                                Tell me more...

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

                                MikeBM 1 Reply Last reply Reply Quote 0
                                • MikeBM
                                  MikeB @d.healey
                                  last edited by

                                  @d-healey
                                  As I said - this is my starting point
                                  I have two knobs - one calls up the folder (InstrumentID).
                                  the other calls the sample (VariationID)

                                  So at the moment it's like this via the knobs:
                                  a. The folder is selected for example "Kick

                                  b. the sample is selected "sample3.wav".

                                  and this is then loaded into the LoopPlayer.

                                  reg myList = Engine.loadAudioFilesIntoPool();
                                  Console.print(trace(myList));
                                  
                                  var InstrumentID_S1;
                                  var VariationID_S1;
                                  const var Instrument_S1 = ["Bass", "Kick", "Snare", "HiHat", "Tom", "Cymbal", "Crash", "Perc", "Electro", "FX" ];
                                  const var Sample_S1 = ["sample1.wav","sample2.wav","sample3.wav","sample4.wav","sample5.wav","sample6.wav","sample7.wav"];
                                  
                                  
                                  
                                  //Start Knob-KitSelector----------------------------------------------------------------------------------------------------------------------
                                  inline function onKitSelector_Knob_S1Control(component, value){
                                  	InstrumentID_S1 = parseInt(value);	
                                  	Synth.getAudioSampleProcessor("Audio Loop Player_S1").setFile("{PROJECT_FOLDER}"+Instrument_S1[InstrumentID_S1]+"/"+Sample_S1[VariationID_S1]); 
                                  };
                                  Content.getComponent("KitSelector_Knob_S1").setControlCallback(onKitSelector_Knob_S1Control);
                                  //End --------------------------------------------------------------------------------------------------------------------------------------
                                  
                                  //Start Knob-SampleSelector----------------------------------------------------------------------------------------------------------------------
                                  inline function onSampleSelector_Knob_S1Control(component, value){
                                  	VariationID_S1 = parseInt(value-1);		
                                     Synth.getAudioSampleProcessor("Audio Loop Player_S1").setFile("{PROJECT_FOLDER}"+Instrument_S1[InstrumentID_S1]+"/"+Sample_S1[VariationID_S1]);   	
                                  };
                                  Content.getComponent("SampleSelector_Knob_S1").setControlCallback(onSampleSelector_Knob_S1Control);
                                  //End --------------------------------------------------------------------------------------------------------------------------------------    
                                  
                                  
                                  

                                  "One hour of trial and error can save 10 minutes of reading the manual."
                                  "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                  HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

                                    Get the list of audio files with Engine.loadAudioFilesIntoPool. Then you can use a loop and the string functions to automatically split that list into two arrays, one for the folders and one for the samples.

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

                                    MikeBM 1 Reply Last reply Reply Quote 0
                                    • MikeBM
                                      MikeB @d.healey
                                      last edited by

                                      @d-healey Thanks David - that's what I meant - if I could do that I wouldn't ask here.

                                      "One hour of trial and error can save 10 minutes of reading the manual."
                                      "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                      HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

                                        @MikeB Which part are you stuck at?

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

                                        MikeBM 1 Reply Last reply Reply Quote 0
                                        • MikeBM
                                          MikeB @d.healey
                                          last edited by

                                          @d-healey Folders and samples have names of different lengths. How can I separate them with string?
                                          Besides, the user should not get a hi-hat sound if he has selected kick.
                                          But only the samples from the Kick folder.

                                          "One hour of trial and error can save 10 minutes of reading the manual."
                                          "It's easier to hit the developer with feature requests than to spend 10 minutes reading the manual. :-)))"
                                          HISE Develop - Mac Pro 5.1, OS X 10.14.6, Projucer 6.02, Xcode 10.3

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

                                            @MikeB

                                            If you have a string like const s = "{PROJECT_FOLDER}Kick/sample12.wav"

                                            You can get the folder with const ss = s.substring(s.indexOf("}") + 1, s.indexOf("/"));

                                            Ready for an hour of trial and error ;)

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

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

                                            49

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.2k

                                            Posts