qambi
Version:
MIDI sequencer, loads MIDI files, can record and playback MIDI, uses WebMIDI and WebAudio
17 lines (15 loc) • 199 kB
JavaScript
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.qambi = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var saveAs=saveAs||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/Version\/[\d\.]+.*Safari/.test(navigator.userAgent),c=e.webkitRequestFileSystem,f=e.requestFileSystem||c||e.mozRequestFileSystem,s=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},u=0,d=function(e){var t=function(){"string"==typeof e?n().revokeObjectURL(e):e.remove()};setTimeout(t,4e4)},l=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(e){s(e)}}},p=function(e){return/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e},v=function(t,s,v){v||(t=p(t));var w,y,m,S=this,h=t.type,R=!1,O=function(){l(S,"writestart progress write writeend".split(" "))},g=function(){if(y&&a&&"undefined"!=typeof FileReader){var o=new FileReader;return o.onloadend=function(){var e=o.result;y.location.href="data:attachment/file"+e.slice(e.search(/[,;]/)),S.readyState=S.DONE,O()},o.readAsDataURL(t),void(S.readyState=S.INIT)}if(!R&&w||(w=n().createObjectURL(t)),y)y.location.href=w;else{void 0===e.open(w,"_blank")&&a&&(e.location.href=w)}S.readyState=S.DONE,O(),d(w)},b=function(e){return function(){if(S.readyState!==S.DONE)return e.apply(this,arguments)}},E={create:!0,exclusive:!1};return S.readyState=S.INIT,s||(s="download"),r?(w=n().createObjectURL(t),void setTimeout(function(){o.href=w,o.download=s,i(o),O(),d(w),S.readyState=S.DONE})):(e.chrome&&h&&"application/octet-stream"!==h&&(m=t.slice||t.webkitSlice,t=m.call(t,0,t.size,"application/octet-stream"),R=!0),c&&"download"!==s&&(s+=".download"),("application/octet-stream"===h||c)&&(y=e),f?(u+=t.size,void f(e.TEMPORARY,u,b(function(e){e.root.getDirectory("saved",E,b(function(e){var n=function(){e.getFile(s,E,b(function(e){e.createWriter(b(function(n){n.onwriteend=function(t){y.location.href=e.toURL(),S.readyState=S.DONE,l(S,"writeend",t),d(e)},n.onerror=function(){var e=n.error;e.code!==e.ABORT_ERR&&g()},"writestart progress write abort".split(" ").forEach(function(e){n["on"+e]=S["on"+e]}),n.write(t),S.abort=function(){n.abort(),S.readyState=S.DONE},S.readyState=S.WRITING}),g)}),g)};e.getFile(s,{create:!1},b(function(e){e.remove(),n()}),b(function(e){e.code===e.NOT_FOUND_ERR?n():g()}))}),g)}),g)):void g())},w=v.prototype,y=function(e,t,n){return new v(e,t,n)};return"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob?function(e,t,n){return n||(e=p(e)),navigator.msSaveOrOpenBlob(e,t||"download")}:(w.abort=function(){var e=this;e.readyState=e.DONE,l(e,"abort")},w.readyState=w.INIT=0,w.WRITING=1,w.DONE=2,w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null,y)}}("undefined"!=typeof self&&self||"undefined"!=typeof window&&window||this.content);"undefined"!=typeof module&&module.exports?module.exports.saveAs=saveAs:"undefined"!=typeof define&&null!==define&&null!==define.amd&&define([],function(){return saveAs});
},{}],2:[function(require,module,exports){
require("whatwg-fetch"),module.exports=self.fetch.bind(self);
},{"whatwg-fetch":6}],3:[function(require,module,exports){
(function (process,__dirname){
var path="./bin/",v=process.versions.node.split(".");0==v[0]&&v[1]<=10?path+="0_10/":0==v[0]&&v[1]<=12?path+="0_12/":v[0]<=4?path+="4_8/":v[0]<=5?path+="5_12/":v[0]<=6?path+="6_12/":v[0]<=7?path+="7_10/":v[0]<=8&&(path+="8_9/"),"win32"==process.platform&&"ia32"==process.arch?path+="win32/jazz":"win32"==process.platform&&"x64"==process.arch?path+="win64/jazz":"darwin"==process.platform&&"x64"==process.arch?path+="macos64/jazz":"darwin"==process.platform&&"ia32"==process.arch?path+="macos32/jazz":"linux"==process.platform&&"x64"==process.arch?path+="linux64/jazz":"linux"==process.platform&&"ia32"==process.arch?path+="linux32/jazz":"linux"==process.platform&&"arm"==process.arch&&(path+="linuxa7/jazz"),module.exports=require(path),module.exports.package=require(__dirname+"/package.json");
}).call(this,require('_process'),"/node_modules/jazz-midi")
},{"_process":5}],4:[function(require,module,exports){
(function (global){
!function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define("JZZ",[],e);else{if(t.JZZ&&t.JZZ.MIDI)return;t.JZZ=e()}}(this,function(){function t(){this._orig=this,this._ready=!1,this._queue=[],this._err=[]}function e(t,e){setTimeout(function(){t._resume()},e)}function n(t){t._resume()}function i(t,e,i){t[i]=function(){var t=arguments,o=e._image();return this._push(n,[o]),o[i].apply(o,t)}}function o(t){t instanceof Function?t.apply(this):console.log(t)}function r(t){t instanceof Function?t.apply(this):console.log(t)}function s(t){this._break("closed"),t._resume()}function u(t){if(!t.length)return void this._break();var e=t.shift();if(t.length){var n=this;this._slip(r,[function(){u.apply(n,[t])}])}try{this._repair(),e.apply(this)}catch(t){this._break(t.toString())}}function a(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return;t.push(e)}function h(t,e){for(var n=0;n<t.length;n++)if(t[n]===e)return void t.splice(n,1)}function c(){t.apply(this)}function p(){c.prototype._time||(c.prototype._time=function(){return Date.now()}),c.prototype._startTime=c.prototype._time(),c.prototype.time=function(){return c.prototype._time()-c.prototype._startTime}}function f(t,e,n){if(void 0===e)return f(t,[],[]);if(t instanceof Object){for(var i=0;i<e.length;i++)if(e[i]===t)return n[i];var o;o=t instanceof Array?[]:{},e.push(t),n.push(o);for(var r in t)t.hasOwnProperty(r)&&(o[r]=f(t[r],e,n));return o}return t}function l(){this._orig._info.engine=qt._type,this._orig._info.version=qt._version,this._orig._info.sysex=qt._sysex,this._orig._info.inputs=[],this._orig._info.outputs=[],Bt=[],xt=[],qt._allOuts={},qt._allIns={};var t,e;for(t=0;t<qt._outs.length;t++)e=qt._outs[t],e.engine=qt,qt._allOuts[e.name]=e,this._orig._info.outputs.push({name:e.name,manufacturer:e.manufacturer,version:e.version,engine:qt._type}),Bt.push(e);for(t=0;t<Dt._outs.length;t++)e=Dt._outs[t],this._orig._info.outputs.push({name:e.name,manufacturer:e.manufacturer,version:e.version,engine:e.type}),Bt.push(e);for(t=0;t<qt._ins.length;t++)e=qt._ins[t],e.engine=qt,qt._allIns[e.name]=e,this._orig._info.inputs.push({name:e.name,manufacturer:e.manufacturer,version:e.version,engine:qt._type}),xt.push(e);for(t=0;t<Dt._ins.length;t++)e=Dt._ins[t],this._orig._info.inputs.push({name:e.name,manufacturer:e.manufacturer,version:e.version,engine:e.type}),xt.push(e)}function _(){this._slip(l,[]),qt._refresh(this)}function d(t,e){if(void 0===t)return e.slice();var n,i,o=[];if(t instanceof RegExp){for(i=0;i<e.length;i++)t.test(e[i].name)&&o.push(e[i]);return o}for(t instanceof Function&&(t=t(e)),t instanceof Array||(t=[t]),n=0;n<t.length;n++)for(i=0;i<e.length;i++)(t[n]+""==i+""||t[n]===e[i].name||t[n]instanceof Object&&t[n].name===e[i].name)&&o.push(e[i]);return o}function m(t,e){var n;n=e instanceof RegExp?"Port matching "+e+" not found":e instanceof Object||void 0===e?"Port not found":'Port "'+e+'" not found',t._crash(n)}function v(t,e){var n=d(e,Bt);if(!n.length)return void m(t,e);for(var i=0;i<n.length;i++)n[i]=function(t){return function(){t.engine._openOut(this,t.name)}}(n[i]);t._slip(u,[n]),t._resume()}function g(t,e){var n=d(e,xt);if(!n.length)return void m(t,e);for(var i=0;i<n.length;i++)n[i]=function(t){return function(){t.engine._openIn(this,t.name)}}(n[i]);t._slip(u,[n]),t._resume()}function y(t,e){t._slip(B,[e]),t._resume()}function w(){t.apply(this),this._handles=[],this._outs=[]}function M(t){this._receive(t)}function b(t){this._emit(t)}function S(t){t instanceof Function?a(this._orig._handles,t):a(this._orig._outs,t)}function O(t){void 0===t?(this._orig._handles=[],this._orig._outs=[]):t instanceof Function?h(this._orig._handles,t):h(this._orig._outs,t)}function I(t,e){this._orig._mpe||(this._orig._mpe=new ct),this._orig._mpe.setup(t,e)}function C(t,e){w.apply(this),this._port=t._orig,this._chan=e,i(this,this._port,"ch"),i(this,this._port,"mpe"),i(this,this._port,"connect"),i(this,this._port,"disconnect"),i(this,this._port,"close")}function E(t,e,n){w.apply(this),this._port=t._orig,this._master=e,this._band=n,i(this,this._port,"ch"),i(this,this._port,"mpe"),i(this,this._port,"connect"),i(this,this._port,"disconnect"),i(this,this._port,"close")}function A(){t.apply(this),this._handles=[],i(this,Pt,"refresh"),i(this,Pt,"openMidiOut"),i(this,Pt,"openMidiIn"),i(this,Pt,"onChange"),i(this,Pt,"close")}function B(t){t instanceof Function&&(this._orig._handles.length||qt._watch(),a(this._orig._handles,t))}function x(t){void 0===t?this._orig._handles=[]:h(this._orig._handles,t),this._orig._handles.length||qt._unwatch()}function P(t,e,n,i){var o;if(t.length!=n.length||e.length!=i.length)return!0;for(o=0;o<t.length;o++)if(t[o].name!=n[o].name)return!0;for(o=0;o<e.length;o++)if(e[o].name!=i[o].name)return!0;return!1}function q(t,e,n,i){if(P(t,e,n,i)){var o,r=[],s=[],u=[],a=[],h={};for(o=0;o<t.length;o++)h[t[o].name]=!0;for(o=0;o<n.length;o++)h[n[o].name]||r.push(n[o]);for(h={},o=0;o<n.length;o++)h[n[o].name]=!0;for(o=0;o<t.length;o++)h[t[o].name]||u.push(t[o]);for(h={},o=0;o<e.length;o++)h[e[o].name]=!0;for(o=0;o<i.length;o++)h[i[o].name]||s.push(i[o]);for(h={},o=0;o<i.length;o++)h[i[o].name]=!0;for(o=0;o<e.length;o++)h[e[o].name]||a.push(e[o]);return r.length||u.length||s.length||a.length?{inputs:{added:r,removed:u},outputs:{added:s,removed:a}}:void 0}}function D(t){for(wt=0;wt<Pt._watcher._handles.length;wt++)Pt._watcher._handles[wt].apply(Pt,[t])}function L(){if("undefined"!=typeof module&&module.exports)return void Z(require("jazz-midi"));this._break()}function k(){var t=document.createElement("div");t.style.visibility="hidden",document.body.appendChild(t);var e=document.createElement("object");if(e.style.visibility="hidden",e.style.width="0px",e.style.height="0px",e.classid="CLSID:1ACE1618-1C7D-4561-AEE1-34842AA85E90",e.type="audio/x-jazz",document.body.appendChild(e),e.isJazz)return void J(e);this._break()}function z(){if(navigator.requestMIDIAccess){var t=this,e=function(e){H(e),t._resume()},n=function(e){t._crash(e)},i={};return navigator.requestMIDIAccess(i).then(e,n),void this._pause()}this._break()}function F(){if(navigator.requestMIDIAccess){var t=this,e=function(e){H(e,!0),t._resume()},n=function(e){t._crash(e)},i={sysex:!0};return navigator.requestMIDIAccess(i).then(e,n),void this._pause()}this._break()}function T(){function t(o){if(e=!0,n||(n=document.getElementById("jazz-midi-msg")),n){var r=[];try{r=JSON.parse(n.innerText)}catch(t){}n.innerText="",document.removeEventListener("jazz-midi-msg",t),"version"===r[0]?(Q(n,r[2]),i._resume()):i._crash()}}var e,n,i=this;this._pause(),document.addEventListener("jazz-midi-msg",t);try{document.dispatchEvent(new Event("jazz-midi"))}catch(t){}window.setTimeout(function(){e||i._crash()},0)}function j(){this._pause();var t=this;setTimeout(function(){t._crash()},0)}function W(t){for(var e=[L,j],n=N(t),i=0;i<n.length;i++)"webmidi"==n[i]?(t&&!0===t.sysex&&e.push(F),t&&!0===t.sysex&&!0!==t.degrade||e.push(z)):"extension"==n[i]?e.push(T):"plugin"==n[i]&&e.push(k);return e.push(V),e}function N(t){var e=["extension","plugin","webmidi"];if(!t||!t.engine)return e;var n,i,o,r=t.engine instanceof Array?t.engine:[t.engine],s={},u=[],a=[];for(o=0;o<r.length;o++){var c=r[o].toString().toLowerCase();s[c]||(s[c]=!0,"none"===c&&(n=!0),"etc"===c&&(i=!0),i?a.push(c):u.push(c),h(e,c))}return(i||u.length||a.length)&&(n=!1),n?[]:u.concat(i?e:a)}function R(t){pt(),Pt=new c,Pt._options=t,Pt._push(u,[W(t)]),Pt.refresh(),Pt._push(p,[]),Pt._push(function(){Bt.length||xt.length||this._break()},[]),Pt._resume()}function V(){qt._type="none",qt._sysex=!0,qt._refresh=function(){qt._outs=[],qt._ins=[]},qt._watch=function(){},qt._unwatch=function(){}}function G(){function t(){n&&(qt._refresh(),n=!1)}function e(e){n=!0,setTimeout(t,0)}qt._inArr=[],qt._outArr=[],qt._inMap={},qt._outMap={},qt._outsW=[],qt._insW=[],qt._version=qt._main.version,qt._sysex=!0;var n;_closeAll=function(){for(var t=0;t<this.clients.length;t++)this._close(this.clients[t])},qt._refresh=function(){qt._outs=[],qt._ins=[];var t,e;for(t=0;(e=qt._main.MidiOutInfo(t)).length;t++)qt._outs.push({type:qt._type,name:e[0],manufacturer:e[1],version:e[2]});for(t=0;(e=qt._main.MidiInInfo(t)).length;t++)qt._ins.push({type:qt._type,name:e[0],manufacturer:e[1],version:e[2]});var i=q(qt._insW,qt._outsW,qt._ins,qt._outs);if(i){for(Mt=0;Mt<i.inputs.removed.length;Mt++)impl=qt._inMap[i.inputs.removed[Mt].name],impl&&impl._closeAll();for(Mt=0;Mt<i.outputs.removed.length;Mt++)impl=qt._outMap[i.inputs.removed[Mt].name],impl&&impl._closeAll();qt._insW=qt._ins,qt._outsW=qt._outs,n&&D(i)}},qt._openOut=function(t,e){var n=qt._outMap[e];if(!n){qt._pool.length<=qt._outArr.length&&qt._pool.push(qt._newPlugin()),n={name:e,clients:[],info:{name:e,manufacturer:qt._allOuts[e].manufacturer,version:qt._allOuts[e].version,type:"MIDI-out",sysex:qt._sysex,engine:qt._type},_close:function(t){qt._closeOut(t)},_closeAll:_closeAll,_receive:function(t){this.plugin.MidiOutRaw(t.slice())}};var i=qt._pool[qt._outArr.length];n.plugin=i,qt._outArr.push(n),qt._outMap[e]=n}if(!n.open){var o=n.plugin.MidiOutOpen(e);if(o!==e)return o&&n.plugin.MidiOutClose(),void t._break();n.open=!0}t._orig._impl=n,a(n.clients,t._orig),t._info=n.info,t._receive=function(t){n._receive(t)},t._close=function(){n._close(this)}},qt._openIn=function(t,e){var n=qt._inMap[e];if(!n){qt._pool.length<=qt._inArr.length&&qt._pool.push(qt._newPlugin()),n={name:e,clients:[],info:{name:e,manufacturer:qt._allIns[e].manufacturer,version:qt._allIns[e].version,type:"MIDI-in",sysex:qt._sysex,engine:qt._type},_close:function(t){qt._closeIn(t)},_closeAll:_closeAll,handle:function(t,e){for(var n=0;n<this.clients.length;n++){var i=et(e);this.clients[n]._emit(i)}}};n.onmidi=function(t){return function(e,n){t.handle(e,n)}}(n);var i=qt._pool[qt._inArr.length];n.plugin=i,qt._inArr.push(n),qt._inMap[e]=n}if(!n.open){var o=n.plugin.MidiInOpen(e,n.onmidi);if(o!==e)return o&&n.plugin.MidiInClose(),void t._break();n.open=!0}t._orig._impl=n,a(n.clients,t._orig),t._info=n.info,t._close=function(){n._close(this)}},qt._closeOut=function(t){var e=t._impl;h(e.clients,t._orig),e.clients.length||(e.open=!1,e.plugin.MidiOutClose())},qt._closeIn=function(t){var e=t._impl;h(e.clients,t._orig),e.clients.length||(e.open=!1,e.plugin.MidiInClose())},qt._close=function(){for(var t=0;t<qt._inArr.length;t++)qt._inArr[t].open&&qt._inArr[t].plugin.MidiInClose();qt._unwatch()},qt._watch=function(){qt._main.OnConnectMidiIn(e),qt._main.OnConnectMidiOut(e),qt._main.OnDisconnectMidiIn(e),qt._main.OnDisconnectMidiOut(e)},qt._unwatch=function(){qt._main.OnConnectMidiIn(),qt._main.OnConnectMidiOut(),qt._main.OnDisconnectMidiIn(),qt._main.OnDisconnectMidiOut()},c.prototype._time=function(){return qt._main.Time()}}function Z(t){qt._type="node",qt._main=t,qt._pool=[],qt._newPlugin=function(){return new t.MIDI},G()}function J(t){qt._type="plugin",qt._main=t,qt._pool=[t],qt._newPlugin=function(){var e=document.createElement("object");return e.style.visibility="hidden",e.style.width="0px",t.style.height="0px",e.classid="CLSID:1ACE1618-1C7D-4561-AEE1-34842AA85E90",e.type="audio/x-jazz",document.body.appendChild(e),e.isJazz?e:void 0},G()}function H(t,e){qt._type="webmidi",qt._version=43,qt._sysex=!!e,qt._access=t,qt._inMap={},qt._outMap={},qt._outsW=[],qt._insW=[];var n;_closeAll=function(){for(var t=0;t<this.clients.length;t++)this._close(this.clients[t])},qt._refresh=function(){qt._outs=[],qt._ins=[],qt._access.outputs.forEach(function(t,e){qt._outs.push({type:qt._type,name:t.name,manufacturer:t.manufacturer,version:t.version})}),qt._access.inputs.forEach(function(t,e){qt._ins.push({type:qt._type,name:t.name,manufacturer:t.manufacturer,version:t.version})});var t=q(qt._insW,qt._outsW,qt._ins,qt._outs);if(t){for(Mt=0;Mt<t.inputs.removed.length;Mt++)impl=qt._inMap[t.inputs.removed[Mt].name],impl&&impl._closeAll();for(Mt=0;Mt<t.outputs.removed.length;Mt++)impl=qt._outMap[t.inputs.removed[Mt].name],impl&&impl._closeAll();qt._insW=qt._ins,qt._outsW=qt._outs,n&&D(t)}},qt._openOut=function(t,e){var n=qt._outMap[e];n||(n={name:e,clients:[],info:{name:e,manufacturer:qt._allOuts[e].manufacturer,version:qt._allOuts[e].version,type:"MIDI-out",sysex:qt._sysex,engine:qt._type},_close:function(t){qt._closeOut(t)},_closeAll:_closeAll,_receive:function(t){n.dev&&this.dev.send(t.slice())}});var i;qt._access.outputs.forEach(function(t,n){t.name===e&&(i=t)}),i?(n.dev=i,qt._outMap[e]=n,n.dev.open&&n.dev.open(),t._orig._impl=n,a(n.clients,t._orig),t._info=n.info,t._receive=function(t){n._receive(t)},t._close=function(){n._close(this)}):t._break()},qt._openIn=function(t,e){var n=qt._inMap[e];n||(n={name:e,clients:[],info:{name:e,manufacturer:qt._allIns[e].manufacturer,version:qt._allIns[e].version,type:"MIDI-in",sysex:qt._sysex,engine:qt._type},_close:function(t){qt._closeIn(t)},_closeAll:_closeAll,handle:function(t){for(var e=0;e<this.clients.length;e++){var n=et([].slice.call(t.data));this.clients[e]._emit(n)}}});var i;if(qt._access.inputs.forEach(function(t,n){t.name===e&&(i=t)}),i){n.dev=i;n.dev.onmidimessage=function(t){return function(e){t.handle(e)}}(n),qt._inMap[e]=n,n.dev.open&&n.dev.open(),t._orig._impl=n,a(n.clients,t._orig),t._info=n.info,t._close=function(){n._close(this)}}else t._break()},qt._closeOut=function(t){var e=t._impl;h(e.clients,t._orig),e.clients.length||(e.dev&&e.dev.close&&e.dev.close(),e.dev=void 0)},qt._closeIn=function(t){var e=t._impl;h(e.clients,t._orig),e.clients.length||(e.dev&&e.dev.close&&e.dev.close(),e.dev=void 0)},qt._close=function(){},qt._watch=function(){qt._access.onstatechange=function(){n=!0,setTimeout(function(){n&&(qt._refresh(),n=!1)},0)}},qt._unwatch=function(){qt._access.onstatechange=void 0}}function Q(t,e){qt._type="extension",qt._version=e,qt._sysex=!0,qt._pool=[],qt._outs=[],qt._ins=[],qt._inArr=[],qt._outArr=[],qt._inMap={},qt._outMap={},qt._outsW=[],qt._insW=[],qt.refreshClients=[],qt._msg=t,qt._newPlugin=function(){var t={id:qt._pool.length};t.id?document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["new"]})):t.ready=!0,qt._pool.push(t)},qt._newPlugin(),qt._refresh=function(t){qt.refreshClients.push(t),t._pause(),setTimeout(function(){document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["refresh"]}))},0)},_closeAll=function(){for(var t=0;t<this.clients.length;t++)this._close(this.clients[t])},qt._openOut=function(t,e){var n=qt._outMap[e];if(!n){qt._pool.length<=qt._outArr.length&&qt._newPlugin();var i=qt._pool[qt._outArr.length];n={name:e,clients:[],info:{name:e,manufacturer:qt._allOuts[e].manufacturer,version:qt._allOuts[e].version,type:"MIDI-out",sysex:qt._sysex,engine:qt._type},_start:function(){document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["openout",i.id,e]}))},_close:function(t){qt._closeOut(t)},_closeAll:_closeAll,_receive:function(t){var e=t.slice();e.splice(0,0,"play",i.id),document.dispatchEvent(new CustomEvent("jazz-midi",{detail:e}))}},n.plugin=i,i.output=n,qt._outArr.push(n),qt._outMap[e]=n}t._orig._impl=n,a(n.clients,t._orig),t._info=n.info,t._receive=function(t){n._receive(t)},t._close=function(){n._close(this)},n.open||(n.plugin.ready&&n._start(),t._pause())},qt._openIn=function(t,e){var n=qt._inMap[e];if(!n){qt._pool.length<=qt._inArr.length&&qt._newPlugin();var i=qt._pool[qt._inArr.length];n={name:e,clients:[],info:{name:e,manufacturer:qt._allIns[e].manufacturer,version:qt._allIns[e].version,type:"MIDI-in",sysex:qt._sysex,engine:qt._type},_start:function(){document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["openin",i.id,e]}))},_close:function(t){qt._closeIn(t)},_closeAll:_closeAll},n.plugin=i,i.input=n,qt._inArr.push(n),qt._inMap[e]=n}t._orig._impl=n,a(n.clients,t._orig),t._info=n.info,t._close=function(){n._close(this)},n.open||(n.plugin.ready&&n._start(),t._pause())},qt._closeOut=function(t){var e=t._impl;h(e.clients,t._orig),e.clients.length||(e.open=!1,document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["closeout",e.plugin.id]})))},qt._closeIn=function(t){var e=t._impl;h(e.clients,t._orig),e.clients.length||(e.open=!1,document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["closein",e.plugin.id]})))},qt._close=function(){};var n;qt._watch=function(){qt._insW=qt._ins,qt._outsW=qt._outs,n=setInterval(function(){document.dispatchEvent(new CustomEvent("jazz-midi",{detail:["refresh"]}))},250)},qt._unwatch=function(){clearInterval(n),n=void 0},document.addEventListener("jazz-midi-msg",function(t){var e,i,o,r=qt._msg.innerText.split("\n");for(qt._msg.innerText="",i=0;i<r.length;i++){var s=[];try{s=JSON.parse(r[i])}catch(t){}if(s.length)if("refresh"===s[0]){if(s[1].ins){for(o=0;o<s[1].ins.length;o++)s[1].ins[o].type=qt._type;qt._ins=s[1].ins}if(s[1].outs){for(o=0;o<s[1].outs.length;o++)s[1].outs[o].type=qt._type;qt._outs=s[1].outs}for(o=0;o<qt.refreshClients.length;o++)qt.refreshClients[o]._resume();qt.refreshClients=[];var u=q(qt._insW,qt._outsW,qt._ins,qt._outs);if(u){for(qt._insW=qt._ins,qt._outsW=qt._outs,o=0;o<u.inputs.removed.length;o++)(e=qt._inMap[u.inputs.removed[o].name])&&e._closeAll();for(o=0;o<u.outputs.removed.length;o++)(e=qt._outMap[u.outputs.removed[o].name])&&e._closeAll();n&&D(u)}}else if("version"===s[0]){var a=qt._pool[s[1]];a&&(a.ready=!0,a.input&&a.input._start(),a.output&&a.output._start())}else if("openout"===s[0]){if(e=qt._pool[s[1]].output)if(s[2]==e.name){if(e.open=!0,e.clients)for(o=0;o<e.clients.length;o++)e.clients[o]._resume()}else if(e.clients)for(o=0;o<e.clients.length;o++)e.clients[o]._crash()}else if("openin"===s[0]){if(e=qt._pool[s[1]].input)if(s[2]==e.name){if(e.open=!0,e.clients)for(o=0;o<e.clients.length;o++)e.clients[o]._resume()}else if(e.clients)for(o=0;o<e.clients.length;o++)e.clients[o]._crash()}else if("midi"===s[0]&&(e=qt._pool[s[1]].input)&&e.clients)for(o=0;o<e.clients.length;o++){var h=et(s.slice(3));e.clients[o]._emit(h)}}})}function U(){var t=this instanceof U?this:t=new U;return U.prototype.reset.apply(t,arguments),t}function K(){29.97==this.type&&!this.second&&this.frame<2&&this.minute%10&&(this.frame=2)}function X(t){return[[24,25,29.97,30][t[7]>>1&3],(1&t[7])<<4|t[6],t[5]<<4|t[4],t[3]<<4|t[2],t[1]<<4|t[0]]}function Y(t){!t.backwards&&t.quarter>=4?t.decrFrame():t.backwards&&t.quarter<4&&t.incrFrame();var e;switch(t.quarter>>1){case 0:e=t.frame;break;case 1:e=t.second;break;case 2:e=t.minute;break;default:e=t.hour}return 1&t.quarter?e>>=4:e&=15,7==t.quarter&&(25==t.type?e|=2:29.97==t.type?e|=4:30==t.type&&(e|=6)),!t.backwards&&t.quarter>=4?t.incrFrame():t.backwards&&t.quarter<4&&t.decrFrame(),e|t.quarter<<4}function $(t){return 25==t.type?32|t.hour:29.97==t.type?64|t.hour:30==t.type?96|t.hour:t.hour}function tt(t){return t<10?"0"+t:t}function et(t){var e=this instanceof et?this:e=new et;if(t instanceof et?(e._from=t._from.slice(),e._mpe=t._mpe):e._from=[],!arguments.length)return e;var n=t instanceof Array?t:arguments;for(wt=0;wt<n.length;wt++)Ot=n[wt],1==wt&&(e[0]>=128&&e[0]<=175&&(Ot=et.noteValue(Ot)),e[0]>=192&&e[0]<=207&&(Ot=et.programValue(Ot))),(Ot!=parseInt(Ot)||Ot<0||Ot>255)&&nt(n[wt]),e.push(Ot);return e}function nt(t){throw RangeError("Bad MIDI value: "+t)}function it(t){return(t!=parseInt(t)||t<0||t>15)&&nt(t),t}function ot(t,e){return(t!=parseInt(t)||t<0||t>127)&&nt(void 0===e?t:e),t}function rt(t){return(t!=parseInt(t)||t<0||t>16383)&&nt(t),127&t}function st(t){return(t!=parseInt(t)||t<0||t>16383)&&nt(t),t>>7}function ut(t,e){et[t]=function(){return new et(e.apply(0,arguments))},w.prototype[t]=function(){return this.send(e.apply(0,arguments)),this}}function at(t,e){ut(t,e),C.prototype[t]=function(){return this.send(e.apply(0,[this._chan].concat(Array.prototype.slice.call(arguments)))),this},E.prototype[t]=function(){var t,n=Array.prototype.slice.call(arguments);n.length<e.length?n=[this._master].concat(n):(t=ot(et.noteValue(n[0],n[0])),n[0]=this._master);var i=e.apply(0,n);return i.mpe=t,this.send(i),this}}function ht(t){for(var e=[],n=0;n<t.length;n++)e[n]=(t[n]<16?"0":"")+t[n].toString(16);return e.join(" ")}function ct(){var t=this instanceof ct?this:t=new ct;return t.reset(),arguments.length&&ct.prototype.setup.apply(t,arguments),t}function pt(){if(!Wt&&"undefined"!=typeof window){var t=window.AudioContext||window.webkitAudioContext;if(t){Wt=new t,Wt&&!Wt.createGain&&(Wt.createGain=Wt.createGainNode);var e=function(){if("running"!=Wt.state){Wt.resume();var t=Wt.createOscillator(),n=Wt.createGain();try{n.gain.value=0}catch(t){}n.gain.setTargetAtTime(0,Wt.currentTime,.01),t.connect(n),n.connect(Wt.destination),t.start||(t.start=t.noteOn),t.stop||(t.stop=t.noteOff),t.start(.1),t.stop(.11)}else document.removeEventListener("touchend",e),document.removeEventListener("mousedown",e),document.removeEventListener("keydown",e)};document.addEventListener("touchend",e),document.addEventListener("mousedown",e),document.addEventListener("keydown",e),e()}}}function ft(){}function lt(){for(var t=new Array(64),e=0;e<64;e++)t[e]=Math.floor(16*Math.random()%16).toString(16).toUpperCase();return t.join("")}function _t(t,e){return e?(Zt[t]||(Zt[t]=lt()),Zt[t]):(Gt[t]||(Gt[t]=lt()),Gt[t])}function dt(){function t(t){return function(){Rt(new mt(t,n))}}function e(e){var i,o,r;for(i=0;i<e.inputs.added.length;i++)o=new yt(e.inputs.added[i]),n.inputs.set(o.id,o),r=t(o),o.open().then(r,r);for(i=0;i<e.outputs.added.length;i++)o=new gt(e.outputs.added[i]),n.outputs.set(o.id,o),r=t(o),o.open().then(r,r);for(i=0;i<e.inputs.removed.length;i++)o=n.inputs.get(Zt[e.inputs.removed[i].name]),o.close(),n.inputs.delete(o.id),Rt(new mt(o,n));for(i=0;i<e.outputs.removed.length;i++)o=n.outputs.get(Gt[e.outputs.removed[i].name]),o.close(),n.outputs.delete(o.id),Rt(new mt(o,n))}this.sysexEnabled=!0,this.outputs=new Ut,this.inputs=new Ut;var n=this;Object.defineProperty(this,"onstatechange",{get:function(){return Rt},set:function(t){t instanceof Function?(Rt||Lt().onChange(e),Rt=t):Rt&&(Lt().onChange().disconnect(e),Rt=void 0)}})}function mt(t,e){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.currentTarget=e,this.defaultPrevented=!1,this.eventPhase=0,this.path=[],this.port=t,this.returnValue=!0,this.srcElement=e,this.target=e,this.timeStamp=At(),this.type="statechange"}function vt(t,e){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.currentTarget=t,this.data=e,this.defaultPrevented=!1,this.eventPhase=0,this.path=[],this.receivedTime=At(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function gt(t){var e=this;this.type="output",this.name=t.name,this.manufacturer=t.manufacturer,this.version=t.version,this.id=_t(this.name,!1),this.state="disconnected",this.connection="closed",Object.defineProperty(this,"onstatechange",{get:function(){return Jt[e.name].onstatechange},set:function(t){Function,Jt[e.name].onstatechange=t}})}function yt(t){var e=this;this.type="input",this.name=t.name,this.manufacturer=t.manufacturer,this.version=t.version,this.id=_t(this.name,!0),this.state="disconnected",this.connection="closed",Object.defineProperty(this,"onstatechange",{get:function(){return Ht[e.name].onstatechange},set:function(t){Function,Ht[e.name].onstatechange=t}})}var wt,Mt,bt,St,Ot,It="undefined"==typeof window?global:window,Ct=Date.now||function(){return(new Date).getTime()},Et=Ct(),At="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return Ct()-Et};t.prototype._exec=function(){for(;this._ready&&this._queue.length;){var t=this._queue.shift();this._orig._bad?this._orig._hope&&t[0]==r?(this._orig._hope=!1,t[0].apply(this,t[1])):(this._queue=[],this._orig._hope=!1):t[0]!=r&&t[0].apply(this,t[1])}},t.prototype._push=function(e,n){this._queue.push([e,n]),t.prototype._exec.apply(this)},t.prototype._slip=function(t,e){this._queue.unshift([t,e])},t.prototype._pause=function(){this._ready=!1},t.prototype._resume=function(){this._ready=!0,t.prototype._exec.apply(this)},t.prototype._break=function(t){this._orig._bad=!0,this._orig._hope=!0,t&&this._orig._err.push(t)},t.prototype._repair=function(){this._orig._bad=!1},t.prototype._crash=function(t){this._break(t),this._resume()},t.prototype.err=function(){return f(this._err)},t.prototype._image=function(){var t=function(){};t.prototype=this._orig;var e=new t;return e._ready=!1,e._queue=[],e},t.prototype.wait=function(t){if(!t)return this;var n=this._image();return this._push(e,[n,t]),n},t.prototype.and=function(t){return this._push(o,[t]),this},t.prototype.or=function(t){return this._push(r,[t]),this},t.prototype._info={},t.prototype.info=function(){var t=f(this._orig._info);return void 0===t.engine&&(t.engine="none"),void 0===t.sysex&&(t.sysex=!0),t},t.prototype.name=function(){return this.info().name},t.prototype.close=function(){var e=new t;return this._close&&this._push(this._close,[]),this._push(s,[e]),e},c.prototype=new t,c.prototype.time=function(){return 0},"undefined"!=typeof performance&&performance.now&&(c.prototype._time=function(){return performance.now()}),c.prototype._info={name:"JZZ.js",ver:"0.4.6",version:"0.4.6"};var Bt=[],xt=[];c.prototype.refresh=function(){return this._push(_,[]),this},c.prototype.openMidiOut=function(t){var e=new w;return this._push(_,[]),this._push(v,[e,t]),e},c.prototype.openMidiIn=function(t){var e=new w;return this._push(_,[]),this._push(g,[e,t]),e},c.prototype.onChange=function(t){this._orig._watcher||(this._orig._watcher=new A);var e=this._orig._watcher._image();return this._push(y,[e,t]),e},c.prototype._close=function(){qt._close()},w.prototype=new t,w.prototype._filter=function(t){if(this._orig._mpe){var e,n=0;this._handles&&this._handles.length&&(n=this._handles.length,e=this._handles[0]),this._outs&&this._outs.length&&(n=this._outs.length,e=this._outs[0]),1!=n||e._mpe||(t=this._orig._mpe.filter(t))}return t},w.prototype._receive=function(t){this._emit(this._filter(t))},w.prototype.send=function(){return this._push(M,[et.apply(null,arguments)]),this},w.prototype.note=function(t,e,n,i){return this.noteOn(t,e,n),i&&this.wait(i).noteOff(t,e),this},w.prototype._emit=function(t){var e;for(e=0;e<this._handles.length;e++)this._handles[e].apply(this,[et(t)._stamp(this)]);for(e=0;e<this._outs.length;e++){var n=et(t);n._stamped(this._outs[e])||this._outs[e].send(n._stamp(this))}},w.prototype.emit=function(t){return this._push(b,[t]),this},w.prototype.connect=function(t){return this._push(S,[t]),this},w.prototype.disconnect=function(t){return this._push(O,[t]),this},w.prototype.ch=function(t){if(void 0===t)return this;if(t!=parseInt(t)||t<0||t>15)throw RangeError("Bad channel value: "+t+" (must be from 0 to 15)");var e=new C(this,t);return this._push(n,[e]),e},w.prototype.mpe=function(t,e){if(void 0===t&&void 0===e)return this;ct.validate(t,e);var i=e?new E(this,t,e):new C(this,t);return this._push(I,[t,e]),this._push(n,[i]),i},C.prototype=new w,C.prototype.channel=function(){return this._chan},C.prototype._receive=function(t){this._port._receive(t)},C.prototype.note=function(t,e,n){return this.noteOn(t,e),n&&this.wait(n).noteOff(t),this},E.prototype=new w,E.prototype.channel=function(){return this._master},E.prototype._receive=function(t){this._port._receive(t)},E.prototype.note=function(t,e,n){return this.noteOn(t,e),n&&this.wait(n).noteOff(t),this},A.prototype=new t,A.prototype.connect=function(t){return this._push(B,[t]),this},A.prototype.disconnect=function(t){return this._push(x,[t]),this};var Pt,qt={},Dt={_outs:[],_ins:[]},Lt=function(t){return Pt||R(t),Pt};Lt.now=At,Lt.info=function(){return c.prototype.info()},Lt.Widget=function(t){var e=new w;if(t instanceof Object)for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e._resume(),e},c.prototype.Widget=Lt.Widget,U.prototype.reset=function(t){if(t instanceof U)return this.setType(t.getType()),this.setHour(t.getHour()),this.setMinute(t.getMinute()),this.setSecond(t.getSecond()),this.setFrame(t.getFrame()),this.setQuarter(t.getQuarter()),this;var e=t instanceof Array?t:arguments;return this.setType(e[0]),this.setHour(e[1]),this.setMinute(e[2]),this.setSecond(e[3]),this.setFrame(e[4]),this.setQuarter(e[5]),this},U.prototype.isFullFrame=function(){return 0==this.quarter||4==this.quarter},U.prototype.getType=function(){return this.type},U.prototype.getHour=function(){return this.hour},U.prototype.getMinute=function(){return this.minute},U.prototype.getSecond=function(){return this.second},U.prototype.getFrame=function(){return this.frame},U.prototype.getQuarter=function(){return this.quarter},U.prototype.setType=function(t){if(void 0===t||24==t)this.type=24;else if(25==t)this.type=25;else if(29.97==t)this.type=29.97,K.apply(this);else{if(30!=t)throw RangeError("Bad SMPTE frame rate: "+t);this.type=30}return this.frame>=this.type&&(this.frame=29.97==this.type?29:this.type-1),this},U.prototype.setHour=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||t>=24)throw RangeError("Bad SMPTE hours value: "+t);return this.hour=t,this},U.prototype.setMinute=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||t>=60)throw RangeError("Bad SMPTE minutes value: "+t);return this.minute=t,K.apply(this),this},U.prototype.setSecond=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||t>=60)throw RangeError("Bad SMPTE seconds value: "+t);return this.second=t,K.apply(this),this},U.prototype.setFrame=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||t>=this.type)throw RangeError("Bad SMPTE frame number: "+t);return this.frame=t,K.apply(this),this},U.prototype.setQuarter=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||t>=8)throw RangeError("Bad SMPTE quarter frame: "+t);return this.quarter=t,this},U.prototype.incrFrame=function(){return this.frame++,this.frame>=this.type&&(this.frame=0,++this.second>=60&&(this.second=0,++this.minute>=60&&(this.minute=0,this.hour=this.hour>=23?0:this.hour+1))),K.apply(this),this},U.prototype.decrFrame=function(){return!this.second&&2==this.frame&&29.97==this.type&&this.minute%10&&(this.frame=0),this.frame--,this.frame<0&&(this.frame=29.97==this.type?29:this.type-1,--this.second<0&&(this.second=59,--this.minute<0&&(this.minute=59,this.hour=this.hour?this.hour-1:23))),this},U.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},U.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},U.prototype.read=function(t){if(t instanceof et||(t=et.apply(null,arguments)),240==t[0]&&127==t[1]&&1==t[3]&&1==t[4]&&247==t[9])return this.type=[24,25,29.97,30][t[5]>>5&3],this.hour=31&t[5],this.minute=t[6],this.second=t[7],this.frame=t[8],this.quarter=0,this._=void 0,this._b=void 0,this._f=void 0,!0;if(241==t[0]&&void 0!==t[1]){var e=t[1]>>4,n=15&t[1];return 0==e?7==this._&&(7==this._f&&(this.reset(X(this._a)),this.incrFrame()),this.incrFrame()):3==e?4==this._&&this.decrFrame():4==e?3==this._&&this.incrFrame():7==e&&0===this._&&(0===this._b&&(this.reset(X(this._a)),this.decrFrame()),this.decrFrame()),this._a||(this._a=[]),this._a[e]=n,this._f=this._f===e-1||0==e?e:void 0,this._b=this._b===e+1||7==e?e:void 0,this._=e,this.quarter=e,!0}return!1},U.prototype.toString=function(){return[tt(this.hour),tt(this.minute),tt(this.second),tt(this.frame)].join(":")},Lt.SMPTE=U,et.prototype=[],et.prototype.constructor=et;var kt={};et.noteValue=function(t){return void 0===t?void 0:kt[t.toString().toLowerCase()]},et.programValue=function(t){return t},et.freq=function(t,e){return void 0===e&&(e=440),e*Math.pow(2,(ot(et.noteValue(t),t)-69)/12)};var zt={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(bt in zt)if(zt.hasOwnProperty(bt))for(Ot=0;Ot<12&&!((St=zt[bt]+12*Ot)>127);Ot++)kt[bt+Ot]=St,St>0&&(kt[bt+"b"+Ot]=St-1,kt[bt+"bb"+Ot]=St-2),St<127&&(kt[bt+"#"+Ot]=St+1,kt[bt+"##"+Ot]=St+2);for(Ot=0;Ot<128;Ot++)kt[Ot]=Ot;var Ft={noteOff:function(t,e,n){return void 0===n&&(n=64),[128+it(t),ot(et.noteValue(e),e),ot(n)]},noteOn:function(t,e,n){return void 0===n&&(n=127),
[144+it(t),ot(et.noteValue(e),e),ot(n)]},aftertouch:function(t,e,n){return[160+it(t),ot(et.noteValue(e),e),ot(n)]},control:function(t,e,n){return[176+it(t),ot(e),ot(n)]},program:function(t,e){return[192+it(t),ot(et.programValue(e),e)]},pressure:function(t,e){return[208+it(t),ot(e)]},pitchBend:function(t,e){return[224+it(t),rt(e),st(e)]},bankMSB:function(t,e){return[176+it(t),0,ot(e)]},bankLSB:function(t,e){return[176+it(t),32,ot(e)]},modMSB:function(t,e){return[176+it(t),1,ot(e)]},modLSB:function(t,e){return[176+it(t),33,ot(e)]},breathMSB:function(t,e){return[176+it(t),2,ot(e)]},breathLSB:function(t,e){return[176+it(t),34,ot(e)]},footMSB:function(t,e){return[176+it(t),4,ot(e)]},footLSB:function(t,e){return[176+it(t),36,ot(e)]},portamentoMSB:function(t,e){return[176+it(t),5,ot(e)]},portamentoLSB:function(t,e){return[176+it(t),37,ot(e)]},volumeMSB:function(t,e){return[176+it(t),7,ot(e)]},volumeLSB:function(t,e){return[176+it(t),39,ot(e)]},balanceMSB:function(t,e){return[176+it(t),8,ot(e)]},balanceLSB:function(t,e){return[176+it(t),40,ot(e)]},panMSB:function(t,e){return[176+it(t),10,ot(e)]},panLSB:function(t,e){return[176+it(t),42,ot(e)]},expressionMSB:function(t,e){return[176+it(t),11,ot(e)]},expressionLSB:function(t,e){return[176+it(t),43,ot(e)]},damper:function(t,e){return[176+it(t),64,e?127:0]},portamento:function(t,e){return[176+it(t),65,e?127:0]},sostenuto:function(t,e){return[176+it(t),66,e?127:0]},soft:function(t,e){return[176+it(t),67,e?127:0]},allSoundOff:function(t){return[176+it(t),120,0]},allNotesOff:function(t){return[176+it(t),123,0]}},Tt={mtc:function(t){return[241,Y(t)]},songPosition:function(t){return[242,rt(t),st(t)]},songSelect:function(t){return[243,ot(t)]},tune:function(){return[246]},clock:function(){return[248]},start:function(){return[250]},continue:function(){return[251]},stop:function(){return[252]},active:function(){return[254]},sxIdRequest:function(){return[240,126,127,6,1,247]},sxFullFrame:function(t){return[240,127,127,1,1,$(t),t.getMinute(),t.getSecond(),t.getFrame(),247]},reset:function(){return[255]}};for(bt in Tt)Tt.hasOwnProperty(bt)&&at(bt,Tt[bt]);for(bt in Ft)Ft.hasOwnProperty(bt)&&at(bt,Ft[bt]);E.prototype.noteOn=function(t,e){var n=et.noteOn(this._master,t,e);return n._mpe=n[1],this.send(n),this},E.prototype.noteOff=function(t,e){var n=et.noteOff(this._master,t,e);return n._mpe=n[1],this.send(n),this},E.prototype.aftertouch=function(t,e){return this.send(et.aftertouch(this._master,t,e)),this};var jt={a:10,b:11,c:12,d:13,e:14,f:15,A:10,B:11,C:12,D:13,E:14,F:15};for(bt=0;bt<16;bt++)jt[bt]=bt;et.prototype.getChannel=function(){var t=this[0];if(!(void 0===t||t<128||t>239))return 15&t},et.prototype.setChannel=function(t){var e=this[0];return void 0===e||e<128||e>239?this:(t=jt[t],void 0!==t&&(this[0]=240&e|t),this)},et.prototype.getNote=function(){var t=this[0];if(!(void 0===t||t<128||t>175))return this[1]},et.prototype.setNote=function(t){var e=this[0];return void 0===e||e<128||e>175?this:(t=et.noteValue(t),void 0!==t&&(this[1]=t),this)},et.prototype.getVelocity=function(){var t=this[0];if(!(void 0===t||t<144||t>159))return this[2]},et.prototype.setVelocity=function(t){var e=this[0];return void 0===e||e<144||e>159?this:(t=parseInt(t),t>=0&&t<128&&(this[2]=t),this)},et.prototype.getSysExChannel=function(){if(240==this[0])return this[2]},et.prototype.setSysExChannel=function(t){return 240==this[0]&&this.length>2&&(t=parseInt(t))>=0&&t<128&&(this[2]=t),this},et.prototype.isNoteOn=function(){var t=this[0];return!(void 0===t||t<144||t>159)&&this[2]>0},et.prototype.isNoteOff=function(){var t=this[0];return!(void 0===t||t<128||t>159)&&(t<144||0==this[2])},et.prototype.isSysEx=function(){return 240==this[0]},et.prototype.isFullSysEx=function(){return 240==this[0]&&247==this[this.length-1]},et.prototype.toString=function(){if(!this.length)return"empty";var t=ht(this);if(this[0]<128)return t;var e={241:"MIDI Time Code",242:"Song Position",243:"Song Select",244:"Undefined",245:"Undefined",246:"Tune request",248:"Timing clock",249:"Undefined",250:"Start",251:"Continue",252:"Stop",253:"Undefined",254:"Active Sensing",255:"Reset"}[this[0]];if(e)return t+" -- "+e;var n=this[0]>>4;return(e={8:"Note Off",10:"Aftertouch",12:"Program Change",13:"Channel Aftertouch",14:"Pitch Wheel"}[n])?t+" -- "+e:9==n?t+" -- "+(this[2]?"Note On":"Note Off"):11!=n?t:(e={0:"Bank Select MSB",1:"Modulation Wheel MSB",2:"Breath Controller MSB",4:"Foot Controller MSB",5:"Portamento Time MSB",6:"Data Entry MSB",7:"Channel Volume MSB",8:"Balance MSB",10:"Pan MSB",11:"Expression Controller MSB",12:"Effect Control 1 MSB",13:"Effect Control 2 MSB",16:"General Purpose Controller 1 MSB",17:"General Purpose Controller 2 MSB",18:"General Purpose Controller 3 MSB",19:"General Purpose Controller 4 MSB",32:"Bank Select LSB",33:"Modulation Wheel LSB",34:"Breath Controller LSB",36:"Foot Controller LSB",37:"Portamento Time LSB",38:"Data Entry LSB",39:"Channel Volume LSB",40:"Balance LSB",42:"Pan LSB",43:"Expression Controller LSB",44:"Effect control 1 LSB",45:"Effect control 2 LSB",48:"General Purpose Controller 1 LSB",49:"General Purpose Controller 2 LSB",50:"General Purpose Controller 3 LSB",51:"General Purpose Controller 4 LSB",64:"Damper Pedal On/Off",65:"Portamento On/Off",66:"Sostenuto On/Off",67:"Soft Pedal On/Off",68:"Legato Footswitch",69:"Hold 2",70:"Sound Controller 1",71:"Sound Controller 2",72:"Sound Controller 3",73:"Sound Controller 4",74:"Sound Controller 5",75:"Sound Controller 6",76:"Sound Controller 7",77:"Sound Controller 8",78:"Sound Controller 9",79:"Sound Controller 10",80:"General Purpose Controller 5",81:"General Purpose Controller 6",82:"General Purpose Controller 7",83:"General Purpose Controller 8",84:"Portamento Control",88:"High Resolution Velocity Prefix",91:"Effects 1 Depth",92:"Effects 2 Depth",93:"Effects 3 Depth",94:"Effects 4 Depth",95:"Effects 5 Depth",96:"Data Increment",97:"Data Decrement",98:"Non-Registered Parameter Number LSB",99:"Non-Registered Parameter Number MSB",100:"Registered Parameter Number LSB",101:"Registered Parameter Number MSB",120:"All Sound Off",121:"Reset All Controllers",122:"Local Control On/Off",123:"All Notes Off",124:"Omni Mode Off",125:"Omni Mode On",126:"Mono Mode On",127:"Poly Mode On"}[this[1]],e||(e="Undefined"),t+" -- "+e)},et.prototype._stamp=function(t){return this._from.push(t._orig?t._orig:t),this},et.prototype._unstamp=function(t){if(void 0===t)this._from=[];else{t._orig&&(t=t._orig);var e=this._from.indexOf(t);e>-1&&this._from.splice(e,1)}return this},et.prototype._stamped=function(t){t._orig&&(t=t._orig);for(var e=0;e<this._from.length;e++)if(this._from[e]==t)return!0;return!1},Lt.MIDI=et,ct.validate=function(t){var e=t instanceof Array?t:arguments;if(e[0]!=parseInt(e[0])||e[0]<0||e[0]>14)throw RangeError("Bad master channel value: "+e[0]);if(e[1]!=parseInt(e[1])||e[1]<0||e[0]+e[1]>15)throw RangeError("Bad zone size value: "+e[1])},ct.prototype.reset=function(){for(var t=0;t<16;t++)this[t]={band:0,master:t}},ct.prototype.setup=function(t,e){ct.validate(t,e);var n,i=t+e;if((this[t].master!=t||this[t].band!=e)&&(e||this[t].band)){for(this[t].band?(n=t+this[t].band,i<n&&(i=n)):this[t].master==t-1?(n=t-1,n+=this[n].band,i<n&&(i=n),this[t-1]={band:0,master:t-1}):this[t].master!=t&&(n=this[t].master,n+=this[n].band,i<n&&(i=n),this[this[t].master].band=t-this[t].master-1),this[t].master=t,this[t].band=e,n=t+1;n<=t+e;n++)this[n].band&&i<n+this[n].band&&(i=n+this[n].band),this[n]={band:0,master:t};for(;n<=i;n++)this[n]={band:0,master:n}}},ct.prototype.filter=function(t){var e=t.getChannel();if(!this[e]||!this[this[e].master].band)return t;var n,i,o,r=this[e].master,s=this[r].band;if(void 0!==t._mpe){for(o=256,n=r+1;n<=r+s;n++)if(this[n].notes){for(o>this[n].notes.length&&(e=n,o=this[n].notes.length),i=0;i<this[n].notes.length;i++)if(this[n].notes[i]==t._mpe){e=n,o=-1;break}}else o>0&&(e=n,o=0);t.setChannel(e),t._mpe=void 0}return e==r?t:(t.isNoteOn()?(this[e].notes||(this[e].notes=[]),a(this[e].notes,t.getNote())):t.isNoteOff()&&this[e].notes&&h(this[e].notes,t.getNote()),t)},Lt.MPE=ct,Lt.lib={},Lt.lib.openMidiOut=function(t,e){var n=new w;return e._openOut(n,t),n},Lt.lib.openMidiIn=function(t,e){var n=new w;return e._openIn(n,t),n},Lt.lib.registerMidiOut=function(t,e){for(var n=e._info(t),i=0;i<Dt._outs.length;i++)if(Dt._outs[i].name==n.name)return!1;return n.engine=e,Dt._outs.push(n),Pt&&Pt._bad&&(Pt._repair(),Pt._resume()),!0},Lt.lib.registerMidiIn=function(t,e){for(var n=e._info(t),i=0;i<Dt._ins.length;i++)if(Dt._ins[i].name==n.name)return!1;return n.engine=e,Dt._ins.push(n),Pt&&Pt._bad&&(Pt._repair(),Pt._resume()),!0};var Wt;Lt.lib.getAudioContext=function(){return pt(),Wt};var Nt,Rt,Vt=[],Gt={},Zt={},Jt={},Ht={},Qt=It.Promise;"function"!=typeof Qt&&(Qt=function(t){this.executor=t},Qt.prototype.then=function(t,e){"function"!=typeof t&&(t=function(){}),"function"!=typeof e&&(e=function(){}),this.executor(t,e)});var Ut=It.Map;return"function"!=typeof Ut&&(Ut=function(){this.store={},this.keys=[]},Ut.prototype.set=function(t,e){return void 0===this.store[t]&&this.keys.push(t),this.store[t]=e,this.size=this.keys.length,this},Ut.prototype.get=function(t){return this.store[t]},Ut.prototype.delete=function(t){delete this.store[t];var e=this.keys.indexOf(t);return e>-1&&this.keys.splice(e,1),this.size=this.keys.length,this},Ut.prototype.forEach=function(t){var e,n,i=this.keys.length;for(e=0;e<i;e++)n=this.store[this.keys[e]],t(n)}),dt.prototype.onstatechange=function(){},gt.prototype.open=function(){var t=this;return new Qt(function(e,n){Jt[t.name]?e(t):(t._resolves||(t._resolves=[]),t._resolves.push(e),1==t._resolves.length&&Lt().openMidiOut(t.name).or(n).and(function(){Jt[t.name]=this,t.state="connected",t.connection="open";for(var n=0;n<t._resolves.length;n++)e(t._resolves[n]);delete t._resolves,t.onstatechange&&t.onstatechange(new mt(t,t))}))})},gt.prototype.close=function(){var t=Jt[this.name];return t&&(t.close(),this.state="disconnected",this.connection="closed",this.onstatechange&&this.onstatechange(new mt(this,this)),Jt[this.name]=void 0),this},gt.prototype.clear=function(){},gt.prototype.send=function(t,e){var n=Jt[this.name];if(n){for(var i=[],o=0;o<t.length;o++){if(!(t[o]==Math.floor(t[o])&&t[o]>=0&&t[o]<=255))return;i.push(t[o])}e>At()?setTimeout(function(){n.send(i)},e-At()):n.send(i)}else{var r=this;r.open().then(function(){r.send(t,e)},ft)}},yt.prototype.onmidimessage=function(){},yt.prototype.open=function(){var t=this;return new Qt(function(e,n){Ht[t.name]?e(t):(t._resolves||(t._resolves=[]),t._resolves.push(e),1==t._resolves.length&&Lt().openMidiIn(t.name).or(n).and(function(){Ht[t.name]=this,t.state="connected",t.connection="open",this.connect(function(e){t.onmidimessage(new vt(t,new Uint8Array(e)))});for(var n=0;n<t._resolves.length;n++)e(t._resolves[n]);delete t._resolves,t.onstatechange&&t.onstatechange(new mt(t,t))}))})},yt.prototype.close=function(){var t=Ht[this.name];return t&&(t.close(),this.state="disconnected",this.connection="closed",this.onstatechange&&this.onstatechange(new mt(this,this)),Ht[this.name]=void 0),this.onmidimessage=yt.prototype.onmidimessage,this},Lt.requestMIDIAccess=function(){function t(){Nt=n;for(var t=0;t<Vt.length;t++)Vt[t](Nt)}function e(){--i||t()}var n,i;return new Qt(function(o,r){Nt?o(Nt):(Vt.push(o),1==Vt.length&&(n=new dt,Lt().or(t).and(function(){var t=this.info();i=t.inputs.length+t.outputs.length;var o,r;for(o=0;o<t.outputs.length;o++)r=new gt(t.outputs[o]),n.outputs.set(r.id,r),r.open().then(e,e);for(o=0;o<t.inputs.length;o++)r=new yt(t.inputs[o]),n.inputs.set(r.id,r),r.open().then(e,e)})))})},"undefined"==typeof navigator||navigator.requestMIDIAccess||(navigator.requestMIDIAccess=Lt.requestMIDIAccess),Lt.close=function(){qt._close&&qt._close()},Lt});
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"jazz-midi":3}],5:[function(require,module,exports){
function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}function cleanUpNextTick(){d