From 1762be906b518153cc3051afd828752252961d50 Mon Sep 17 00:00:00 2001 From: Wang Qiu Date: Thu, 10 Aug 2017 08:33:53 +0800 Subject: [PATCH 1/3] here should be property 'id' otherwise calling `MIDI.noteOn` causes voice could not be found. --- js/midi/plugin.webaudio.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/midi/plugin.webaudio.js b/js/midi/plugin.webaudio.js index 15a6f0a7..e736b536 100644 --- a/js/midi/plugin.webaudio.js +++ b/js/midi/plugin.webaudio.js @@ -275,7 +275,7 @@ } /// var synth = root.GM.byName[instrument]; - var instrumentId = synth.number; + var instrumentId = synth.id; /// bufferPending[instrumentId] = 0; /// @@ -323,4 +323,4 @@ return new (window.AudioContext || window.webkitAudioContext)(); }; })(); -})(MIDI); \ No newline at end of file +})(MIDI); From 877b8902587bca70c91c8dd24b60aa26525a9bca Mon Sep 17 00:00:00 2001 From: Wang Qiu Date: Tue, 13 Feb 2018 18:01:03 +0800 Subject: [PATCH 2/3] Update MIDI.js --- build/MIDI.js | 3209 +++++++++++++++++++++++++------------------------ 1 file changed, 1609 insertions(+), 1600 deletions(-) diff --git a/build/MIDI.js b/build/MIDI.js index ef200e04..73f8283c 100644 --- a/build/MIDI.js +++ b/build/MIDI.js @@ -11,92 +11,93 @@ if (typeof MIDI === 'undefined') MIDI = {}; -(function(root) { 'use strict'; - - var supports = {}; // object of supported file types - var pending = 0; // pending file types to process - var canPlayThrough = function (src) { // check whether format plays through - pending ++; - var body = document.body; - var audio = new Audio(); - var mime = src.split(';')[0]; - audio.id = 'audio'; - audio.setAttribute('preload', 'auto'); - audio.setAttribute('audiobuffer', true); - audio.addEventListener('error', function() { - body.removeChild(audio); - supports[mime] = false; - pending --; - }, false); - audio.addEventListener('canplaythrough', function() { - body.removeChild(audio); - supports[mime] = true; - pending --; - }, false); - audio.src = 'data:' + src; - body.appendChild(audio); - }; - - root.audioDetect = function(onsuccess) { - /// detect jazz-midi plugin - if (navigator.requestMIDIAccess) { - var isNative = Function.prototype.toString.call(navigator.requestMIDIAccess).indexOf('[native code]'); - if (isNative) { // has native midiapi support - supports['webmidi'] = true; - } else { // check for jazz plugin midiapi support - for (var n = 0; navigator.plugins.length > n; n ++) { - var plugin = navigator.plugins[n]; - if (plugin.name.indexOf('Jazz-Plugin') >= 0) { - supports['webmidi'] = true; - } - } - } - } +(function(root) { + 'use strict'; + + var supports = {}; // object of supported file types + var pending = 0; // pending file types to process + var canPlayThrough = function(src) { // check whether format plays through + pending++; + var body = document.body; + var audio = new Audio(); + var mime = src.split(';')[0]; + audio.id = 'audio'; + audio.setAttribute('preload', 'auto'); + audio.setAttribute('audiobuffer', true); + audio.addEventListener('error', function() { + body.removeChild(audio); + supports[mime] = false; + pending--; + }, false); + audio.addEventListener('canplaythrough', function() { + body.removeChild(audio); + supports[mime] = true; + pending--; + }, false); + audio.src = 'data:' + src; + body.appendChild(audio); + }; + + root.audioDetect = function(onsuccess) { + /// detect jazz-midi plugin + if (navigator.requestMIDIAccess) { + var isNative = Function.prototype.toString.call(navigator.requestMIDIAccess).indexOf('[native code]'); + if (isNative) { // has native midiapi support + supports['webmidi'] = true; + } else { // check for jazz plugin midiapi support + for (var n = 0; navigator.plugins.length > n; n++) { + var plugin = navigator.plugins[n]; + if (plugin.name.indexOf('Jazz-Plugin') >= 0) { + supports['webmidi'] = true; + } + } + } + } - /// check whether