HISE Logo Forum
    • Categories
    • Register
    • Login

    Trigger Audio Loop Player with a Button

    Scheduled Pinned Locked Moved General Questions
    11 Posts 3 Posters 580 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 @bendurso
      last edited by

      @bendurso Synth.playNote()

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

      bendursoB 1 Reply Last reply Reply Quote 0
      • bendursoB
        bendurso @d.healey
        last edited by

        @d-healey Thanks. Why the console says "function not found" when I trigger the button?

        const var btnPlay = Content.getComponent("btnPlay");
        const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1");
        
        inline function onbtnPlayControl(component, value)
        {
        	if (value)
        	{
        		AudioLoopPlayer1.playNote(40, 100);
        	}
        };
        
        Content.getComponent("btnPlay").setControlCallback(onbtnPlayControl);
        
        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @bendurso
          last edited by

          @bendurso Because that isn't a valid function. As I said, Synth.playNote() is what you want :)

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

          bendursoB 1 Reply Last reply Reply Quote 1
          • bendursoB
            bendurso @d.healey
            last edited by

            @d-healey Oh, yeah, but I have other samplers/synths in the project. I want to play only the AudioLoopPlayer.

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

              @bendurso then you need to put the script within the loop player

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

              bendursoB 1 Reply Last reply Reply Quote 1
              • bendursoB
                bendurso @d.healey
                last edited by

                @d-healey Thanks! I didn't know how script midi processors worked inside samplers/loop players/etc, but this post helped me understand it. It works now :) https://forum.hise.audio/topic/1634/how-to-add-show-connect-the-interface-of-sampler-s-script-processor-to-the-main-interface/4

                1 Reply Last reply Reply Quote 1
                • F
                  fellowfinch
                  last edited by

                  apologies for reviving this old topic but I have a similar question. Basically I'm trying to do the same, have two buttons connected to Audio Loop Players for additional ambience.

                  I managed to trigger one of the Loops by using a button and some scripting however I still trigger the audio loop when playing the keyboard. I scripted it this way;

                  //button atmos
                  const var Button1 = Content.getComponent("Button1");
                  const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1");
                  
                  
                  reg eventId; 
                  
                  inline function PlayAtmo(component, value)
                  {
                  	if (value)
                  	{
                  		eventId = Synth.playNote(64, 100);
                  	}
                  	else 
                  		
                  		Synth.noteOffByEventId(eventId);
                  };
                  
                  Content.getComponent("Button1").setControlCallback(PlayAtmo);
                  

                  I assume this is correct? And when triggering the button I can loop it normally, however when there is a note off event I can still hear it if I play the keyboard on the user interface floating Point. I see that @d-healey mentioned that maybe this script should be put into the loop player itself, but am puzzled what exactly should go into the MIDI script processor that is hooked up to the Audio Loop Player, or better yet how exactly do these interconnect (what needs to be in the main init script, and what in the midi script processor)?

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

                    @fellowfinch The main interface script should contain anything related to the interface that the user needs to interact with. If you need to do any realtime MIDI stuff that should go in a separate (non-deferred script processor). More info here - https://forum.hise.audio/topic/79/scripting-best-practices

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

                    F 1 Reply Last reply Reply Quote 0
                    • F
                      fellowfinch @d.healey
                      last edited by

                      @d-healey

                      thank you for your help, however I'm still struggling a bit to understand what would be the best practice here.

                      Looking at the Scripting practices I think I understand the gist, comments added to showcase my though process

                      //button atmos
                      const var Button1 = Content.addButton("Button1", 0, 0);  // call for button to be added to the main script
                      const var MIDIprocessor = Synth.getMidiProcessor("Midi Processor"); //calling a MIDI processor to be added
                      
                      Synth.deferCallbacks("true"); // need this to to run in the message thread instead of audio thread?
                      
                      
                      ///call for a function
                      function onControl(number, value)
                      {
                      	MidiProcessor.setAttribute(0,value); //calling our Midi processor
                      }
                      
                      
                      

                      after this, jump into my MIDI processor & Script Processor, I have added this

                       const var processorButton = Content.addButton("processorButton", 0, 0); // adds a button to the MIDI processor
                       const var AudioLoopPlayer1 = Synth.getChildSynth("Audio Loop Player1"); //connects to my Audio Loop Player?
                       
                       reg eventId; 
                       
                      inline function playAtmo(component, value) //function to play the atmo button
                      {
                      	if (value)
                      	{
                      		eventId = Synth.playNote(64, 100); 
                      	}
                      	else 
                      		
                      		Synth.noteOffByEventId(eventId);
                      };
                      

                      and then back to my interface with

                      Content.getComponent("processorButton");
                      

                      I can see the button in both interface and MIDI processor but cannot get them linked up or to play a note. I'm still trying to wrap my head around how exactly to set up this trigger :) I'm assuming that I need to somehow tell my MIDI processor to trigger the button for the atmo.

                      F 1 Reply Last reply Reply Quote 0
                      • F
                        fellowfinch @fellowfinch
                        last edited by

                        @fellowfinch

                        edit:

                        needed to add this in inteface

                        Button1.setControlCallback(onControl);
                        

                        and this in MIDI processor

                        processorButton.setControlCallback(playAtmo);
                        

                        works fine now! however, I still get MIDI keyboard (floating tile) that plays the audio loop. What would be the best way to have the keyboard fltile be hooked only to the main sampler?

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

                        44

                        Online

                        1.7k

                        Users

                        11.7k

                        Topics

                        101.8k

                        Posts