HISE Logo Forum
    • Categories
    • Register
    • Login

    Help with loading 4x file_players from Ui button/Knob

    Scheduled Pinned Locked Moved ScriptNode
    30 Posts 4 Posters 171 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.
    • d.healeyD
      d.healey @Rognvald
      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.

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

      R 1 Reply Last reply Reply Quote 0
      • R
        Rognvald @d.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);
        //--------------------------------------------------------------------------------------------------------
        
        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @Rognvald
          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.

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

          R 1 Reply Last reply Reply Quote 0
          • R
            Rognvald @d.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);
            
            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @Rognvald
              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);
              }
              

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

              R 1 Reply Last reply Reply Quote 0
              • R
                Rognvald @d.healey
                last edited by Rognvald

                @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

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

                  @Rognvald I'm not familiar with that project

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

                  R 1 Reply Last reply Reply Quote 0
                  • R
                    Rognvald @d.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);
                    
                    d.healeyD 1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey @Rognvald
                      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.

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

                      R 1 Reply Last reply Reply Quote 0
                      • R
                        Rognvald @d.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);
                        
                        d.healeyD 1 Reply Last reply Reply Quote 0
                        • d.healeyD
                          d.healey @Rognvald
                          last edited by d.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()
                          

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

                          R 2 Replies Last reply Reply Quote 0
                          • R
                            Rognvald @d.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
                            • R
                              Rognvald @d.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);
                              //--------------------------------------------------------------------------------------------------------
                              
                              d.healeyD ChazroxC 3 Replies Last reply Reply Quote 0
                              • d.healeyD
                                d.healey @Rognvald
                                last edited by

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

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

                                R 1 Reply Last reply Reply Quote 0
                                • R
                                  Rognvald @d.healey
                                  last edited by Rognvald

                                  @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

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • ChazroxC
                                    Chazrox @Rognvald
                                    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
                                    • d.healeyD
                                      d.healey @Rognvald
                                      last edited by

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

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

                                      R 1 Reply Last reply Reply Quote 0
                                      • R
                                        Rognvald @d.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
                                        • ChazroxC
                                          Chazrox @Rognvald
                                          last edited by

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

                                          +inst[value]);

                                          also, you're grabbing from the same 'inst' array in both knob callbacks. idk if you meant to do that but you do have inst2 commented as being for Player 2.

                                          R 1 Reply Last reply Reply Quote 0
                                          • R
                                            Rognvald @Chazrox
                                            last edited by

                                            @Chazrox Yes, I am not sure how to call inst more than once.. i keep getting error - Duplicate const var declaration.

                                            // PLAYER 1 Array Samples in AudioFiles-Folder----------------------------------------------------------------------
                                            const var inst[0]  = ["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 inst[1]  = ["Wi_Kick-1.wav","Wi_Kick-2.wav","Wi_Kick-3.wav","Wi_Kick-4.wav","Wi_Kick-5.wav","Wi_Kick-6.wav"];
                                            //--------------------------------------------------------------------------------------------------------
                                            
                                            ChazroxC 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            35

                                            Online

                                            1.9k

                                            Users

                                            12.5k

                                            Topics

                                            108.5k

                                            Posts