HISE Logo Forum
    • Categories
    • Register
    • Login

    PLAY et STOP " Midi Player 1 "

    Scheduled Pinned Locked Moved General Questions
    21 Posts 3 Posters 1.4k 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.
    • tsempireT
      tsempire @tsempire
      last edited by

      @tsempire I'll give the solution to those who need it.

      1. Copy this code:

      // Get a reference to the MIDI processor as MIDI player
      const MIDIplayer = Synth.getMidiProcessor("MIDI Player1").asMidiPlayer();

      // Get a reference to the transport buttons
      const grpTranportBtn = [Content.getComponent("btnPlay"),
      Content.getComponent("btnStop")];
      for(b in grpTranportBtn)
      {
      // Make sure the buttons are not saved with the presets
      b.set("saveInPreset", false);

      // Assign the control callback to the transport buttons
      b.setControlCallback(onTransportBtnControl);
      

      }

      // Also set the STOP button to be momentary
      grpTranportBtn[1].set("isMomentary", true);

      inline function onTransportBtnControl(component, value)
      {
      // get which button triggered the callback
      local index = grpTranportBtn.indexOf(component);

      // If it's the PLAY button
      if(index == 0)
      {
      	// if the PLAY button is pressed
      	if(value)
      	{
      		// start playing
      		MIDIplayer.play(0);
      	}
      	else
      	{
      		// keep the button's value to 1 if it's still playing
      		grpTranportBtn[0].setValue(1);
      	}
      }
      // if it's the STOP button
      else
      {
      	// only react if the mouse is clicked (not released)
      	if(!value)
      		return;
      	
      	// stop playing
      	MIDIplayer.stop(0);
      	// set the PLAY button's value to 0
      	grpTranportBtn[0].setValue(0);
      }
      

      };

      // on compilation, reset the playhead position to the beginning
      // comment it out if not needed
      MIDIplayer.setPlaybackPosition(0.0);

      1. Create 2 buttons with the ID

      btnPlay

      btnStop

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

      30

      Online

      1.8k

      Users

      12.0k

      Topics

      104.4k

      Posts