How to stop playing all notes

186 Views Asked by At

I am using MIDI.js library and I want to stop playing all notes which are activated with following code.

  function myPlayer(myMid){       
      var delay = 0; // play one note every quarter second
      var start = 0;
      var note = 36; // the MIDI note
      var velocity = 127; // how hard the note hits
      var currentIds = [];
      MIDI.setVolume(0, 127);

      for(j=0; j<myMid.length; j++){
          delay = parseFloat(myMid[j][0])/8;                    

          for(i=2; i<myMid[j].length; i++){               
              note = mIn[parseInt(myMid[j][i])-1];   

              MIDI.noteOn(0, note, velocity, start);                        
              MIDI.noteOff(0, note, start + delay);    
          }            
          start += delay;
      }
  }

I was trying with MIDI.stop() and MIDI.stopAllNotes() but not working...

0

There are 0 best solutions below