HISE Logo Forum
    • Categories
    • Register
    • Login

    Sample switching with presets in Audio Loop Player

    Scheduled Pinned Locked Moved General Questions
    12 Posts 3 Posters 772 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.
    • callybeatC
      callybeat @ulrik
      last edited by

      @ulrik Thank you very much friend! :)

      You know I already corrected the spelling mistake but it still did not work, in fact I noticed that Sample maps in the name of the folder is written with capital letters and I thought about changing that in the references but in the same way it did not work :( .. it still sends me the same error the console

      //Audio Loop Player
      const var Sampler = Synth.getChildSynth("Sampler");
      
      //Sample maps array
      const var SampleMaps = Sampler.getSampleMapList();
      
      //Combo box
      const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
      cmbSampleMaps.set("items", SampleMaps.join("\n"));
      
      inline function oncmbSampleMapsControl(component, value)
      {
      	Console.print(value);
          Sampler.asSampler().loadSampleMap(SampleMaps[value-1]);
      };
      
      Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
      

      Interface:! function not found {SW50ZXJmYWNlfHwxMjI5fDUyfDQ4}
      : onInit() - Line 52, column 48 {SW50ZXJmYWNlfHwxMjI5fDUyfDQ4}

      😅

      IBM Netvista A40 PIII 1000 MHz

      ulrikU 1 Reply Last reply Reply Quote 0
      • ulrikU
        ulrik @callybeat
        last edited by

        @callybeat you made a reference to the Sampler using the "Create generic script reference" so the

        const var SampleMaps = Sampler.getSampleMapList();
        

        throws an error saying "function not found"
        So if you instead make a "Create typed Sampler script reference" this function exist and can be used.

        And when you have this reference to the Sampler you have to use

        Sampler.loadSampleMap(SampleMaps[value-1]);
        

        instead of

        Sampler.asSampler().loadSampleMap(SampleMaps[value-1]);
        

        Skärmavbild 2021-05-20 kl. 07.06.41.png

        Here's the changed code

        //Audio Loop Player
        const var Sampler = Synth.getSampler("Sampler");
        //Sample maps array
        const var SampleMaps = Sampler.getSampleMapList();
        
        //Combo box
        const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
        cmbSampleMaps.set("items", SampleMaps.join("\n"));
        
        inline function oncmbSampleMapsControl(component, value)
        {
        	Console.print(value);
            Sampler.loadSampleMap(SampleMaps[value-1]);
        };
        
        Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
        

        Hise Develop branch
        MacOs 15.3.1, Xcode 16.2
        http://musikboden.se

        callybeatC 1 Reply Last reply Reply Quote 0
        • callybeatC
          callybeat @ulrik
          last edited by

          @ulrik Friend thank you very much! 😎

          You are right the reference changes totally when selecting "Create typed Sampler script reference" although I see that it changes a bit since it is an Audio Loop Player

          this looks much better

          const var Sampler = Synth.getAudioSampleProcessor("Sampler");
          

          that this old reference

          const var Sampler = Synth.getChildSynth("Sampler");
          

          referencia.png

          I also change the custom logic
          this

          Sampler.asSampler().loadSampleMap(SampleMaps[value-1]);
          

          to this

          Sampler.loadSampleMap(SampleMaps[value-1]);
          

          and the result is this code

          //Audio Loop Player
          const var Sampler = Synth.getAudioSampleProcessor("Sampler");
          
          //Sample maps array
          const var SampleMaps = Sampler.getSampleMapList();
          
          //Combo box
          const var cmbSampleMaps = Content.getComponent("cmbSampleMaps");
          cmbSampleMaps.set("items", SampleMaps.join("\n"));
          
          inline function oncmbSampleMapsControl(component, value)
          {
          	    Sampler.loadSampleMap(SampleMaps[value-1]);
          };
          
          Content.getComponent("cmbSampleMaps").setControlCallback(oncmbSampleMapsControl);
          

          But I think luck is not with me since the console sends me an error :) I think it is known that I am a beginner and it does not stop welcoming me lol 🤣

          Interface:! function not found {SW50ZXJmYWNlfHwxMjM5fDUyfDQ4}
          : onInit() - Line 52, column 48 {SW50ZXJmYWNlfHwxMjM5fDUyfDQ4}

          The only thing I'm sure of is that I'm doing something wrong lol 😂

          IBM Netvista A40 PIII 1000 MHz

          ulrikU 1 Reply Last reply Reply Quote 0
          • ulrikU
            ulrik @callybeat
            last edited by ulrik

            @callybeat Aha, ok so your reference to "Sampler" is not a reference to a sampler actually, cause it's an "Audio Loop Player", then I understand why it's not working.
            You can not get a sampleMap list from an Audio Loop Player because it's not a sampler :)
            So this line is not working:

            const var SampleMaps = Sampler.getSampleMapList();
            

            because an ALP doesn't have a sample map.

            Can you describe what you want to do?

            Never mind, I see you want to load samples into the ALP using a combobox, right?

            Hise Develop branch
            MacOs 15.3.1, Xcode 16.2
            http://musikboden.se

            ulrikU 1 Reply Last reply Reply Quote 0
            • ulrikU
              ulrik @ulrik
              last edited by

              @ulrik I think you need to use this

              Engine.loadAudioFilesIntoPool();
              Sampler.setFile(String fileName)
              

              to load the audio file into the ALP
              so I would do something like this:

              store the audio files names in an array

              audioFiles = ["audio1.wav", "audio2.wav", "audio3.wav"];
              

              and point to this array in the cmb

              Hise Develop branch
              MacOs 15.3.1, Xcode 16.2
              http://musikboden.se

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

                @ulrik said in Sample switching with presets in Audio Loop Player:

                @ulrik I think you need to use this

                Engine.loadAudioFilesIntoPool();
                Sampler.setFile(String fileName)
                

                to load the audio file into the ALP
                so I would do something like this:

                store the audio files names in an array

                audioFiles = ["audio1.wav", "audio2.wav", "audio3.wav"];
                

                and point to this array in the cmb

                Do you have an example snippet for this?
                I am missing the connection 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

                ulrikU 1 Reply Last reply Reply Quote 0
                • ulrikU
                  ulrik @MikeB
                  last edited by

                  @MikeB sorry, no snippet here, just looking at the documentation
                  https://docs.hise.audio/scripting/scripting-api/audiosampleprocessor/index.html

                  Hise Develop branch
                  MacOs 15.3.1, Xcode 16.2
                  http://musikboden.se

                  callybeatC 1 Reply Last reply Reply Quote 0
                  • callybeatC
                    callybeat @ulrik
                    last edited by

                    @ulrik a thousand thanks 🤝 for the support thanks to you and @MikeB for the help, I think that with the example mikeB shared I almost finished my first project in Hise, thank you both are very helpful 😁

                    IBM Netvista A40 PIII 1000 MHz

                    ulrikU 1 Reply Last reply Reply Quote 1
                    • ulrikU
                      ulrik @callybeat
                      last edited by

                      @callybeat I'm glad it worked out allright for you! 👍

                      Hise Develop branch
                      MacOs 15.3.1, Xcode 16.2
                      http://musikboden.se

                      1 Reply Last reply Reply Quote 0
                      • callybeatC
                        callybeat
                        last edited by callybeat

                        I thought I would paste the solution of the theme here in case someone needs it ..
                        :beaming_face_with_smiling_eyes:

                        // Load Audiofiles into pool ----------------------------------------------------------------------------------------------
                        Engine.loadAudioFilesIntoPool();
                        //--------------------------------------------------------------------------------------------------------
                        
                        
                        
                        // const vars----------------------------------------------------------------------------------------------
                        const var AudioLoopPlayer = Synth.getChildSynth("Sampler");
                        const var Random = Content.getComponent("Random");
                        const var Knob62 = Content.getComponent("Knob62");
                        const var Next = Content.getComponent("Next");
                        const var Prev = Content.getComponent("Prev");
                        //--------------------------------------------------------------------------------------------------------
                        
                        // Array Samples in AudioFiles-Folder----------------------------------------------------------------------
                        const var inst = ["sample01.wav","sample02.wav","sample03.wav","sample04.wav","sample05.wav","sample06.wav","sample07.wav","CBsample2.wav"];
                        //--------------------------------------------------------------------------------------------------------
                        
                        
                        
                        //Knob1 Sample selection---------------------------------------------------------------------------------
                        inline function onKnob62Control(component, value)
                        {
                            Synth.getAudioSampleProcessor("Sampler").setFile("{PROJECT_FOLDER}"+inst[value]);
                        };
                        Content.getComponent("Knob62").setControlCallback(onKnob62Control);
                        //--------------------------------------------------------------------------------------------------------
                        
                        // Random Button------------------------------------------------------------------------------------------
                        Random.setControlCallback(onRandom_Control);
                        
                        inline function onRandom_Control(component, value)
                        {    
                            if (value)
                            {
                                Knob62.setValue((Math.randInt(0, 5)));
                                Knob62.changed();
                            }
                        };
                        //--------------------------------------------------------------------------------------------------------
                        
                        
                        
                        // Prev-Button----------------------------------------------------------------------------------------------
                        inline function onPrevControl(component, value)
                        {
                            if (value)
                            {
                                Knob62.getValue() > Knob62.get("min") ? Knob62.setValue(Knob62.getValue() - 1) : Knob62.setValue(Knob62.get("max"));
                        	    Knob62.changed();
                            }
                        };
                        Content.getComponent("Prev").setControlCallback(onPrevControl);
                        //--------------------------------------------------------------------------------------------------------
                        
                        
                        
                        // Next-Button ----------------------------------------------------------------------------------------------
                        inline function onNextControl(component, value)
                        {
                            if (value)
                            {
                        	    Knob62.getValue() < Knob62.get("max") ? Knob62.setValue(Knob62.getValue() + 1) : Knob62.setValue(Knob62.get("min"));
                        	    Knob62.changed();
                            }
                        };
                        Content.getComponent("Next").setControlCallback(onNextControl);
                        //--------------------------------------------------------------------------------------------------------
                        

                        IBM Netvista A40 PIII 1000 MHz

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

                        22

                        Online

                        1.7k

                        Users

                        11.8k

                        Topics

                        102.6k

                        Posts