1

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...

xkcd149
  • 842
  • 1
  • 11
  • 17
zuro
  • 71
  • 2
  • 12
  • It's unclear where you are attempting to stop the midi in your example. – xkcd149 Jan 13 '16 at 19:39
  • I have button with stop() content: $('#pauseBtn').click(function () { MIDI.stopAllNotes(); }); – zuro Jan 13 '16 at 19:58
  • @zuro, i was trying to use that as well. but get `Uncaught TypeError: Cannot read properties of undefined (reading 'linearRampToValueAtTime')` when i call that function – vivi17 Dec 05 '22 at 13:45

0 Answers0