Forum
    • Categories
    • Register
    • Login

    Help with loading 4x file_players from Ui button/Knob

    Scheduled Pinned Locked Moved ScriptNode
    30 Posts 4 Posters 2.6k 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.
    • David HealeyD
      David Healey @Brongled
      last edited by

      @Rognvald the same idea as here should work I think

      https://forum.hise.audio/topic/12889/fill-all-audio-loop-players?_=1757391041558

      Free HISE Bootcamp Full Course for beginners.
      YouTube Channel - Public HISE tutorials
      My Patreon - HISE tutorials

      B 1 Reply Last reply Reply Quote 0
      • B
        Brongled @David Healey
        last edited by

        @d-healey This is great for setting one sample to all players.
        I am looking for separate controls to swap samples in a folder for each file_player in Scriptnode.
        I can only get it functioning with one file_player, as I dont know how to reference the other 3 file_players in the Script FX1..

        Thanks for your time*

        David HealeyD 1 Reply Last reply Reply Quote 0
        • David HealeyD
          David Healey @Brongled
          last edited by

          @Rognvald

          const slot = ScriptFX1.getAudioFile(0);
          

          The number you pass in here 0 is for the first slot, 1 is for the second, etc.

          Free HISE Bootcamp Full Course for beginners.
          YouTube Channel - Public HISE tutorials
          My Patreon - HISE tutorials

          B 1 Reply Last reply Reply Quote 0
          • B
            Brongled @David Healey
            last edited by

            @d-healey Ahh ok I was trying this before.. let me give it another go.

            I am using the demo snippet code for the buttons to swap samples.

            const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1");
            const slot = ScriptFX1.getAudioFile(0);
            
            
            
            // Load Audiofiles into pool ----------------------------------------------------------------------------------------------
            Engine.loadAudioFilesIntoPool();
            //--------------------------------------------------------------------------------------------------------
            
            
            
            // const vars----------------------------------------------------------------------------------------------
            //const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1");
            const var Random = Content.getComponent("Random1");
            const var KnS1 = Content.getComponent("KnS1");
            const var Next = Content.getComponent("Next1");
            const var Prev = Content.getComponent("Prev1");
            //--------------------------------------------------------------------------------------------------------
            
            // Array Samples in AudioFiles-Folder----------------------------------------------------------------------
            const var inst = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"];
            //--------------------------------------------------------------------------------------------------------
            
            
            
            //Knob1 Sample selection---------------------------------------------------------------------------------
            inline function onKnS1Control(component, value)
            {
                Synth.getAudioSampleProcessor("Script FX1").setFile("{PROJECT_FOLDER}"+inst[value]);
            };
            Content.getComponent("KnS1").setControlCallback(onKnS1Control);
            //--------------------------------------------------------------------------------------------------------
            
            // Random Button------------------------------------------------------------------------------------------
            Random.setControlCallback(onRandom_Control);
            
            inline function onRandom_Control(component, value)
            {    
                if (value)
                {
                    KnS1.setValue((Math.randInt(0, 5)));
                    KnS1.changed();
                }
            };
            //--------------------------------------------------------------------------------------------------------
            
            
            
            // Prev-Button----------------------------------------------------------------------------------------------
            inline function onPrevControl(component, value)
            {
                if (value)
                {
                    KnS1.getValue() > KnS1.get("min") ? KnS1.setValue(KnS1.getValue() - 1) : KnS1.setValue(KnS1.get("max"));
            	    KnS1.changed();
                }
            };
            Content.getComponent("Prev1").setControlCallback(onPrevControl);
            //--------------------------------------------------------------------------------------------------------
            
            
            
            // Next-Button ----------------------------------------------------------------------------------------------
            inline function onNextControl(component, value)
            {
                if (value)
                {
            	    KnS1.getValue() < KnS1.get("max") ? KnS1.setValue(KnS1.getValue() + 1) : KnS1.setValue(KnS1.get("min"));
            	    KnS1.changed();
                }
            };
            Content.getComponent("Next1").setControlCallback(onNextControl);
            //--------------------------------------------------------------------------------------------------------
            
            David HealeyD 1 Reply Last reply Reply Quote 0
            • David HealeyD
              David Healey @Brongled
              last edited by

              @Rognvald said in Help with loading 4x file_players from Ui button/Knob:

              const slot = ScriptFX1.getAudioFile(0);

              You need 4 of these, one for each of your node external audio files.

              Free HISE Bootcamp Full Course for beginners.
              YouTube Channel - Public HISE tutorials
              My Patreon - HISE tutorials

              B 1 Reply Last reply Reply Quote 0
              • B
                Brongled @David Healey
                last edited by

                @d-healey Ok I get that part, but how to set different files for each 4 knobs through Script FX1 is where I am confused.

                //Knob1 Sample selection---------------------------------------------------------------------------------
                inline function onKnS1Control(component, value)
                {
                    Synth.getAudioSampleProcessor("Script FX1").setFile("{PROJECT_FOLDER}"+inst[value]);
                };
                Content.getComponent("KnS1").setControlCallback(onKnS1Control);
                
                David HealeyD 1 Reply Last reply Reply Quote 0
                • David HealeyD
                  David Healey @Brongled
                  last edited by

                  Each slot is separate.

                  const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1");
                  const slots = [];
                  
                  for (i = 0; i < 4; i++)
                  {
                      slots[i] = ScriptFX1.getAudioFile(i);
                  }
                  

                  Free HISE Bootcamp Full Course for beginners.
                  YouTube Channel - Public HISE tutorials
                  My Patreon - HISE tutorials

                  B 1 Reply Last reply Reply Quote 0
                  • B
                    Brongled @David Healey
                    last edited by Brongled

                    @d-healey Thats the one, is it similar for the sample array?

                    // Array Samples in AudioFiles-Folder----------------------------------------------------------------------
                    const var inst = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"];
                    

                    4x file_players.png

                    David HealeyD 1 Reply Last reply Reply Quote 0
                    • David HealeyD
                      David Healey @Brongled
                      last edited by

                      @Rognvald I'm not familiar with that project

                      Free HISE Bootcamp Full Course for beginners.
                      YouTube Channel - Public HISE tutorials
                      My Patreon - HISE tutorials

                      B 1 Reply Last reply Reply Quote 0
                      • B
                        Brongled @David Healey
                        last edited by

                        @d-healey its the interface I am trying to link to scriptFX.
                        Can I reference the separate slots in the knob function?

                        inline function onKnS1Control(component, value)
                        {
                            Synth.getAudioSampleProcessor("Script FX1").setFile("{PROJECT_FOLDER}"+inst[value]);
                        };
                        Content.getComponent("KnS1").setControlCallback(onKnS1Control);
                        
                        David HealeyD 1 Reply Last reply Reply Quote 0
                        • David HealeyD
                          David Healey @Brongled
                          last edited by

                          @Rognvald said in Help with loading 4x file_players from Ui button/Knob:

                          Can I reference the separate slots in the knob function?

                          You create the references in on init using the code I posted above.

                          You can use these within the callback.

                          slot[0].setFile()...
                          slot[1].setFile()...
                          etc.

                          Free HISE Bootcamp Full Course for beginners.
                          YouTube Channel - Public HISE tutorials
                          My Patreon - HISE tutorials

                          B 1 Reply Last reply Reply Quote 0
                          • B
                            Brongled @David Healey
                            last edited by

                            @d-healey said in Help with loading 4x file_players from Ui button/Knob:

                            slot[0].

                            I added the references and added slot function here* and getting error "Unknown function 'setFile'

                            inline function onKnS1Control(component, value)
                            {
                                Synth.getAudioSampleProcessor("Script FX1").slot[0].setFile("{PROJECT_FOLDER}"+inst[value]);
                            };
                            Content.getComponent("KnS1").setControlCallback(onKnS1Control);
                            
                            David HealeyD 1 Reply Last reply Reply Quote 0
                            • David HealeyD
                              David Healey @Brongled
                              last edited by David Healey

                              @Rognvald You already have the references in on init you don't need to get the reference in the control callback - in fact you should never create references in control callbacks.

                              // This goes in on init
                              const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1");
                              const slots = [];
                              
                              for (i = 0; i < 4; i++)
                              {
                                  slots[i] = ScriptFX1.getAudioFile(i);
                              }
                              
                              // This goes in the control callback
                              slot[0].setFile()
                              

                              Free HISE Bootcamp Full Course for beginners.
                              YouTube Channel - Public HISE tutorials
                              My Patreon - HISE tutorials

                              B 2 Replies Last reply Reply Quote 0
                              • B
                                Brongled @David Healey
                                last edited by

                                @d-healey Thanks again, this is where I was going wrong. Learning slowly but surly :)

                                1 Reply Last reply Reply Quote 1
                                • B
                                  Brongled @David Healey
                                  last edited by

                                  @d-healey Sorry i am still battling with this same error "Unknown function 'setFile'..

                                  //--------------------------------------------------------------------------------------------------------
                                  const var ScriptFX1 = Synth.getAudioSampleProcessor("Script FX1");
                                  const slots = [];
                                  
                                  for (i = 0; i < 4; i++)
                                  {
                                      slots[i] = ScriptFX1.getAudioFile(i);
                                  }
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  // Load Audiofiles into pool ----------------------------------------------------------------------------------------------
                                  Engine.loadAudioFilesIntoPool();
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  // PLAYER-1 const vars----------------------------------------------------------------------------------------------
                                  //const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1");
                                  const var Random = Content.getComponent("Random1");
                                  const var KnS1 = Content.getComponent("KnS1");
                                  const var Next = Content.getComponent("Next1");
                                  const var Prev = Content.getComponent("Prev1");
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  // PLAYER 2 const vars----------------------------------------------------------------------------------------------
                                  //const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1");
                                  const var Random2 = Content.getComponent("Random2");
                                  const var KnS2 = Content.getComponent("KnS2");
                                  const var Next2 = Content.getComponent("Next2");
                                  const var Prev2 = Content.getComponent("Prev2");
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  // PLAYER 1 Array Samples in AudioFiles-Folder----------------------------------------------------------------------
                                  const var inst  = ["Wi_trap808-1.wav","Wi_trap808-2.wav","Wi_trap808-3.wav","Wi_trap808-4.wav","Wi_trap808-5.wav","Wi_trap808-6.wav"];
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  // PLAYER 2 Array Samples in AudioFiles-Folder----------------------------------------------------------------------
                                  const var inst2  = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"];
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  //PLAYER 1 Knob1 Sample selection---------------------------------------------------------------------------------
                                  inline function onKnS1Control(component, value)
                                  {
                                      slot[0].setFile("{PROJECT_FOLDER}"+inst[value]);
                                  };
                                  Content.getComponent("KnS1").setControlCallback(onKnS1Control);
                                  //--------------------------------------------------------------------------------------------------------
                                  //PLAYER 2 Knob1 Sample selection---------------------------------------------------------------------------------
                                  inline function onKnS2Control(component, value)
                                  {
                                      slot[1].setFile("{PROJECT_FOLDER}"+inst[value]);
                                  };
                                  Content.getComponent("KnS2").setControlCallback(onKnS2Control);
                                  //--------------------------------------------------------------------------------------------------------
                                  
                                  David HealeyD ChazroxC 3 Replies Last reply Reply Quote 0
                                  • David HealeyD
                                    David Healey @Brongled
                                    last edited by

                                    @Rognvald Have you created external audio slots for your script effect node?

                                    Free HISE Bootcamp Full Course for beginners.
                                    YouTube Channel - Public HISE tutorials
                                    My Patreon - HISE tutorials

                                    B 1 Reply Last reply Reply Quote 0
                                    • B
                                      Brongled @David Healey
                                      last edited by Brongled

                                      @d-healey Yes as in the image I posted

                                      Screenshot 2025-09-10 at 12.59.28 am (2).png

                                      same for all 4

                                      Screenshot 2025-09-10 at 1.01.05 am (2).png

                                      David HealeyD 1 Reply Last reply Reply Quote 0
                                      • ChazroxC
                                        Chazrox @Brongled
                                        last edited by

                                        @Rognvald

                                        Shouldn't ScriptFX1 module be a part of your button script? I think you're writing to slot[i] but thats not a module. It looks like you're assigning to a slot....but it doesn't know what that slot is for.

                                        1 Reply Last reply Reply Quote 0
                                        • David HealeyD
                                          David Healey @Brongled
                                          last edited by

                                          @Rognvald send me a snippet, I'll take a look in the morning. It's some issue with the references

                                          Free HISE Bootcamp Full Course for beginners.
                                          YouTube Channel - Public HISE tutorials
                                          My Patreon - HISE tutorials

                                          B 1 Reply Last reply Reply Quote 0
                                          • B
                                            Brongled @David Healey
                                            last edited by

                                            @d-healey The buttons are linked to the knobs which should change the files in the slot. I thought..
                                            Thanks I will create a snippet :)

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

                                            19

                                            Online

                                            2.1k

                                            Users

                                            13.0k

                                            Topics

                                            112.6k

                                            Posts