midi-audio-player 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "midi-audio-player",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Javascript Midi Audio Player for WebAudioFont",
5
5
  "keywords": [
6
6
  "audio",
@@ -48,6 +48,7 @@ export default class MidiAudioPlayer {
48
48
  async stop() {
49
49
  await this.#midiPlayer.stop();
50
50
  await this.#audioCtx.suspend();
51
+ await this.#audioPlayer.cancelQueue();
51
52
  await this.#clearActiveNotes();
52
53
  }
53
54
 
@@ -70,10 +70,10 @@ class WebAudioFontPlayer {
70
70
  }
71
71
 
72
72
 
73
- cancelQueue(audioContext) {
73
+ async cancelQueue() {
74
74
  this.#envelopes.forEach(e => {
75
75
  e.gain.cancelScheduledValues(0);
76
- e.gain.setValueAtTime(this.#nearZero, audioContext.currentTime);
76
+ e.gain.setValueAtTime(this.#nearZero, this.#audioCtx.currentTime);
77
77
  e.when = -1;
78
78
  try { e.audioBufferSourceNode?.disconnect(); } catch (e) { }
79
79
  });