From e4a184e1955a6e0f83c23574fcd3abc5fecb1b32 Mon Sep 17 00:00:00 2001 From: Sema Date: Tue, 14 May 2024 20:38:06 -0400 Subject: [PATCH] substr() to substring() --- javascript/JZZ.js | 4 ++-- minified/JZZ.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/javascript/JZZ.js b/javascript/JZZ.js index 09fcab8..092f24a 100644 --- a/javascript/JZZ.js +++ b/javascript/JZZ.js @@ -2582,12 +2582,12 @@ s += ss ? ' ' + ss : ''; s += ': '; if (this.dd.charCodeAt(2) == 0) { - return s + this.dd.substr(3, 4) + ' ' + _hex(_s2a(this.dd.substr(7))); + return s + this.dd.substring(3, 7) + ' ' + _hex(_s2a(this.dd.substring(7))); } if (this.dd.charCodeAt(2) == 1) { return s + this.getText(); } - return s + _hex(_s2a(this.dd.substr(3))); + return s + _hex(_s2a(this.dd.substring(3))); } } s += 'Sequencer Specific' + _smfhex(this.dd); diff --git a/minified/JZZ.js b/minified/JZZ.js index f4dec4f..8454c31 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 D,L,n,i,t="undefined"==typeof window?global:window,q="1.8.3",G=Date.now||function(){return(new Date).getTime()},j=G(),z="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return G()-j},U=function(t){setTimeout(t,0)};function V(){}function a(t){return"function"==typeof t}function e(){(this._orig=this)._ready=!1,this._queue=[],this._log=[]}function W(t,n){this._bad?a(n)&&n.apply(this,[new Error(this._err())]):a(t)&&t.apply(this,[this])}function Z(t,n){this._bad?t._crash(this._err()):setTimeout(function(){t._resume()},n)}function o(t){this._bad&&t._break(this._err()),t._resume()}function J(t,e,r){t[r]=function(){var t=arguments,n=e._image();return this._push(o,[n]),n[r].apply(n,t)}}function X(t){this._bad||(a(t)?t.apply(this):console.log(t))}function H(t){this._bad&&(a(t)?t.apply(this):console.log(t))}function Q(t){this._bad?t._crash(this._err()):(this._break("Closed"),t._resume())}function K(t){if(t.length){var n,e=t.shift();t.length&&(n=this)._slip(H,[function(){K.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 Gt(t){for(var n,e=[],r=0;r=this.type&&(this.frame=this.type-1),this},l.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},l.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,Lt.apply(this),this},l.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,Lt.apply(this),this},l.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,Lt.apply(this),this},l.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},l.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))),Lt.apply(this),this},l.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},l.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},l.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},l.prototype.read=function(t){return 240==(t=t instanceof d?t:d.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(qt(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(qt(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},l.prototype.toString=function(){return Gt([this.hour,this.minute,this.second,this.frame])},p.SMPTE=l,r.prototype.SMPTE=l,d.prototype=[],(d.prototype.constructor=d).prototype.isMidi=function(){return 1};var m={};function jt(t){if(t!=parseFloat(t))throw TypeError("Not a number: "+t)}function zt(){}d.noteValue=function(t){return void 0===t?void 0:m[t.toString().toLowerCase()]},d.programValue=function(t){return t},d.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},d.freq=function(t,n){return jt(n=void 0===n?440:n),t!=parseFloat(t)&&(t=b(t)),n*Math.pow(2,(t-69)/12)},d.shift=function(t,n){return void 0===n&&(n=440),jt(t),jt(n),12*Math.log2(t/n)},d.midi=function(t,n){return t!=parseFloat(t)?b(t):d.shift(t,n)+69},d.to7b=function(t){return jt(t),t<=0?0:1<=t?127:Math.floor(128*t)},d.to14b=function(t){return jt(t),t<=0?0:1<=t?16383:Math.floor(16384*t)},d.to21b=function(t){return void 0===t?2097151:(jt(t),t<=0?0:(t=(Math.floor(t)<<14)+d.to14b(t-Math.floor(t)))<2097151?t:2097150)},d.to32b=function(t){return jt(t),t<=0?0:1<=t?4294967295:Math.floor(4294967296*t)},(zt.prototype=d)._sxid=127,d.sxId=function(t){if((t=void 0===t?d._sxid:t)==this._sxid)return this;t=v(t);var n=new zt;return n._ch=this._ch,n._sxid=t,n},d.ch=function(t){if(t==this._ch||void 0===t&&void 0===this._ch)return this;var n=new zt;return void 0!==t&&(t=g(t)),n._ch=t,n._sxid=this._sxid,n};var Ut={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(s(Ut,function(t){for(i=0;i<12&&!(127<(n=Ut[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 Vt(t){throw RangeError("Bad MIDI value: "+t)}function Wt(t){throw TypeError("Invalid value: "+t)}function g(t){return bt(t),parseInt(t)}function _(t){if(t!=parseInt(t)||t<0||15>7}function Xt(t){return[t>>14,t>>7&127,127&t]}function Ht(t,n){if(t!=parseFloat(t)&&Wt(void 0===n?t:n),t<0||1>12&15,t>>8&15,t>>4&15,15&t])}function en(t){return jt(t),(t=Math.round(65536*t+16384))<0?0:65535>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,C(t),M(t)]:[242,v(n),v(t)]},songSelect:function(t){return[243,v(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]}},S={sxIdRequest:function(){return[240,126,this._sxid,6,1,247]},sxTuningDumpRequest:function(t,n){return void 0===n?[240,126,this._sxid,8,0,v(t),247]:[240,126,this._sxid,8,3,v(t),v(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,C(t),M(t),247]:[240,127,this._sxid,4,1,v(n),v(t),247]},sxMasterVolumeF:function(t){return S.sxMasterVolume.call(this,d.to14b(Ht(t)))},sxMasterFineTuning:function(t,n){return void 0===n?[240,127,this._sxid,4,3,C(t),M(t),247]:[240,127,this._sxid,4,3,v(n),v(t),247]},sxMasterFineTuningF:function(t){return S.sxMasterFineTuning.call(this,d.to14b(Ht((t%1+1)/2,t)))},sxMasterCoarseTuning:function(t){return[240,127,this._sxid,4,4,0,v(t),247]},sxMasterCoarseTuningF:function(t){return S.sxMasterCoarseTuning.call(this,t-t%1+64)},sxNoteTuning:function(t,n,e,r){return n==parseInt(n)?[240,Qt(r),this._sxid,8,7,v(t),v(n)].concat(Kt(e),[247]):[240,127,this._sxid,8,2,v(t)].concat(Kt(n),[247])},sxNoteTuningF:function(t,n,e,r){return n==parseInt(n)?S.sxNoteTuning.call(this,t,n,Yt(e),r):S.sxNoteTuning.call(this,t,Yt(n))},sxNoteTuningHZ:function(t,n,e,r){return n==parseInt(n)?S.sxNoteTuning.call(this,t,n,$t(e),r):S.sxNoteTuning.call(this,t,$t(n))},sxScaleTuning1:function(t,n,e){return t==parseInt(t)?[240,Qt(e),this._sxid,8,8].concat(Xt(Jt(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(v(t[e]));return n}(n),[247]):S.sxScaleTuning1.call(this,65535,t,n)},sxScaleTuning1F:function(t,n,e){if(t!=parseInt(t))return S.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"+vn(ln(t)))},smfBPM:function(t){return sn.smfTempo(Math.round(6e7/t))},smfSMPTE:function(t){if(t instanceof l)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),sn.smfSMPTE(new l(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"+vn(ln(""+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"+vn(t))},smfSequencer:function(t){return w(127,ln(t))}},un={};function an(t,n){d[t]=function(){return new d(n.apply(this,arguments))},un[t]=function(){return this.send(n.apply(this,arguments))}}function cn(n){s(un,function(t){n.prototype[t]=un[t]})}s(rn,function(t){an(t,rn[t])}),s(S,function(t){an(t,S[t])}),s(sn,function(t){var n;n=sn[t=t],d[t]=function(){return n.apply(this,arguments)},un[t]=function(){return this.send(n.apply(this,arguments))}}),s(on,function(t){var r;r=on[t=t],d[t]=function(){for(var t=[],n=r.apply(this,arguments),e=0;e>4,e=c=(15&t[0]).toString(16),this._cc[e]||(this._cc[e]={}),2==r?n=new d(t.slice(1)):3==r?(i=t[1]>>4,o=15&t[1],o=t.slice(2,2+o),0==i&&(n=new d([240].concat(o,[247])),this._cc[e].sx=void 0),1==i&&(this._cc[e].sx=o),2==i&&this._cc[e].sx&&(this._cc[e].sx=this._cc[e].sx.concat(o)),3==i&&this._cc[e].sx&&(o=this._cc[e].sx.concat(o),n=new d([240].concat(o,[247])),this._cc[e].sx=void 0)):4==r?(i=t[1]>>4,h=(15&t[1]).toString(16),this._cc[e=c+h]||(this._cc[e]={}),12==i&&(1&t[3]&&(this._cc[e].bm=t[6],this._cc[e].bl=t[7]),t._bm=this._cc[e].bm,t._bl=this._cc[e].bl,p.MIDI.programName&&t.label(p.MIDI.programName(t[4],t._bm,t._bl)))):13==r&&(i=t[1]>>6,48&t[1]||(h=(15&t[1]).toString(16)),this._cc[e=c+h]||(this._cc[e]={}),o=t.slice(4),0==i&&(t.label(bn(o)),this._cc[e].tx=void 0),1==i&&(this._cc[e].tx=o),2==i&&this._cc[e].tx&&(this._cc[e].tx=this._cc[e].tx.concat(o)),3==i&&this._cc[e].tx&&(o=this._cc[e].tx.concat(o),t.label(bn(o)),this._cc[e].tx=void 0))):n=t,!n||!n.length||n[0]<128)return t;if(255==n[0])return this._clear(),t;if(i=n[0]>>4,h=(15&n[0]).toString(16),this._cc[e=15==i?c:c+h]||(this._cc[e]={}),12==i)n._bm=this._cc[e].bm,n._bl=this._cc[e].bl,p.MIDI.programName&&t.label(p.MIDI.programName(n[1],n._bm,n._bl));else if(11==i)switch(n[1]){case 0:this._cc[e].bm=n[2];break;case 32:this._cc[e].bl=n[2];break;case 98:this._cc[e].nl=n[2],this._cc[e].rn="n";break;case 99:this._cc[e].nm=n[2],this._cc[e].rn="n";break;case 100:this._cc[e].rl=n[2],this._cc[e].rn="r";break;case 101:this._cc[e].rm=n[2],this._cc[e].rn="r";break;case 6:case 38:case 96:case 97:"r"==this._cc[e].rn&&(n._rm=this._cc[e].rm,n._rl=this._cc[e].rl,t.label((a=this._cc[e].rm,u=this._cc[e].rl,a=void 0===a?"??":I(a),u=void 0===u?"??":I(u),"RPN "+a+" "+u+((a={"0000":"Pitch Bend Sensitivity","0001":"Channel Fine Tuning","0002":"Channel Coarse Tuning","0003":"Select Tuning Program","0004":"Select Tuning Bank","0005":"Vibrato Depth Range","7f7f":"NONE"}[a+""+u])?": "+a:"")))),"n"==this._cc[e].rn&&(n._nm=this._cc[e].rm,n._nl=this._cc[e].nl,t.label((u=this._cc[e].nm,a=this._cc[e].nl,"NRPN "+(void 0===u?"??":I(u))+" "+(void 0===a?"??":I(a)))))}else n.isFullSysEx()&&(127==n[1]?4==n[3]?(s={1:"Master Volume",2:"Master Balance",3:"Master Fine Tuning",4:"Master Coarse Tuning"}[n[4]])&&t.label(s):8==n[3]&&(s={2:"Note Tuning",7:"Note Tuning, Bank",8:"Scale Tuning, 1 byte format",9:"Scale Tuning, 2 byte format"}[n[4]])&&t.label(s):126==n[1]?6==n[3]?1==n[4]?t.label("Device ID Request"):2==n[4]&&t.label("Device ID Response"):8==n[3]?(s={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"}[n[4]])&&t.label(s):9==n[3]&&(1==n[4]?(t.label("GM1 System On"),this._clear(c),this._cc[c].gm="1"):2==n[4]?(t.label("GM System Off"),this._clear(c),this._cc[c].gm="0"):3==n[4]&&(t.label("GM2 System On"),this._clear(c),this._cc[c].gm="2")):67==n[1]?16==(240&n[2])&&76==n[3]&&(0==n[4]&&0==n[5]&&126==n[6]&&0==n[7]?(t.label("XG System On"),this._clear(c),this._cc[c].gm="Y"):0==n[4]&&0==n[5]&&0==n[6]?t.label("XG Master Tuning"):0==n[4]&&0==n[5]&&4==n[6]?t.label("XG Master Volume"):0==n[4]&&0==n[5]&&6==n[6]?t.label("XG Master Transpose"):8==n[4]&&n[5]<16&&65<=n[6]&&n[6]<=76?t.label("XG Scale Tuning"):t.label("XG Parameter")):65==n[1]&&66==n[3]&&18==n[4]&&(64==n[5]&&(0==n[6]?127==n[7]&&0==n[8]&&65==n[9]?(t.label("GS Reset"),this._clear(c),this._cc[c].gm="R"):0==n[7]?t.label("GS Master Tuning"):4==n[7]?t.label("GS Master Volume"):5==n[7]?t.label("GS Master Transpose"):t.label("GS Parameter"):16==(240&n[6])&&21==n[7]?t.label("GS Drum Part Change"):16==(240&n[6])&&64<=n[7]&&n[7]<=75?t.label("GS Scale Tuning"):t.label("GS Parameter")),65==n[5]&&t.label("GS Parameter")));return t}function Mn(){var t=new c;return t._clear=yn,t._read=Cn,t._receive=function(t){this._emit(this._read(t))},t.gm=function(t){return this._cc[t=void 0===t?"x":t]&&this._cc[t].gm||0},t._clear(),t._resume(),t}function xn(){var t=this instanceof xn?this:new xn;return t.reset(),arguments.length&&xn.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 Sn(){}d.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")},d.prototype._stamp=function(t){return this._from.push(t._orig||t),this},d.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},d.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 Tn=[0,0,0,0,0,0,0,0,0,0,0,0,0];function wn(t,n,e,r){return void 0!==n?[y(t),y(n),y(e),y(r)]:(((n=t)!=parseInt(n)||n<0||4294967295>24&255,t>>16&255,t>>8&255,255&t])}function In(t){return 4294967295<(t=Math.floor(4294967296*t))?4294967295:t<0?0:t}var An={noop:function(){return[0,0,0,0]},umpClock:function(t){return[0,16,(t=Jt(t))>>8,255&t]},umpTimestamp:function(t){return[0,32,(t=Jt(t))>>8,255&t]},umpTicksPQN:function(t){return[0,48,(t=Jt(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].concat(wn(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<>8,255&r,o>>8,255&o]},umpNoteOff:function(t,n,e,r,i,o){return i=i||0,o=o||0,r=Jt(r=r||0),o=Jt(o),[64+_(t),128+g(n),b(e),y(i),r>>8,255&r,o>>8,255&o]},umpAftertouch:function(t,n,e,r,i,o,s){return[64+_(t),160+g(n),b(e),0].concat(wn(r,i,o,s))},umpAftertouchF:function(t,n,e,r){return B.umpAftertouch(t,n,e,In(r))},umpControl:function(t,n,e,r,i,o,s){return Fn.includes(e)&&Vt(e),[64+_(t),176+g(n),v(e),0].concat(wn(r,i,o,s))},umpPortamento:function(t,n,e){return[64+_(t),176+g(n),84,0,b(e),0,0,0]},umpPressure:function(t,n,e,r,i,o){return[64+_(t),208+g(n),0,0].concat(wn(e,r,i,o))},umpPressureF:function(t,n,e){return B.umpPressure(t,n,In(e))},umpProgram:function(t,n,e,r,i){return void 0===r&&void 0===i?[64+_(t),192+g(n),0,0,b(e),0,0,0]:[64+_(t),192+g(n),0,1,b(e),0,b(r),b(i)]},umpPitchBend:function(t,n,e,r,i,o){return[64+_(t),224+g(n),0,0].concat(wn(e,r,i,o))},umpPitchBendF:function(t,n,e){return B.umpPitchBend(t,n,In((e+1)/2))},umpPnPitchBend:function(t,n,e,r,i,o,s){return[64+_(t),96+g(n),b(e),0].concat(wn(r,i,o,s))},umpPnPitchBendF:function(t,n,e,r){return B.umpPnPitchBend(t,n,e,In((r+1)/2))},umpRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),32+g(n),v(e),v(r)].concat(wn(i,o,s,u))},umpNRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),48+g(n),v(e),v(r)].concat(wn(i,o,s,u))},umpPnRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),0+g(n),b(e),y(r)].concat(wn(i,o,s,u))},umpPnNRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),16+g(n),b(e),y(r)].concat(wn(i,o,s,u))},umpFineTuning:function(t,n,e,r,i,o){return B.umpRPN(t,n,0,1,e,r,i,o)},umpFineTuningF:function(t,n,e){return B.umpFineTuning(t,n,d.to32b(Ht((e%1+1)/2,e)))},umpCoarseTuning:function(t,n,e){return[64+_(t),32+g(n),0,2,2*v(e),0,0,0]},umpCoarseTuningF:function(t,n,e){return B.umpCoarseTuning(t,n,e-e%1+64)},umpTuningProgram:function(t,n,e){return[64+_(t),32+g(n),0,3,2*v(e),0,0,0]},umpTuningBank:function(t,n,e){return[64+_(t),32+g(n),0,4,2*v(e),0,0,0]},umpPnManagement:function(t,n,e,r){for(var i=r.toString().split(""),o=0,s=0;s>25&127}function E(t,n){return t.gr=n,t}function Ln(t){if(t.isMidi2){var n,e,r=t[0]>>4,i=15&t[0];if(1==r||2==r)this._emit(E(new d(t.slice(1)),i));else if(3==r)e=t[1]>>4,n=15&t[1],0==e?(this._emit(E(new d([240].concat(t.slice(2,2+n),[247])),i)),this._sx[i]=void 0):1==e?this._sx[i]=t.slice(2,2+n):2==e?this._sx[i]&&(this._sx[i]=this._sx[i].concat(t.slice(2,2+n))):3==e&&(this._sx[i]&&this._emit(E(new d([240].concat(this._sx[i],t.slice(2,2+n),[247])),i)),this._sx[i]=void 0);else if(4==r){if(n=t[1]>>4,e=15&t[1],2==n||3==n?(this._emit(E(new d([176+e,2==n?101:99,t[2]]),i)),this._emit(E(new d([176+e,2==n?100:98,t[3]]),i)),this._emit(E(new d([176+e,6,t[4]>>1]),i)),this._emit(E(new d([176+e,38,64*(1&t[4])+(t[4]>>2)]),i))):8!=n&&9!=n||this._emit(E(new d([t[1],t[2],(r=t[4],o=t[5],(r=256*r+o)?r>>9||1:0)]),i)),10==n&&this._emit(E(new d([t[1],t[2],Dn(t[4],t[5],t[6],t[7])]),i)),11==n){if(Fn.includes(t[2]))return;this._emit(E(new d([t[1],t[2],Dn(t[4],t[5],t[6],t[7])]),i))}13==n&&this._emit(E(new d([t[1],Dn(t[4],t[5],t[6],t[7])]),i)),14==n?(o=16777216*t[4]+65536*t[5]+256*t[6]+t[4]>>18,this._emit(E(new d([t[1],127&o,o>>7&127]),i))):12==n&&(t[3]&&(this._emit(E(new d([176+e,0,t[6]]),i)),this._emit(E(new d([176+e,32,t[7]]),i))),this._emit(E(new d([t[1],t[4]]),i)))}}else this._emit(t);var o}function qn(t){if(t.isMidi2)this._emit(t);else{var n=0<=t.gr&&t.gr<=15?t.gr:0;if(128<=t[0]&&t[0]<240)this._emit(p.MIDI2([32+n].concat(t.slice(),Tn).slice(0,4)));else if(240>6:this.isData()||this.isSX()?this[1]>>4:void 0},A.prototype.isTempo=function(){return this[0]>>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.isTicksPQN=function(){return 0==this[0]&&this[1]>>4==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.isData=function(){return 80==(240&this[0])},A.prototype.isFlex=function(){return 208==(240&this[0])},A.prototype.isText=function(){return 208==(240&this[0])&&(1==this[2]||2==this[2])},A.prototype.isSX=function(){return 48==(240&this[0])},A.prototype.isNoteOn=function(){var t=(this[0]||0)>>4,n=(this[1]||0)>>4;return 4==t?9==n:2==t&&(9==n&&!!this[3])},A.prototype.isNoteOff=function(){var t=(this[0]||0)>>4,n=(this[1]||0)>>4;return 4==t?8==n:2==t&&(8==n||9==n&&!this[3])},A.prototype.label=d.prototype.label,A.prototype.toString=d.prototype.toString,A.prototype._str=function(){var t=this._string();return t?mn(this)+" -- "+t:mn(this)},A.prototype._string=function(){var t,n,e,r=this[0]>>4;return 1==r||2==r?new d(this.slice(1))._string():(0==r?n=["NOOP","JR Clock","JR Timestamp","Ticks Per Quarter Note","Delta Ticks"][t=this[1]>>4]:3==r?n="SysEx":4==r?(n={0:"Registered Per-Note Controller",1:"Assignable Per-Note Controller",2:"Registered Controller",3:"Assignable Controller",4:"Relative Registered Controller",5:"Relative Assignable Controller",6:"Per-Note Pitch Bend",8:"Note Off",9:"Note On",10:"Poly Pressure",11:"Control Change",12:"Program Change",13:"Channel Pressure",14:"Pitch Bend",15:"Per-Note Management"}[t=this[1]>>4],11==t&&(n={84:"Portamento"}[this[2]]||n),2==t&&(e={"0000":"Pitch Bend Sensitivity","0001":"Fine Tuning","0002":"Coarse Tuning","0003":"Select Tuning Program","0004":"Select Tuning Bank","0005":"Vibrato Depth Range","7f7f":"NONE"}[I(this[2])+""+I(this[3])])&&(n+=": "+e)):5==r?n="Data":13==r&&(0==(t=this[2])?(n={0:"Tempo ",1:"Time Signature ",2:"Metronome",5:"Key Signature",6:"Chord Name"}[t=this[3]],0==t?n+=this.getBPM()+" BPM":1==t&&(n+=this.getTimeSignature().join("/"))):1==t?n={0:"Metadata",1:"Project Name",2:"Composition Name",3:"Clip Name",4:"Copyright",5:"Composer Name",6:"Lyricist Name",7:"Arranger Name",8:"Publisher Name",9:"Primary Performer Name",10:"Accompanying Performer Name",11:"Recording Date",12:"Recording Location"}[t=this[3]]||"Unknown Text":2==t&&(n={0:"Text",1:"Lyrics",2:"Lyrics Language",3:"Ruby",4:"Ruby Language"}[t=this[3]]||"Unknown Text")),15==r?{32:"Start of Clip",33:"End of Clip"}[this[1]]:n)},A.prototype._stamp=d.prototype._stamp,A.prototype._unstamp=d.prototype._unstamp,A.prototype._stamped=d.prototype._stamped,A.prototype.match=d.prototype.match,p.UMP=A,p.MIDI2=r.prototype.UMP=A,r.prototype.MIDI2=A,p.M2M1=function(){var t=new c;return t._sx=[],t._receive=Ln,t._resume(),t.MIDI2()},r.prototype.M2M1=p.M2M1,p.M1M2=function(){var t=new c;return t._receive=qn,t._resume(),t},r.prototype.M1M2=p.M1M2,p.lib={},p.lib.now=z,p.lib.schedule=U;var Gn,O,jn=[],zn=0;try{function Un(){for(var t=jn.length,n=0;n>2,e=(3&o)<<6|(s=Zn.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},p.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++]=Zn.charAt(i>>18&63)+Zn.charAt(n)+Zn.charAt(e)+Zn.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},p.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},[]),k={},R={},Jn=t.Promise;function Xn(t,n,e){this.name=t,this.message=n,this.code=e}function Hn(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=z(),this.type="statechange"}function Qn(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=z(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function Kn(t,n){t&&(t.onstatechange&&t.onstatechange(new Hn(t,t)),n.onstatechange&&n.onstatechange(new Hn(t,n)))}function Yn(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 Jn(function(t,n){o?t(i):r.open().then(function(){o||(o=!0,Kn(i,e)),t(i)},function(){n(new Xn("InvalidAccessError","Port is not available",15))})})},this.close=function(){return new Jn(function(t){o&&(o=!1,r.close(),Kn(i,e)),t(i)})},Object.freeze(this)}function $n(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 Gt(t){for(var n,e=[],r=0;r=this.type&&(this.frame=this.type-1),this},l.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},l.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,Lt.apply(this),this},l.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,Lt.apply(this),this},l.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,Lt.apply(this),this},l.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},l.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))),Lt.apply(this),this},l.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},l.prototype.incrQF=function(){return this.backwards=!1,this.quarter=this.quarter+1&7,0!=this.quarter&&4!=this.quarter||this.incrFrame(),this},l.prototype.decrQF=function(){return this.backwards=!0,this.quarter=this.quarter+7&7,3!=this.quarter&&7!=this.quarter||this.decrFrame(),this},l.prototype.read=function(t){return 240==(t=t instanceof d?t:d.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(qt(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(qt(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},l.prototype.toString=function(){return Gt([this.hour,this.minute,this.second,this.frame])},p.SMPTE=l,r.prototype.SMPTE=l,d.prototype=[],(d.prototype.constructor=d).prototype.isMidi=function(){return 1};var m={};function jt(t){if(t!=parseFloat(t))throw TypeError("Not a number: "+t)}function zt(){}d.noteValue=function(t){return void 0===t?void 0:m[t.toString().toLowerCase()]},d.programValue=function(t){return t},d.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},d.freq=function(t,n){return jt(n=void 0===n?440:n),t!=parseFloat(t)&&(t=b(t)),n*Math.pow(2,(t-69)/12)},d.shift=function(t,n){return void 0===n&&(n=440),jt(t),jt(n),12*Math.log2(t/n)},d.midi=function(t,n){return t!=parseFloat(t)?b(t):d.shift(t,n)+69},d.to7b=function(t){return jt(t),t<=0?0:1<=t?127:Math.floor(128*t)},d.to14b=function(t){return jt(t),t<=0?0:1<=t?16383:Math.floor(16384*t)},d.to21b=function(t){return void 0===t?2097151:(jt(t),t<=0?0:(t=(Math.floor(t)<<14)+d.to14b(t-Math.floor(t)))<2097151?t:2097150)},d.to32b=function(t){return jt(t),t<=0?0:1<=t?4294967295:Math.floor(4294967296*t)},(zt.prototype=d)._sxid=127,d.sxId=function(t){if((t=void 0===t?d._sxid:t)==this._sxid)return this;t=v(t);var n=new zt;return n._ch=this._ch,n._sxid=t,n},d.ch=function(t){if(t==this._ch||void 0===t&&void 0===this._ch)return this;var n=new zt;return void 0!==t&&(t=g(t)),n._ch=t,n._sxid=this._sxid,n};var Ut={c:0,d:2,e:4,f:5,g:7,a:9,b:11,h:11};for(s(Ut,function(t){for(i=0;i<12&&!(127<(n=Ut[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 Vt(t){throw RangeError("Bad MIDI value: "+t)}function Wt(t){throw TypeError("Invalid value: "+t)}function g(t){return bt(t),parseInt(t)}function _(t){if(t!=parseInt(t)||t<0||15>7}function Xt(t){return[t>>14,t>>7&127,127&t]}function Ht(t,n){if(t!=parseFloat(t)&&Wt(void 0===n?t:n),t<0||1>12&15,t>>8&15,t>>4&15,15&t])}function en(t){return jt(t),(t=Math.round(65536*t+16384))<0?0:65535>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,C(t),M(t)]:[242,v(n),v(t)]},songSelect:function(t){return[243,v(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]}},S={sxIdRequest:function(){return[240,126,this._sxid,6,1,247]},sxTuningDumpRequest:function(t,n){return void 0===n?[240,126,this._sxid,8,0,v(t),247]:[240,126,this._sxid,8,3,v(t),v(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,C(t),M(t),247]:[240,127,this._sxid,4,1,v(n),v(t),247]},sxMasterVolumeF:function(t){return S.sxMasterVolume.call(this,d.to14b(Ht(t)))},sxMasterFineTuning:function(t,n){return void 0===n?[240,127,this._sxid,4,3,C(t),M(t),247]:[240,127,this._sxid,4,3,v(n),v(t),247]},sxMasterFineTuningF:function(t){return S.sxMasterFineTuning.call(this,d.to14b(Ht((t%1+1)/2,t)))},sxMasterCoarseTuning:function(t){return[240,127,this._sxid,4,4,0,v(t),247]},sxMasterCoarseTuningF:function(t){return S.sxMasterCoarseTuning.call(this,t-t%1+64)},sxNoteTuning:function(t,n,e,r){return n==parseInt(n)?[240,Qt(r),this._sxid,8,7,v(t),v(n)].concat(Kt(e),[247]):[240,127,this._sxid,8,2,v(t)].concat(Kt(n),[247])},sxNoteTuningF:function(t,n,e,r){return n==parseInt(n)?S.sxNoteTuning.call(this,t,n,Yt(e),r):S.sxNoteTuning.call(this,t,Yt(n))},sxNoteTuningHZ:function(t,n,e,r){return n==parseInt(n)?S.sxNoteTuning.call(this,t,n,$t(e),r):S.sxNoteTuning.call(this,t,$t(n))},sxScaleTuning1:function(t,n,e){return t==parseInt(t)?[240,Qt(e),this._sxid,8,8].concat(Xt(Jt(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(v(t[e]));return n}(n),[247]):S.sxScaleTuning1.call(this,65535,t,n)},sxScaleTuning1F:function(t,n,e){if(t!=parseInt(t))return S.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"+vn(ln(t)))},smfBPM:function(t){return sn.smfTempo(Math.round(6e7/t))},smfSMPTE:function(t){if(t instanceof l)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),sn.smfSMPTE(new l(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"+vn(ln(""+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"+vn(t))},smfSequencer:function(t){return w(127,ln(t))}},un={};function an(t,n){d[t]=function(){return new d(n.apply(this,arguments))},un[t]=function(){return this.send(n.apply(this,arguments))}}function cn(n){s(un,function(t){n.prototype[t]=un[t]})}s(rn,function(t){an(t,rn[t])}),s(S,function(t){an(t,S[t])}),s(sn,function(t){var n;n=sn[t=t],d[t]=function(){return n.apply(this,arguments)},un[t]=function(){return this.send(n.apply(this,arguments))}}),s(on,function(t){var r;r=on[t=t],d[t]=function(){for(var t=[],n=r.apply(this,arguments),e=0;e>4,e=c=(15&t[0]).toString(16),this._cc[e]||(this._cc[e]={}),2==r?n=new d(t.slice(1)):3==r?(i=t[1]>>4,o=15&t[1],o=t.slice(2,2+o),0==i&&(n=new d([240].concat(o,[247])),this._cc[e].sx=void 0),1==i&&(this._cc[e].sx=o),2==i&&this._cc[e].sx&&(this._cc[e].sx=this._cc[e].sx.concat(o)),3==i&&this._cc[e].sx&&(o=this._cc[e].sx.concat(o),n=new d([240].concat(o,[247])),this._cc[e].sx=void 0)):4==r?(i=t[1]>>4,h=(15&t[1]).toString(16),this._cc[e=c+h]||(this._cc[e]={}),12==i&&(1&t[3]&&(this._cc[e].bm=t[6],this._cc[e].bl=t[7]),t._bm=this._cc[e].bm,t._bl=this._cc[e].bl,p.MIDI.programName&&t.label(p.MIDI.programName(t[4],t._bm,t._bl)))):13==r&&(i=t[1]>>6,48&t[1]||(h=(15&t[1]).toString(16)),this._cc[e=c+h]||(this._cc[e]={}),o=t.slice(4),0==i&&(t.label(bn(o)),this._cc[e].tx=void 0),1==i&&(this._cc[e].tx=o),2==i&&this._cc[e].tx&&(this._cc[e].tx=this._cc[e].tx.concat(o)),3==i&&this._cc[e].tx&&(o=this._cc[e].tx.concat(o),t.label(bn(o)),this._cc[e].tx=void 0))):n=t,!n||!n.length||n[0]<128)return t;if(255==n[0])return this._clear(),t;if(i=n[0]>>4,h=(15&n[0]).toString(16),this._cc[e=15==i?c:c+h]||(this._cc[e]={}),12==i)n._bm=this._cc[e].bm,n._bl=this._cc[e].bl,p.MIDI.programName&&t.label(p.MIDI.programName(n[1],n._bm,n._bl));else if(11==i)switch(n[1]){case 0:this._cc[e].bm=n[2];break;case 32:this._cc[e].bl=n[2];break;case 98:this._cc[e].nl=n[2],this._cc[e].rn="n";break;case 99:this._cc[e].nm=n[2],this._cc[e].rn="n";break;case 100:this._cc[e].rl=n[2],this._cc[e].rn="r";break;case 101:this._cc[e].rm=n[2],this._cc[e].rn="r";break;case 6:case 38:case 96:case 97:"r"==this._cc[e].rn&&(n._rm=this._cc[e].rm,n._rl=this._cc[e].rl,t.label((a=this._cc[e].rm,u=this._cc[e].rl,a=void 0===a?"??":I(a),u=void 0===u?"??":I(u),"RPN "+a+" "+u+((a={"0000":"Pitch Bend Sensitivity","0001":"Channel Fine Tuning","0002":"Channel Coarse Tuning","0003":"Select Tuning Program","0004":"Select Tuning Bank","0005":"Vibrato Depth Range","7f7f":"NONE"}[a+""+u])?": "+a:"")))),"n"==this._cc[e].rn&&(n._nm=this._cc[e].rm,n._nl=this._cc[e].nl,t.label((u=this._cc[e].nm,a=this._cc[e].nl,"NRPN "+(void 0===u?"??":I(u))+" "+(void 0===a?"??":I(a)))))}else n.isFullSysEx()&&(127==n[1]?4==n[3]?(s={1:"Master Volume",2:"Master Balance",3:"Master Fine Tuning",4:"Master Coarse Tuning"}[n[4]])&&t.label(s):8==n[3]&&(s={2:"Note Tuning",7:"Note Tuning, Bank",8:"Scale Tuning, 1 byte format",9:"Scale Tuning, 2 byte format"}[n[4]])&&t.label(s):126==n[1]?6==n[3]?1==n[4]?t.label("Device ID Request"):2==n[4]&&t.label("Device ID Response"):8==n[3]?(s={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"}[n[4]])&&t.label(s):9==n[3]&&(1==n[4]?(t.label("GM1 System On"),this._clear(c),this._cc[c].gm="1"):2==n[4]?(t.label("GM System Off"),this._clear(c),this._cc[c].gm="0"):3==n[4]&&(t.label("GM2 System On"),this._clear(c),this._cc[c].gm="2")):67==n[1]?16==(240&n[2])&&76==n[3]&&(0==n[4]&&0==n[5]&&126==n[6]&&0==n[7]?(t.label("XG System On"),this._clear(c),this._cc[c].gm="Y"):0==n[4]&&0==n[5]&&0==n[6]?t.label("XG Master Tuning"):0==n[4]&&0==n[5]&&4==n[6]?t.label("XG Master Volume"):0==n[4]&&0==n[5]&&6==n[6]?t.label("XG Master Transpose"):8==n[4]&&n[5]<16&&65<=n[6]&&n[6]<=76?t.label("XG Scale Tuning"):t.label("XG Parameter")):65==n[1]&&66==n[3]&&18==n[4]&&(64==n[5]&&(0==n[6]?127==n[7]&&0==n[8]&&65==n[9]?(t.label("GS Reset"),this._clear(c),this._cc[c].gm="R"):0==n[7]?t.label("GS Master Tuning"):4==n[7]?t.label("GS Master Volume"):5==n[7]?t.label("GS Master Transpose"):t.label("GS Parameter"):16==(240&n[6])&&21==n[7]?t.label("GS Drum Part Change"):16==(240&n[6])&&64<=n[7]&&n[7]<=75?t.label("GS Scale Tuning"):t.label("GS Parameter")),65==n[5]&&t.label("GS Parameter")));return t}function Mn(){var t=new c;return t._clear=yn,t._read=Cn,t._receive=function(t){this._emit(this._read(t))},t.gm=function(t){return this._cc[t=void 0===t?"x":t]&&this._cc[t].gm||0},t._clear(),t._resume(),t}function xn(){var t=this instanceof xn?this:new xn;return t.reset(),arguments.length&&xn.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 Sn(){}d.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")},d.prototype._stamp=function(t){return this._from.push(t._orig||t),this},d.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},d.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 Tn=[0,0,0,0,0,0,0,0,0,0,0,0,0];function wn(t,n,e,r){return void 0!==n?[y(t),y(n),y(e),y(r)]:(((n=t)!=parseInt(n)||n<0||4294967295>24&255,t>>16&255,t>>8&255,255&t])}function In(t){return 4294967295<(t=Math.floor(4294967296*t))?4294967295:t<0?0:t}var An={noop:function(){return[0,0,0,0]},umpClock:function(t){return[0,16,(t=Jt(t))>>8,255&t]},umpTimestamp:function(t){return[0,32,(t=Jt(t))>>8,255&t]},umpTicksPQN:function(t){return[0,48,(t=Jt(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].concat(wn(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<>8,255&r,o>>8,255&o]},umpNoteOff:function(t,n,e,r,i,o){return i=i||0,o=o||0,r=Jt(r=r||0),o=Jt(o),[64+_(t),128+g(n),b(e),y(i),r>>8,255&r,o>>8,255&o]},umpAftertouch:function(t,n,e,r,i,o,s){return[64+_(t),160+g(n),b(e),0].concat(wn(r,i,o,s))},umpAftertouchF:function(t,n,e,r){return B.umpAftertouch(t,n,e,In(r))},umpControl:function(t,n,e,r,i,o,s){return Fn.includes(e)&&Vt(e),[64+_(t),176+g(n),v(e),0].concat(wn(r,i,o,s))},umpPortamento:function(t,n,e){return[64+_(t),176+g(n),84,0,b(e),0,0,0]},umpPressure:function(t,n,e,r,i,o){return[64+_(t),208+g(n),0,0].concat(wn(e,r,i,o))},umpPressureF:function(t,n,e){return B.umpPressure(t,n,In(e))},umpProgram:function(t,n,e,r,i){return void 0===r&&void 0===i?[64+_(t),192+g(n),0,0,b(e),0,0,0]:[64+_(t),192+g(n),0,1,b(e),0,b(r),b(i)]},umpPitchBend:function(t,n,e,r,i,o){return[64+_(t),224+g(n),0,0].concat(wn(e,r,i,o))},umpPitchBendF:function(t,n,e){return B.umpPitchBend(t,n,In((e+1)/2))},umpPnPitchBend:function(t,n,e,r,i,o,s){return[64+_(t),96+g(n),b(e),0].concat(wn(r,i,o,s))},umpPnPitchBendF:function(t,n,e,r){return B.umpPnPitchBend(t,n,e,In((r+1)/2))},umpRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),32+g(n),v(e),v(r)].concat(wn(i,o,s,u))},umpNRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),48+g(n),v(e),v(r)].concat(wn(i,o,s,u))},umpPnRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),0+g(n),b(e),y(r)].concat(wn(i,o,s,u))},umpPnNRPN:function(t,n,e,r,i,o,s,u){return[64+_(t),16+g(n),b(e),y(r)].concat(wn(i,o,s,u))},umpFineTuning:function(t,n,e,r,i,o){return B.umpRPN(t,n,0,1,e,r,i,o)},umpFineTuningF:function(t,n,e){return B.umpFineTuning(t,n,d.to32b(Ht((e%1+1)/2,e)))},umpCoarseTuning:function(t,n,e){return[64+_(t),32+g(n),0,2,2*v(e),0,0,0]},umpCoarseTuningF:function(t,n,e){return B.umpCoarseTuning(t,n,e-e%1+64)},umpTuningProgram:function(t,n,e){return[64+_(t),32+g(n),0,3,2*v(e),0,0,0]},umpTuningBank:function(t,n,e){return[64+_(t),32+g(n),0,4,2*v(e),0,0,0]},umpPnManagement:function(t,n,e,r){for(var i=r.toString().split(""),o=0,s=0;s>25&127}function E(t,n){return t.gr=n,t}function Ln(t){if(t.isMidi2){var n,e,r=t[0]>>4,i=15&t[0];if(1==r||2==r)this._emit(E(new d(t.slice(1)),i));else if(3==r)e=t[1]>>4,n=15&t[1],0==e?(this._emit(E(new d([240].concat(t.slice(2,2+n),[247])),i)),this._sx[i]=void 0):1==e?this._sx[i]=t.slice(2,2+n):2==e?this._sx[i]&&(this._sx[i]=this._sx[i].concat(t.slice(2,2+n))):3==e&&(this._sx[i]&&this._emit(E(new d([240].concat(this._sx[i],t.slice(2,2+n),[247])),i)),this._sx[i]=void 0);else if(4==r){if(n=t[1]>>4,e=15&t[1],2==n||3==n?(this._emit(E(new d([176+e,2==n?101:99,t[2]]),i)),this._emit(E(new d([176+e,2==n?100:98,t[3]]),i)),this._emit(E(new d([176+e,6,t[4]>>1]),i)),this._emit(E(new d([176+e,38,64*(1&t[4])+(t[4]>>2)]),i))):8!=n&&9!=n||this._emit(E(new d([t[1],t[2],(r=t[4],o=t[5],(r=256*r+o)?r>>9||1:0)]),i)),10==n&&this._emit(E(new d([t[1],t[2],Dn(t[4],t[5],t[6],t[7])]),i)),11==n){if(Fn.includes(t[2]))return;this._emit(E(new d([t[1],t[2],Dn(t[4],t[5],t[6],t[7])]),i))}13==n&&this._emit(E(new d([t[1],Dn(t[4],t[5],t[6],t[7])]),i)),14==n?(o=16777216*t[4]+65536*t[5]+256*t[6]+t[4]>>18,this._emit(E(new d([t[1],127&o,o>>7&127]),i))):12==n&&(t[3]&&(this._emit(E(new d([176+e,0,t[6]]),i)),this._emit(E(new d([176+e,32,t[7]]),i))),this._emit(E(new d([t[1],t[4]]),i)))}}else this._emit(t);var o}function qn(t){if(t.isMidi2)this._emit(t);else{var n=0<=t.gr&&t.gr<=15?t.gr:0;if(128<=t[0]&&t[0]<240)this._emit(p.MIDI2([32+n].concat(t.slice(),Tn).slice(0,4)));else if(240>6:this.isData()||this.isSX()?this[1]>>4:void 0},A.prototype.isTempo=function(){return this[0]>>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.isTicksPQN=function(){return 0==this[0]&&this[1]>>4==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.isData=function(){return 80==(240&this[0])},A.prototype.isFlex=function(){return 208==(240&this[0])},A.prototype.isText=function(){return 208==(240&this[0])&&(1==this[2]||2==this[2])},A.prototype.isSX=function(){return 48==(240&this[0])},A.prototype.isNoteOn=function(){var t=(this[0]||0)>>4,n=(this[1]||0)>>4;return 4==t?9==n:2==t&&(9==n&&!!this[3])},A.prototype.isNoteOff=function(){var t=(this[0]||0)>>4,n=(this[1]||0)>>4;return 4==t?8==n:2==t&&(8==n||9==n&&!this[3])},A.prototype.label=d.prototype.label,A.prototype.toString=d.prototype.toString,A.prototype._str=function(){var t=this._string();return t?mn(this)+" -- "+t:mn(this)},A.prototype._string=function(){var t,n,e,r=this[0]>>4;return 1==r||2==r?new d(this.slice(1))._string():(0==r?n=["NOOP","JR Clock","JR Timestamp","Ticks Per Quarter Note","Delta Ticks"][t=this[1]>>4]:3==r?n="SysEx":4==r?(n={0:"Registered Per-Note Controller",1:"Assignable Per-Note Controller",2:"Registered Controller",3:"Assignable Controller",4:"Relative Registered Controller",5:"Relative Assignable Controller",6:"Per-Note Pitch Bend",8:"Note Off",9:"Note On",10:"Poly Pressure",11:"Control Change",12:"Program Change",13:"Channel Pressure",14:"Pitch Bend",15:"Per-Note Management"}[t=this[1]>>4],11==t&&(n={84:"Portamento"}[this[2]]||n),2==t&&(e={"0000":"Pitch Bend Sensitivity","0001":"Fine Tuning","0002":"Coarse Tuning","0003":"Select Tuning Program","0004":"Select Tuning Bank","0005":"Vibrato Depth Range","7f7f":"NONE"}[I(this[2])+""+I(this[3])])&&(n+=": "+e)):5==r?n="Data":13==r&&(0==(t=this[2])?(n={0:"Tempo ",1:"Time Signature ",2:"Metronome",5:"Key Signature",6:"Chord Name"}[t=this[3]],0==t?n+=this.getBPM()+" BPM":1==t&&(n+=this.getTimeSignature().join("/"))):1==t?n={0:"Metadata",1:"Project Name",2:"Composition Name",3:"Clip Name",4:"Copyright",5:"Composer Name",6:"Lyricist Name",7:"Arranger Name",8:"Publisher Name",9:"Primary Performer Name",10:"Accompanying Performer Name",11:"Recording Date",12:"Recording Location"}[t=this[3]]||"Unknown Text":2==t&&(n={0:"Text",1:"Lyrics",2:"Lyrics Language",3:"Ruby",4:"Ruby Language"}[t=this[3]]||"Unknown Text")),15==r?{32:"Start of Clip",33:"End of Clip"}[this[1]]:n)},A.prototype._stamp=d.prototype._stamp,A.prototype._unstamp=d.prototype._unstamp,A.prototype._stamped=d.prototype._stamped,A.prototype.match=d.prototype.match,p.UMP=A,p.MIDI2=r.prototype.UMP=A,r.prototype.MIDI2=A,p.M2M1=function(){var t=new c;return t._sx=[],t._receive=Ln,t._resume(),t.MIDI2()},r.prototype.M2M1=p.M2M1,p.M1M2=function(){var t=new c;return t._receive=qn,t._resume(),t},r.prototype.M1M2=p.M1M2,p.lib={},p.lib.now=z,p.lib.schedule=U;var Gn,O,jn=[],zn=0;try{function Un(){for(var t=jn.length,n=0;n>2,e=(3&o)<<6|(s=Zn.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},p.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++]=Zn.charAt(i>>18&63)+Zn.charAt(n)+Zn.charAt(e)+Zn.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},p.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},[]),k={},R={},Jn=t.Promise;function Xn(t,n,e){this.name=t,this.message=n,this.code=e}function Hn(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=z(),this.type="statechange"}function Qn(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=z(),this.returnValue=!0,this.srcElement=t,this.target=t,this.timeStamp=this.receivedTime,this.type="midimessage"}function Kn(t,n){t&&(t.onstatechange&&t.onstatechange(new Hn(t,t)),n.onstatechange&&n.onstatechange(new Hn(t,n)))}function Yn(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 Jn(function(t,n){o?t(i):r.open().then(function(){o||(o=!0,Kn(i,e)),t(i)},function(){n(new Xn("InvalidAccessError","Port is not available",15))})})},this.close=function(){return new Jn(function(t){o&&(o=!1,r.close(),Kn(i,e)),t(i)})},Object.freeze(this)}function $n(t){for(var n,e;t.length;){for(n=0;nt.length)return;for(n=1;n