diff --git a/README.md b/README.md index 7aa9628..a69aebc 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ by running `npm remove midi-test --save-dev`. ```html // the latest version, or - // any particular version + // any particular version //... ``` @@ -75,7 +75,7 @@ by running `npm remove midi-test --save-dev`. ```html // the latest version, or - // any particular version + // any particular version //... ``` diff --git a/javascript/JZZ.js b/javascript/JZZ.js index 6b26b9b..c3f16c4 100644 --- a/javascript/JZZ.js +++ b/javascript/JZZ.js @@ -14,7 +14,7 @@ })(this, function() { var _scope = typeof window === 'undefined' ? global : window; - var _version = '1.1.8'; + var _version = '1.1.9'; var i, j, k, m, n; var _time = Date.now || function () { return new Date().getTime(); }; @@ -1614,6 +1614,7 @@ sostenuto: function(c, b) { if (typeof b == 'undefined') b = true; return [0xB0 + _ch(c), 0x42, b ? 127 : 0]; }, soft: function(c, b) { if (typeof b == 'undefined') b = true; return [0xB0 + _ch(c), 0x43, b ? 127 : 0]; }, legato: function(c, b) { if (typeof b == 'undefined') b = true; return [0xB0 + _ch(c), 0x44, b ? 127 : 0]; }, + ptc: function(c, n) { return [0xB0 + _ch(c), 0x54, _7b(MIDI.noteValue(n), n)]; }, dataIncr: function(c) { return [0xB0 + _ch(c), 0x60, 0]; }, dataDecr: function(c) { return [0xB0 + _ch(c), 0x61, 0]; }, nrpnLSB: function(c, n) { return [0xB0 + _ch(c), 0x62, _7b(n)]; }, @@ -1625,7 +1626,7 @@ localControl: function(c, b) { return [0xB0 + _ch(c), 0x7a, b ? 127 : 0]; }, allNotesOff: function(c) { return [0xB0 + _ch(c), 0x7b, 0]; }, omni: function(c, b) { if (typeof b == 'undefined') b = true; return [0xB0 + _ch(c), b ? 0x7d : 0x7c, 0]; }, - mono: function(c, n) { if (!n) n = 0; return [0xB0 + _ch(c), 0x7e, _7b(n)]; }, + mono: function(c, n) { if (typeof n == 'undefined') n = 1; return [0xB0 + _ch(c), 0x7e, _7b(n)]; }, poly: function(c) { return [0xB0 + _ch(c), 0x7f, 0]; }, }; var _helperNC = { // no channel diff --git a/minified/JZZ.js b/minified/JZZ.js index 1de49aa..585b7ec 100644 --- a/minified/JZZ.js +++ b/minified/JZZ.js @@ -1 +1 @@ -!function(t,n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define("JZZ",[],n);else{if((t=t||window).JZZ&&t.JZZ.MIDI)return;t.JZZ=n()}}(this,function(){var o,r,t,i,n="undefined"==typeof window?global:window,e="1.1.8",s=Date.now||function(){return(new Date).getTime()},u=s(),a="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return s()-u},h=function(t){setTimeout(t,0)};function c(){(this._orig=this)._ready=!1,this._queue=[],this._log=[]}function f(t,n){this._bad?n instanceof Function&&n.apply(this,[new Error(this._err())]):t instanceof Function&&t.apply(this,[this])}function p(t,n){this._bad?t._crash(this._err()):setTimeout(function(){t._resume()},n)}function l(t){this._bad&&t._break(this._err()),t._resume()}function d(t,e,r){t[r]=function(){var t=arguments,n=e._image();return this._push(l,[n]),n[r].apply(n,t)}}function _(t){this._bad||(t instanceof Function?t.apply(this):console.log(t))}function m(t){this._bad&&(t instanceof Function?t.apply(this):console.log(t))}function g(t){this._bad?t._crash(this._err()):(this._break("Closed"),t._resume())}function v(t){if(t.length){var n,e=t.shift();t.length&&(n=this)._slip(m,[function(){v.apply(n,[t])}]);try{this._repair(),e.apply(this)}catch(t){this._break(t.toString())}}else this._break()}function y(t,n){for(var e=0;e>1&3],(1&t[7])<<4|t[6],t[5]<<4|t[4],t[3]<<4|t[2],t[1]<<4|t[0]]}function ht(t){for(var n,e=[],r=0;r=this.type&&(this.frame=this.type-1),this},st.prototype.setHour=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||24<=t)throw RangeError("Bad SMPTE hours value: "+t);return this.hour=t,this},st.prototype.setMinute=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE minutes value: "+t);return this.minute=t,ut.apply(this),this},st.prototype.setSecond=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE seconds value: "+t);return this.second=t,ut.apply(this),this},st.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,ut.apply(this),this},st.prototype.setQuarter=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||8<=t)throw RangeError("Bad SMPTE quarter frame: "+t);return this.quarter=t,this},st.prototype.incrFrame=function(){return this.frame++,this.frame>=this.type&&(this.frame=0,this.second++,60<=this.second&&(this.second=0,this.minute++,60<=this.minute&&(this.minute=0,this.hour=23<=this.hour?0:this.hour+1))),ut.apply(this),this},st.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--,this.second<0&&(this.second=59,this.minute--,this.minute<0&&(this.minute=59,this.hour=this.hour?this.hour-1:23))),this},st.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},st.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},st.prototype.read=function(t){if(t instanceof ct||(t=ct.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);if(241!=t[0]||void 0===t[1])return!1;var n=t[1]>>4,e=15&t[1];return 0==n?7==this._&&(7==this._f&&(this.reset(at(this._a)),this.incrFrame()),this.incrFrame()):3==n?4==this._&&this.decrFrame():4==n?3==this._&&this.incrFrame():7==n&&0===this._&&(0===this._b&&(this.reset(at(this._a)),this.decrFrame()),this.decrFrame()),this._a||(this._a=[]),this._a[n]=e,this._f=this._f===n-1||0==n?n:void 0,this._b=this._b===1+n||7==n?n:void 0,this._=n,this.quarter=n,!0},st.prototype.toString=function(){return ht([this.hour,this.minute,this.second,this.frame])},ot.SMPTE=st,ct.prototype=[],ct.prototype.constructor=ct;var ft={};function pt(){}ct.noteValue=function(t){return void 0===t?void 0:ft[t.toString().toLowerCase()]},ct.programValue=function(t){return t},ct.freq=function(t,n){return void 0===n&&(n=440),n*Math.pow(2,(mt(ct.noteValue(t),t)-69)/12)},ct.shift=function(t,n){return void 0===n&&(n=440),12*Math.log2(t/n)},ct.to14b=function(t){return t<=0?0:1<=t?16383:Math.floor(16384*t)},(pt.prototype=ct)._sxid=127,ct.sxId=function(t){if(void 0===t&&(t=ct._sxid),t==this._sxid)return this;t=mt(t);var n=new pt;return n._ch=this._ch,n._sxid=t,n},ct.ch=function(t){if(t==this._ch||void 0===t&&void 0===this._ch)return this;var n=new pt;return void 0!==t&&(t=_t(t)),n._ch=t,n._sxid=this._sxid,n};var lt={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(Pt in lt)if(lt.hasOwnProperty(Pt))for(i=0;i<12&&!(127<(t=lt[Pt]+12*i));i++)0<(ft[Pt+i]=t)&&(ft[Pt+"b"+i]=t-1,ft[Pt+"bb"+i]=t-2),t<127&&(ft[Pt+"#"+i]=t+1,ft[Pt+"##"+i]=t+2);for(i=0;i<128;i++)ft[i]=i;function dt(t){throw RangeError("Bad MIDI value: "+t)}function _t(t){return N(t),parseInt(t)}function mt(t,n){return(t!=parseInt(t)||t<0||127>7}var bt={noteOff:function(t,n,e){return void 0===e&&(e=64),[128+_t(t),mt(ct.noteValue(n),n),mt(e)]},noteOn:function(t,n,e){return void 0===e&&(e=127),[144+_t(t),mt(ct.noteValue(n),n),mt(e)]},aftertouch:function(t,n,e){return[160+_t(t),mt(ct.noteValue(n),n),mt(e)]}},St={control:function(t,n,e){return[176+_t(t),mt(n),mt(e)]},program:function(t,n){return[192+_t(t),mt(ct.programValue(n),n)]},pressure:function(t,n){return[208+_t(t),mt(n)]},pitchBend:function(t,n,e){return void 0===e?[224+_t(t),vt(n),yt(n)]:[224+_t(t),mt(e),mt(n)]},pitchBendF:function(t,n){return St.pitchBend(t,ct.to14b((n+1)/2))},bankMSB:function(t,n){return[176+_t(t),0,mt(n)]},bankLSB:function(t,n){return[176+_t(t),32,mt(n)]},modMSB:function(t,n){return[176+_t(t),1,mt(n)]},modLSB:function(t,n){return[176+_t(t),33,mt(n)]},breathMSB:function(t,n){return[176+_t(t),2,mt(n)]},breathLSB:function(t,n){return[176+_t(t),34,mt(n)]},footMSB:function(t,n){return[176+_t(t),4,mt(n)]},footLSB:function(t,n){return[176+_t(t),36,mt(n)]},portamentoMSB:function(t,n){return[176+_t(t),5,mt(n)]},portamentoLSB:function(t,n){return[176+_t(t),37,mt(n)]},dataMSB:function(t,n){return[176+_t(t),6,mt(n)]},dataLSB:function(t,n){return[176+_t(t),38,mt(n)]},volumeMSB:function(t,n){return[176+_t(t),7,mt(n)]},volumeLSB:function(t,n){return[176+_t(t),39,mt(n)]},balanceMSB:function(t,n){return[176+_t(t),8,mt(n)]},balanceLSB:function(t,n){return[176+_t(t),40,mt(n)]},panMSB:function(t,n){return[176+_t(t),10,mt(n)]},panLSB:function(t,n){return[176+_t(t),42,mt(n)]},expressionMSB:function(t,n){return[176+_t(t),11,mt(n)]},expressionLSB:function(t,n){return[176+_t(t),43,mt(n)]},damper:function(t,n){return[176+_t(t),64,n?127:0]},portamento:function(t,n){return[176+_t(t),65,n?127:0]},sostenuto:function(t,n){return[176+_t(t),66,n?127:0]},soft:function(t,n){return[176+_t(t),67,n?127:0]},dataIncr:function(t){return[176+_t(t),96,0]},dataDecr:function(t){return[176+_t(t),97,0]},nrpnLSB:function(t,n){return[176+_t(t),98,mt(n)]},nrpnMSB:function(t,n){return[176+_t(t),99,mt(n)]},rpnLSB:function(t,n){return[176+_t(t),100,mt(n)]},rpnMSB:function(t,n){return[176+_t(t),101,mt(n)]},allSoundOff:function(t){return[176+_t(t),120,0]},allNotesOff:function(t){return[176+_t(t),123,0]}},Ct={mtc:function(t){return[241,function(t){var n;switch(!t.backwards&&4<=t.quarter?t.decrFrame():t.backwards&&t.quarter<4&&t.incrFrame(),t.quarter>>1){case 0:n=t.frame;break;case 1:n=t.second;break;case 2:n=t.minute;break;default:n=t.hour}return 1&t.quarter?n>>=4:n&=15,7==t.quarter&&(25==t.type?n|=2:29.97==t.type?n|=4:30==t.type&&(n|=6)),!t.backwards&&4<=t.quarter?t.incrFrame():t.backwards&&t.quarter<4&&t.decrFrame(),n|t.quarter<<4}(t)]},songPosition:function(t,n){return void 0===n?[242,vt(t),yt(t)]:[242,mt(n),mt(t)]},songSelect:function(t){return[243,mt(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,this._sxid,6,1,247]},sxFullFrame:function(t){return[240,127,this._sxid,1,1,25==(n=t).type?32|n.hour:29.97==n.type?64|n.hour:30==n.type?96|n.hour:n.hour,t.getMinute(),t.getSecond(),t.getFrame(),247];var n},sxMasterVolume:function(t){return t=ct.to14b(t),[240,127,this._sxid,4,1,vt(t),yt(t),247]},sxMasterFineTuning:function(t){return t=ct.to14b((t%1+1)/2),[240,127,this._sxid,4,3,vt(t),yt(t),247]},sxMasterCoarseTuning:function(t){return[240,127,this._sxid,4,4,0,64+t-t%1,247]},reset:function(){return[255]}},wt={bank:function(t,n,e){return void 0===e?[St.bankMSB(t,yt(n)),St.bankLSB(t,vt(n))]:[St.bankMSB(t,n),St.bankLSB(t,e)]},modF:function(t,n){return wt.mod(t,ct.to14b(n))},mod:function(t,n,e){return void 0===e?[St.modMSB(t,yt(n)),St.modLSB(t,vt(n))]:[St.modMSB(t,n),St.modLSB(t,e)]},breathF:function(t,n){return wt.breath(t,ct.to14b(n))},breath:function(t,n,e){return void 0===e?[St.breathMSB(t,yt(n)),St.breathLSB(t,vt(n))]:[St.breathMSB(t,n),St.breathLSB(t,e)]},footF:function(t,n){return wt.foot(t,ct.to14b(n))},foot:function(t,n,e){return void 0===e?[St.footMSB(t,yt(n)),St.footLSB(t,vt(n))]:[St.footMSB(t,n),St.footLSB(t,e)]},portamentoTimeF:function(t,n){return wt.portamentoTime(t,ct.to14b(n))},portamentoTime:function(t,n,e){return void 0===e?[St.portamentoMSB(t,yt(n)),St.portamentoLSB(t,vt(n))]:[St.portamentoMSB(t,n),St.portamentoLSB(t,e)]},dataF:function(t,n){return wt.data(t,ct.to14b(n))},data:function(t,n,e){return void 0===e?[St.dataMSB(t,yt(n)),St.dataLSB(t,vt(n))]:[St.dataMSB(t,n),St.dataLSB(t,e)]},volumeF:function(t,n){return wt.volume(t,ct.to14b(n))},volume:function(t,n,e){return void 0===e?[St.volumeMSB(t,yt(n)),St.volumeLSB(t,vt(n))]:[St.volumeMSB(t,n),St.volumeLSB(t,e)]},balanceF:function(t,n){return wt.balance(t,ct.to14b((n+1)/2))},balance:function(t,n,e){return void 0===e?[St.balanceMSB(t,yt(n)),St.balanceLSB(t,vt(n))]:[St.balanceMSB(t,n),St.balanceLSB(t,e)]},panF:function(t,n){return wt.pan(t,ct.to14b((n+1)/2))},pan:function(t,n,e){return void 0===e?[St.panMSB(t,yt(n)),St.panLSB(t,vt(n))]:[St.panMSB(t,n),St.panLSB(t,e)]},expressionF:function(t,n){return wt.expression(t,ct.to14b(n))},expression:function(t,n,e){return void 0===e?[St.expressionMSB(t,yt(n)),St.expressionLSB(t,vt(n))]:[St.expressionMSB(t,n),St.expressionLSB(t,e)]},nrpn:function(t,n,e){return void 0===e?[St.nrpnMSB(t,yt(n)),St.nrpnLSB(t,vt(n))]:[St.nrpnMSB(t,n),St.nrpnLSB(t,e)]},rpn:function(t,n,e){return void 0===e?[St.rpnMSB(t,yt(n)),St.rpnLSB(t,vt(n))]:[St.rpnMSB(t,n),St.rpnLSB(t,e)]},rpnPitchBendRange:function(t,n){return wt.rpn(t,0,0).concat(wt.data(t,mt(n-n%1),Math.floor(n%1*128)))},rpnFineTuning:function(t,n){return wt.rpn(t,0,1).concat(wt.dataF(t,(n%1+1)/2))},rpnCoarseTuning:function(t,n){return wt.rpn(t,0,2).concat([St.dataMSB(t,64+n-n%1)])},rpnTuning:function(t,n){return wt.rpnCoarseTuning(t,n).concat(wt.rpnFineTuning(t,n))},rpnTuningA:function(t,n){return wt.rpnTuning(t,ct.shift(n))}},Mt={sxMasterTuning:function(t){return[Ct.sxMasterCoarseTuning.call(this,t),Ct.sxMasterFineTuning.call(this,t)]},sxMasterTuningA:function(t){return Mt.sxMasterTuning.call(this,ct.shift(t))}};function xt(t,n){var e=new ct;return e.ff=gt(t),e.dd=void 0===n?"":function(t){t=""+t;for(var n=0;n>8)+String.fromCharCode(255&t)}else if(0==(t=""+t).length)t="\0\0";else if(1==t.length)t="\0"+t;else if(2>16)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t));throw RangeError("Out of range: "+kt(Ft(t)))},smfBPM:function(t){return Bt.smfTempo(Math.round(6e7/t))},smfSMPTE:function(t){if(t instanceof st)return xt(84,String.fromCharCode(t.hour)+String.fromCharCode(t.minute)+String.fromCharCode(t.second)+String.fromCharCode(t.frame)+String.fromCharCode(t.quarter%4*25));if(5==(""+t).length)return xt(84,t);var n=t instanceof Array?t:Array.prototype.slice.call(arguments);return n.splice(0,0,30),Bt.smfSMPTE(new st(n))},smfTimeSignature:function(t,n,e,r){var i,o,s,u,a=(""+t).match(/^\s*(\d+)\s*\/\s*(\d+)\s*$/);if(a){if(i=parseInt(a[1]),o=parseInt(a[2]),0>=1;s;s>>=1)o++;return s=n==parseInt(n)?n:24,u=e==parseInt(e)?e:8,xt(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return xt(88,t)}else{if(t==parseInt(t)&&n==parseInt(n)&&n&&!(n&n-1)){for(i=t,o=0,s=n,s>>=1;s;s>>=1)o++;return s=e==parseInt(e)?e:24,u=r==parseInt(r)?r:8,xt(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return xt(88,t)}throw RangeError("Wrong time signature: "+kt(Ft(t)))},smfKeySignature:function(t){var n,e,r=(t=""+t).match(/^\s*([A-H][b#]?)\s*(|maj|major|dur|m|min|minor|moll)\s*$/i);if(r&&(n={CB:0,GB:1,DB:2,AB:3,EB:4,BB:5,F:6,C:7,G:8,D:9,A:10,E:11,B:12,H:12,"F#":13,"C#":14,"G#":15,"D#":16,"A#":17}[r[1].toUpperCase()],e={"":0,MAJ:0,MAJOR:0,DUR:0,M:1,MIN:1,MINOR:1,MOLL:1}[r[2].toUpperCase()],void 0!==n&&void 0!==e&&(e&&(n-=3),-7<=(n-=7)&&n<0?t=String.fromCharCode(256+n)+String.fromCharCode(e):0<=n&&n<=7&&(t=String.fromCharCode(n)+String.fromCharCode(e)))),2==t.length&&t.charCodeAt(1)<=1&&(t.charCodeAt(0)<=7||t.charCodeAt(0)<=255&&249<=t.charCodeAt(0)))return xt(89,t);throw RangeError("Incorrect key signature: "+kt(t))},smfSequencer:function(t){return xt(127,Ft(t))}},It={};for(i in Ct)Ct.hasOwnProperty(i)&&function(t,n){ct[t]=function(){return new ct(n.apply(this,arguments))},It[t]=function(){return this.send(n.apply(this,arguments))}}(i,Ct[i]);for(i in Bt)Bt.hasOwnProperty(i)&&function(t,n){ct[t]=function(){return n.apply(this,arguments)},It[t]=function(){return this.send(n.apply(this,arguments))}}(i,Bt[i]);for(i in Mt)Mt.hasOwnProperty(i)&&function(t,r){ct[t]=function(){for(var t=[],n=r.apply(this,arguments),e=0;e>4;return(r={8:"Note Off",10:"Aftertouch",12:"Program Change",13:"Channel Aftertouch",14:"Pitch Wheel"}[i])?e+" -- "+r:9==i?e+" -- "+(this[2]?"Note On":"Note Off"):11!=i?e:e+" -- "+(r=(r={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]])||"Undefined")},ct.prototype._stamp=function(t){return this._from.push(t._orig?t._orig:t),this},ct.prototype._unstamp=function(t){var n;return void 0===t?this._from=[]:(t._orig&&(t=t._orig),-1<(n=this._from.indexOf(t))&&this._from.splice(n,1)),this},ct.prototype._stamped=function(t){t._orig&&(t=t._orig);for(var n=0;nthis[e].notes.length&&(i=this[n=e].notes.length),r=0;r>4,e=(15&i)<<4|(o=Rt.indexOf(t.charAt(a++)))>>2,r=(3&o)<<6|(s=Rt.indexOf(t.charAt(a++))),u+=String.fromCharCode(n),64!=o&&(u+=String.fromCharCode(e)),64!=s&&(u+=String.fromCharCode(r));return u},ot.lib.toBase64=function(t){var n,e,r,i,o,s=0,u=0,a="",h=[];if(!t)return t;for(;n=(o=t.charCodeAt(s++)<<16|t.charCodeAt(s++)<<8|t.charCodeAt(s++))>>18&63,e=o>>12&63,r=o>>6&63,i=63&o,h[u++]=Rt.charAt(n)+Rt.charAt(e)+Rt.charAt(r)+Rt.charAt(i),s=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;n+=63&e,r+=String.fromCharCode(n)}else if(224==(240&n)){if(n=(15&n)<<12,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(n+=(63&e)<<6,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;n+=63&e,r+=String.fromCharCode(n)}else if(240==(248&n)){if(n=(7&n)<<18,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(n+=(63&e)<<12,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(n+=(63&e)<<6,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(1114111<(n+=63&e))return t;n-=65536,r+=String.fromCharCode(55296+(n>>10)),r+=String.fromCharCode(56320+(1023&n))}}return r},ot.lib.toUTF8=function(t){t=void 0===t?"":""+t;for(var n,e="",r=0;r>6)):(n<65536?e+=String.fromCharCode(224+(n>>12)):(e+=String.fromCharCode(240+(n>>18)),e+=String.fromCharCode(128+(n>>12&63))),e+=String.fromCharCode(128+(n>>6&63))),e+=String.fromCharCode(128+(63&n)));return e};var Nt=[],Ut={},Gt={},Vt=n.Promise;function Zt(t,n,e){this.name=t,this.message=n,this.code=e}function Jt(t,n){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.currentTarget=n,this.defaultPrevented=!1,this.eventPhase=0,this.path=[],this.port=t,this.returnValue=!0,this.srcElement=n,this.target=n,this.timeStamp=a(),this.type="statechange"}function Wt(t,n){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.currentTarget=t,this.data=n,this.defaultPrevented=!1,this.eventPhase=0,this.path=[],this.receivedTime=a(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function Ht(t,n){t&&(t.onstatechange&&t.onstatechange(new Jt(t,t)),n.onstatechange&&n.onstatechange(new Jt(t,n)))}function Qt(e,r){var i=this,o=!1,n=null,s=null;this.type="input",this.id=r.id,this.name=r.name,this.manufacturer=r.man,this.version=r.ver,Object.defineProperty(this,"state",{get:function(){return r.connected?"connected":"disconnected"},enumerable:!0}),Object.defineProperty(this,"connection",{get:function(){return o?r.proxy?"open":"pending":"closed"},enumerable:!0}),Object.defineProperty(this,"onmidimessage",{get:function(){return s},set:function(t){if(t instanceof Function){if(s=t,!o)try{i.open()}catch(t){}}else s=null},enumerable:!0}),Object.defineProperty(this,"onstatechange",{get:function(){return n},set:function(t){n=t instanceof Function?t:null},enumerable:!0}),this.open=function(){return new Vt(function(t,n){o?t(i):r.open().then(function(){o||(o=!0,Ht(i,e)),t(i)},function(){n(new Zt("InvalidAccessError","Port is not available",15))})})},this.close=function(){return new Vt(function(t){o&&(o=!1,r.close(),Ht(i,e)),t(i)})},Object.freeze(this)}function Kt(t){for(var n,e;t.length;){for(n=0;nt.length)return;for(n=1;n>1&3],(1&t[7])<<4|t[6],t[5]<<4|t[4],t[3]<<4|t[2],t[1]<<4|t[0]]}function ht(t){for(var n,e=[],r=0;r=this.type&&(this.frame=this.type-1),this},st.prototype.setHour=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||24<=t)throw RangeError("Bad SMPTE hours value: "+t);return this.hour=t,this},st.prototype.setMinute=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE minutes value: "+t);return this.minute=t,ut.apply(this),this},st.prototype.setSecond=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE seconds value: "+t);return this.second=t,ut.apply(this),this},st.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,ut.apply(this),this},st.prototype.setQuarter=function(t){if(void 0===t&&(t=0),t!=parseInt(t)||t<0||8<=t)throw RangeError("Bad SMPTE quarter frame: "+t);return this.quarter=t,this},st.prototype.incrFrame=function(){return this.frame++,this.frame>=this.type&&(this.frame=0,this.second++,60<=this.second&&(this.second=0,this.minute++,60<=this.minute&&(this.minute=0,this.hour=23<=this.hour?0:this.hour+1))),ut.apply(this),this},st.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--,this.second<0&&(this.second=59,this.minute--,this.minute<0&&(this.minute=59,this.hour=this.hour?this.hour-1:23))),this},st.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},st.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},st.prototype.read=function(t){if(t instanceof ct||(t=ct.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);if(241!=t[0]||void 0===t[1])return!1;var n=t[1]>>4,e=15&t[1];return 0==n?7==this._&&(7==this._f&&(this.reset(at(this._a)),this.incrFrame()),this.incrFrame()):3==n?4==this._&&this.decrFrame():4==n?3==this._&&this.incrFrame():7==n&&0===this._&&(0===this._b&&(this.reset(at(this._a)),this.decrFrame()),this.decrFrame()),this._a||(this._a=[]),this._a[n]=e,this._f=this._f===n-1||0==n?n:void 0,this._b=this._b===1+n||7==n?n:void 0,this._=n,this.quarter=n,!0},st.prototype.toString=function(){return ht([this.hour,this.minute,this.second,this.frame])},ot.SMPTE=st,ct.prototype=[],ct.prototype.constructor=ct;var ft={};function pt(){}ct.noteValue=function(t){return void 0===t?void 0:ft[t.toString().toLowerCase()]},ct.programValue=function(t){return t},ct.freq=function(t,n){return void 0===n&&(n=440),n*Math.pow(2,(mt(ct.noteValue(t),t)-69)/12)},ct.shift=function(t,n){return void 0===n&&(n=440),12*Math.log2(t/n)},ct.to14b=function(t){return t<=0?0:1<=t?16383:Math.floor(16384*t)},(pt.prototype=ct)._sxid=127,ct.sxId=function(t){if(void 0===t&&(t=ct._sxid),t==this._sxid)return this;t=mt(t);var n=new pt;return n._ch=this._ch,n._sxid=t,n},ct.ch=function(t){if(t==this._ch||void 0===t&&void 0===this._ch)return this;var n=new pt;return void 0!==t&&(t=_t(t)),n._ch=t,n._sxid=this._sxid,n};var lt={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(Pt in lt)if(lt.hasOwnProperty(Pt))for(i=0;i<12&&!(127<(t=lt[Pt]+12*i));i++)0<(ft[Pt+i]=t)&&(ft[Pt+"b"+i]=t-1,ft[Pt+"bb"+i]=t-2),t<127&&(ft[Pt+"#"+i]=t+1,ft[Pt+"##"+i]=t+2);for(i=0;i<128;i++)ft[i]=i;function dt(t){throw RangeError("Bad MIDI value: "+t)}function _t(t){return N(t),parseInt(t)}function mt(t,n){return(t!=parseInt(t)||t<0||127>7}var bt={noteOff:function(t,n,e){return void 0===e&&(e=64),[128+_t(t),mt(ct.noteValue(n),n),mt(e)]},noteOn:function(t,n,e){return void 0===e&&(e=127),[144+_t(t),mt(ct.noteValue(n),n),mt(e)]},aftertouch:function(t,n,e){return[160+_t(t),mt(ct.noteValue(n),n),mt(e)]}},St={control:function(t,n,e){return[176+_t(t),mt(n),mt(e)]},program:function(t,n){return[192+_t(t),mt(ct.programValue(n),n)]},pressure:function(t,n){return[208+_t(t),mt(n)]},pitchBend:function(t,n,e){return void 0===e?[224+_t(t),vt(n),yt(n)]:[224+_t(t),mt(e),mt(n)]},pitchBendF:function(t,n){return St.pitchBend(t,ct.to14b((n+1)/2))},bankMSB:function(t,n){return[176+_t(t),0,mt(n)]},bankLSB:function(t,n){return[176+_t(t),32,mt(n)]},modMSB:function(t,n){return[176+_t(t),1,mt(n)]},modLSB:function(t,n){return[176+_t(t),33,mt(n)]},breathMSB:function(t,n){return[176+_t(t),2,mt(n)]},breathLSB:function(t,n){return[176+_t(t),34,mt(n)]},footMSB:function(t,n){return[176+_t(t),4,mt(n)]},footLSB:function(t,n){return[176+_t(t),36,mt(n)]},portamentoMSB:function(t,n){return[176+_t(t),5,mt(n)]},portamentoLSB:function(t,n){return[176+_t(t),37,mt(n)]},dataMSB:function(t,n){return[176+_t(t),6,mt(n)]},dataLSB:function(t,n){return[176+_t(t),38,mt(n)]},volumeMSB:function(t,n){return[176+_t(t),7,mt(n)]},volumeLSB:function(t,n){return[176+_t(t),39,mt(n)]},balanceMSB:function(t,n){return[176+_t(t),8,mt(n)]},balanceLSB:function(t,n){return[176+_t(t),40,mt(n)]},panMSB:function(t,n){return[176+_t(t),10,mt(n)]},panLSB:function(t,n){return[176+_t(t),42,mt(n)]},expressionMSB:function(t,n){return[176+_t(t),11,mt(n)]},expressionLSB:function(t,n){return[176+_t(t),43,mt(n)]},damper:function(t,n){return void 0===n&&(n=!0),[176+_t(t),64,n?127:0]},portamento:function(t,n){return void 0===n&&(n=!0),[176+_t(t),65,n?127:0]},sostenuto:function(t,n){return void 0===n&&(n=!0),[176+_t(t),66,n?127:0]},soft:function(t,n){return void 0===n&&(n=!0),[176+_t(t),67,n?127:0]},legato:function(t,n){return void 0===n&&(n=!0),[176+_t(t),68,n?127:0]},ptc:function(t,n){return[176+_t(t),84,mt(ct.noteValue(n),n)]},dataIncr:function(t){return[176+_t(t),96,0]},dataDecr:function(t){return[176+_t(t),97,0]},nrpnLSB:function(t,n){return[176+_t(t),98,mt(n)]},nrpnMSB:function(t,n){return[176+_t(t),99,mt(n)]},rpnLSB:function(t,n){return[176+_t(t),100,mt(n)]},rpnMSB:function(t,n){return[176+_t(t),101,mt(n)]},allSoundOff:function(t){return[176+_t(t),120,0]},resetAllControllers:function(t){return[176+_t(t),121,0]},localControl:function(t,n){return[176+_t(t),122,n?127:0]},allNotesOff:function(t){return[176+_t(t),123,0]},omni:function(t,n){return void 0===n&&(n=!0),[176+_t(t),n?125:124,0]},mono:function(t,n){return void 0===n&&(n=1),[176+_t(t),126,mt(n)]},poly:function(t){return[176+_t(t),127,0]}},Ct={mtc:function(t){return[241,function(t){var n;switch(!t.backwards&&4<=t.quarter?t.decrFrame():t.backwards&&t.quarter<4&&t.incrFrame(),t.quarter>>1){case 0:n=t.frame;break;case 1:n=t.second;break;case 2:n=t.minute;break;default:n=t.hour}return 1&t.quarter?n>>=4:n&=15,7==t.quarter&&(25==t.type?n|=2:29.97==t.type?n|=4:30==t.type&&(n|=6)),!t.backwards&&4<=t.quarter?t.incrFrame():t.backwards&&t.quarter<4&&t.decrFrame(),n|t.quarter<<4}(t)]},songPosition:function(t,n){return void 0===n?[242,vt(t),yt(t)]:[242,mt(n),mt(t)]},songSelect:function(t){return[243,mt(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,this._sxid,6,1,247]},sxFullFrame:function(t){return[240,127,this._sxid,1,1,25==(n=t).type?32|n.hour:29.97==n.type?64|n.hour:30==n.type?96|n.hour:n.hour,t.getMinute(),t.getSecond(),t.getFrame(),247];var n},sxMasterVolume:function(t){return t=ct.to14b(t),[240,127,this._sxid,4,1,vt(t),yt(t),247]},sxMasterFineTuning:function(t){return t=ct.to14b((t%1+1)/2),[240,127,this._sxid,4,3,vt(t),yt(t),247]},sxMasterCoarseTuning:function(t){return[240,127,this._sxid,4,4,0,64+t-t%1,247]},reset:function(){return[255]}},wt={bank:function(t,n,e){return void 0===e?[St.bankMSB(t,yt(n)),St.bankLSB(t,vt(n))]:[St.bankMSB(t,n),St.bankLSB(t,e)]},modF:function(t,n){return wt.mod(t,ct.to14b(n))},mod:function(t,n,e){return void 0===e?[St.modMSB(t,yt(n)),St.modLSB(t,vt(n))]:[St.modMSB(t,n),St.modLSB(t,e)]},breathF:function(t,n){return wt.breath(t,ct.to14b(n))},breath:function(t,n,e){return void 0===e?[St.breathMSB(t,yt(n)),St.breathLSB(t,vt(n))]:[St.breathMSB(t,n),St.breathLSB(t,e)]},footF:function(t,n){return wt.foot(t,ct.to14b(n))},foot:function(t,n,e){return void 0===e?[St.footMSB(t,yt(n)),St.footLSB(t,vt(n))]:[St.footMSB(t,n),St.footLSB(t,e)]},portamentoTimeF:function(t,n){return wt.portamentoTime(t,ct.to14b(n))},portamentoTime:function(t,n,e){return void 0===e?[St.portamentoMSB(t,yt(n)),St.portamentoLSB(t,vt(n))]:[St.portamentoMSB(t,n),St.portamentoLSB(t,e)]},dataF:function(t,n){return wt.data(t,ct.to14b(n))},data:function(t,n,e){return void 0===e?[St.dataMSB(t,yt(n)),St.dataLSB(t,vt(n))]:[St.dataMSB(t,n),St.dataLSB(t,e)]},volumeF:function(t,n){return wt.volume(t,ct.to14b(n))},volume:function(t,n,e){return void 0===e?[St.volumeMSB(t,yt(n)),St.volumeLSB(t,vt(n))]:[St.volumeMSB(t,n),St.volumeLSB(t,e)]},balanceF:function(t,n){return wt.balance(t,ct.to14b((n+1)/2))},balance:function(t,n,e){return void 0===e?[St.balanceMSB(t,yt(n)),St.balanceLSB(t,vt(n))]:[St.balanceMSB(t,n),St.balanceLSB(t,e)]},panF:function(t,n){return wt.pan(t,ct.to14b((n+1)/2))},pan:function(t,n,e){return void 0===e?[St.panMSB(t,yt(n)),St.panLSB(t,vt(n))]:[St.panMSB(t,n),St.panLSB(t,e)]},expressionF:function(t,n){return wt.expression(t,ct.to14b(n))},expression:function(t,n,e){return void 0===e?[St.expressionMSB(t,yt(n)),St.expressionLSB(t,vt(n))]:[St.expressionMSB(t,n),St.expressionLSB(t,e)]},nrpn:function(t,n,e){return void 0===e?[St.nrpnMSB(t,yt(n)),St.nrpnLSB(t,vt(n))]:[St.nrpnMSB(t,n),St.nrpnLSB(t,e)]},rpn:function(t,n,e){return void 0===e?[St.rpnMSB(t,yt(n)),St.rpnLSB(t,vt(n))]:[St.rpnMSB(t,n),St.rpnLSB(t,e)]},rpnPitchBendRange:function(t,n){return wt.rpn(t,0,0).concat(wt.data(t,mt(n-n%1),Math.floor(n%1*128)))},rpnFineTuning:function(t,n){return wt.rpn(t,0,1).concat(wt.dataF(t,(n%1+1)/2))},rpnCoarseTuning:function(t,n){return wt.rpn(t,0,2).concat([St.dataMSB(t,64+n-n%1)])},rpnTuning:function(t,n){return wt.rpnCoarseTuning(t,n).concat(wt.rpnFineTuning(t,n))},rpnTuningA:function(t,n){return wt.rpnTuning(t,ct.shift(n))}},Mt={sxMasterTuning:function(t){return[Ct.sxMasterCoarseTuning.call(this,t),Ct.sxMasterFineTuning.call(this,t)]},sxMasterTuningA:function(t){return Mt.sxMasterTuning.call(this,ct.shift(t))}};function xt(t,n){var e=new ct;return e.ff=gt(t),e.dd=void 0===n?"":function(t){t=""+t;for(var n=0;n>8)+String.fromCharCode(255&t)}else if(0==(t=""+t).length)t="\0\0";else if(1==t.length)t="\0"+t;else if(2>16)+String.fromCharCode(t>>8&255)+String.fromCharCode(255&t));throw RangeError("Out of range: "+kt(Ft(t)))},smfBPM:function(t){return Bt.smfTempo(Math.round(6e7/t))},smfSMPTE:function(t){if(t instanceof st)return xt(84,String.fromCharCode(t.hour)+String.fromCharCode(t.minute)+String.fromCharCode(t.second)+String.fromCharCode(t.frame)+String.fromCharCode(t.quarter%4*25));if(5==(""+t).length)return xt(84,t);var n=t instanceof Array?t:Array.prototype.slice.call(arguments);return n.splice(0,0,30),Bt.smfSMPTE(new st(n))},smfTimeSignature:function(t,n,e,r){var i,o,s,u,a=(""+t).match(/^\s*(\d+)\s*\/\s*(\d+)\s*$/);if(a){if(i=parseInt(a[1]),o=parseInt(a[2]),0>=1;s;s>>=1)o++;return s=n==parseInt(n)?n:24,u=e==parseInt(e)?e:8,xt(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return xt(88,t)}else{if(t==parseInt(t)&&n==parseInt(n)&&n&&!(n&n-1)){for(i=t,o=0,s=n,s>>=1;s;s>>=1)o++;return s=e==parseInt(e)?e:24,u=r==parseInt(r)?r:8,xt(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return xt(88,t)}throw RangeError("Wrong time signature: "+kt(Ft(t)))},smfKeySignature:function(t){var n,e,r=(t=""+t).match(/^\s*([A-H][b#]?)\s*(|maj|major|dur|m|min|minor|moll)\s*$/i);if(r&&(n={CB:0,GB:1,DB:2,AB:3,EB:4,BB:5,F:6,C:7,G:8,D:9,A:10,E:11,B:12,H:12,"F#":13,"C#":14,"G#":15,"D#":16,"A#":17}[r[1].toUpperCase()],e={"":0,MAJ:0,MAJOR:0,DUR:0,M:1,MIN:1,MINOR:1,MOLL:1}[r[2].toUpperCase()],void 0!==n&&void 0!==e&&(e&&(n-=3),-7<=(n-=7)&&n<0?t=String.fromCharCode(256+n)+String.fromCharCode(e):0<=n&&n<=7&&(t=String.fromCharCode(n)+String.fromCharCode(e)))),2==t.length&&t.charCodeAt(1)<=1&&(t.charCodeAt(0)<=7||t.charCodeAt(0)<=255&&249<=t.charCodeAt(0)))return xt(89,t);throw RangeError("Incorrect key signature: "+kt(t))},smfSequencer:function(t){return xt(127,Ft(t))}},It={};for(i in Ct)Ct.hasOwnProperty(i)&&function(t,n){ct[t]=function(){return new ct(n.apply(this,arguments))},It[t]=function(){return this.send(n.apply(this,arguments))}}(i,Ct[i]);for(i in Bt)Bt.hasOwnProperty(i)&&function(t,n){ct[t]=function(){return n.apply(this,arguments)},It[t]=function(){return this.send(n.apply(this,arguments))}}(i,Bt[i]);for(i in Mt)Mt.hasOwnProperty(i)&&function(t,r){ct[t]=function(){for(var t=[],n=r.apply(this,arguments),e=0;e>4;return(r={8:"Note Off",10:"Aftertouch",12:"Program Change",13:"Channel Aftertouch",14:"Pitch Wheel"}[i])?e+" -- "+r:9==i?e+" -- "+(this[2]?"Note On":"Note Off"):11!=i?e:e+" -- "+(r=(r={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 On/Off",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]])||"Undefined")},ct.prototype._stamp=function(t){return this._from.push(t._orig?t._orig:t),this},ct.prototype._unstamp=function(t){var n;return void 0===t?this._from=[]:(t._orig&&(t=t._orig),-1<(n=this._from.indexOf(t))&&this._from.splice(n,1)),this},ct.prototype._stamped=function(t){t._orig&&(t=t._orig);for(var n=0;nthis[e].notes.length&&(i=this[n=e].notes.length),r=0;r>4,e=(15&i)<<4|(o=Rt.indexOf(t.charAt(a++)))>>2,r=(3&o)<<6|(s=Rt.indexOf(t.charAt(a++))),u+=String.fromCharCode(n),64!=o&&(u+=String.fromCharCode(e)),64!=s&&(u+=String.fromCharCode(r));return u},ot.lib.toBase64=function(t){var n,e,r,i,o,s=0,u=0,a="",h=[];if(!t)return t;for(;n=(o=t.charCodeAt(s++)<<16|t.charCodeAt(s++)<<8|t.charCodeAt(s++))>>18&63,e=o>>12&63,r=o>>6&63,i=63&o,h[u++]=Rt.charAt(n)+Rt.charAt(e)+Rt.charAt(r)+Rt.charAt(i),s=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;n+=63&e,r+=String.fromCharCode(n)}else if(224==(240&n)){if(n=(15&n)<<12,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(n+=(63&e)<<6,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;n+=63&e,r+=String.fromCharCode(n)}else if(240==(248&n)){if(n=(7&n)<<18,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(n+=(63&e)<<12,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(n+=(63&e)<<6,++i>=t.length)return t;if(128!=(192&(e=t.charCodeAt(i))))return t;if(1114111<(n+=63&e))return t;n-=65536,r+=String.fromCharCode(55296+(n>>10)),r+=String.fromCharCode(56320+(1023&n))}}return r},ot.lib.toUTF8=function(t){t=void 0===t?"":""+t;for(var n,e="",r=0;r>6)):(n<65536?e+=String.fromCharCode(224+(n>>12)):(e+=String.fromCharCode(240+(n>>18)),e+=String.fromCharCode(128+(n>>12&63))),e+=String.fromCharCode(128+(n>>6&63))),e+=String.fromCharCode(128+(63&n)));return e};var Nt=[],Ut={},Gt={},Vt=n.Promise;function Zt(t,n,e){this.name=t,this.message=n,this.code=e}function Jt(t,n){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.currentTarget=n,this.defaultPrevented=!1,this.eventPhase=0,this.path=[],this.port=t,this.returnValue=!0,this.srcElement=n,this.target=n,this.timeStamp=a(),this.type="statechange"}function Wt(t,n){this.bubbles=!1,this.cancelBubble=!1,this.cancelable=!1,this.currentTarget=t,this.data=n,this.defaultPrevented=!1,this.eventPhase=0,this.path=[],this.receivedTime=a(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function Ht(t,n){t&&(t.onstatechange&&t.onstatechange(new Jt(t,t)),n.onstatechange&&n.onstatechange(new Jt(t,n)))}function Qt(e,r){var i=this,o=!1,n=null,s=null;this.type="input",this.id=r.id,this.name=r.name,this.manufacturer=r.man,this.version=r.ver,Object.defineProperty(this,"state",{get:function(){return r.connected?"connected":"disconnected"},enumerable:!0}),Object.defineProperty(this,"connection",{get:function(){return o?r.proxy?"open":"pending":"closed"},enumerable:!0}),Object.defineProperty(this,"onmidimessage",{get:function(){return s},set:function(t){if(t instanceof Function){if(s=t,!o)try{i.open()}catch(t){}}else s=null},enumerable:!0}),Object.defineProperty(this,"onstatechange",{get:function(){return n},set:function(t){n=t instanceof Function?t:null},enumerable:!0}),this.open=function(){return new Vt(function(t,n){o?t(i):r.open().then(function(){o||(o=!0,Ht(i,e)),t(i)},function(){n(new Zt("InvalidAccessError","Port is not available",15))})})},this.close=function(){return new Vt(function(t){o&&(o=!1,r.close(),Ht(i,e)),t(i)})},Object.freeze(this)}function Kt(t){for(var n,e;t.length;){for(n=0;nt.length)return;for(n=1;n