diff --git a/README.md b/README.md
index f62df66..7b22454 100644
--- a/README.md
+++ b/README.md
@@ -68,7 +68,7 @@ by running `npm remove midi-test --save-dev`.
```html
// the latest version, or
- // any particular version
+ // any particular version
//...
```
@@ -76,7 +76,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 bfaa5c8..be36635 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.6.6';
+ var _version = '1.6.7';
var i, j, k, m, n;
/* istanbul ignore next */
diff --git a/minified/JZZ.js b/minified/JZZ.js
index 13eb49e..6ea5d1e 100644
--- a/minified/JZZ.js
+++ b/minified/JZZ.js
@@ -1 +1 @@
-!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define("JZZ",[],n):(t=t||window).JZZ&&t.JZZ.MIDI||(t.JZZ=n())}(this,function(){var o,i,n,s,D="undefined"==typeof window?global:window,L="1.6.6",N=Date.now||function(){return(new Date).getTime()},q=N(),G="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return N()-q},j=function(t){setTimeout(t,0)};function z(){}function a(t){return"function"==typeof t}function e(){(this._orig=this)._ready=!1,this._queue=[],this._log=[]}function V(t,n){this._bad?a(n)&&n.apply(this,[new Error(this._err())]):a(t)&&t.apply(this,[this])}function U(t,n){this._bad?t._crash(this._err()):setTimeout(function(){t._resume()},n)}function W(t){this._bad&&t._break(this._err()),t._resume()}function Z(t,e,r){t[r]=function(){var t=arguments,n=e._image();return this._push(W,[n]),n[r].apply(n,t)}}function J(t){this._bad||(a(t)?t.apply(this):console.log(t))}function X(t){this._bad&&(a(t)?t.apply(this):console.log(t))}function H(t){this._bad?t._crash(this._err()):(this._break("Closed"),t._resume())}function Q(t){if(t.length){var n,e=t.shift();t.length&&(n=this)._slip(X,[function(){Q.apply(n,[t])}]);try{this._repair(),e.apply(this)}catch(t){this._break(t.toString())}}else this._break()}function c(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 Rt(t){for(var n,e=[],r=0;r=this.type&&(this.frame=this.type-1),this},_.prototype.setHour=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||24<=t)throw RangeError("Bad SMPTE hours value: "+t);return this.hour=t,this},_.prototype.setMinute=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE minutes value: "+t);return this.minute=t,Pt.apply(this),this},_.prototype.setSecond=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE seconds value: "+t);return this.second=t,Pt.apply(this),this},_.prototype.setFrame=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||t>=this.type)throw RangeError("Bad SMPTE frame number: "+t);return this.frame=t,Pt.apply(this),this},_.prototype.setQuarter=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||8<=t)throw RangeError("Bad SMPTE quarter frame: "+t);return this.quarter=t,this},_.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))),Pt.apply(this),this},_.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},_.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},_.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},_.prototype.read=function(t){return 240==(t=t instanceof m?t:m.apply(null,arguments))[0]&&127==t[1]&&1==t[3]&&1==t[4]&&247==t[9]?(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)):241==t[0]&&void 0!==t[1]&&(n=t[1]>>4,e=15&t[1],0==n?7==this._&&(7==this._f&&(this.reset(kt(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(kt(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);var n,e},_.prototype.toString=function(){return Rt([this.hour,this.minute,this.second,this.frame])},g.SMPTE=_,r.prototype.SMPTE=_,m.prototype=[],m.prototype.constructor=m;var v={};function Dt(t){if(t!=parseFloat(t))throw TypeError("Not a number: "+t)}function Lt(){}m.noteValue=function(t){return void 0===t?void 0:v[t.toString().toLowerCase()]},m.programValue=function(t){return t},m.octaveValue=function(t){var n=v[t.toString().toLowerCase()];return void 0===(n=void 0===n?v[t.toString().toLowerCase()+"1"]:n)?void 0:n%12},m.freq=function(t,n){return Dt(n=void 0===n?440:n),t!=parseFloat(t)&&(t=S(t)),n*Math.pow(2,(t-69)/12)},m.shift=function(t,n){return void 0===n&&(n=440),Dt(t),Dt(n),12*Math.log2(t/n)},m.midi=function(t,n){return t!=parseFloat(t)?S(t):m.shift(t,n)+69},m.to7b=function(t){return Dt(t),t<=0?0:1<=t?127:Math.floor(128*t)},m.to14b=function(t){return Dt(t),t<=0?0:1<=t?16383:Math.floor(16384*t)},m.to21b=function(t){return void 0===t?2097151:(Dt(t),t<=0?0:(t=(Math.floor(t)<<14)+m.to14b(t-Math.floor(t)))<2097151?t:2097150)},(Lt.prototype=m)._sxid=127,m.sxId=function(t){if((t=void 0===t?m._sxid:t)==this._sxid)return this;t=b(t);var n=new Lt;return n._ch=this._ch,n._sxid=t,n},m.ch=function(t){if(t==this._ch||void 0===t&&void 0===this._ch)return this;var n=new Lt;return void 0!==t&&(t=y(t)),n._ch=t,n._sxid=this._sxid,n};var Nt={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(u(Nt,function(t){for(s=0;s<12&&!(127<(n=Nt[t]+12*s));s++)v[t+s]=n,0<(v[t+"♮"+s]=n)&&(v[t+"b"+s]=n-1,v[t+"♭"+s]=n-1,v[t+"bb"+s]=n-2,v[t+"♭♭"+s]=n-2,v[t+"𝄫"+s]=n-2),n<127&&(v[t+"#"+s]=n+1,v[t+"♯"+s]=n+1,v[t+"##"+s]=n+2,v[t+"♯♯"+s]=n+2,v[t+"𝄪"+s]=n+2)}),s=0;s<128;s++)v[s]=s;function qt(t){throw RangeError("Bad MIDI value: "+t)}function Gt(t){throw TypeError("Invalid value: "+t)}function y(t){return _t(t),parseInt(t)}function b(t,n){return(t!=parseInt(t)||t<0||127>7}function Ut(t){return[t>>14,t>>7&127,127&t]}function Wt(t,n){if(t!=parseFloat(t)&&Gt(void 0===n?t:n),t<0||1>12&15,t>>8&15,t>>4&15,15&t])}function Yt(t){return Dt(t),Math.round(1e3*t+1024)}var $t={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,M(t),C(t)]:[242,b(n),b(t)]},songSelect:function(t){return[243,b(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]},reset:function(){return[255]}},T={sxIdRequest:function(){return[240,126,this._sxid,6,1,247]},sxTuningDumpRequest:function(t,n){return void 0===n?[240,126,this._sxid,8,0,b(t),247]:[240,126,this._sxid,8,3,b(t),b(n),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,n){return void 0===n?[240,127,this._sxid,4,1,M(t),C(t),247]:[240,127,this._sxid,4,1,b(n),b(t),247]},sxMasterVolumeF:function(t){return T.sxMasterVolume.call(this,m.to14b(Wt(t)))},sxMasterFineTuning:function(t,n){return void 0===n?[240,127,this._sxid,4,3,M(t),C(t),247]:[240,127,this._sxid,4,3,b(n),b(t),247]},sxMasterFineTuningF:function(t){return T.sxMasterFineTuning.call(this,m.to14b(Wt((t%1+1)/2,t)))},sxMasterCoarseTuning:function(t){return[240,127,this._sxid,4,4,0,b(t),247]},sxMasterCoarseTuningF:function(t){return T.sxMasterCoarseTuning.call(this,t-t%1+64)},sxNoteTuning:function(t,n,e,r){return n==parseInt(n)?[240,Zt(r),this._sxid,8,7,b(t),b(n)].concat(Jt(e),[247]):[240,127,this._sxid,8,2,b(t)].concat(Jt(n),[247])},sxNoteTuningF:function(t,n,e,r){return n==parseInt(n)?T.sxNoteTuning.call(this,t,n,Xt(e),r):T.sxNoteTuning.call(this,t,Xt(n))},sxNoteTuningHZ:function(t,n,e,r){return n==parseInt(n)?T.sxNoteTuning.call(this,t,n,Ht(e),r):T.sxNoteTuning.call(this,t,Ht(n))},sxScaleTuning1:function(t,n,e){return t==parseInt(t)?[240,Zt(e),this._sxid,8,8].concat(Ut(Vt(t)),function(t){var n=[];if(!(t instanceof Array)||12!=t.length)throw TypeError("Expected an array of size 12");for(var e=0;e<12;e++)n.push(b(t[e]));return n}(n),[247]):T.sxScaleTuning1.call(this,65535,t,n)},sxScaleTuning1F:function(t,n,e){if(t!=parseInt(t))return T.sxScaleTuning1F.call(this,65535,t,n);for(var r=[],i=0;i>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"+dn(cn(t)))},smfBPM:function(t){return nn.smfTempo(Math.round(6e7/t))},smfSMPTE:function(t){if(t instanceof _)return I(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 I(84,t);var n=t instanceof Array?t:Array.prototype.slice.call(arguments);return n.splice(0,0,30),nn.smfSMPTE(new _(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,I(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return I(88,t)}else if(t==parseInt(t)&&n==parseInt(n)){if(0>=1;s;s>>=1)o++;return s=e==parseInt(e)?e:24,u=r==parseInt(r)?r:8,I(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return I(88,t);t=t+"/"+n}else if(4==(""+t).length)return I(88,t);throw RangeError("Wrong time signature"+dn(cn(""+t)))},smfKeySignature:function(t){var n,e=(t=""+t).match(/^\s*([A-H][b#]?)\s*(|maj|major|dur|m|min|minor|moll)\s*$/i);if(e&&(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}[e[1].toUpperCase()],e={"":0,MAJ:0,MAJOR:0,DUR:0,M:1,MIN:1,MINOR:1,MOLL:1}[e[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 I(89,t);throw RangeError("Incorrect key signature"+dn(t))},smfSequencer:function(t){return I(127,cn(t))}},en={};function rn(t,n){m[t]=function(){return new m(n.apply(this,arguments))},en[t]=function(){return this.send(n.apply(this,arguments))}}function on(n){u(en,function(t){n.prototype[t]=en[t]})}u($t,function(t){rn(t,$t[t])}),u(T,function(t){rn(t,T[t])}),u(nn,function(t){var n;n=nn[t=t],m[t]=function(){return n.apply(this,arguments)},en[t]=function(){return this.send(n.apply(this,arguments))}}),u(tn,function(t){var r;r=tn[t=t],m[t]=function(){for(var t=[],n=r.apply(this,arguments),e=0;e>4;if(12==o)t._bm=this._cc[i].bm,t._bl=this._cc[i].bl,g.MIDI.programName&&t.label(g.MIDI.programName(t[1],t._bm,t._bl));else if(11==o)switch(t[1]){case 0:this._cc[i].bm=t[2];break;case 32:this._cc[i].bl=t[2];break;case 98:this._cc[i].nl=t[2],this._cc[i].rn="n";break;case 99:this._cc[i].nm=t[2],this._cc[i].rn="n";break;case 100:this._cc[i].rl=t[2],this._cc[i].rn="r";break;case 101:this._cc[i].rm=t[2],this._cc[i].rn="r";break;case 6:case 38:case 96:case 97:"r"==this._cc[i].rn&&(t._rm=this._cc[i].rm,t._rl=this._cc[i].rl,t.label((r=this._cc[i].rm,e=this._cc[i].rl,r=void 0===r?"??":B(r),e=void 0===e?"??":B(e),"RPN "+r+" "+e+((r={"0000":"Pitch Bend Sensitivity","0001":"Channel Fine Tune","0002":"Channel Coarse Tune","0003":"Select Tuning Program","0004":"Select Tuning Bank","0005":"Vibrato Depth Range","7f7f":"NONE"}[r+""+e])?": "+r:"")))),"n"==this._cc[i].rn&&(t._nm=this._cc[i].rm,t._nl=this._cc[i].nl,t.label((e=this._cc[i].nm,r=this._cc[i].nl,"NRPN "+(void 0===e?"??":B(e))+" "+(void 0===r?"??":B(r)))))}else t.isFullSysEx()&&(127==t[1]?4==t[3]?(n={1:"Master Volume",2:"Master Balance",3:"Master Fine Tuning",4:"Master Coarse Tuning"}[t[4]])&&t.label(n):8==t[3]&&(n={2:"Note Tuning",7:"Note Tuning, Bank",8:"Scale Tuning, 1 byte format",9:"Scale Tuning, 2 byte format"}[t[4]])&&t.label(n):126==t[1]?6==t[3]?1==t[4]?t.label("Device ID Request"):2==t[4]&&t.label("Device ID Response"):8==t[3]?(n={0:"Bulk Tuning Dump Request",1:"Bulk Tuning Dump",3:"Bulk Tuning Dump Request, Bank",4:"Bulk Tuning Dump, Bank",5:"Scale Tuning Dump, 1 byte format",6:"Scale Tuning Dump, 2 byte format",7:"Note Tuning, Bank",8:"Scale Tuning, 1 byte format",9:"Scale Tuning, 2 byte format"}[t[4]])&&t.label(n):9==t[3]&&(1==t[4]?(t.label("GM1 System On"),this._clear(),this._gm="1"):2==t[4]?(t.label("GM System Off"),this._clear(),this._gm="0"):3==t[4]&&(t.label("GM2 System On"),this._clear(),this._gm="2")):67==t[1]?16==(240&t[2])&&76==t[3]&&(0==t[4]&&0==t[5]&&126==t[6]&&0==t[7]?(t.label("XG System On"),this._clear(),this._gm="Y"):0==t[4]&&0==t[5]&&0==t[6]?t.label("XG Master Tuning"):0==t[4]&&0==t[5]&&4==t[6]?t.label("XG Master Volume"):0==t[4]&&0==t[5]&&6==t[6]?t.label("XG Master Transpose"):8==t[4]&&t[5]<16&&65<=t[6]&&t[6]<=76?t.label("XG Scale Tuning"):t.label("XG Parameter")):65==t[1]&&66==t[3]&&18==t[4]&&(64==t[5]&&(0==t[6]?127==t[7]&&0==t[8]&&65==t[9]?(t.label("GS Reset"),this._clear(),this._gm="R"):0==t[7]?t.label("GS Master Tuning"):4==t[7]?t.label("GS Master Volume"):5==t[7]?t.label("GS Master Transpose"):t.label("GS Parameter"):16==(240&t[6])&&21==t[7]?t.label("GS Drum Part Change"):16==(240&t[6])&&64<=t[7]&&t[7]<=75?t.label("GS Scale Tuning"):t.label("GS Parameter")),65==t[5]&&t.label("GS Parameter")));return t}function mn(){var t=new l;return t._clear=gn,t._read=_n,t._receive=function(t){this._emit(this._read(t))},t._clear(),t._resume(),t}function A(){var t=this instanceof A?this:new A;return t.reset(),arguments.length&&A.prototype.setup.apply(t,arguments),t}function E(n){var e=this instanceof E?this:new E;if(n instanceof E)return e._from=n._from.slice(),u(n,function(t){"_from"!=t&&(e[t]=n[t])}),e;e._from=[];for(var t=(n=void 0===n?[0,0,0,0]:n)instanceof Array?n:arguments,r=e.length=0;r>4])throw RangeError("Wrong UMP size");return e}function vn(){}m.prototype.getChannel=function(){if(32==this.ff&&1==this.dd.length&&this.dd.charCodeAt(0)<16)return this.dd.charCodeAt(0);var t=this[0];return void 0===t||t<128||239>4,0<(t=15&t)&&t<8&&n<7?(t=["C","D","E","F","G","A","B"][t-1]+["bbb","bb","b","","#","##","###"][n],34>4;return(e={8:"Note Off",10:"Aftertouch",12:"Program Change",13:"Channel Aftertouch",14:"Pitch Wheel"}[n])?e:9==n?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",31:"Karaoke",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",65:"Portamento",66:"Sostenuto",67:"Soft Pedal",68:"Legato",69:"Hold 2",70:"Sound Variation",71:"Filter Resonance",72:"Release Time",73:"Attack Time",74:"Brightness",75:"Decay Time",76:"Vibrato Rate",77:"Vibrato Depth",78:"Vibrato Delay",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]],64<=this[1]&&this[1]<=69&&(e+=this[2]<64?" Off":" On"),e||"Undefined")},m.prototype._stamp=function(t){return this._from.push(t._orig||t),this},m.prototype._unstamp=function(t){return void 0===t?this._from=[]:(t._orig&&(t=t._orig),-1<(t=this._from.indexOf(t))&&this._from.splice(t,1)),this},m.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,1==t||2==t||3==t||4==t||5==t||13==t?15&this[0]:void 0};var yn={noop:function(){return[0,0,0,0]},umpClock:function(t){return[0,16,(t=Vt(t))>>8,255&t]},umpTimestamp:function(t){return[0,32,(t=Vt(t))>>8,255&t]},umpTicksPQN:function(t){return[0,48,(t=Vt(t))>>8,255&t]},umpDelta:function(t){return[0,64+((t=function(t){if(t!=parseInt(t)||t<0||1048575>16),t>>8&255,255&t]},umpStartClip:function(){return[240,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},umpEndClip:function(){return[240,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},bn={umpTempo:function(t,n){return[208+t,16,0,0,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,0,0,0,0,0]},umpBPM:function(t,n){return bn.umpTempo(t,Math.round(6e9/n))},umpTimeSignature:function(t,n,e){var r,i,o,s=(""+n).match(/^\s*(\d+)\s*\/\s*(\d+)\s*$/);if(s?(r=parseInt(s[1]),i=parseInt(s[2])):n==parseInt(n)&&e==parseInt(e)&&(r=parseInt(n),i=parseInt(e)),0>=1;i;i>>=1)o++;if((i=Math.round(32*r/(1<>4==13&&this[1]>>4==1&&0==this[2]&&0==this[3]},E.prototype.isTimeSignature=function(){return this[0]>>4==13&&this[1]>>4==1&&0==this[2]&&1==this[3]},E.prototype.isStartClip=function(){return this.match([240,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},E.prototype.isEndClip=function(){return this.match([240,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},E.prototype.toString=m.prototype.toString,E.prototype._str=function(){var t=this._string();return t?fn(this)+" -- "+t:fn(this)},E.prototype._string=function(){var t=this[0]>>4;if(1==t||2==t)return new m(this.slice(1))._string();if(0==t)return["NOOP","JR Clock","JR Timestamp","Ticks Per Quarter Note","Delta Ticks"][this[1]>>4];if(208==this[0]&&0==this[2]){if(0==this[3])return"Tempo "+this.getBPM()+" BPM";if(1==this[3])return"Time Signature "+this.getTimeSignature().join("/")}return 240==this[0]?{32:"Start of Clip",33:"End of Clip"}[this[1]]:void 0},E.prototype._stamp=m.prototype._stamp,E.prototype._unstamp=m.prototype._unstamp,E.prototype._stamped=m.prototype._stamped,E.prototype.match=m.prototype.match,g.UMP=E,r.prototype.UMP=E,g.lib={},g.lib.now=G,g.lib.schedule=j;var xn,F,Tn=[],wn=0;try{function In(){for(var t=Tn.length,n=0;n>2,e=(3&o)<<6|(s=En.indexOf(t.charAt(a++))),u+=String.fromCharCode(r<<2|i>>4),64!=o&&(u+=String.fromCharCode(n)),64!=s&&(u+=String.fromCharCode(e));return u},g.lib.toBase64=function(t){var n,e,r,i,o=0,s=0,u="",a=[];if(!t)return t;for(;n=(i=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>12&63,e=i>>6&63,r=63&i,a[s++]=En.charAt(i>>18&63)+En.charAt(n)+En.charAt(e)+En.charAt(r),o=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=(r+=String.fromCharCode(55296+(n>>10)))+String.fromCharCode(56320+(1023&n))}}return r},g.lib.toUTF8=function(t){t=void 0===t?"":""+t;for(var n,e="",r=0;r>6)))+String.fromCharCode(128+(63&n)):n<65536?(e=(e+=String.fromCharCode(224+(n>>12)))+String.fromCharCode(128+(n>>6&63)))+String.fromCharCode(128+(63&n)):(e=(e=(e+=String.fromCharCode(240+(n>>18)))+String.fromCharCode(128+(n>>12&63)))+String.fromCharCode(128+(n>>6&63)))+String.fromCharCode(128+(63&n));return e},[]),P={},k={},t=D.Promise;function Fn(t,n,e){this.name=t,this.message=n,this.code=e}function On(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=G(),this.type="statechange"}function Pn(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=G(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function R(t,n){t&&(t.onstatechange&&t.onstatechange(new On(t,t)),n.onstatechange&&n.onstatechange(new On(t,n)))}function kn(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){a(t)?(s=t,o||i.open().then(z,z)):s=null},enumerable:!0}),Object.defineProperty(this,"onstatechange",{get:function(){return n},set:function(t){n=a(t)?t:null},enumerable:!0}),this.open=function(){return new t(function(t,n){o?t(i):r.open().then(function(){o||(o=!0,R(i,e)),t(i)},function(){n(new Fn("InvalidAccessError","Port is not available",15))})})},this.close=function(){return new t(function(t){o&&(o=!1,r.close(),R(i,e)),t(i)})},Object.freeze(this)}function Rn(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 Rt(t){for(var n,e=[],r=0;r=this.type&&(this.frame=this.type-1),this},g.prototype.setHour=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||24<=t)throw RangeError("Bad SMPTE hours value: "+t);return this.hour=t,this},g.prototype.setMinute=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE minutes value: "+t);return this.minute=t,kt.apply(this),this},g.prototype.setSecond=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||60<=t)throw RangeError("Bad SMPTE seconds value: "+t);return this.second=t,kt.apply(this),this},g.prototype.setFrame=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||t>=this.type)throw RangeError("Bad SMPTE frame number: "+t);return this.frame=t,kt.apply(this),this},g.prototype.setQuarter=function(t){if((t=void 0===t?0:t)!=parseInt(t)||t<0||8<=t)throw RangeError("Bad SMPTE quarter frame: "+t);return this.quarter=t,this},g.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))),kt.apply(this),this},g.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},g.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},g.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},g.prototype.read=function(t){return 240==(t=t instanceof _?t:_.apply(null,arguments))[0]&&127==t[1]&&1==t[3]&&1==t[4]&&247==t[9]?(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)):241==t[0]&&void 0!==t[1]&&(n=t[1]>>4,e=15&t[1],0==n?7==this._&&(7==this._f&&(this.reset(Dt(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(Dt(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);var n,e},g.prototype.toString=function(){return Rt([this.hour,this.minute,this.second,this.frame])},d.SMPTE=g,r.prototype.SMPTE=g,_.prototype=[],_.prototype.constructor=_;var m={};function Lt(t){if(t!=parseFloat(t))throw TypeError("Not a number: "+t)}function Nt(){}_.noteValue=function(t){return void 0===t?void 0:m[t.toString().toLowerCase()]},_.programValue=function(t){return t},_.octaveValue=function(t){var n=m[t.toString().toLowerCase()];return void 0===(n=void 0===n?m[t.toString().toLowerCase()+"1"]:n)?void 0:n%12},_.freq=function(t,n){return Lt(n=void 0===n?440:n),t!=parseFloat(t)&&(t=b(t)),n*Math.pow(2,(t-69)/12)},_.shift=function(t,n){return void 0===n&&(n=440),Lt(t),Lt(n),12*Math.log2(t/n)},_.midi=function(t,n){return t!=parseFloat(t)?b(t):_.shift(t,n)+69},_.to7b=function(t){return Lt(t),t<=0?0:1<=t?127:Math.floor(128*t)},_.to14b=function(t){return Lt(t),t<=0?0:1<=t?16383:Math.floor(16384*t)},_.to21b=function(t){return void 0===t?2097151:(Lt(t),t<=0?0:(t=(Math.floor(t)<<14)+_.to14b(t-Math.floor(t)))<2097151?t:2097150)},(Nt.prototype=_)._sxid=127,_.sxId=function(t){if((t=void 0===t?_._sxid:t)==this._sxid)return this;t=y(t);var n=new Nt;return n._ch=this._ch,n._sxid=t,n},_.ch=function(t){if(t==this._ch||void 0===t&&void 0===this._ch)return this;var n=new Nt;return void 0!==t&&(t=v(t)),n._ch=t,n._sxid=this._sxid,n};var qt={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(s(qt,function(t){for(i=0;i<12&&!(127<(n=qt[t]+12*i));i++)m[t+i]=n,0<(m[t+"♮"+i]=n)&&(m[t+"b"+i]=n-1,m[t+"♭"+i]=n-1,m[t+"bb"+i]=n-2,m[t+"♭♭"+i]=n-2,m[t+"𝄫"+i]=n-2),n<127&&(m[t+"#"+i]=n+1,m[t+"♯"+i]=n+1,m[t+"##"+i]=n+2,m[t+"♯♯"+i]=n+2,m[t+"𝄪"+i]=n+2)}),i=0;i<128;i++)m[i]=i;function Gt(t){throw RangeError("Bad MIDI value: "+t)}function jt(t){throw TypeError("Invalid value: "+t)}function v(t){return mt(t),parseInt(t)}function y(t,n){return(t!=parseInt(t)||t<0||127>7}function Wt(t){return[t>>14,t>>7&127,127&t]}function Zt(t,n){if(t!=parseFloat(t)&&jt(void 0===n?t:n),t<0||1>12&15,t>>8&15,t>>4&15,15&t])}function $t(t){return Lt(t),Math.round(1e3*t+1024)}var tn={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,S(t),M(t)]:[242,y(n),y(t)]},songSelect:function(t){return[243,y(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]},reset:function(){return[255]}},x={sxIdRequest:function(){return[240,126,this._sxid,6,1,247]},sxTuningDumpRequest:function(t,n){return void 0===n?[240,126,this._sxid,8,0,y(t),247]:[240,126,this._sxid,8,3,y(t),y(n),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,n){return void 0===n?[240,127,this._sxid,4,1,S(t),M(t),247]:[240,127,this._sxid,4,1,y(n),y(t),247]},sxMasterVolumeF:function(t){return x.sxMasterVolume.call(this,_.to14b(Zt(t)))},sxMasterFineTuning:function(t,n){return void 0===n?[240,127,this._sxid,4,3,S(t),M(t),247]:[240,127,this._sxid,4,3,y(n),y(t),247]},sxMasterFineTuningF:function(t){return x.sxMasterFineTuning.call(this,_.to14b(Zt((t%1+1)/2,t)))},sxMasterCoarseTuning:function(t){return[240,127,this._sxid,4,4,0,y(t),247]},sxMasterCoarseTuningF:function(t){return x.sxMasterCoarseTuning.call(this,t-t%1+64)},sxNoteTuning:function(t,n,e,r){return n==parseInt(n)?[240,Jt(r),this._sxid,8,7,y(t),y(n)].concat(Xt(e),[247]):[240,127,this._sxid,8,2,y(t)].concat(Xt(n),[247])},sxNoteTuningF:function(t,n,e,r){return n==parseInt(n)?x.sxNoteTuning.call(this,t,n,Ht(e),r):x.sxNoteTuning.call(this,t,Ht(n))},sxNoteTuningHZ:function(t,n,e,r){return n==parseInt(n)?x.sxNoteTuning.call(this,t,n,Qt(e),r):x.sxNoteTuning.call(this,t,Qt(n))},sxScaleTuning1:function(t,n,e){return t==parseInt(t)?[240,Jt(e),this._sxid,8,8].concat(Wt(Ut(t)),function(t){var n=[];if(!(t instanceof Array)||12!=t.length)throw TypeError("Expected an array of size 12");for(var e=0;e<12;e++)n.push(y(t[e]));return n}(n),[247]):x.sxScaleTuning1.call(this,65535,t,n)},sxScaleTuning1F:function(t,n,e){if(t!=parseInt(t))return x.sxScaleTuning1F.call(this,65535,t,n);for(var r=[],i=0;i>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"+gn(hn(t)))},smfBPM:function(t){return en.smfTempo(Math.round(6e7/t))},smfSMPTE:function(t){if(t instanceof g)return w(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 w(84,t);var n=t instanceof Array?t:Array.prototype.slice.call(arguments);return n.splice(0,0,30),en.smfSMPTE(new g(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,w(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return w(88,t)}else if(t==parseInt(t)&&n==parseInt(n)){if(0>=1;s;s>>=1)o++;return s=e==parseInt(e)?e:24,u=r==parseInt(r)?r:8,w(88,String.fromCharCode(i)+String.fromCharCode(o)+String.fromCharCode(s)+String.fromCharCode(u))}if(4==(""+t).length)return w(88,t);t=t+"/"+n}else if(4==(""+t).length)return w(88,t);throw RangeError("Wrong time signature"+gn(hn(""+t)))},smfKeySignature:function(t){var n,e=(t=""+t).match(/^\s*([A-H][b#]?)\s*(|maj|major|dur|m|min|minor|moll)\s*$/i);if(e&&(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}[e[1].toUpperCase()],e={"":0,MAJ:0,MAJOR:0,DUR:0,M:1,MIN:1,MINOR:1,MOLL:1}[e[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 w(89,t);throw RangeError("Incorrect key signature"+gn(t))},smfSequencer:function(t){return w(127,hn(t))}},rn={};function on(t,n){_[t]=function(){return new _(n.apply(this,arguments))},rn[t]=function(){return this.send(n.apply(this,arguments))}}function sn(n){s(rn,function(t){n.prototype[t]=rn[t]})}s(tn,function(t){on(t,tn[t])}),s(x,function(t){on(t,x[t])}),s(en,function(t){var n;n=en[t=t],_[t]=function(){return n.apply(this,arguments)},rn[t]=function(){return this.send(n.apply(this,arguments))}}),s(nn,function(t){var r;r=nn[t=t],_[t]=function(){for(var t=[],n=r.apply(this,arguments),e=0;e>4;if(12==o)t._bm=this._cc[i].bm,t._bl=this._cc[i].bl,d.MIDI.programName&&t.label(d.MIDI.programName(t[1],t._bm,t._bl));else if(11==o)switch(t[1]){case 0:this._cc[i].bm=t[2];break;case 32:this._cc[i].bl=t[2];break;case 98:this._cc[i].nl=t[2],this._cc[i].rn="n";break;case 99:this._cc[i].nm=t[2],this._cc[i].rn="n";break;case 100:this._cc[i].rl=t[2],this._cc[i].rn="r";break;case 101:this._cc[i].rm=t[2],this._cc[i].rn="r";break;case 6:case 38:case 96:case 97:"r"==this._cc[i].rn&&(t._rm=this._cc[i].rm,t._rl=this._cc[i].rl,t.label((r=this._cc[i].rm,e=this._cc[i].rl,r=void 0===r?"??":I(r),e=void 0===e?"??":I(e),"RPN "+r+" "+e+((r={"0000":"Pitch Bend Sensitivity","0001":"Channel Fine Tune","0002":"Channel Coarse Tune","0003":"Select Tuning Program","0004":"Select Tuning Bank","0005":"Vibrato Depth Range","7f7f":"NONE"}[r+""+e])?": "+r:"")))),"n"==this._cc[i].rn&&(t._nm=this._cc[i].rm,t._nl=this._cc[i].nl,t.label((e=this._cc[i].nm,r=this._cc[i].nl,"NRPN "+(void 0===e?"??":I(e))+" "+(void 0===r?"??":I(r)))))}else t.isFullSysEx()&&(127==t[1]?4==t[3]?(n={1:"Master Volume",2:"Master Balance",3:"Master Fine Tuning",4:"Master Coarse Tuning"}[t[4]])&&t.label(n):8==t[3]&&(n={2:"Note Tuning",7:"Note Tuning, Bank",8:"Scale Tuning, 1 byte format",9:"Scale Tuning, 2 byte format"}[t[4]])&&t.label(n):126==t[1]?6==t[3]?1==t[4]?t.label("Device ID Request"):2==t[4]&&t.label("Device ID Response"):8==t[3]?(n={0:"Bulk Tuning Dump Request",1:"Bulk Tuning Dump",3:"Bulk Tuning Dump Request, Bank",4:"Bulk Tuning Dump, Bank",5:"Scale Tuning Dump, 1 byte format",6:"Scale Tuning Dump, 2 byte format",7:"Note Tuning, Bank",8:"Scale Tuning, 1 byte format",9:"Scale Tuning, 2 byte format"}[t[4]])&&t.label(n):9==t[3]&&(1==t[4]?(t.label("GM1 System On"),this._clear(),this._gm="1"):2==t[4]?(t.label("GM System Off"),this._clear(),this._gm="0"):3==t[4]&&(t.label("GM2 System On"),this._clear(),this._gm="2")):67==t[1]?16==(240&t[2])&&76==t[3]&&(0==t[4]&&0==t[5]&&126==t[6]&&0==t[7]?(t.label("XG System On"),this._clear(),this._gm="Y"):0==t[4]&&0==t[5]&&0==t[6]?t.label("XG Master Tuning"):0==t[4]&&0==t[5]&&4==t[6]?t.label("XG Master Volume"):0==t[4]&&0==t[5]&&6==t[6]?t.label("XG Master Transpose"):8==t[4]&&t[5]<16&&65<=t[6]&&t[6]<=76?t.label("XG Scale Tuning"):t.label("XG Parameter")):65==t[1]&&66==t[3]&&18==t[4]&&(64==t[5]&&(0==t[6]?127==t[7]&&0==t[8]&&65==t[9]?(t.label("GS Reset"),this._clear(),this._gm="R"):0==t[7]?t.label("GS Master Tuning"):4==t[7]?t.label("GS Master Volume"):5==t[7]?t.label("GS Master Transpose"):t.label("GS Parameter"):16==(240&t[6])&&21==t[7]?t.label("GS Drum Part Change"):16==(240&t[6])&&64<=t[7]&&t[7]<=75?t.label("GS Scale Tuning"):t.label("GS Parameter")),65==t[5]&&t.label("GS Parameter")));return t}function vn(){var t=new f;return t._clear=_n,t._read=mn,t._receive=function(t){this._emit(this._read(t))},t._clear(),t._resume(),t}function B(){var t=this instanceof B?this:new B;return t.reset(),arguments.length&&B.prototype.setup.apply(t,arguments),t}function A(n){var e=this instanceof A?this:new A;if(n instanceof A)return e._from=n._from.slice(),s(n,function(t){"_from"!=t&&(e[t]=n[t])}),e;e._from=[];for(var t=(n=void 0===n?[0,0,0,0]:n)instanceof Array?n:arguments,r=e.length=0;r>4])throw RangeError("Wrong UMP size");return e}function yn(){}_.prototype.getChannel=function(){if(32==this.ff&&1==this.dd.length&&this.dd.charCodeAt(0)<16)return this.dd.charCodeAt(0);var t=this[0];return void 0===t||t<128||239>4,0<(t=15&t)&&t<8&&n<7?(t=["C","D","E","F","G","A","B"][t-1]+["bbb","bb","b","","#","##","###"][n],34>4;return(e={8:"Note Off",10:"Aftertouch",12:"Program Change",13:"Channel Aftertouch",14:"Pitch Wheel"}[n])?e:9==n?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",31:"Karaoke",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",65:"Portamento",66:"Sostenuto",67:"Soft Pedal",68:"Legato",69:"Hold 2",70:"Sound Variation",71:"Filter Resonance",72:"Release Time",73:"Attack Time",74:"Brightness",75:"Decay Time",76:"Vibrato Rate",77:"Vibrato Depth",78:"Vibrato Delay",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]],64<=this[1]&&this[1]<=69&&(e+=this[2]<64?" Off":" On"),e||"Undefined")},_.prototype._stamp=function(t){return this._from.push(t._orig||t),this},_.prototype._unstamp=function(t){return void 0===t?this._from=[]:(t._orig&&(t=t._orig),-1<(t=this._from.indexOf(t))&&this._from.splice(t,1)),this},_.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,1==t||2==t||3==t||4==t||5==t||13==t?15&this[0]:void 0};var bn={noop:function(){return[0,0,0,0]},umpClock:function(t){return[0,16,(t=Ut(t))>>8,255&t]},umpTimestamp:function(t){return[0,32,(t=Ut(t))>>8,255&t]},umpTicksPQN:function(t){return[0,48,(t=Ut(t))>>8,255&t]},umpDelta:function(t){return[0,64+((t=function(t){if(t!=parseInt(t)||t<0||1048575>16),t>>8&255,255&t]},umpStartClip:function(){return[240,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0]},umpEndClip:function(){return[240,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},Sn={umpTempo:function(t,n){return[208+t,16,0,0,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,0,0,0,0,0]},umpBPM:function(t,n){return Sn.umpTempo(t,Math.round(6e9/n))},umpTimeSignature:function(t,n,e){var r,i,o,s=(""+n).match(/^\s*(\d+)\s*\/\s*(\d+)\s*$/);if(s?(r=parseInt(s[1]),i=parseInt(s[2])):n==parseInt(n)&&e==parseInt(e)&&(r=parseInt(n),i=parseInt(e)),0>=1;i;i>>=1)o++;if((i=Math.round(32*r/(1<>4==13&&this[1]>>4==1&&0==this[2]&&0==this[3]},A.prototype.isTimeSignature=function(){return this[0]>>4==13&&this[1]>>4==1&&0==this[2]&&1==this[3]},A.prototype.isDelta=function(){return 0==this[0]&&this[1]>>4==4},A.prototype.isStartClip=function(){return this.match([240,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},A.prototype.isEndClip=function(){return this.match([240,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0])},A.prototype.toString=_.prototype.toString,A.prototype._str=function(){var t=this._string();return t?pn(this)+" -- "+t:pn(this)},A.prototype._string=function(){var t=this[0]>>4;if(1==t||2==t)return new _(this.slice(1))._string();if(0==t)return["NOOP","JR Clock","JR Timestamp","Ticks Per Quarter Note","Delta Ticks"][this[1]>>4];if(208==this[0]&&0==this[2]){if(0==this[3])return"Tempo "+this.getBPM()+" BPM";if(1==this[3])return"Time Signature "+this.getTimeSignature().join("/")}return 240==this[0]?{32:"Start of Clip",33:"End of Clip"}[this[1]]:void 0},A.prototype._stamp=_.prototype._stamp,A.prototype._unstamp=_.prototype._unstamp,A.prototype._stamped=_.prototype._stamped,A.prototype.match=_.prototype.match,d.UMP=A,r.prototype.UMP=A,d.lib={},d.lib.now=j,d.lib.schedule=z;var In,E,Bn=[],An=0;try{function En(){for(var t=Bn.length,n=0;n>2,e=(3&o)<<6|(s=Pn.indexOf(t.charAt(a++))),u+=String.fromCharCode(r<<2|i>>4),64!=o&&(u+=String.fromCharCode(n)),64!=s&&(u+=String.fromCharCode(e));return u},d.lib.toBase64=function(t){var n,e,r,i,o=0,s=0,u="",a=[];if(!t)return t;for(;n=(i=t.charCodeAt(o++)<<16|t.charCodeAt(o++)<<8|t.charCodeAt(o++))>>12&63,e=i>>6&63,r=63&i,a[s++]=Pn.charAt(i>>18&63)+Pn.charAt(n)+Pn.charAt(e)+Pn.charAt(r),o=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=(r+=String.fromCharCode(55296+(n>>10)))+String.fromCharCode(56320+(1023&n))}}return r},d.lib.toUTF8=function(t){t=void 0===t?"":""+t;for(var n,e="",r=0;r>6)))+String.fromCharCode(128+(63&n)):n<65536?(e=(e+=String.fromCharCode(224+(n>>12)))+String.fromCharCode(128+(n>>6&63)))+String.fromCharCode(128+(63&n)):(e=(e=(e+=String.fromCharCode(240+(n>>18)))+String.fromCharCode(128+(n>>12&63)))+String.fromCharCode(128+(n>>6&63)))+String.fromCharCode(128+(63&n));return e},[]),O={},P={},k=L.Promise;function kn(t,n,e){this.name=t,this.message=n,this.code=e}function Dn(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=j(),this.type="statechange"}function Rn(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=j(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function D(t,n){t&&(t.onstatechange&&t.onstatechange(new Dn(t,t)),n.onstatechange&&n.onstatechange(new Dn(t,n)))}function Ln(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){a(t)?(s=t,o||i.open().then(V,V)):s=null},enumerable:!0}),Object.defineProperty(this,"onstatechange",{get:function(){return n},set:function(t){n=a(t)?t:null},enumerable:!0}),this.open=function(){return new k(function(t,n){o?t(i):r.open().then(function(){o||(o=!0,D(i,e)),t(i)},function(){n(new kn("InvalidAccessError","Port is not available",15))})})},this.close=function(){return new k(function(t){o&&(o=!1,r.close(),D(i,e)),t(i)})},Object.freeze(this)}function Nn(t){for(var n,e;t.length;){for(n=0;nt.length)return;for(n=1;n