/*! * midicube 0.9.2 built on 2025-08-07. * * ---------------------------------------------------------- * midicube * 2025-05-23 - version 0.9.1 * * based on MIDI.js. v. 0.3.4 : 2015-03-26 * * MIT License * https://github.com/mscuthbert/midicube/ * * Technologies: Web MIDI API, Web Audio API, HTML5 Audio Tag * ---------------------------------------------------------- */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("MIDI",[],t):"object"==typeof exports?exports.MIDI=t():e.MIDI=t()}(self,(()=>(()=>{var e={452:e=>{var t=function(e){"use strict";var t,n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var i=t&&t.prototype instanceof A?t:A,a=Object.create(i.prototype),s=new k(r||[]);return o(a,"_invoke",{value:C(e,n,s)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var h="suspendedStart",p="suspendedYield",f="executing",g="completed",m={};function A(){}function y(){}function b(){}var v={};l(v,a,(function(){return this}));var w=Object.getPrototypeOf,q=w&&w(w(I([])));q&&q!==n&&r.call(q,a)&&(v=q);var S=b.prototype=A.prototype=Object.create(v);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function F(e,t){function n(o,i,a,s){var c=d(e[o],e,i);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==typeof u&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(u).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(c.arg)}var i;o(this,"_invoke",{value:function(e,r){function o(){return new t((function(t,o){n(e,r,t,o)}))}return i=i?i.then(o,o):o()}})}function C(e,t,n){var r=h;return function(o,i){if(r===f)throw new Error("Generator is already running");if(r===g){if("throw"===o)throw i;return M()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var s=B(a,n);if(s){if(s===m)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(r===h)throw r=g,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r=f;var c=d(e,t,n);if("normal"===c.type){if(r=n.done?g:p,c.arg===m)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(r=g,n.method="throw",n.arg=c.arg)}}}function B(e,n){var r=n.method,o=e.iterator[r];if(o===t)return n.delegate=null,"throw"===r&&e.iterator.return&&(n.method="return",n.arg=t,B(e,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),m;var i=d(o,e.iterator,n.arg);if("throw"===i.type)return n.method="throw",n.arg=i.arg,n.delegate=null,m;var a=i.arg;return a?a.done?(n[e.resultName]=a.value,n.next=e.nextLoc,"return"!==n.method&&(n.method="next",n.arg=t),n.delegate=null,m):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,m)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function I(e){if(e){var n=e[a];if(n)return n.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function n(){for(;++o=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),l=r.call(a,"finallyLoc");if(c&&l){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),T(n),m}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;T(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,n,r){return this.delegate={iterator:I(e),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=t),m}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{AudioTag:()=>e,GM:()=>g,Player:()=>pt,Soundfont:()=>Je,Synesthesia:()=>i,WebAudio:()=>t,WebMIDI:()=>o,audioDetect_supports:()=>He,audio_contexts:()=>Ye,channels:()=>m,chordOff:()=>ct,chordOn:()=>st,config:()=>Ne,getContext:()=>dt,keyToNote:()=>A,loadPlugin:()=>Ve,loadProgram:()=>je,noteOff:()=>at,noteOn:()=>it,noteToKey:()=>y,pitchBend:()=>ot,playChannel:()=>ze,programChange:()=>rt,requestQueue:()=>Xe,send:()=>et,sendRequest:()=>Qe,setContext:()=>ht,setController:()=>tt,setEffects:()=>ut,setVolume:()=>nt,stopAllNotes:()=>lt,stopChannel:()=>$e});var e={};n.r(e),n.d(e,{api:()=>b,chordOff:()=>U,chordOn:()=>D,connect:()=>C,getContext:()=>I,noteOff:()=>O,noteOn:()=>L,pitchBend:()=>T,playChannel:()=>R,programChange:()=>K,send:()=>B,setContext:()=>M,setController:()=>x,setEffects:()=>k,setVolume:()=>G,shared_root_info:()=>v,stopAllNotes:()=>W,stopChannel:()=>_});var t={};n.r(t),n.d(t,{api:()=>Y,chordOff:()=>ce,chordOn:()=>se,connect:()=>Q,createAudioContext:()=>fe,getContext:()=>de,loadAudio:()=>pe,noteOff:()=>ae,noteOn:()=>ie,pitchBend:()=>oe,playChannel:()=>z,programChange:()=>re,send:()=>ee,setContext:()=>he,setController:()=>te,setEffects:()=>ue,setVolume:()=>ne,shared_root_info:()=>N,stopAllNotes:()=>le,stopChannel:()=>$});var o={};n.r(o),n.d(o,{api:()=>ge,chordOff:()=>Me,chordOn:()=>Ie,connect:()=>ye,getContext:()=>qe,noteOff:()=>ke,noteOn:()=>Te,pitchBend:()=>xe,playChannel:()=>be,programChange:()=>Be,send:()=>Ee,setContext:()=>Se,setController:()=>Fe,setEffects:()=>we,setVolume:()=>Ce,shared_root_info:()=>me,stopAllNotes:()=>Re,stopChannel:()=>ve});var i={};n.r(i),n.d(i,{data:()=>Ue,map:()=>We});n(452);const a=void 0!==window.safari,s=window.navigator.userAgent.toLowerCase().includes("firefox"),c="function"==typeof window.ShadowRoot.prototype.getSelection,l="function"==typeof window.InputEvent.prototype.getTargetRanges,u=!c&&l&&!s||a,d={};let h=0;const p=e=>{h+=1;const t=document.body,n=new Audio,r=e.split(";")[0];n.id="audio",n.setAttribute("preload","auto"),n.setAttribute("audiobuffer","true"),n.addEventListener("error",(()=>{t.removeChild(n),d[r]=!1,h-=1}),!1),n.addEventListener("canplaythrough",(()=>{t.removeChild(n),d[r]=!0,h-=1}),!1),n.src="data:"+e,t.appendChild(n)};const f=!1,g=(e=>{const t=e=>e.replace(/[^a-z0-9 ]/gi,"").replace(/ /g,"_").toLowerCase(),n={byName:{},byId:{},byCategory:{}};for(const[r,o]of Object.entries(e))for(const e of o){if(!e)continue;const o=parseInt(e.substr(0,e.indexOf(" ")),10),i=o-1,a=e.replace(o+" ",""),s=t(a),c=t(r),l={id:s,name:a,program:i,category:r};n.byId[i]=l,n.byName[s]=l,n.byCategory[c]=n.byCategory[c]||[],n.byCategory[c].push(l)}return n})({Piano:["1 Acoustic Grand Piano","2 Bright Acoustic Piano","3 Electric Grand Piano","4 Honky-tonk Piano","5 Electric Piano 1","6 Electric Piano 2","7 Harpsichord","8 Clavinet"],"Chromatic Percussion":["9 Celesta","10 Glockenspiel","11 Music Box","12 Vibraphone","13 Marimba","14 Xylophone","15 Tubular Bells","16 Dulcimer"],Organ:["17 Drawbar Organ","18 Percussive Organ","19 Rock Organ","20 Church Organ","21 Reed Organ","22 Accordion","23 Harmonica","24 Tango Accordion"],Guitar:["25 Acoustic Guitar (nylon)","26 Acoustic Guitar (steel)","27 Electric Guitar (jazz)","28 Electric Guitar (clean)","29 Electric Guitar (muted)","30 Overdriven Guitar","31 Distortion Guitar","32 Guitar Harmonics"],Bass:["33 Acoustic Bass","34 Electric Bass (finger)","35 Electric Bass (pick)","36 Fretless Bass","37 Slap Bass 1","38 Slap Bass 2","39 Synth Bass 1","40 Synth Bass 2"],Strings:["41 Violin","42 Viola","43 Cello","44 Contrabass","45 Tremolo Strings","46 Pizzicato Strings","47 Orchestral Harp","48 Timpani"],Ensemble:["49 String Ensemble 1","50 String Ensemble 2","51 Synth Strings 1","52 Synth Strings 2","53 Choir Aahs","54 Voice Oohs","55 Synth Choir","56 Orchestra Hit"],Brass:["57 Trumpet","58 Trombone","59 Tuba","60 Muted Trumpet","61 French Horn","62 Brass Section","63 Synth Brass 1","64 Synth Brass 2"],Reed:["65 Soprano Sax","66 Alto Sax","67 Tenor Sax","68 Baritone Sax","69 Oboe","70 English Horn","71 Bassoon","72 Clarinet"],Pipe:["73 Piccolo","74 Flute","75 Recorder","76 Pan Flute","77 Blown Bottle","78 Shakuhachi","79 Whistle","80 Ocarina"],"Synth Lead":["81 Lead 1 (square)","82 Lead 2 (sawtooth)","83 Lead 3 (calliope)","84 Lead 4 (chiff)","85 Lead 5 (charang)","86 Lead 6 (voice)","87 Lead 7 (fifths)","88 Lead 8 (bass + lead)"],"Synth Pad":["89 Pad 1 (new age)","90 Pad 2 (warm)","91 Pad 3 (polysynth)","92 Pad 4 (choir)","93 Pad 5 (bowed)","94 Pad 6 (metallic)","95 Pad 7 (halo)","96 Pad 8 (sweep)"],"Synth Effects":["97 FX 1 (rain)","98 FX 2 (soundtrack)","99 FX 3 (crystal)","100 FX 4 (atmosphere)","101 FX 5 (brightness)","102 FX 6 (goblins)","103 FX 7 (echoes)","104 FX 8 (sci-fi)"],Ethnic:["105 Sitar","106 Banjo","107 Shamisen","108 Koto","109 Kalimba","110 Bagpipe","111 Fiddle","112 Shanai"],Percussive:["113 Tinkle Bell","114 Agogo","115 Steel Drums","116 Woodblock","117 Taiko Drum","118 Melodic Tom","119 Synth Drum"],"Sound effects":["120 Reverse Cymbal","121 Guitar Fret Noise","122 Breath Noise","123 Seashore","124 Bird Tweet","125 Telephone Ring","126 Helicopter","127 Applause","128 Gunshot"]}),m=(()=>{const e={};for(let t=0;t<16;t++)e[t]={program:t,pitchBend:0,mute:!1,mono:!1,omni:!1,solo:!1};return e})(),A={},y={};!function(){const e=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"];for(let t=21;t<=108;t++){const n=Math.floor((t-12)/12),r=e[t%12]+n;A[r]=t,y[t]=r}}();const b="audiotag",v={},w=[];for(let e=0;e<16;e++)w[e]=127;let q=-1;const S=[],E={},F=[];for(let e=0;e<12;e++)F[e]=new Audio;const C=e=>{for(const e of Object.keys(A))E[e]={id:e};e.onsuccess&&e.onsuccess()},B=(e,t)=>{},x=(e,t,n,r)=>{},T=(e,t,n)=>{},k=()=>{},I=()=>{},M=()=>{},R=(e,t)=>{if(!m[e])return;const n=m[e].program,r=g.byId[n].id,o=E[t];if(o){const t=r+""+o.id,n=(q+1)%F.length,i=F[n];if(S[n]=t,!v.Soundfont[r])return void 0;i.src=v.Soundfont[r][o.id],i.volume=w[e]/127,i.play(),q=n}},_=(e,t)=>{if(!m[e])return;const n=m[e].program,r=g.byId[n].id,o=E[t];if(o){const e=r+""+o.id;for(let t=0,n=F.length;t{w[e]=t},K=(e,t)=>{m[e].instrument=t},L=(e,t,n,r)=>{const o=y[t];return!!E[o]&&(r?setTimeout((()=>{w[e]=n,R(e,o)}),1e3*r):(w[e]=n,R(e,o),!0))},O=(e,t,n)=>{},D=(e,t,n,r)=>{for(let n=0;n{R(e,i)}),1e3*r):R(e,i))}},U=(e,t,n)=>{for(let r=0;r{_(e,i)}),1e3*n):_(e,i))}},W=()=>{for(let e=0,{length:t}=F;e>4,a=(15&l)<<4|u>>2,s=(3&u)<<6|d,o[t]=i,64!==u&&(o[t+1]=a),64!==d&&(o[t+2]=s)}(e,n),n}const Y="webaudio",N={};let V;const j={},P={};let Z=127;const X={},Q=e=>{he(V||fe(),e.onsuccess)},z=()=>{},$=()=>{},ee=(e,t)=>{},te=(e,t,n,r)=>{},ne=(e,t,n)=>{n?setTimeout((()=>{Z=t}),1e3*n):Z=t},re=(e,t,n)=>{const r=m[e];r&&(r.program=t)},oe=(e,t,n)=>{const r=m[e];r&&(n?setTimeout((()=>{r.pitchBend=t}),n):r.pitchBend=t)},ie=function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=m[e].program,i=X[o+"x"+t];if(!i)return void 0;if(!V)return void 0;let a;if(r2&&void 0!==arguments[2]?arguments[2]:0;const r=m[e].program,o=X[r+"x"+t];if(V&&o){n{const o={};for(const i of t)o[i]=ie(e,i,n,r);return o},ce=(e,t,n)=>{const r={};for(const o of t)r[o]=ae(e,o,n);return r},le=()=>{if(V)for(const e of Object.keys(j)){let t=0;t{if(V&&V.tunajs)for(const t of e){const e=new V.tunajs[t.type](t);e.connect(V.destination),P[t.type]=e}else console.log("Effects module not installed.")},de=()=>V,he=(e,t,n,r)=>{V=e,"undefined"==typeof Tuna||V.tunajs instanceof Tuna||(V.tunajs=new Tuna(V));const o=[];for(const e of Object.keys(A))o.push(e);const i=e=>{for(const e of Object.keys(s))if(s[e])return;t&&(t(),t=null)},a=(e,t,n,r)=>{const o=e[r];o&&(s[t]+=1,pe(o,(n=>{n.id=r;const o=A[r];if(X[t+"x"+o]=n,s[t]-=1,0===s[t]){f,e.isLoaded=!0,i()}}),(e=>{console.log(e)})))},s={};for(const[e,t]of Object.entries(N.Soundfont)){if(t.isLoaded)continue;const n=g.byName[e];if(n){const e=n.program;s[e]=0;for(let n=0;n{if(0===e.indexOf("data:audio")){const r=J(e.split(",")[1]);return V.decodeAudioData(r,t,n)}{const r=new XMLHttpRequest;return r.open("GET",e,!0),r.responseType="arraybuffer",r.onsuccess=()=>V.decodeAudioData(r.response,t,n),void r.send()}},fe=()=>new(window.AudioContext||window.webkitAudioContext),ge="webmidi",me={};let Ae=null;const ye=e=>{const t=t=>{console.error("Could not connect to web midi! Falling back to WebAudio:",t),me.webaudio_backup_connect&&(me.config.api="webaudio",me.webaudio_backup_connect(e))};navigator.requestMIDIAccess().then((n=>{const r=n.outputs;return Ae="function"==typeof r?r()[0]:r[0],void 0===Ae?t("No outputs defined"):e.onsuccess&&e.onsuccess()}),t)},be=()=>{},ve=()=>{},we=()=>{},qe=()=>{},Se=()=>{},Ee=(e,t)=>{Ae.send(e,1e3*t)},Fe=(e,t,n,r)=>{Ae.send([e,t,n],1e3*r)},Ce=(e,t,n)=>{Ae.send([176+e,7,t],1e3*n)},Be=(e,t,n)=>{Ae.send([192+e,t],1e3*n)},xe=(e,t,n)=>{Ae.send([224+e,t],1e3*n)},Te=(e,t,n,r)=>{Ae.send([144+e,t,n],1e3*r)},ke=(e,t,n)=>{Ae.send([128+e,t,0],1e3*n)},Ie=(e,t,n,r)=>{for(const o of t)Ae.send([144+e,o,n],1e3*r)},Me=(e,t,n)=>{for(const r of t)Ae.send([128+e,r,0],1e3*n)},Re=()=>{Ae.cancel();for(let e=0;e<16;e++)Ae.send([176+e,123,0])};class _e{constructor(e){this.str=e,this.position=0}read(e){const t=this.str.substr(this.position,e);return this.position+=e,t}readInt32(){const e=(this.str.charCodeAt(this.position)<<24)+(this.str.charCodeAt(this.position+1)<<16)+(this.str.charCodeAt(this.position+2)<<8)+this.str.charCodeAt(this.position+3);return this.position+=4,e}readInt16(){const e=(this.str.charCodeAt(this.position)<<8)+this.str.charCodeAt(this.position+1);return this.position+=2,e}readInt8(e){let t=this.str.charCodeAt(this.position);return e&&t>127&&(t-=256),this.position+=1,t}eof(){return this.position>=this.str.length}readVarInt(){let e=0;for(;;){const t=this.readInt8();if(!(128&t))return e+t;e+=127&t,e<<=7}}}class Ge{constructor(e){this.data=e,this.stream=new _e(e),this.lastEventTypeByte=void 0}readChunk(e){const t=e.read(4),n=e.readInt32();return{id:t,length:n,data:e.read(n)}}readEvent(e){const t={};t.deltaTime=e.readVarInt();let n=e.readInt8();if(240&~n){let r;128&n?(r=e.readInt8(),this.lastEventTypeByte=n):(r=n,n=this.lastEventTypeByte);const o=n>>4;switch(t.channel=15&n,t.type="channel",o){case 8:return t.subtype="noteOff",t.noteNumber=r,t.velocity=e.readInt8(),t;case 9:return t.noteNumber=r,t.velocity=e.readInt8(),0===t.velocity?t.subtype="noteOff":t.subtype="noteOn",t;case 10:return t.subtype="noteAftertouch",t.noteNumber=r,t.amount=e.readInt8(),t;case 11:return t.subtype="controller",t.controllerType=r,t.value=e.readInt8(),t;case 12:return t.subtype="programChange",t.programNumber=r,t;case 13:return t.subtype="channelAftertouch",t.amount=r,t;case 14:return t.subtype="pitchBend",t.value=r+(e.readInt8()<<7),t;default:throw new Error("Unrecognised MIDI event type: "+o)}}else{if(255!==n){if(240===n){t.type="sysEx";const n=e.readVarInt();return t.data=e.read(n),t}if(247===n){t.type="dividedSysEx";const n=e.readVarInt();return t.data=e.read(n),t}throw new Error("Unrecognised MIDI event type byte: "+n)}{t.type="meta";const n=e.readInt8(),r=e.readVarInt();switch(n){case 0:if(t.subtype="sequenceNumber",2!==r)throw new Error("Expected length for sequenceNumber event is 2, got "+r);return t.number=e.readInt16(),t;case 1:return t.subtype="text",t.text=e.read(r),t;case 2:return t.subtype="copyrightNotice",t.text=e.read(r),t;case 3:return t.subtype="trackName",t.text=e.read(r),t;case 4:return t.subtype="instrumentName",t.text=e.read(r),t;case 5:return t.subtype="lyrics",t.text=e.read(r),t;case 6:return t.subtype="marker",t.text=e.read(r),t;case 7:return t.subtype="cuePoint",t.text=e.read(r),t;case 32:if(t.subtype="midiChannelPrefix",1!==r)throw new Error("Expected length for midiChannelPrefix event is 1, got "+r);return t.channel=e.readInt8(),t;case 47:if(t.subtype="endOfTrack",0!==r)throw new Error("Expected length for endOfTrack event is 0, got "+r);return t;case 81:if(t.subtype="setTempo",3!==r)throw new Error("Expected length for setTempo event is 3, got "+r);return t.microsecondsPerBeat=(e.readInt8()<<16)+(e.readInt8()<<8)+e.readInt8(),t;case 84:if(t.subtype="smpteOffset",5!==r)throw new Error("Expected length for smpteOffset event is 5, got "+r);const n=e.readInt8();return t.frameRate={0:24,32:25,64:29,96:30}[96&n],t.hour=31&n,t.min=e.readInt8(),t.sec=e.readInt8(),t.frame=e.readInt8(),t.subframe=e.readInt8(),t;case 88:if(t.subtype="timeSignature",4!==r)throw new Error("Expected length for timeSignature event is 4, got "+r);return t.numerator=e.readInt8(),t.denominator=2**e.readInt8(),t.metronome=e.readInt8(),t.thirtyseconds=e.readInt8(),t;case 89:if(t.subtype="keySignature",2!==r)throw new Error("Expected length for keySignature event is 2, got "+r);return t.key=e.readInt8(!0),t.scale=e.readInt8(),t;case 127:return t.subtype="sequencerSpecific",t.data=e.read(r),t;default:return t.subtype="unknown",t.data=e.read(r),t}}}}parseAndReturn(){const e=this.stream,t=this.readChunk(e);if("MThd"!==t.id||6!==t.length)throw new Error("Bad .mid file - header not found");const n=new _e(t.data),r=n.readInt16(),o=n.readInt16(),i=n.readInt16();let a;if(32768&i)throw new Error("Expressing time division in SMTPE frames is not supported yet");a=i;const s={formatType:r,trackCount:o,ticksPerBeat:a},c=[];for(let t=0;t{if("object"!=typeof e)return e;if(null==e)return e;const t="number"==typeof e.length?[]:{};for(const n in e)t[n]=Ke(e[n]);return t};class Le{constructor(e,t,n,r){this.midiFile=e,this.timeWarp=t,this.eventProcessor=n,this.trackStates=[],this.beatsPerMinute=r||120,this.bpmOverride=!!r,this.ticksPerBeat=e.header.ticksPerBeat;for(let t=0;t0&&(t=e.ticksToEvent/this.ticksPerBeat,n=t/(this.beatsPerMinute/60));const r=1e3*n*this.timeWarp||0;this.temporal.push([e,r]),e=this.getNextEvent()}}getData(){return Ke(this.temporal)}}class Oe{constructor(e){this.plugin=e,this.currentTime=0,this.endTime=0,this.restart=0,this.playing=!1,this.timeWarp=1,this.startDelay=0,this.BPM=void 0,this.data=[],this.eventQueue=[],this.queuedTime=0,this.startTime=0,this.noteRegistrar={},this.onMidiEvent=void 0,this.MIDIOffset=0,this.frame=void 0,this.__now=void 0}start(e){this.currentTime<-1&&(this.currentTime=-1),this.startAudio(this.currentTime,null,e)}resume(e){this.start(e)}pause(){const e=this.restart;this.stopAudio(),this.restart=e}stop(){this.stopAudio(),this.restart=0,this.currentTime=0}addListener(e){this.onMidiEvent=e}removeListener(){this.onMidiEvent=void 0}clearAnimation(){this.animationFrameId&&cancelAnimationFrame(this.animationFrameId)}setAnimation(e){let t=0,n=0,r=0;this.clearAnimation(),this.frame=()=>{if(this.animationFrameId=requestAnimationFrame(this.frame),0===this.endTime)return;this.playing?(t=r===this.currentTime?n-Date.now():0,t=0===this.currentTime?0:this.currentTime-t,r!==this.currentTime&&(n=Date.now(),r=this.currentTime)):t=this.currentTime;const o=this.endTime,i=t/1e3,a=i/60,s=60*a+(i-60*a),c=o/1e3;c-s<-1||e({now:s,end:c,events:this.noteRegistrar})},requestAnimationFrame(this.frame)}loadMidiFile(e,t,n){try{this.replayer=new Le(function(e){return new Ge(e).parseAndReturn()}(this.currentData),this.timeWarp,null,this.BPM),this.data=this.replayer.getData(),this.endTime=this.getLength(),this.loadPlugin({onsuccess:e,onprogress:t,onerror:n})}catch(e){n&&n(e)}}loadPlugin(){}loadFile(e,t,n,r){if(this.stop(),-1!==e.indexOf("base64,"))this.currentData=atob(e.split(",")[1]),this.loadMidiFile(t,n,r);else{const o=new XMLHttpRequest;o.open("GET",e),o.overrideMimeType("text/plain; charset=x-user-defined"),o.onreadystatechange=()=>{if(4===o.readyState)if(200===o.status){const e=o.responseText||"",i=[],a=e.length,s=String.fromCharCode;for(let t=0;t{const r={channel:e,note:t,now:n,end:this.endTime,message:o,velocity:i};128===o?delete this.noteRegistrar[t]:this.noteRegistrar[t]=r,this.onMidiEvent&&this.onMidiEvent(r),this.currentTime=n,this.eventQueue.shift(),(this.eventQueue.length<1e3||this.currentTime===this.queuedTime&&this.queuedTimeHSL":"HEX24>RGB>HSL","HEX32>HSLA":"HEX32>RGBA>HSLA","HEX24>CMYK":"HEX24>RGB>CMY>CMYK","RGB>CMYK":"RGB>CMY>CMYK"},n=De.Space=function(r,o){t[o]&&(o=t[o]);const i=o.split(">");if("object"==typeof r&&r[0]>=0){const e=i[0],t={};for(let n=0;n1&&(t=t.substr(t.indexOf("_")+1)),t+=(0===e?"":"_")+i[e],r=n[t](r);return r};n.RGB_W3=function(e){return"rgb("+(e.R|0)+","+(e.G|0)+","+(e.B|0)+")"},n.RGBA_W3=function(e){const t="number"==typeof e.A?e.A/255:1;return"rgba("+(e.R|0)+","+(e.G|0)+","+(e.B|0)+","+t+")"},n.W3_RGB=function(e){const t=e.substr(4,e.length-5).split(",");return{R:parseInt(t[0]),G:parseInt(t[1]),B:parseInt(t[2])}},n.W3_RGBA=function(e){const t=e.substr(5,e.length-6).split(",");return{R:parseInt(t[0]),G:parseInt(t[1]),B:parseInt(t[2]),A:255*parseFloat(t[3])}},n.HSL_W3=function(e){return"hsl("+(e.H+.5|0)+","+(e.S+.5|0)+"%,"+(e.L+.5|0)+"%)"},n.HSLA_W3=function(e){const t="number"==typeof e.A?e.A/255:1;return"hsla("+(e.H+.5|0)+","+(e.S+.5|0)+"%,"+(e.L+.5|0)+"%,"+t+")"},n.W3_HSL=function(e){const t=e.substr(4,e.length-5).split(",");return{H:parseInt(t[0]),S:parseInt(t[1]),L:parseInt(t[2])}},n.W3_HSLA=function(e){const t=e.substr(5,e.length-6).split(",");return{H:parseInt(t[0]),S:parseInt(t[1]),L:parseInt(t[2]),A:255*parseFloat(t[3])}},n.W3_HEX=n.W3_HEX24=function(e){return"#"===e.substr(0,1)&&(e=e.substr(1)),3===e.length&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),parseInt("0x"+e)},n.W3_HEX32=function(e){return"#"===e.substr(0,1)&&(e=e.substr(1)),6===e.length?parseInt("0xFF"+e):parseInt("0x"+e)},n.HEX_W3=n.HEX24_W3=function(e,t){t||(t=6),e||(e=0);let n=e.toString(16),r=n.length;for(;rt;)n=n.substring(1),r-=1;return"#"+n},n.HEX32_W3=function(e){return n.HEX_W3(e,8)},n.HEX_RGB=n.HEX24_RGB=function(e){return{R:e>>16,G:e>>8&255,B:255&e}},n.HEX32_RGBA=function(e){return{R:e>>>16&255,G:e>>>8&255,B:255&e,A:e>>>24}},n.RGBA_HEX32=function(e){return(e.A<<24|e.R<<16|e.G<<8|e.B)>>>0},n.RGB_HEX24=n.RGB_HEX=function(e){return e.R<0&&(e.R=0),e.G<0&&(e.G=0),e.B<0&&(e.B=0),e.R>255&&(e.R=255),e.G>255&&(e.G=255),e.B>255&&(e.B=255),e.R<<16|e.G<<8|e.B},n.RGB_CMY=function(e){return{C:1-e.R/255,M:1-e.G/255,Y:1-e.B/255}},n.RGBA_HSLA=n.RGB_HSL=function(e){const t=e.R/255,n=e.G/255,r=e.B/255,o=Math.min(t,n,r),i=Math.max(t,n,r),a=i-o;let s,c;const l=(i+o)/2;if(0===a)s=0,c=0;else{c=l<.5?a/(i+o):a/(2-i-o);const e=((i-t)/6+a/2)/a,u=((i-n)/6+a/2)/a,d=((i-r)/6+a/2)/a;t===i?s=d-u:n===i?s=1/3+e-d:r===i&&(s=2/3+u-e),s<0&&(s+=1),s>1&&(s-=1)}return{H:360*s,S:100*c,L:100*l,A:e.A}},n.RGBA_HSVA=n.RGB_HSV=function(e){const t=e.R/255,n=e.G/255,r=e.B/255,o=Math.min(t,n,r),i=Math.max(t,n,r),a=i-o;let s,c;if(0===a)s=0,c=0;else{c=a/i;const e=((i-t)/6+a/2)/a,o=((i-n)/6+a/2)/a,l=((i-r)/6+a/2)/a;t===i?s=l-o:n===i?s=1/3+e-l:r===i&&(s=2/3+o-e),s<0&&(s+=1),s>1&&(s-=1)}return{H:360*s,S:100*c,V:100*i,A:e.A}},n.CMY_RGB=function(e){return{R:Math.max(0,255*(1-e.C)),G:Math.max(0,255*(1-e.M)),B:Math.max(0,255*(1-e.Y))}},n.CMY_CMYK=function(e){let t=e.C,n=e.M,r=e.Y,o=Math.min(r,Math.min(n,Math.min(t,1)));return t=Math.round((t-o)/(1-o)*100),n=Math.round((n-o)/(1-o)*100),r=Math.round((r-o)/(1-o)*100),o=Math.round(100*o),{C:t,M:n,Y:r,K:o}},n.CMYK_CMY=function(e){return{C:e.C*(1-e.K)+e.K,M:e.M*(1-e.K)+e.K,Y:e.Y*(1-e.K)+e.K}},n.HSLA_RGBA=n.HSL_RGB=function(e){const t=e.H/360,n=e.S/100,r=e.L/100;let o,i,a,s,c,l;return 0===n?o=i=a=r:(c=r<.5?r*(1+n):r+n-n*r,s=2*r-c,l=t+1/3,l<0&&(l+=1),l>1&&(l-=1),o=6*l<1?s+6*(c-s)*l:2*l<1?c:3*l<2?s+(c-s)*(2/3-l)*6:s,l=t,l<0&&(l+=1),l>1&&(l-=1),i=6*l<1?s+6*(c-s)*l:2*l<1?c:3*l<2?s+(c-s)*(2/3-l)*6:s,l=t-1/3,l<0&&(l+=1),l>1&&(l-=1),a=6*l<1?s+6*(c-s)*l:2*l<1?c:3*l<2?s+(c-s)*(2/3-l)*6:s),{R:255*o,G:255*i,B:255*a,A:e.A}},n.HSVA_RGBA=n.HSV_RGB=function(e){let t=e.H/360;const n=e.S/100;let r,o,i,a,s,c,l=e.V/100;if(0===n)r=o=i=Math.round(255*l);else switch(t>=1&&(t=0),t*=6,a=t-Math.floor(t),s=Math.round(255*l*(1-n)),i=Math.round(255*l*(1-n*a)),c=Math.round(255*l*(1-n*(1-a))),l=Math.round(255*l),Math.floor(t)){case 0:r=l,o=c,i=s;break;case 1:r=i,o=l,i=s;break;case 2:r=s,o=l,i=c;break;case 3:r=s,o=i,i=l;break;case 4:r=c,o=s,i=l;break;case 5:r=l,o=s}return{R:r,G:o,B:i,A:e.A}}}();const Ue={"Isaac Newton (1704)":{format:"HSL",ref:"Gerstner, p.167",english:["red",null,"orange",null,"yellow","green",null,"blue",null,"indigo",null,"violet"],0:[0,96,51],1:[0,0,0],2:[29,94,52],3:[0,0,0],4:[60,90,60],5:[135,76,32],6:[0,0,0],7:[248,82,28],8:[0,0,0],9:[302,88,26],10:[0,0,0],11:[325,84,46]},"Louis Bertrand Castel (1734)":{format:"HSL",ref:"Peacock, p.400",english:["blue","blue-green","green","olive green","yellow","yellow-orange","orange","red","crimson","violet","agate","indigo"],0:[248,82,28],1:[172,68,34],2:[135,76,32],3:[79,59,36],4:[60,90,60],5:[49,90,60],6:[29,94,52],7:[360,96,51],8:[1,89,33],9:[325,84,46],10:[273,80,27],11:[302,88,26]},"George Field (1816)":{format:"HSL",ref:"Klein, p.69",english:["blue",null,"purple",null,"red","orange",null,"yellow",null,"yellow green",null,"green"],0:[248,82,28],1:[0,0,0],2:[302,88,26],3:[0,0,0],4:[360,96,51],5:[29,94,52],6:[0,0,0],7:[60,90,60],8:[0,0,0],9:[79,59,36],10:[0,0,0],11:[135,76,32]},"D. D. Jameson (1844)":{format:"HSL",ref:"Jameson, p.12",english:["red","red-orange","orange","orange-yellow","yellow","green","green-blue","blue","blue-purple","purple","purple-violet","violet"],0:[360,96,51],1:[14,91,51],2:[29,94,52],3:[49,90,60],4:[60,90,60],5:[135,76,32],6:[172,68,34],7:[248,82,28],8:[273,80,27],9:[302,88,26],10:[313,78,37],11:[325,84,46]},"Theodor Seemann (1881)":{format:"HSL",ref:"Klein, p.86",english:["carmine","scarlet","orange","yellow-orange","yellow","green","green blue","blue","indigo","violet","brown","black"],0:[0,58,26],1:[360,96,51],2:[29,94,52],3:[49,90,60],4:[60,90,60],5:[135,76,32],6:[172,68,34],7:[248,82,28],8:[302,88,26],9:[325,84,46],10:[0,58,26],11:[0,0,3]},"A. Wallace Rimington (1893)":{format:"HSL",ref:"Peacock, p.402",english:["deep red","crimson","orange-crimson","orange","yellow","yellow-green","green","blueish green","blue-green","indigo","deep blue","violet"],0:[360,96,51],1:[1,89,33],2:[14,91,51],3:[29,94,52],4:[60,90,60],5:[79,59,36],6:[135,76,32],7:[163,62,40],8:[172,68,34],9:[302,88,26],10:[248,82,28],11:[325,84,46]},"Bainbridge Bishop (1893)":{format:"HSL",ref:"Bishop, p.11",english:["red","orange-red or scarlet","orange","gold or yellow-orange","yellow or green-gold","yellow-green","green","greenish-blue or aquamarine","blue","indigo or violet-blue","violet","violet-red","red"],0:[360,96,51],1:[1,89,33],2:[29,94,52],3:[50,93,52],4:[60,90,60],5:[73,73,55],6:[135,76,32],7:[163,62,40],8:[302,88,26],9:[325,84,46],10:[343,79,47],11:[360,96,51]},"H. von Helmholtz (1910)":{format:"HSL",ref:"Helmholtz, p.22",english:["yellow","green","greenish blue","cyan-blue","indigo blue","violet","end of red","red","red","red","red orange","orange"],0:[60,90,60],1:[135,76,32],2:[172,68,34],3:[211,70,37],4:[302,88,26],5:[325,84,46],6:[330,84,34],7:[360,96,51],8:[10,91,43],9:[10,91,43],10:[8,93,51],11:[28,89,50]},"Alexander Scriabin (1911)":{format:"HSL",ref:"Jones, p.104",english:["red","violet","yellow","steely with the glint of metal","pearly blue the shimmer of moonshine","dark red","bright blue","rosy orange","purple","green","steely with a glint of metal","pearly blue the shimmer of moonshine"],0:[360,96,51],1:[325,84,46],2:[60,90,60],3:[245,21,43],4:[211,70,37],5:[1,89,33],6:[248,82,28],7:[29,94,52],8:[302,88,26],9:[135,76,32],10:[245,21,43],11:[211,70,37]},"Adrian Bernard Klein (1930)":{format:"HSL",ref:"Klein, p.209",english:["dark red","red","red orange","orange","yellow","yellow green","green","blue-green","blue","blue violet","violet","dark violet"],0:[0,91,40],1:[360,96,51],2:[14,91,51],3:[29,94,52],4:[60,90,60],5:[73,73,55],6:[135,76,32],7:[172,68,34],8:[248,82,28],9:[292,70,31],10:[325,84,46],11:[330,84,34]},"August Aeppli (1940)":{format:"HSL",ref:"Gerstner, p.169",english:["red",null,"orange",null,"yellow",null,"green","blue-green",null,"ultramarine blue","violet","purple"],0:[0,96,51],1:[0,0,0],2:[29,94,52],3:[0,0,0],4:[60,90,60],5:[0,0,0],6:[135,76,32],7:[172,68,34],8:[0,0,0],9:[211,70,37],10:[273,80,27],11:[302,88,26]},"I. J. Belmont (1944)":{ref:"Belmont, p.226",english:["red","red-orange","orange","yellow-orange","yellow","yellow-green","green","blue-green","blue","blue-violet","violet","red-violet"],0:[360,96,51],1:[14,91,51],2:[29,94,52],3:[50,93,52],4:[60,90,60],5:[73,73,55],6:[135,76,32],7:[172,68,34],8:[248,82,28],9:[313,78,37],10:[325,84,46],11:[338,85,37]},"Steve Zieverink (2004)":{format:"HSL",ref:"Cincinnati Contemporary Art Center",english:["yellow-green","green","blue-green","blue","indigo","violet","ultra violet","infra red","red","orange","yellow-white","yellow"],0:[73,73,55],1:[135,76,32],2:[172,68,34],3:[248,82,28],4:[302,88,26],5:[325,84,46],6:[326,79,24],7:[1,89,33],8:[360,96,51],9:[29,94,52],10:[62,78,74],11:[60,90,60]},"Circle of Fifths (Johnston 2003)":{format:"RGB",ref:"Joseph Johnston",english:["yellow","blue","orange","teal","red","green","purple","light orange","light blue","dark orange","dark green","violet"],0:[255,255,0],1:[50,0,255],2:[255,150,0],3:[0,210,180],4:[255,0,0],5:[130,255,0],6:[150,0,200],7:[255,195,0],8:[30,130,255],9:[255,100,0],10:[0,200,0],11:[225,0,225]},"Circle of Fifths (Wheatman 2002)":{format:"HEX",ref:"Stuart Wheatman",english:[],data:["#122400","#2E002E","#002914","#470000","#002142","#2E2E00","#290052","#003D00","#520029","#003D3D","#522900","#000080","#244700","#570057","#004D26","#7A0000","#003B75","#4C4D00","#47008F","#006100","#850042","#005C5C","#804000","#0000C7","#366B00","#80007F","#00753B","#B80000","#0057AD","#6B6B00","#6600CC","#008A00","#B8005C","#007F80","#B35900","#2424FF","#478F00","#AD00AD","#00994D","#F00000","#0073E6","#8F8F00","#8A14FF","#00AD00","#EB0075","#00A3A3","#E07000","#6B6BFF","#5CB800","#DB00DB","#00C261","#FF5757","#3399FF","#ADAD00","#B56BFF","#00D600","#FF57AB","#00C7C7","#FF9124","#9999FF","#6EDB00","#FF29FF","#00E070","#FF9999","#7ABDFF","#D1D100","#D1A3FF","#00FA00","#FFA3D1","#00E5E6","#FFC285","#C2C2FF","#80FF00","#FFA8FF","#00E070","#FFCCCC","#C2E0FF","#F0F000","#EBD6FF","#ADFFAD","#FFD6EB","#8AFFFF","#FFEBD6","#EBEBFF","#E0FFC2","#FFEBFF","#E5FFF2","#FFF5F5"]}},We=e=>{const t={},n=Ue,r=n[e]||n["D. D. Jameson (1844)"];let o,i,a,s=r[3];for(let e=0;e<=88;e++)if(r.data)t[e]={hsl:r.data[e],hex:r.data[e]};else{let n=r[(e+9)%12];"RGB"===r.format?(n=De.Space(n,"RGB>HSL"),o=Math.floor(n.H),i=Math.floor(n.S),a=Math.floor(n.L)):(o=n[0],i=n[1],a=n[2]),o===i&&i===a&&(c=s,l=r[(e+10)%12],n=[Math.floor(.5*c[0]+.5*l[0]+.5),Math.floor(.5*c[1]+.5*l[1]+.5),Math.floor(.5*c[2]+.5*l[2]+.5)]),t[e]={hsl:"hsla("+o+","+i+"%,"+a+"%, 1)",hex:De.Space({H:o,S:i,L:a},"HSL>RGB>HEX>W3")},s=n}var c,l;return t},He=d,Je={},Ye={AudioTag:e,WebAudio:t,WebMIDI:o},Ne={soundfontUrl:"./soundfont/",api:"",audioFormat:"",supports:{},connected_plugin:t,is_connected:!1},Ve=e=>{"function"==typeof e&&(e={onsuccess:e}),e.onprogress=e.onprogress||void 0,e.api=e.api||"",e.targetFormat=e.targetFormat||"",e.instrument=e.instrument||"acoustic_grand_piano",e.instruments=e.instruments||void 0,e.apiPrecedence=e.apiPrecedence||["webaudio","webmidi","audiotag"],Ne.soundfontUrl=e.soundfontUrl||Ne.soundfontUrl,function(e){if("undefined"!=typeof navigator&&navigator.requestMIDIAccess)if(Function.prototype.toString.call(navigator.requestMIDIAccess).indexOf("[native code]"))d.webmidi=!0;else if("undefined"!=typeof navigator&&void 0!==navigator.plugins)for(const e of Array.from(navigator.plugins))e.name.indexOf("Jazz-Plugin")>=0&&(d.webmidi=!0);if("undefined"==typeof Audio)return e({});d.audiotag=!0;const t=window.AudioContext||window.webkitAudioContext;t&&t.prototype.createGain&&(d.webaudio=!0);const n=new Audio;if(void 0===n.canPlayType)return e(d);const r=n.canPlayType('audio/ogg; codecs="vorbis"'),o="probably"===r||"maybe"===r,i=n.canPlayType("audio/mpeg"),a="probably"===i||"maybe"===i;if(d.ogg_mp3_precedence="probably"===r?"ogg":"probably"===i?"mp3":"ogg",u&&(d.ogg_mp3_precedence="mp3"),!o&&!a)return e(d);o&&p("audio/ogg;base64,T2dnUwACAAAAAAAAAADqnjMlAAAAAOyyzPIBHgF2b3JiaXMAAAAAAUAfAABAHwAAQB8AAEAfAACZAU9nZ1MAAAAAAAAAAAAA6p4zJQEAAAANJGeqCj3//////////5ADdm9yYmlzLQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMTAxMTAxIChTY2hhdWZlbnVnZ2V0KQAAAAABBXZvcmJpcw9CQ1YBAAABAAxSFCElGVNKYwiVUlIpBR1jUFtHHWPUOUYhZBBTiEkZpXtPKpVYSsgRUlgpRR1TTFNJlVKWKUUdYxRTSCFT1jFloXMUS4ZJCSVsTa50FkvomWOWMUYdY85aSp1j1jFFHWNSUkmhcxg6ZiVkFDpGxehifDA6laJCKL7H3lLpLYWKW4q91xpT6y2EGEtpwQhhc+211dxKasUYY4wxxsXiUyiC0JBVAAABAABABAFCQ1YBAAoAAMJQDEVRgNCQVQBABgCAABRFcRTHcRxHkiTLAkJDVgEAQAAAAgAAKI7hKJIjSZJkWZZlWZameZaouaov+64u667t6roOhIasBACAAAAYRqF1TCqDEEPKQ4QUY9AzoxBDDEzGHGNONKQMMogzxZAyiFssLqgQBKEhKwKAKAAAwBjEGGIMOeekZFIi55iUTkoDnaPUUcoolRRLjBmlEluJMYLOUeooZZRCjKXFjFKJscRUAABAgAMAQICFUGjIigAgCgCAMAYphZRCjCnmFHOIMeUcgwwxxiBkzinoGJNOSuWck85JiRhjzjEHlXNOSuekctBJyaQTAAAQ4AAAEGAhFBqyIgCIEwAwSJKmWZomipamiaJniqrqiaKqWp5nmp5pqqpnmqpqqqrrmqrqypbnmaZnmqrqmaaqiqbquqaquq6nqrZsuqoum65q267s+rZru77uqapsm6or66bqyrrqyrbuurbtS56nqqKquq5nqq6ruq5uq65r25pqyq6purJtuq4tu7Js664s67pmqq5suqotm64s667s2rYqy7ovuq5uq7Ks+6os+75s67ru2rrwi65r66os674qy74x27bwy7ouHJMnqqqnqq7rmarrqq5r26rr2rqmmq5suq4tm6or26os67Yry7aumaosm64r26bryrIqy77vyrJui67r66Ys67oqy8Lu6roxzLat+6Lr6roqy7qvyrKuu7ru+7JuC7umqrpuyrKvm7Ks+7auC8us27oxuq7vq7It/KosC7+u+8Iy6z5jdF1fV21ZGFbZ9n3d95Vj1nVhWW1b+V1bZ7y+bgy7bvzKrQvLstq2scy6rSyvrxvDLux8W/iVmqratum6um7Ksq/Lui60dd1XRtf1fdW2fV+VZd+3hV9pG8OwjK6r+6os68Jry8ov67qw7MIvLKttK7+r68ow27qw3L6wLL/uC8uq277v6rrStXVluX2fsSu38QsAABhwAAAIMKEMFBqyIgCIEwBAEHIOKQahYgpCCKGkEEIqFWNSMuakZM5JKaWUFEpJrWJMSuaclMwxKaGUlkopqYRSWiqlxBRKaS2l1mJKqcVQSmulpNZKSa2llGJMrcUYMSYlc05K5pyUklJrJZXWMucoZQ5K6iCklEoqraTUYuacpA46Kx2E1EoqMZWUYgupxFZKaq2kFGMrMdXUWo4hpRhLSrGVlFptMdXWWqs1YkxK5pyUzDkqJaXWSiqtZc5J6iC01DkoqaTUYiopxco5SR2ElDLIqJSUWiupxBJSia20FGMpqcXUYq4pxRZDSS2WlFosqcTWYoy1tVRTJ6XFklKMJZUYW6y5ttZqDKXEVkqLsaSUW2sx1xZjjqGkFksrsZWUWmy15dhayzW1VGNKrdYWY40x5ZRrrT2n1mJNMdXaWqy51ZZbzLXnTkprpZQWS0oxttZijTHmHEppraQUWykpxtZara3FXEMpsZXSWiypxNhirLXFVmNqrcYWW62ltVprrb3GVlsurdXcYqw9tZRrrLXmWFNtBQAADDgAAASYUAYKDVkJAEQBAADGMMYYhEYpx5yT0ijlnHNSKucghJBS5hyEEFLKnINQSkuZcxBKSSmUklJqrYVSUmqttQIAAAocAAACbNCUWByg0JCVAEAqAIDBcTRNFFXVdX1fsSxRVFXXlW3jVyxNFFVVdm1b+DVRVFXXtW3bFn5NFFVVdmXZtoWiqrqybduybgvDqKqua9uybeuorqvbuq3bui9UXVmWbVu3dR3XtnXd9nVd+Bmzbeu2buu+8CMMR9/4IeTj+3RCCAAAT3AAACqwYXWEk6KxwEJDVgIAGQAAgDFKGYUYM0gxphhjTDHGmAAAgAEHAIAAE8pAoSErAoAoAADAOeecc84555xzzjnnnHPOOeecc44xxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY0wAwE6EA8BOhIVQaMhKACAcAABACCEpKaWUUkoRU85BSSmllFKqFIOMSkoppZRSpBR1lFJKKaWUIqWgpJJSSimllElJKaWUUkoppYw6SimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaVUSimllFJKKaWUUkoppRQAYPLgAACVYOMMK0lnhaPBhYasBAByAwAAhRiDEEJpraRUUkolVc5BKCWUlEpKKZWUUqqYgxBKKqmlklJKKbXSQSihlFBKKSWUUkooJYQQSgmhlFRCK6mEUkoHoYQSQimhhFRKKSWUzkEoIYUOQkmllNRCSB10VFIpIZVSSiklpZQ6CKGUklJLLZVSWkqpdBJSKamV1FJqqbWSUgmhpFZKSSWl0lpJJbUSSkklpZRSSymFVFJJJYSSUioltZZaSqm11lJIqZWUUkqppdRSSiWlkEpKqZSSUmollZRSaiGVlEpJKaTUSimlpFRCSamlUlpKLbWUSkmptFRSSaWUlEpJKaVSSksppRJKSqmllFpJKYWSUkoplZJSSyW1VEoKJaWUUkmptJRSSymVklIBAEAHDgAAAUZUWoidZlx5BI4oZJiAAgAAQABAgAkgMEBQMApBgDACAQAAAADAAAAfAABHARAR0ZzBAUKCwgJDg8MDAAAAAAAAAAAAAACAT2dnUwAEAAAAAAAAAADqnjMlAgAAADzQPmcBAQA="),a&&p("audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");const s=(new Date).getTime(),c=window.setInterval((()=>{const t=(new Date).getTime();h&&!(t-s>5e3)||(window.clearInterval(c),e(d))}),1)}((t=>{const n=window.location.hash;let r="";if(t[e.api])r=e.api;else if(t[n.substring(1)])r=n.substring(1);else for(const n of e.apiPrecedence)if(t[n]){r=n;break}if(Pe[r]){let n="";const o=t["audio/ogg"],i=t["audio/mpeg"],a=t.ogg_mp3_precedence;e.targetFormat?n=e.targetFormat:o&&"ogg"===a?n="ogg":i&&"mp3"===a?n="mp3":o?n="ogg":i?n="mp3":"webmidi"!==r&&(console.warn("no supporting playback formats...will try mp3 but unlikely"),n="mp3"),Ne.api=r,Ne.audioFormat=n,Ne.supports=t,je(e)}}))},je=e=>{let t=e.instruments||e.instrument||"acoustic_grand_piano";"object"!=typeof t&&(t=t||0===t?[t]:[]);for(let e=0;e{Ze(o,e),ye(e),Ne.is_connected=!0},audiotag:t=>{Ze(e,t),Xe(t,"AudioTag")},webaudio:e=>{Ze(t,e),Xe(e,"WebAudio")}},Ze=(e,t)=>{Ne.connected_plugin=e,e.shared_root_info.Soundfont=Je,e.shared_root_info.config=Ne,e.shared_root_info.webaudio_backup_connect=e=>Pe.webaudio(e)},Xe=(e,t)=>{const n=e.format,{instruments:r,onprogress:o,onerror:i}=e,a=Ye[t]||t.WebAudio,s=r.length;let c=s;const l=()=>{c-=1,c||(a.connect(e),Ne.is_connected=!0,o&&o("load",1))},u=(e,t,n)=>{o&&o("load",t/s+(s-c)/s,n)};for(const e of r)if(Je[e])l();else{Qe(e,n,((t,n)=>u(0,n,e)),(()=>l()),i)}},Qe=(e,t,n,r,o)=>{const i=Ne.soundfontUrl+e+"-"+t+".js",a=new XMLHttpRequest;a.open("GET",i),a.setRequestHeader("Content-Type","text/plain"),a.onload=()=>{if(200===a.status){const e=document.createElement("script");e.language="javascript",e.type="text/javascript",e.text=a.responseText,document.body.appendChild(e),r()}else o?o():console.error(`Could not load soundfont; path was ${i}`)},a.send()},ze=function(){if(Ne.is_connected)return Ne.connected_plugin.playChannel(...arguments);console.error("Connect before calling")},$e=function(){if(Ne.is_connected)return Ne.connected_plugin.stopChannel(...arguments);console.error("Connect before calling")},et=function(){if(Ne.is_connected)return Ne.connected_plugin.send(...arguments);console.error("Connect before calling")},tt=function(){if(Ne.is_connected)return Ne.connected_plugin.setController(...arguments);console.error("Connect before calling")},nt=function(){if(Ne.is_connected)return Ne.connected_plugin.setVolume(...arguments);console.error("Connect before calling")},rt=function(){if(Ne.is_connected)return Ne.connected_plugin.programChange(...arguments);console.error("Connect before calling")},ot=function(){if(Ne.is_connected)return Ne.connected_plugin.pitchBend(...arguments);console.error("Connect before calling")},it=function(){if(Ne.is_connected)return Ne.connected_plugin.noteOn(...arguments);console.error("Connect before calling")},at=function(){if(Ne.is_connected)return Ne.connected_plugin.noteOff(...arguments);console.error("Connect before calling")},st=function(){if(Ne.is_connected)return Ne.connected_plugin.chordOn(...arguments);console.error("Connect before calling")},ct=function(){if(Ne.is_connected)return Ne.connected_plugin.chordOff(...arguments);console.error("Connect before calling")},lt=function(){if(Ne.is_connected)return Ne.connected_plugin.stopAllNotes(...arguments);console.error("Connect before calling")},ut=function(){if(Ne.is_connected)return Ne.connected_plugin.setEffects();console.error("Connect before calling")},dt=()=>{if(Ne.is_connected)return Ne.connected_plugin.getContext();console.error("Connect before calling")},ht=function(){if(Ne.is_connected)return Ne.connected_plugin.setContext(...arguments);console.error("Connect before calling")};class pt extends Oe{constructor(){super(Ne.connected_plugin)}loadPlugin(){return Ve(...arguments)}}})(),r})())); //# sourceMappingURL=midicube.js.map