>>0)+4294967296*+(E>>>0):+(a>>>0)+4294967296*+(0|E)}function at(a,E,Q){return Q&&Q.length?I["dynCall_"+a].apply(null,[E].concat(Q)):I["dynCall_"+a].call(null,E)}var be=0,Vt=0;function _A(a,E){a||ZA("Assertion failed: "+E)}function Ot(a){var E=I["_"+a];return _A(E,"Cannot call unknown function "+a+", make sure it is exported"),E}var Zt={stackSave:function(){ct()},stackRestore:function(){Qt()},arrayToC:function(a){var E,Q,f=Je(a.length);return E=a,Q=f,n.set(E,Q),f},stringToC:function(a){var E=0;if(a!=null&&a!==0){var Q=(a.length<<2)+1;E=Je(Q),_t(a,E,Q)}return E}},fo={string:Zt.stringToC,array:Zt.arrayToC};function Xt(a,E,Q,f,R){var q=Ot(a),_=[],M=0;if(f)for(var hA=0;hA>0]=E;break;case"i16":i[a>>1]=E;break;case"i32":c[a>>2]=E;break;case"i64":tempI64=[E>>>0,+ko(tempDouble=E)>=1?tempDouble>0?(0|Fo(+ns(tempDouble/4294967296),4294967295))>>>0:~~+wo((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0],c[a>>2]=tempI64[0],c[a+4>>2]=tempI64[1];break;case"float":d[a>>2]=E;break;case"double":h[a>>3]=E;break;default:ZA("invalid type for setValue: "+Q)}}function Zo(a,E,Q){switch((E=E||"i8").charAt(E.length-1)==="*"&&(E="i32"),E){case"i1":case"i8":return n[a>>0];case"i16":return i[a>>1];case"i32":case"i64":return c[a>>2];case"float":return d[a>>2];case"double":return h[a>>3];default:ZA("invalid type for getValue: "+E)}return null}function Xo(a,E,Q,f){typeof a=="number"?(q=!0,_=a):(q=!1,_=a.length);var R=typeof E=="string"?E:null;if(M=Q==4?f:[typeof Ye=="function"?Ye:Ne,Je,Ne,Pt][Q===void 0?2:Q](Math.max(_,R?1:E.length)),q){for(f=M,_A((3&M)==0),hA=M+(-4&_);f >2]=0;for(hA=M+_;f >0]=0;return M}if(R==="i8")return a.subarray||a.slice?o.set(a,M):o.set(new Uint8Array(a),M),M;for(var q,_,M,hA,rA,iA,tA,v=0;v<_;){var mA=a[v];if((rA=R||E[v])===0){v++;continue}rA=="i64"&&(rA="i32"),mo(M+v,mA,rA),tA!==rA&&(iA=lo(rA),tA=rA),v+=iA}return M}function Wo(a){return D?Bt?Ye(a):Pt(a):Ne(a)}function Le(a,E){if(E===0||!a)return"";for(var Q,f,R,q=0,_=0;q|=f=o[a+_>>0],(f!=0||E)&&(_++,!E||_!=E););E||(E=_);var M="";if(q<128){for(;E>0;)R=String.fromCharCode.apply(String,o.subarray(a,a+Math.min(E,1024))),M=M?M+R:R,a+=1024,E-=1024;return M}return Q=a,function(rA,iA){for(var tA=iA;rA[tA];)++tA;if(tA-iA>16&&rA.subarray&&Wt)return Wt.decode(rA.subarray(iA,tA));for(var v,mA,GA,xA,MA,ee,NA="";;){if(!(v=rA[iA++]))return NA;if(!(128&v)){NA+=String.fromCharCode(v);continue}if(mA=63&rA[iA++],(224&v)==192){NA+=String.fromCharCode((31&v)<<6|mA);continue}if(GA=63&rA[iA++],(240&v)==224?v=(15&v)<<12|mA<<6|GA:(xA=63&rA[iA++],(248&v)==240?v=(7&v)<<18|mA<<12|GA<<6|xA:(MA=63&rA[iA++],v=(252&v)==248?(3&v)<<24|mA<<18|GA<<12|xA<<6|MA:(1&v)<<30|mA<<24|GA<<18|xA<<12|MA<<6|(ee=63&rA[iA++]))),v<65536)NA+=String.fromCharCode(v);else{var Se=v-65536;NA+=String.fromCharCode(55296|Se>>10,56320|1023&Se)}}}(o,Q)}function _o(a){for(var E="";;){var Q=n[a++>>0];if(!Q)return E;E+=String.fromCharCode(Q)}}function zo(a,E){return function(f,R,q){for(var _=0;_ >0]=f.charCodeAt(_);q||(n[R>>0]=0)}(a,E,!1)}var Wt=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Ue(a,E,Q,f){if(!(f>0))return 0;for(var R=Q,q=Q+f-1,_=0;_ =55296&&M<=57343&&(M=65536+((1023&M)<<10)|1023&a.charCodeAt(++_)),M<=127){if(Q>=q)break;E[Q++]=M}else if(M<=2047){if(Q+1>=q)break;E[Q++]=192|M>>6,E[Q++]=128|63&M}else if(M<=65535){if(Q+2>=q)break;E[Q++]=224|M>>12,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}else if(M<=2097151){if(Q+3>=q)break;E[Q++]=240|M>>18,E[Q++]=128|M>>12&63,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}else if(M<=67108863){if(Q+4>=q)break;E[Q++]=248|M>>24,E[Q++]=128|M>>18&63,E[Q++]=128|M>>12&63,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}else{if(Q+5>=q)break;E[Q++]=252|M>>30,E[Q++]=128|M>>24&63,E[Q++]=128|M>>18&63,E[Q++]=128|M>>12&63,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}}return E[Q]=0,Q-R}function _t(a,E,Q){return Ue(a,o,E,Q)}function Te(a){for(var E=0,Q=0;Q =55296&&f<=57343&&(f=65536+((1023&f)<<10)|1023&a.charCodeAt(++Q)),f<=127?++E:f<=2047?E+=2:f<=65535?E+=3:f<=2097151?E+=4:f<=67108863?E+=5:E+=6}return E}var zt=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function jo(a){for(var E=a,Q=E>>1;i[Q];)++Q;if((E=Q<<1)-a>32&&zt)return zt.decode(o.subarray(a,E));for(var f=0,R="";;){var q=i[a+2*f>>1];if(q==0)return R;++f,R+=String.fromCharCode(q)}}function $o(a,E,Q){if(Q===void 0&&(Q=2147483647),Q<2)return 0;for(var f=E,R=(Q-=2)<2*a.length?Q/2:a.length,q=0;q >1]=_,E+=2}return i[E>>1]=0,E-f}function Ar(a){return 2*a.length}function er(a){for(var E=0,Q="";;){var f=c[a+4*E>>2];if(f==0)return Q;if(++E,f>=65536){var R=f-65536;Q+=String.fromCharCode(55296|R>>10,56320|1023&R)}else Q+=String.fromCharCode(f)}}function tr(a,E,Q){if(Q===void 0&&(Q=2147483647),Q<4)return 0;for(var f=E,R=f+Q-4,q=0;q =55296&&_<=57343&&(_=65536+((1023&_)<<10)|1023&a.charCodeAt(++q)),c[E>>2]=_,(E+=4)+4>R)break}return c[E>>2]=0,E-f}function sr(a){for(var E=0,Q=0;Q =55296&&f<=57343&&++Q,E+=4}return E}function nr(a){var E=Te(a)+1,Q=Ye(E);return Q&&Ue(a,n,Q,E),Q}function or(a){var E=Te(a)+1,Q=Je(E);return Ue(a,n,Q,E),Q}function rr(a){return a}function ir(){var a,E=function(){var f=Error();if(!f.stack){try{throw Error(0)}catch(R){f=R}if(!f.stack)return"(no stack trace available)"}return f.stack.toString()}();return I.extraStackTrace&&(E+=` -`+I.extraStackTrace()),(a=E).replace(/__Z[\w\d_]+/g,function(Q){var f,R=f=Q;return Q===R?Q:Q+" ["+R+"]"})}function It(a,E){return a%E>0&&(a+=E-a%E),a}function jt(a){I.buffer=s=a}function gt(){I.HEAP8=n=new Int8Array(s),I.HEAP16=i=new Int16Array(s),I.HEAP32=c=new Int32Array(s),I.HEAPU8=o=new Uint8Array(s),I.HEAPU16=C=new Uint16Array(s),I.HEAPU32=B=new Uint32Array(s),I.HEAPF32=d=new Float32Array(s),I.HEAPF64=h=new Float64Array(s)}function $t(){var a=I.usingWasm?65536:16777216,E=2147483648-a;if(c[G>>2]>E)return!1;var Q=BA;for(BA=Math.max(BA,16777216);BA >2];)BA=BA<=536870912?It(2*BA,a):Math.min(It((3*BA+2147483648)/4,a),E);var f=I.reallocBuffer(BA);return f&&f.byteLength==BA?(jt(f),gt(),!0):(BA=Q,!1)}u=l=S=w=y=N=G=0,D=!1,I.reallocBuffer||(I.reallocBuffer=function(a){try{if(ArrayBuffer.transfer)E=ArrayBuffer.transfer(s,a);else{var E,Q=n;E=new ArrayBuffer(a),new Int8Array(E).set(Q)}}catch{return!1}return!!Ro(E)&&E});try{(K=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get))(new ArrayBuffer(4))}catch{K=function(E){return E.byteLength}}var Ct=I.TOTAL_STACK||5242880,BA=I.TOTAL_MEMORY||16777216;function po(){return BA}function me(a){for(;a.length>0;){var E=a.shift();if(typeof E=="function"){E();continue}var Q=E.func;typeof Q=="number"?E.arg===void 0?I.dynCall_v(Q):I.dynCall_vi(Q,E.arg):Q(E.arg===void 0?null:E.arg)}}BA =0?a:E<=32?2*Math.abs(1< =f&&(E<=32||a>f)&&(a=-2*f+a),a}var ko=Math.abs,wo=Math.ceil,ns=Math.floor,Fo=Math.min,Ae=0,ht=null,pe=null;function hr(a){return a}I.preloadedImages={},I.preloadedAudios={};var os="data:application/octet-stream;base64,";function He(a){return String.prototype.startsWith?a.startsWith(os):a.indexOf(os)===0}(function(){var E="main.wast",Q="main.wasm",f="main.temp.asm.js";He(E)||(E=fA(E)),He(Q)||(Q=fA(Q)),He(f)||(f=fA(f));var R={global:null,env:null,asm2wasm:uo,parent:I},q=null;function _(tA){return tA}function M(){try{if(I.wasmBinary)return new Uint8Array(I.wasmBinary);if(I.readBinary)return I.readBinary(Q);throw"both async and sync fetching of the wasm failed"}catch(tA){ZA(tA)}}I.asmPreload=I.asm;var hA=I.reallocBuffer,rA=function(tA){tA=It(tA,I.usingWasm?65536:16777216);var v=I.buffer.byteLength;if(I.usingWasm)try{var mA=I.wasmMemory.grow((tA-v)/65536);return mA!==-1?I.buffer=I.wasmMemory.buffer:null}catch{return null}};I.reallocBuffer=function(tA){return iA==="asmjs"?hA(tA):rA(tA)};var iA="";I.asm=function(tA,v,mA){var GA;if(!(v=GA=v).table){var xA,MA=I.wasmTableSize;MA===void 0&&(MA=1024);var ee=I.wasmMaxTableSize;typeof WebAssembly=="object"&&typeof WebAssembly.Table=="function"?ee!==void 0?v.table=new WebAssembly.Table({initial:MA,maximum:ee,element:"anyfunc"}):v.table=new WebAssembly.Table({initial:MA,element:"anyfunc"}):v.table=Array(MA),I.wasmTable=v.table}return v.memoryBase||(v.memoryBase=I.STATIC_BASE),v.tableBase||(v.tableBase=0),xA=function(Se,oe,ut){if(typeof WebAssembly!="object")return RA("no native wasm support detected"),!1;if(!(I.wasmMemory instanceof WebAssembly.Memory))return RA("no native wasm Memory in use"),!1;function ve(vA,qA){if((q=vA.exports).memory){var De,dt,as;De=q.memory,dt=I.buffer,De.byteLength 0?Q:Te(a)+1,R=Array(f),q=Ue(a,R,0,R.length);return E&&(R.length=q),R}function ur(a){for(var E=[],Q=0;Q 255&&(f&=255),E.push(String.fromCharCode(f))}return E.join("")}l+=16,G=Ne(4),y=(S=w=Kt(l))+Ct,N=Kt(y),c[G>>2]=N,D=!0,I.wasmTableSize=4,I.wasmMaxTableSize=4,I.asmGlobalArg={},I.asmLibraryArg={abort:ZA,assert:_A,enlargeMemory:$t,getTotalMemory:po,abortOnCannotGrowMemory:function(){ZA("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+BA+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")},invoke_iii:function(E,Q,f){var R=ct();try{return I.dynCall_iii(E,Q,f)}catch(q){if(Qt(R),typeof q!="number"&&q!=="longjmp")throw q;I.setThrew(1,0)}},___assert_fail:function(E,Q,f,R){ZA("Assertion failed: "+Le(E)+", at: "+[Q?Le(Q):"unknown filename",f,R?Le(R):"unknown function"])},___setErrNo:function(E){return I.___errno_location&&(c[I.___errno_location()>>2]=E),E},_abort:function(){I.abort()},_emscripten_memcpy_big:function(E,Q,f){return o.set(o.subarray(Q,Q+f),E),E},_llvm_floor_f64:ns,DYNAMICTOP_PTR:G,tempDoublePtr:kA,ABORT:be,STACKTOP:w,STACK_MAX:y};var rs=I.asm(I.asmGlobalArg,I.asmLibraryArg,s);I.asm=rs,I.___errno_location=function(){return I.asm.___errno_location.apply(null,arguments)};var Ro=I._emscripten_replace_memory=function(){return I.asm._emscripten_replace_memory.apply(null,arguments)};I._free=function(){return I.asm._free.apply(null,arguments)};var Ye=I._malloc=function(){return I.asm._malloc.apply(null,arguments)};I._memcpy=function(){return I.asm._memcpy.apply(null,arguments)},I._memset=function(){return I.asm._memset.apply(null,arguments)},I._sbrk=function(){return I.asm._sbrk.apply(null,arguments)},I._stb_vorbis_js_channels=function(){return I.asm._stb_vorbis_js_channels.apply(null,arguments)},I._stb_vorbis_js_close=function(){return I.asm._stb_vorbis_js_close.apply(null,arguments)},I._stb_vorbis_js_decode=function(){return I.asm._stb_vorbis_js_decode.apply(null,arguments)},I._stb_vorbis_js_open=function(){return I.asm._stb_vorbis_js_open.apply(null,arguments)},I._stb_vorbis_js_sample_rate=function(){return I.asm._stb_vorbis_js_sample_rate.apply(null,arguments)},I.establishStackSpace=function(){return I.asm.establishStackSpace.apply(null,arguments)},I.getTempRet0=function(){return I.asm.getTempRet0.apply(null,arguments)},I.runPostSets=function(){return I.asm.runPostSets.apply(null,arguments)},I.setTempRet0=function(){return I.asm.setTempRet0.apply(null,arguments)},I.setThrew=function(){return I.asm.setThrew.apply(null,arguments)};var Je=I.stackAlloc=function(){return I.asm.stackAlloc.apply(null,arguments)},Qt=I.stackRestore=function(){return I.asm.stackRestore.apply(null,arguments)},ct=I.stackSave=function(){return I.asm.stackSave.apply(null,arguments)};function ye(a){this.name="ExitStatus",this.message="Program terminated with exit("+a+")",this.status=a}function lt(a){a=a||I.arguments,!(Ae>0)&&(function(){if(I.preRun)for(typeof I.preRun=="function"&&(I.preRun=[I.preRun]);I.preRun.length;)So(I.preRun.shift());me(As)}(),!(Ae>0)&&(I.calledRun||(I.setStatus?(I.setStatus("Running..."),setTimeout(function(){setTimeout(function(){I.setStatus("")},1),E()},1)):E())));function E(){!I.calledRun&&(I.calledRun=!0,be||(Bt||(Bt=!0,me(Et)),me(es),I.onRuntimeInitialized&&I.onRuntimeInitialized(),function(){if(I.postRun)for(typeof I.postRun=="function"&&(I.postRun=[I.postRun]);I.postRun.length;)Do(I.postRun.shift());me(ss)}()))}}function dr(a,E){(!E||!I.noExitRuntime||a!==0)&&(I.noExitRuntime||(be=!0,Vt=a,w=W,me(ts),yo=!0,I.onExit&&I.onExit(a)),I.quit(a,new ye(a)))}function ZA(a){throw I.onAbort&&I.onAbort(a),a!==void 0?(Me(a),RA(a),a=JSON.stringify(a)):a="",be=!0,Vt=1,"abort("+a+"). Build with -s ASSERTIONS=1 for more info."}if(I.dynCall_iii=function(){return I.asm.dynCall_iii.apply(null,arguments)},I.asm=rs,I.ccall=Xt,I.cwrap=function(E,Q,f,R){var q=(f=f||[]).every(function(_){return _==="number"});return Q!=="string"&&q&&!R?Ot(E):function(){return Xt(E,Q,f,arguments,R)}},ye.prototype=Error(),ye.prototype.constructor=ye,pe=function a(){I.calledRun||lt(),I.calledRun||(pe=a)},I.run=lt,I.abort=ZA,I.preInit)for(typeof I.preInit=="function"&&(I.preInit=[I.preInit]);I.preInit.length>0;)I.preInit.pop()();I.noExitRuntime=!0,lt(),I.onRuntimeInitialized=()=>{tn=!0,sn()},OA.decode=function(a){return function(Q){if(!tn)throw Error("Not initialized");var f={};function R(oe){return new Int32Array(I.HEAPU8.buffer,oe,1)[0]}function q(oe,ut){var ve=new ArrayBuffer(ut*Float32Array.BYTES_PER_ELEMENT),re=new Float32Array(ve);return re.set(new Float32Array(I.HEAPU8.buffer,oe,ut)),re}f.open=I.cwrap("stb_vorbis_js_open","number",[]),f.close=I.cwrap("stb_vorbis_js_close","void",["number"]),f.channels=I.cwrap("stb_vorbis_js_channels","number",["number"]),f.sampleRate=I.cwrap("stb_vorbis_js_sample_rate","number",["number"]),f.decode=I.cwrap("stb_vorbis_js_decode","number",["number","number","number","number","number"]);var _,M,hA,rA,iA=f.open(),tA=(_=Q,M=Q.byteLength,hA=I._malloc(M),(rA=new Uint8Array(I.HEAPU8.buffer,hA,M)).set(new Uint8Array(_,0,M)),rA),v=I._malloc(4),mA=I._malloc(4),GA=f.decode(iA,tA.byteOffset,tA.byteLength,v,mA);if(I._free(tA.byteOffset),GA<0)throw f.close(iA),I._free(v),Error("stbvorbis decode failed: "+GA);for(var xA=f.channels(iA),MA=Array(xA),ee=new Int32Array(I.HEAPU32.buffer,R(v),xA),NA=0;NA =0&&(s=this.workletProcessorChannels[e]),t.messageType){case eA.noteOn:this.noteOn(e,A[0],A[1],A[2]);break;case eA.noteOff:this.noteOff(e,A);break;case eA.pitchWheel:this.pitchWheel(e,A[0],A[1]);break;case eA.ccChange:this.controllerChange(e,A[0],A[1],A[2]);break;case eA.customcCcChange:s.customControllers[A[0]]=A[1];break;case eA.killNote:this.killNote(e,A);break;case eA.programChange:this.programChange(e,A[0],A[1]);break;case eA.channelPressure:this.channelPressure(e,A);break;case eA.polyPressure:this.polyPressure(e,A[0],A[1]);break;case eA.ccReset:e===UA?this.resetAllControllers():this.resetControllers(e);break;case eA.systemExclusive:this.systemExclusive(A);break;case eA.setChannelVibrato:if(e===UA)for(let i=0;i {let e=(A.midiControllers[EA+P.pitchWheelRange]>>7)+(A.midiControllers[EA+P.pitchWheelRange]&127)/127;return{voicesAmount:A.voices.length,pitchBend:A.midiControllers[EA+P.pitchWheel],pitchBendRangeSemitones:e,isMuted:A.isMuted,isDrum:A.drumChannel}});this.post({messageType:pA.channelProperties,messageData:t})}function Ho(t,A,e){let s=t,n=A<<7|e;return t===127&&A===127&&e===127?{midiNote:-1,centTuning:null}:{midiNote:s,centTuning:n*.0061}}function an(t,A=0){let e=t[0];if(!(this.deviceID!==UA&&t[1]!==127&&this.deviceID!==t[1]))switch(e){default:L(`%cUnrecognized SysEx: %c${lA(t)}`,r.warn,r.unrecognized);break;case 126:case 127:switch(t[2]){case 4:let n;switch(t[3]){case 1:let o=t[5]<<7|t[4];this.setMIDIVolume(o/16384),m(`%cMaster Volume. Volume: %c${o}`,r.info,r.value);break;case 2:let C=((t[5]<<7|t[4])-8192)/8192;this.setMasterPan(C),m(`%cMaster Pan. Pan: %c${C}`,r.info,r.value);break;case 3:let c=(t[5]<<7|t[6])-8192;n=Math.floor(c/81.92),this.setMasterTuning(n),m(`%cMaster Fine Tuning. Cents: %c${n}`,r.info,r.value);break;case 4:n=(t[5]-64)*100,this.setMasterTuning(n),m(`%cMaster Coarse Tuning. Cents: %c${n}`,r.info,r.value);break;default:L(`%cUnrecognized MIDI Device Control Real-time message: %c${lA(t)}`,r.warn,r.unrecognized)}break;case 9:t[3]===1?(m("%cGM system on",r.info),this.system="gm"):t[3]===3?(m("%cGM2 system on",r.info),this.system="gm2"):(m("%cGM system off, defaulting to GS",r.info),this.system="gs");break;case 8:switch(t[3]){case 2:case 7:let o=4;t[3]===7&&o++;let i=t[o++],C=t[o++];for(let B=0;B >1&1)===1&&this.setOctaveTuning(15+A,c);for(let B=0;B<7;B++)(t[5]>>B&1)===1&&this.setOctaveTuning(7+B+A,c);for(let B=0;B<7;B++)(t[6]>>B&1)===1&&this.setOctaveTuning(B+A,c);m(`%cMIDI Octave Scale ${t[3]===8?"(1 byte)":"(2 bytes)"} tuning via Tuning: %c${c.join(" ")}`,r.info,r.value);break;default:L(`%cUnrecognized MIDI Tuning standard message: %c${lA(t)}`,r.warn,r.unrecognized);break}break;default:L(`%cUnrecognized MIDI Realtime/non realtime message: %c${lA(t)}`,r.warn,r.unrecognized)}break;case 65:let s=function(){L(`%cUnrecognized Roland %cGS %cSysEx: %c${lA(t)}`,r.warn,r.recognized,r.warn,r.unrecognized)};if(t[2]===66&&t[3]===18){let n=t[7];if(t[6]===127){n===0?(m("%cGS Reset received!",r.info),this.resetAllControllers(!1),this.system="gs"):n===127&&(m("%cGS system off, switching to GM2",r.info),this.resetAllControllers(!1),this.system="gm2");return}else if(t[4]===64){if((t[5]&16)>0){let o=[9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15][t[5]&15]+A;switch(t[6]){default:s();break;case 21:let i=n>0&&t[5]>>4;this.setDrums(o,i),m(`%cChannel %c${o}%c ${i?"is now a drum channel":"now isn't a drum channel"}%c via: %c${lA(t)}`,r.info,r.value,r.recognized,r.info,r.value);return;case 22:let C=n-64;this.transposeChannel(o,C),m(`%cChannel %c${o}%c pitch shift. Semitones %c${C}%c, with %c${lA(t)}`,r.info,r.recognized,r.info,r.value,r.info,r.value);return;case 28:let c=n;c===0&&(c=Math.floor(Math.random()*128)),this.controllerChange(o,p.pan,c);break;case 33:this.controllerChange(o,p.effects3Depth,n);break;case 34:this.controllerChange(o,p.effects1Depth,n);break;case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:let B=t.length-9,d=new Int8Array(12);for(let u=0;u=this.workletProcessorChannels.length)return;let o=t[6];switch(t[5]){case 1:this.controllerChange(n,p.bankSelect,o);break;case 2:this.controllerChange(n,p.lsbForControl0BankSelect,o);break;case 3:this.programChange(n,o);break;case 8:let i=this.workletProcessorChannels[n];if(i.drumChannel)return;let C=o-64;i.channelTransposeKeyShift=C;break;case 11:this.controllerChange(n,p.mainVolume,o);break;case 14:let c=o;c===0&&(c=Math.floor(Math.random()*127)),this.controllerChange(n,p.pan,c);break;case 19:this.controllerChange(n,p.effects1Depth,o);break;case 18:this.controllerChange(n,p.effects3Depth,o);break;default:L(`%cUnrecognized Yamaha XG Part Setup: %c${t[5].toString(16).toUpperCase()}`,r.warn,r.unrecognized)}}else this.system==="xg"&&L(`%cUnrecognized Yamaha XG SysEx: %c${lA(t)}`,r.warn,r.unrecognized);else this.system==="xg"&&L(`%cUnrecognized Yamaha SysEx: %c${lA(t)}`,r.warn,r.unrecognized);break}}function In(t,A,e){if(A.transformAmount===0)return A.currentValue=0,0;let s;if(A.sourceUsesCC)s=t[A.sourceIndex];else{let c=A.sourceIndex+EA;switch(A.sourceIndex){case P.noController:s=16383;break;case P.noteOnKeyNum:s=e.midiNote<<7;break;case P.noteOnVelocity:s=e.velocity<<7;break;case P.polyPressure:s=e.pressure<<7;break;default:s=t[c];break}}let n=dA[A.sourceCurveType][A.sourcePolarity][A.sourceDirection][s],o;if(A.secSrcUsesCC)o=t[A.secSrcIndex];else{let c=A.secSrcIndex+EA;switch(A.secSrcIndex){case P.noController:o=16383;break;case P.noteOnKeyNum:o=e.midiNote<<7;break;case P.noteOnVelocity:o=e.velocity<<7;break;case P.polyPressure:o=e.pressure<<7;break;default:o=t[c]}}let i=dA[A.secSrcCurveType][A.secSrcPolarity][A.secSrcDirection][o],C=n*i*A.transformAmount;return A.transformType===2&&(C=Math.abs(C)),A.currentValue=C,C}function XA(t,A,e=-1,s=0){let n=t.modulators,o=t.generators,i=t.modulatedGenerators;if(YA.recalculate(t),e===-1){i.set(o),n.forEach(B=>{let d=b[B.modulatorDestination],h=i[B.modulatorDestination]+In(A,B,t);i[B.modulatorDestination]=Math.max(d.min,Math.min(h,d.max))}),LA.recalculate(t);return}let C=new Set([g.initialAttenuation,g.delayVolEnv,g.attackVolEnv,g.holdVolEnv,g.decayVolEnv,g.sustainVolEnv,g.releaseVolEnv,g.keyNumToVolEnvHold,g.keyNumToVolEnvDecay]),c=new Set;n.forEach(B=>{if(B.sourceUsesCC===e&&B.sourceIndex===s||B.secSrcUsesCC===e&&B.secSrcIndex===s){let d=B.modulatorDestination;c.has(d)||(i[d]=o[d],In(A,B,t),n.forEach(h=>{if(h.modulatorDestination===d){let u=b[B.modulatorDestination],l=i[B.modulatorDestination]+h.currentValue;i[B.modulatorDestination]=Math.max(u.min,Math.min(l,u.max))}}),c.add(d))}}),[...c].some(B=>C.has(B))&&LA.recalculate(t)}var dA=[];for(let t=0;t<4;t++){dA[t]=[[new Float32Array(gA),new Float32Array(gA)],[new Float32Array(gA),new Float32Array(gA)]];for(let A=0;A 200&&e<40||this.highPerformanceMode&&e<10||i.isMuted)return;let C=A+i.channelTransposeKeyShift;if(A>127||A<0)return;let c=i.preset.program;this.tunings[c]?.[A]?.midiNote>=0&&(C=this.tunings[c]?.[A].midiNote),i.velocityOverride>0&&(e=i.velocityOverride);let B=this.getWorkletVoices(t,C,e,i,o,s),d=i.voices;B.forEach(h=>{let u=h.generators[g.exclusiveClass];u!==0&&d.forEach(G=>{G.generators[g.exclusiveClass]===u&&(this.releaseVoice(G),G.modulatedGenerators[g.releaseVolEnv]=-7e3,G.modulatedGenerators[g.releaseModEnv]=-7e3,LA.recalculate(G),YA.recalculate(G))}),XA(h,i.midiControllers);let l=h.modulatedGenerators[g.startAddrsOffset]+h.modulatedGenerators[g.startAddrsCoarseOffset]*32768,D=h.modulatedGenerators[g.endAddrOffset]+h.modulatedGenerators[g.endAddrsCoarseOffset]*32768,S=h.modulatedGenerators[g.startloopAddrsOffset]+h.modulatedGenerators[g.startloopAddrsCoarseOffset]*32768,w=h.modulatedGenerators[g.endloopAddrsOffset]+h.modulatedGenerators[g.endloopAddrsCoarseOffset]*32768,y=h.sample,N=G=>Math.max(0,Math.min(y.sampleData.length-1,G));if(y.cursor=N(y.cursor+l),y.end=N(y.end+D),y.loopStart=N(y.loopStart+S),y.loopEnd=N(y.loopEnd+w),y.loopEnd this.voiceCap&&this.voiceKilling(B.length),d.push(...B),n&&(this.sendChannelProperties(),this.callEvent("noteon",{midiNote:A,channel:t,velocity:e}))}function Cn(t,A){if(A>127||A<0){L("Received a noteOn for note",A,"Ignoring.");return}let e=A+this.workletProcessorChannels[t].channelTransposeKeyShift,s=this.workletProcessorChannels[t].preset.program;if(this.tunings[s]?.[A]?.midiNote>=0&&(e=this.tunings[s]?.[A].midiNote),this.highPerformanceMode&&!this.workletProcessorChannels[t].drumChannel){this.killNote(t,e);return}this.workletProcessorChannels[t].voices.forEach(o=>{o.midiNote!==e||o.isInRelease===!0||(this.workletProcessorChannels[t].holdPedal?this.workletProcessorChannels[t].sustainedVoices.push(o):this.releaseVoice(o))}),this.callEvent("noteoff",{midiNote:A,channel:t})}function En(t,A){this.workletProcessorChannels[t].voices.forEach(e=>{e.midiNote===A&&(e.modulatedGenerators[g.releaseVolEnv]=-12e3,this.releaseVoice(e))})}function Bn(t,A=!1){let e=this.workletProcessorChannels[t].voices;A?(e.length=0,this.workletProcessorChannels[t].sustainedVoices.length=0,this.sendChannelProperties()):(e.forEach(s=>{s.isInRelease||this.releaseVoice(s)}),this.workletProcessorChannels[t].sustainedVoices.forEach(s=>{this.releaseVoice(s)}))}function hn(t=!1){m("%cStop all received!",r.info);for(let A=0;A XA(n,this.workletProcessorChannels[t].midiControllers,0,P.pitchWheel)),this.sendChannelProperties()}function pn(t,A){let e=this.workletProcessorChannels[t];e.midiControllers[EA+P.channelPressure]=A<<7,this.workletProcessorChannels[t].voices.forEach(s=>XA(s,e.midiControllers,0,P.channelPressure)),this.callEvent("channelpressure",{channel:t,pressure:A})}function yn(t,A,e){this.workletProcessorChannels[t].voices.forEach(s=>{s.midiNote===A&&(s.pressure=e,XA(s,this.workletProcessorChannels[t].midiControllers,0,P.polyPressure))}),this.callEvent("polypressure",{channel:t,midiNote:A,pressure:e})}function Sn(t,A){if(A.length!==12)throw new Error("Tuning is not the length of 12.");this.workletProcessorChannels[t].channelOctaveTuning=A}function Dn(t,A,e,s=!1){let n=this.workletProcessorChannels[t];if(n===void 0){L(`Trying to access channel ${t} which does not exist... ignoring!`);return}if(A>127){if(!s)return;switch(A){default:return;case wt.velocityOverride:n.velocityOverride=e}}if(A>=p.lsbForControl1ModulationWheel&&A<=p.lsbForControl13EffectControl2&&A!==p.lsbForControl6DataEntry){let o=A-32;if(n.lockedControllers[o])return;n.midiControllers[o]=n.midiControllers[o]&16256|e&127,n.voices.forEach(i=>XA(i,n.midiControllers,1,o))}switch(A){case p.allNotesOff:this.stopAll(t);break;case p.allSoundOff:this.stopAll(t,!0);break;case p.bankSelect:let o=e;if(!s){switch(this.system){case"gm":m(`%cIgnoring the Bank Select (${e}), as the synth is in GM mode.`,r.info);return;case"xg":o===120||o===126||o===127?this.setDrums(t,!0):t%16!==DA&&this.setDrums(t,!1);break;case"gm2":o===120&&(n.drumChannel=!0,this.callEvent("drumchange",{channel:t,isDrumChannel:!0}))}n.drumChannel&&(o=128),o===128&&!n.drumChannel&&(o=n.midiControllers[p.bankSelect])}n.midiControllers[p.bankSelect]=o;break;case p.lsbForControl0BankSelect:this.system==="xg"?n.drumChannel||e!==127&&(n.midiControllers[p.bankSelect]=e):this.system==="gm2"&&(n.midiControllers[p.bankSelect]=e);break;case p.RPNLsb:n.RPValue=n.RPValue<<7|e,n.dataEntryState=uA.RPFine;break;case p.RPNMsb:n.RPValue=e,n.dataEntryState=uA.RPCoarse;break;case p.NRPNMsb:n.NRPCoarse=e,n.dataEntryState=uA.NRPCoarse;break;case p.NRPNLsb:n.NRPFine=e,n.dataEntryState=uA.NRPFine;break;case p.dataEntryMsb:this.dataEntryCoarse(t,e);break;case p.lsbForControl6DataEntry:this.dataEntryFine(t,e);break;case p.resetAllControllers:this.resetControllers(t);break;case p.sustainPedal:e>=64?n.holdPedal=!0:(n.holdPedal=!1,n.sustainedVoices.forEach(i=>{this.releaseVoice(i)}),n.sustainedVoices=[]);break;default:if(n.lockedControllers[A])return;n.midiControllers[A]=e<<7,n.voices.forEach(i=>XA(i,n.midiControllers,1,A)),this.callEvent("controllerchange",{channel:t,controllerNumber:A,controllerValue:e});break}}function kn(t){this.midiVolume=t,this.setMasterPan(this.pan)}function wn(t){this.masterGain=t*Ut,this.setMasterPan(this.pan)}function Fn(t){this.pan=t,t=t/2+.5,this.panLeft=(1-t)*this.currentGain,this.panRight=t*this.currentGain}function Rn(t,A){A&&this.stopAll(t,!0),this.workletProcessorChannels[t].isMuted=A,this.sendChannelProperties(),this.callEvent("mutechannel",{channel:t,isMuted:A})}function Gn(t){this.workletProcessorChannels[t].lockGSNRPNParams=!0,this.workletProcessorChannels[t].channelVibrato.rate=0,this.workletProcessorChannels[t].channelVibrato.delay=0,this.workletProcessorChannels[t].channelVibrato.depth=0}function xn(t,A,e,s){this.workletProcessorChannels[t].lockGSNRPNParams||(this.workletProcessorChannels[t].channelVibrato.rate=e,this.workletProcessorChannels[t].channelVibrato.delay=s,this.workletProcessorChannels[t].channelVibrato.depth=A)}function Mn(t,A){let e=this.workletProcessorChannels[t],s=()=>{e.channelVibrato.delay===0&&e.channelVibrato.rate===0&&e.channelVibrato.depth===0&&(e.channelVibrato.depth=50,e.channelVibrato.rate=8,e.channelVibrato.delay=.6)};switch(e.dataEntryState){default:case uA.Idle:break;case uA.NRPFine:if(this.system!=="gs"||e.lockGSNRPNParams)return;switch(e.NRPCoarse){default:if(A===64)return;L(`%cUnrecognized NRPN for %c${t}%c: %c(0x${e.NRPCoarse.toString(16).toUpperCase()} 0x${e.NRPFine.toString(16).toUpperCase()})%c data value: %c${A}`,r.warn,r.recognized,r.warn,r.unrecognized,r.warn,r.value);break;case 1:switch(e.NRPFine){default:if(A===64)return;L(`%cUnrecognized NRPN for %c${t}%c: %c(0x${e.NRPCoarse.toString(16)} 0x${e.NRPFine.toString(16)})%c data value: %c${A}`,r.warn,r.recognized,r.warn,r.unrecognized,r.warn,r.value);break;case 8:if(A===64)return;s(),e.channelVibrato.rate=A/64*8,m(`%cVibrato rate for %c${t}%c is now set to %c${A} = ${e.channelVibrato.rate}%cHz.`,r.info,r.recognized,r.info,r.value,r.info);break;case 9:if(A===64)return;s(),e.channelVibrato.depth=A/2,m(`%cVibrato depth for %c${t}%c is now set to %c${A} = ${e.channelVibrato.depth}%c cents range of detune.`,r.info,r.recognized,r.info,r.value,r.info);break;case 10:if(A===64)return;s(),e.channelVibrato.delay=A/64/3,m(`%cVibrato delay for %c${t}%c is now set to %c${A} = ${e.channelVibrato.delay}%c seconds.`,r.info,r.recognized,r.info,r.value,r.info);break;case 32:let i=A;this.controllerChange(t,p.brightness,A),m(`%cFilter cutoff for %c${t}%c is now set to %c${i}`,r.info,r.recognized,r.info,r.value)}break;case 24:let n=A-64;e.keyCentTuning[e.NRPFine]=n*100,m(`%cGS drum key tuning. MIDI note: %c${e.NRPFine}%c semitones: %c${n}`,r.info,r.recognized,r.info,r.value);break;case 29:let o=A;this.controllerChange(t,p.effects1Depth,o),m(`%cGS Drum reverb for %c${t}%c: %c${o}`,r.info,r.recognized,r.info,r.value);break}break;case uA.RPCoarse:case uA.RPFine:switch(e.RPValue){default:L(`%cUnrecognized RPN for %c${t}%c: %c(0x${e.RPValue.toString(16)})%c data value: %c${A}`,r.warn,r.recognized,r.warn,r.unrecognized,r.warn,r.value);break;case 0:e.midiControllers[EA+P.pitchWheelRange]=A<<7,m(`%cChannel ${t} bend range. Semitones: %c${A}`,r.info,r.value);break;case 2:this.setChannelTuningSemitones(t,A-64);break;case 1:this.setChannelTuning(t,A-64,!1);break;case 5:this.setModulationDepth(t,A*100);break;case 16383:this.resetParameters(t);break}}}function Nn(t,A){let e=this.workletProcessorChannels[t];switch(e.dataEntryState){default:break;case uA.RPCoarse:case uA.RPFine:switch(e.RPValue){default:break;case 0:if(A===0)break;e.midiControllers[EA+P.pitchWheelRange]|=A;let s=(e.midiControllers[EA+P.pitchWheelRange]>>7)+A/127;m(`%cChannel ${t} bend range. Semitones: %c${s}`,r.info,r.value);break;case 1:let o=e.customControllers[IA.channelTuning]<<7|A;this.setChannelTuning(t,o*.01220703125);break;case 5:let C=e.customControllers[IA.modulationMultiplier]*50+A/128*100;this.setModulationDepth(t,C);break;case 16383:this.resetParameters(t);break}}}function bn(t=!0){t&&m("%cResetting all controllers!",r.info),this.callEvent("allcontrollerreset",void 0);for(let A=0;A {this.workletProcessorChannels[A].lockedControllers[n]&&this.callEvent("controllerchange",{channel:A,controllerNumber:n,controllerValue:this.workletProcessorChannels[A].midiControllers[n]>>7})};if(s(p.mainVolume),s(p.pan),s(p.expressionController),s(p.modulationWheel),s(p.effects3Depth),s(p.effects1Depth),s(p.brightness),this.workletProcessorChannels[A].lockedControllers[EA+P.pitchWheel]){let n=this.workletProcessorChannels[A].midiControllers[EA+P.pitchWheel],o=n>>7,i=n&127;this.callEvent("pitchwheel",{channel:A,MSB:o,LSB:i})}}this.tunings=[],this.tunings=[];for(let A=0;A<127;A++)this.tunings.push([]);this.setMIDIVolume(1),this.system=Oe}function Ln(t){let A=this.workletProcessorChannels[t],s=A.lockedControllers.reduce((o,i,C)=>(i&&o.push(C),o),[]).map(o=>({ccNum:o,ccVal:A.midiControllers[o]}));A.channelOctaveTuning.fill(0),A.keyCentTuning.fill(0),A.midiControllers.set(PA),A.channelVibrato={rate:0,depth:0,delay:0},A.holdPedal=!1,s.forEach(o=>{A.midiControllers[o.ccNum]=o.ccVal});let n=A.customControllers[IA.channelTransposeFine];A.customControllers.set(kt),A.customControllers[IA.channelTransposeFine]=n,this.resetParameters(t)}function Un(t){let A=this.workletProcessorChannels[t];A.NRPCoarse=0,A.NRPFine=0,A.RPValue=0,A.dataEntryState=uA.Idle}function Tn(){let t=4;for(let s of this.instruments)t+=s.instrumentZones.reduce((n,o)=>(o.generators=o.generators.filter(i=>i.generatorType!==g.sampleID&&i.generatorType!==g.keyRange&&i.generatorType!==g.velRange),(o.velRange.max!==127||o.velRange.min!==0)&&o.generators.unshift({generatorType:g.velRange,generatorValue:o.velRange.max<<8|o.velRange.min}),(o.keyRange.max!==127||o.keyRange.min!==0)&&o.generators.unshift({generatorType:g.keyRange,generatorValue:o.keyRange.max<<8|o.keyRange.min}),o.isGlobal||o.generators.push({generatorType:g.sampleID,generatorValue:this.samples.indexOf(o.sample)}),o.generators.length*4+n),0);let A=new H(t),e=0;for(let s of this.instruments)for(let n of s.instrumentZones){n.generatorZoneStartIndex=e;for(let o of n.generators)Y(A,o.generatorType),Y(A,o.generatorValue),e++}return cA(A,0),sA(new AA("igen",A.length,A))}function Hn(t,A,e,s,n){let o=this.samples.map((B,d)=>{e&&B.compressSample(s,n);let h=B.getRawData();return m(`%cEncoded sample %c${d}. ${B.sampleName}%c of %c${this.samples.length}`,r.info,r.recognized,r.info,r.recognized),h}),i=this.samples.reduce((B,d,h)=>B+o[h].length+46,0),C=new H(i);this.samples.forEach((B,d)=>{let h=o[d],u,l,D=h.length;B.isCompressed?(u=C.currentIndex,l=u+h.length):(u=C.currentIndex/2,l=u+h.length/2,D+=46),t.push(u),C.set(h,C.currentIndex),C.currentIndex+=D,A.push(l)});let c=sA(new AA("smpl",C.length,C),new H([115,100,116,97]));return sA(new AA("LIST",c.length,c))}function Yn(t,A){let s=new H(46*(this.samples.length+1));return this.samples.forEach((n,o)=>{wA(s,n.sampleName,20);let i=t[o];cA(s,i);let C=A[o];cA(s,C);let c=n.sampleLoopStartIndex+i,B=n.sampleLoopEndIndex+i;n.isCompressed&&(c-=i,B-=i),cA(s,c),cA(s,B),cA(s,n.sampleRate),s[s.currentIndex++]=n.samplePitch,s[s.currentIndex++]=n.samplePitchCorrection,Y(s,n.sampleLink),Y(s,n.sampleType)}),wA(s,"EOS",46),sA(new AA("shdr",s.length,s))}function Jn(){let t=10;for(let s of this.instruments)t+=s.instrumentZones.reduce((n,o)=>o.modulators.length*10+n,0);let A=new H(t),e=0;for(let s of this.instruments)for(let n of s.instrumentZones){n.modulatorZoneStartIndex=e;for(let o of n.modulators)Y(A,o.sourceEnum),Y(A,o.modulatorDestination),Y(A,o.transformAmount),Y(A,o.secondarySourceEnum),Y(A,o.transformType),e++}return ge(A,0,10),sA(new AA("imod",A.length,A))}function vn(){let t=this.instruments.reduce((o,i)=>i.instrumentZones.length*4+o,4),A=new H(t),e=0,s=0,n=0;for(let o of this.instruments){o.instrumentZoneIndex=e;for(let i of o.instrumentZones)i.zoneID=e,Y(A,s),Y(A,n),s+=i.generators.length,n+=i.modulators.length,e++}return Y(A,s),Y(A,n),sA(new AA("ibag",A.length,A))}function qn(){let t=this.instruments.length*22+22,A=new H(t),e=0,s=0;for(let n of this.instruments)wA(A,n.instrumentName,20),Y(A,e),e+=n.instrumentZones.length,n.instrumentID=s,s++;return wA(A,"EOI",20),Y(A,e),sA(new AA("inst",A.length,A))}function Pn(){let t=4;for(let s of this.presets)t+=s.presetZones.reduce((n,o)=>(o.generators=o.generators.filter(i=>i.generatorType!==g.instrument&&i.generatorType!==g.keyRange&&i.generatorType!==g.velRange),(o.velRange.max!==127||o.velRange.min!==0)&&o.generators.unshift({generatorType:g.velRange,generatorValue:o.velRange.max<<8|o.velRange.min}),(o.keyRange.max!==127||o.keyRange.min!==0)&&o.generators.unshift({generatorType:g.keyRange,generatorValue:o.keyRange.max<<8|o.keyRange.min}),o.isGlobal||o.generators.push({generatorType:g.instrument,generatorValue:this.instruments.indexOf(o.instrument)}),o.generators.length*4+n),0);let A=new H(t),e=0;for(let s of this.presets)for(let n of s.presetZones){n.generatorZoneStartIndex=e;for(let o of n.generators)Y(A,o.generatorType),Y(A,o.generatorValue);e+=n.generators.length}return Y(A,0),Y(A,0),sA(new AA("pgen",A.length,A))}function Kn(){let t=10;for(let s of this.presets)t+=s.presetZones.reduce((n,o)=>o.modulators.length*10+n,0);let A=new H(t),e=0;for(let s of this.presets)for(let n of s.presetZones){n.modulatorZoneStartIndex=e;for(let o of n.modulators)Y(A,o.sourceEnum),Y(A,o.modulatorDestination),Y(A,o.transformAmount),Y(A,o.secondarySourceEnum),Y(A,o.transformType),e++}return ge(A,0,10),sA(new AA("pmod",A.length,A))}function Vn(){let t=this.presets.reduce((o,i)=>i.presetZones.length*4+o,4),A=new H(t),e=0,s=0,n=0;for(let o of this.presets){o.presetZoneStartIndex=e;for(let i of o.presetZones)i.zoneID=e,Y(A,s),Y(A,n),s+=i.generators.length,n+=i.modulators.length,e++}return Y(A,s),Y(A,n),sA(new AA("pbag",A.length,A))}function On(){let t=this.presets.length*38+38,A=new H(t),e=0;for(let s of this.presets)wA(A,s.presetName,20),Y(A,s.program),Y(A,s.bank),Y(A,e),cA(A,s.library),cA(A,s.genre),cA(A,s.morphology),e+=s.presetZones.length;return wA(A,"EOP",20),Y(A,0),Y(A,0),Y(A,e),cA(A,0),cA(A,0),cA(A,0),sA(new AA("phdr",A.length,A))}var Yo={compress:!1,compressionQuality:.5,compressionFunction:void 0};function Zn(t=Yo){if(t.compress&&typeof t.compressionFunction!="function")throw new TypeError("No compression function supplied but compression enabled.");yA("%cSaving soundfont...",r.info),m(`%cCompression: %c${t?.compress||"false"}%c quality: %c${t?.compressionQuality||"none"}`,r.info,r.recognized,r.info,r.recognized),m("%cWriting INFO...",r.info);let A=[];this.soundFontInfo.ISFT="SpessaSynth",t?.compress&&(this.soundFontInfo.ifil="3.0");for(let[K,W]of Object.entries(this.soundFontInfo))if(K==="ifil"||K==="iver"){let I=parseInt(W.split(".")[0]),nA=parseInt(W.split(".")[1]),j=new H(4);Y(j,I),Y(j,nA),A.push(sA(new AA(K,4,j)))}else if(K==="DMOD")A.push(sA(new AA(K,W.length,W)));else{let I=new H(W.length);wA(I,W),A.push(sA(new AA(K,W.length,I)))}let e=ke([new H([73,78,70,79]),...A]),s=sA(new AA("LIST",e.length,e));m("%cWriting SDTA...",r.info);let n=[],o=[],i=Hn.call(this,n,o,t?.compress,t?.compressionQuality||.5,t.compressionFunction);m("%cWriting PDTA...",r.info),m("%cWriting SHDR...",r.info);let C=Yn.call(this,n,o);m("%cWriting IGEN...",r.info);let c=Tn.call(this);m("%cWriting IMOD...",r.info);let B=Jn.call(this);m("%cWriting IBAG...",r.info);let d=vn.call(this);m("%cWriting INST...",r.info);let h=qn.call(this),u=Pn.call(this);m("%cWriting PMOD...",r.info);let l=Kn.call(this);m("%cWriting PBAG...",r.info);let D=Vn.call(this);m("%cWriting PHDR...",r.info);let S=On.call(this),w=ke([new H([112,100,116,97]),S,D,l,u,h,d,B,c,C]),y=sA(new AA("LIST",w.length,w));m("%cWriting the output file...",r.info);let N=ke([new H([115,102,98,107]),s,i,y]),G=sA(new AA("RIFF",N.length,N));return m(`%cSaved succesfully! Final file size: %c${G.length}`,r.info,r.recognized),X(),G}var ne=class t{constructor(A=void 0){this.soundFontInfo={},this.presets=[],this.samples=[],this.instruments=[],this.defaultModulators=Pe.map(e=>$.copy(e)),A?.presets&&(this.presets.push(...A.presets),this.soundFontInfo=A.info)}removeUnusedElements(){this.instruments.forEach(A=>{A.useCount<1&&A.instrumentZones.forEach(e=>{e.isGlobal||e.sample.useCount--})}),this.instruments=this.instruments.filter(A=>A.useCount>0),this.samples=this.samples.filter(A=>A.useCount>0)}deleteInstrument(A){if(A.useCount>0)throw new Error(`Cannot delete an instrument that has ${A.useCount} usages.`);this.instruments.splice(this.instruments.indexOf(A),1),A.deleteInstrument(),this.removeUnusedElements()}deleteSample(A){if(A.useCount>0)throw new Error(`Cannot delete sample that has ${A.useCount} usages.`);this.samples.splice(this.samples.indexOf(A),1),this.removeUnusedElements()}deletePreset(A){A.deletePreset(),this.presets.splice(this.presets.indexOf(A),1),this.removeUnusedElements()}getPresetNoFallback(A,e,s=!1){let n=this.presets.find(o=>o.bank===A&&o.program===e);if(n)return n;if(s!==!1)return A===128?this.presets.find(o=>o.bank===128):this.presets.find(o=>o.program===e)}setSampleIDOffset(A){this.presets.forEach(e=>e.sampleIDOffset=A)}getPreset(A,e){let s=this.presets.find(n=>n.bank===A&&n.program===e);return s||(A===128?(s=this.presets.find(n=>n.bank===128&&n.program===e),s||(s=this.presets.find(n=>n.bank===128))):s=this.presets.find(n=>n.program===e&&n.bank!==128),s&&L(`%cPreset ${A}.${e} not found. Replaced with %c${s.presetName} (${s.bank}.${s.program})`,r.warn,r.recognized)),s||(L(`Preset ${e} not found. Defaulting to`,this.presets[0].presetName),s=this.presets[0]),s}getPresetByName(A){let e=this.presets.find(s=>s.presetName===A);return e||(L("Preset not found. Defaulting to:",this.presets[0].presetName),e=this.presets[0]),e}static mergeSoundfonts(...A){let e=A.shift(),s=e.presets;for(;A.length;)A.shift().presets.forEach(o=>{s.find(i=>i.bank===o.bank&&i.program===o.program)===void 0&&s.push(o)});return new t({presets:s,info:e.soundFontInfo})}};ne.prototype.write=Zn;function Xn(t){yA("%cLoading instruments...",r.info);for(let A=0;A A.deleteZone()),this.presetZones.length=0}deleteZone(A){this.presetZones[A].deleteZone(),this.presetZones.splice(A,1)}preload(A,e){for(let s=A;s {o.sample.isSampleLoaded||o.sample.getAudioData()})}preloadSpecific(A,e){this.getSamplesAndGenerators(A,e).forEach(s=>{s.sample.isSampleLoaded||s.sample.getAudioData()})}getSamplesAndGenerators(A,e){let s=this.foundSamplesAndGenerators[A][e];if(s)return s;if(this.presetZones.length<1)return[];function n(h,u,l){return l>=h&&l<=u}function o(h,u){h.push(...u.filter(l=>!h.find(D=>D.generatorType===l.generatorType)))}function i(h,u){h.push(...u.filter(l=>!h.find(D=>$.isIdentical(l,D))))}let C=[],c=this.presetZones[0].isGlobal?[...this.presetZones[0].generators]:[],B=this.presetZones[0].isGlobal?[...this.presetZones[0].modulators]:[];return this.presetZones.filter(h=>n(h.keyRange.min,h.keyRange.max,A)&&n(h.velRange.min,h.velRange.max,e)&&!h.isGlobal).forEach(h=>{if(h.instrument.instrumentZones.length<1)return;let u=h.generators,l=h.modulators,D=h.instrument.instrumentZones[0].isGlobal?[...h.instrument.instrumentZones[0].generators]:[],S=h.instrument.instrumentZones[0].isGlobal?[...h.instrument.instrumentZones[0].modulators]:[];h.instrument.instrumentZones.filter(y=>n(y.keyRange.min,y.keyRange.max,A)&&n(y.velRange.min,y.velRange.max,e)&&!y.isGlobal).forEach(y=>{let N=[...y.generators],G=[...y.modulators];o(u,c),o(N,D),i(l,B),i(G,S),i(G,this.defaultModulators);let K=[...G];for(let W=0;W $.isIdentical(I,j));nA!==-1?K[nA]=K[nA].sumTransform(I):K.push(I)}C.push({instrumentGenerators:N,presetGenerators:u,modulators:K,sample:y.sample,sampleID:y.generators.find(W=>W.generatorType===g.sampleID).generatorValue})})}),this.foundSamplesAndGenerators[A][e]=C,C}};var Re=class{velRange={min:0,max:127};keyRange={min:0,max:127};isGlobal=!1;generators=[];modulators=[]};var $A=class extends Re{sample=void 0;useCount=0;deleteZone(){this.useCount--,!this.isGlobal&&this.sample.useCount--}},le=class extends Re{instrument=void 0;deleteZone(){this.isGlobal||this.instrument.removeUseCount()}};var ue=class{constructor(){this.instrumentName="",this.instrumentZones=[],this._useCount=0}addUseCount(){this._useCount++,this.instrumentZones.forEach(A=>A.useCount++)}removeUseCount(){this._useCount--;for(let A=0;A A.deleteZone()),this.instrumentZones.length=0}safeDeleteZone(A){return this.instrumentZones[A].useCount--,this.instrumentZones[A].useCount<1?(this.deleteZone(A),!0):!1}deleteZone(A){this.instrumentZones[A].deleteZone(),this.instrumentZones.splice(A,1)}};var At=class extends ce{constructor(A,e){super(Pe),this.program=e&127,this.bank=A>>8&127,A>>31&&(this.bank=128),this.DLSInstrument=new ue,this.DLSInstrument.addUseCount();let n=new le;n.instrument=this.DLSInstrument,this.presetZones=[n]}};function Wn(t){this.verifyHeader(t,"LIST"),this.verifyText(V(t.chunkData,4),"ins ");let A=[];for(;t.chunkData.length>t.chunkData.currentIndex;)A.push(O(t.chunkData));let e=A.find(l=>l.header==="insh");if(!e)throw X(),new Error("No instrument header!");let s=k(e.chunkData,4),n=k(e.chunkData,4),o=k(e.chunkData,4),i=new At(n,o),C="unnamedPreset",c=SA(A,"INFO");if(c){let l=O(c.chunkData);for(;l.header!=="INAM";)l=O(c.chunkData);C=V(l.chunkData,l.chunkData.length).trim()}i.presetName=C,i.DLSInstrument.instrumentName=C,te(`%cParsing %c"${C}"%c...`,r.info,r.recognized,r.info);let B=SA(A,"lrgn");if(!B)throw X(),new Error("No region list!");let d=new $A;d.isGlobal=!0;let h=SA(A,"lart"),u=SA(A,"lar2");this.readLart(h,u,d),i.DLSInstrument.instrumentZones.push(d);for(let l=0;l >10&15;y===QA.linear&&w!==QA.linear&&(y=w);let N=s>>14&1,G=s>>15&1;i===g.initialAttenuation&&(G=!G),h=TA(y,N,G,C.isCC,C.enum)}let u=s>>4&15,l=s>>8&1,D=s>>9&1,S=TA(u,l,D,d.isCC,d.enum);if(c){let w=S;S=h,h=w}return new $({srcEnum:h,secSrcEnum:S,dest:i,transform:0,amt:n})}function Tt(t,A){let e=t.chunkData,s=[],n=[];k(e,4);let o=k(e,4);for(let i=0;i>16;if(C===0&&c===0&&d===0){let l;switch(B){case x.pan:l=new U(g.pan,u);break;case x.gain:l=new U(g.initialAttenuation,-u*10/.4);break;case x.filterCutoff:l=new U(g.initialFilterFc,u);break;case x.filterQ:l=new U(g.initialFilterQ,u);break;case x.modLfoFreq:l=new U(g.freqModLFO,u);break;case x.modLfoDelay:l=new U(g.delayModLFO,u);break;case x.vibLfoFreq:l=new U(g.freqVibLFO,u);break;case x.vibLfoDelay:l=new U(g.delayVibLFO,u);break;case x.volEnvDelay:l=new U(g.delayVolEnv,u);break;case x.volEnvAttack:l=new U(g.attackVolEnv,u);break;case x.volEnvHold:l=new U(g.holdVolEnv,u);break;case x.volEnvDecay:l=new U(g.decayVolEnv,u);break;case x.volEnvRelease:l=new U(g.releaseVolEnv,u);break;case x.volEnvSustain:let D=(1e3-u)/10;l=new U(g.sustainVolEnv,D*10);break;case x.modEnvDelay:l=new U(g.delayModEnv,u);break;case x.modEnvAttack:l=new U(g.attackModEnv,u);break;case x.modEnvHold:l=new U(g.holdModEnv,u);break;case x.modEnvDecay:l=new U(g.decayModEnv,u);break;case x.modEnvRelease:l=new U(g.releaseModEnv,u);break;case x.modEnvSustain:let S=1e3-u;l=new U(g.sustainModEnv,S);break;case x.reverbSend:l=new U(g.reverbEffectsSend,u);break;case x.chorusSend:l=new U(g.chorusEffectsSend,u);break;case x.pitch:let w=Math.floor(u/100),y=Math.floor(u-w*100);l=new U(g.fineTune,y),s.push(new U(g.coarseTune,w));break}l&&s.push(l)}else{let l=!0;if(c===z.none)if(C===z.modLfo&&B===x.pitch)s.push(new U(g.modLfoToPitch,u));else if(C===z.modLfo&&B===x.gain)s.push(new U(g.modLfoToVolume,u));else if(C===z.modLfo&&B===x.filterCutoff)s.push(new U(g.modLfoToFilterFc,u));else if(C===z.vibratoLfo&&B===x.pitch)s.push(new U(g.vibLfoToPitch,u));else if(C===z.modEnv&&B===x.pitch)s.push(new U(g.modEnvToPitch,u));else if(C===z.modEnv&&B===x.filterCutoff)s.push(new U(g.modEnvToFilterFc,u));else if(C===z.keyNum&&B===x.volEnvHold){s.push(new U(g.keyNumToVolEnvHold,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.holdVolEnv&&(S.generatorValue+=D)})}else if(C===z.keyNum&&B===x.volEnvDecay){s.push(new U(g.keyNumToVolEnvDecay,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.decayVolEnv&&(S.generatorValue+=D)})}else if(C===z.keyNum&&B===x.modEnvHold){s.push(new U(g.keyNumToModEnvHold,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.holdModEnv&&(S.generatorValue+=D)})}else if(C===z.keyNum&&B===x.modEnvDecay){s.push(new U(g.keyNumToModEnvDecay,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.decayModEnv&&(S.generatorValue+=D)})}else l=!1;else l=!1;if(l===!1){let D=zn(C,c,B,d,u);D?(n.push(D),m("%cSucceeded converting to SF2 Modulator!",r.recognized)):L("Failed converting to SF2 Modulator!")}}}return n.find(i=>i.modulatorDestination===g.reverbEffectsSend)===void 0&&n.push(new $({srcEnum:219,dest:g.reverbEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),n.find(i=>i.modulatorDestination===g.chorusEffectsSend)===void 0&&n.push(new $({srcEnum:221,dest:g.chorusEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),A&&n.push(new $({srcEnum:129,dest:g.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0}),new $({srcEnum:13,dest:g.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0})),{modulators:n,generators:s}}function jn(t,A,e){if(t)for(;t.chunkData.currentIndex t.chunkData.currentIndex;)A.push(O(t.chunkData));let e=A.find(j=>j.header==="rgnh"),s=k(e.chunkData,2),n=k(e.chunkData,2),o=k(e.chunkData,2),i=k(e.chunkData,2),C=new et({min:s,max:n},{min:o,max:i});k(e.chunkData,2);let c=k(e.chunkData,2);c!==0&&C.generators.push(new U(g.exclusiveClass,c));let B=SA(A,"lart"),d=SA(A,"lar2");this.readLart(B,d,C),C.isGlobal=!1;let h=A.find(j=>j.header==="wsmp");k(h.chunkData,4);let u=k(h.chunkData,2),l=zA(h.chunkData[h.chunkData.currentIndex++],h.chunkData[h.chunkData.currentIndex++]),S=(k(h.chunkData,4)|0)/-655360;k(h.chunkData,4);let w=k(h.chunkData,4),y,N={start:0,end:0};if(w===0)y=0;else{k(h.chunkData,4),k(h.chunkData,4)===0?y=1:y=3,N.start=k(h.chunkData,4);let J=k(h.chunkData,4);N.end=N.start+J}let G=A.find(j=>j.header==="wlnk");if(G===void 0)return;k(G.chunkData,2),k(G.chunkData,2),k(G.chunkData,4);let K=k(G.chunkData,4),W=this.samples[K];if(W===void 0)throw new Error("Invalid sample ID!");let nA=(S||W.sampleDbAttenuation)*10/.4;return C.setWavesample(nA,y,N,u,W,K,l),C}var de=class{constructor(A,e,s,n,o,i,C,c){this.sampleName=A,this.sampleRate=e,this.samplePitch=s,this.samplePitchCorrection=n,this.sampleLink=o,this.sampleType=i,this.sampleLoopStartIndex=C,this.sampleLoopEndIndex=c,this.isCompressed=(i&16)>0,this.compressedData=void 0,this.useCount=0}getRawData(){let A=new Error("Not implemented");throw A.name="NotImplementedError",A}compressSample(A,e){if(!this.isCompressed)try{this.compressedData=e([this.getAudioData()],1,this.sampleRate,A),this.sampleType|=16,this.isCompressed=!0}catch{L(`Failed to compress ${this.sampleName}. Leaving as uncompressed!`),this.isCompressed=!1,this.compressedData=void 0,this.sampleType&=-17}}getAudioData(){let A=new Error("Not implemented");throw A.name="NotImplementedError",A}};var tt=class extends de{constructor(A,e,s,n,o,i,C,c){super(A,e,s,n,0,1,o,i-1),this.sampleData=C,this.sampleDbAttenuation=c}getAudioData(){return this.sampleData}sampleDbAttenuation;sampleData;getRawData(){if(this.isCompressed){if(!this.compressedData)throw new Error("Compressed but no data??");return this.compressedData}let A=new Uint8Array(this.sampleData.length*2);for(let e=0;e >8&255}return A}};function Ao(t){yA("%cLoading Wave samples...",r.recognized);let A=0;for(;t.chunkData.currentIndex J.header==="fmt ");if(!n)throw new Error("No fmt chunk in the wave file!");if(k(n.chunkData,2)!==1)throw new Error("Only PCM format in WAVE is supported.");if(k(n.chunkData,2)!==1)throw new Error("Only mono samples are supported.");let C=k(n.chunkData,4);k(n.chunkData,4),k(n.chunkData,2);let c=k(n.chunkData,2),B=c/8,d=Math.pow(2,B*8-1),h=Math.pow(2,B*8),u,l=!1;c===8?(u=255,l=!0):u=d;let D=s.find(J=>J.header==="data");if(!D)throw new Error("No data chunk in the wave chunk!");let S=D.size/B,w=new Float32Array(S);for(let J=0;J =d&&(Z-=h),w[J]=Z/u)}let y=60,N=0,G=0,K=w.length-1,W=0,I=s.find(J=>J.header==="wsmp");if(I){if(k(I.chunkData,4),y=k(I.chunkData,2),N=zA(I.chunkData[I.chunkData.currentIndex++],I.chunkData[I.chunkData.currentIndex++]),W=(k(I.chunkData,4)|0)/-655360,k(I.chunkData,4),k(I.chunkData,4)===1){k(I.chunkData,8),G=k(I.chunkData,4);let CA=k(I.chunkData,4);K=G+CA}}else L("No wsmp chunk in wave... using sane defaults.");let nA=SA(s,"INFO"),j=`Unnamed ${A}`;if(nA){let J=O(nA.chunkData);for(;J.header!=="INAM"&&nA.chunkData.currentIndex (y.messageStatusByte&240)===F.noteOn);w&&l.push(w.ticks)}this.firstNoteOn=Math.min(...l),m(`%cFirst note-on detected at: %c${this.firstNoteOn}%c ticks!`,r.info,r.recognized,r.info),d!==null&&h===null?(d=this.firstNoteOn,h=this.lastVoiceEventTick):(d===null&&(d=this.firstNoteOn),(h===null||h===0)&&(h=this.lastVoiceEventTick)),this.loop={start:d,end:h},m(`%cLoop points: start: %c${this.loop.start}%c end: %c${this.loop.end}`,r.info,r.recognized,r.info,r.recognized);let D=0;for(let S of this.midiPorts)if(S!==-1){D=S;break}if(this.midiPorts=this.midiPorts.map(S=>S===-1?D:S),this.midiPortChannelOffsets.length===0&&(this.midiPortChannelOffsets=[0]),this.midiPortChannelOffsets.length<2?m("%cNo additional MIDI Ports detected.",r.info):m("%cMIDI Ports detected!",r.recognized),!i)if(this.tracks.length>1){if(this.tracks[0].find(S=>S.messageStatusByte>=F.noteOn&&S.messageStatusByte w.messageStatusByte===F.trackName);S&&(this.rawMidiName=S.messageData,this.midiName=V(S.messageData,S.messageData.length,void 0,!1))}}else{let S=this.tracks[0].find(w=>w.messageStatusByte===F.trackName);S&&(this.rawMidiName=S.messageData,this.midiName=V(S.messageData,S.messageData.length,void 0,!1))}if(this.fileName=e,this.midiName=this.midiName.trim(),this.midiName.length===0){m("%cNo name detected. Using the alt name!",r.info),this.midiName=Cs(e),this.rawMidiName=new Uint8Array(this.midiName.length);for(let S=0;S u>h?u:h),s=[];for(let h=0;h {i[D]>=l.length||l[i[D]].ticks0;){let h=c(),u=t.tracks[h];if(i[h]>=u.length){C--;continue}let l=u[i[h]];if(i[h]++,l.messageStatusByte===F.midiPort){B[h]=l.messageData[0];continue}let D=l.messageStatusByte&240;if(D!==F.noteOn&&D!==F.controllerChange&&D!==F.programChange&&D!==F.systemExclusive)continue;let S=(l.messageStatusByte&15)+t.midiPortChannelOffsets[B[h]]||0,w=s[S];switch(D){case F.programChange:w.program=l.messageData[0],n(w);break;case F.controllerChange:if(l.messageData[0]!==p.bankSelect||d==="gs"&&w.drums)continue;let y=l.messageData[1],N=Math.max(0,y-t.bankOffset);if(d==="xg"){let W=y===120||y===126||y===127;W!==w.drums?(w.drums=W,w.bank=w.drums?128:N,n(w)):w.bank=w.drums?128:N;continue}s[S].bank=N;break;case F.noteOn:if(l.messageData[1]===0)continue;n(w),o[w.string].add(`${l.messageData[0]}-${l.messageData[1]}`);break;case F.systemExclusive:if(l.messageData[0]!==65||l.messageData[2]!==66||l.messageData[3]!==18||l.messageData[4]!==64||!(l.messageData[5]&16)||l.messageData[6]!==21){l.messageData[0]===67&&l.messageData[2]===76&&l.messageData[5]===126&&l.messageData[6]===0&&(d="xg");continue}let G=[9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15][l.messageData[5]&15]+t.midiPortChannelOffsets[B[h]],K=!!(l.messageData[7]>0&&l.messageData[5]>>4);w=s[G],w.drums=K,w.bank=K?128:0,n(w);break}}for(let h of Object.keys(o))o[h].size===0&&(m(`%cDetected change but no keys for %c${h}`,r.info,r.value),delete o[h]);return X(),o}function Gs(t,A){this.midiPortChannelOffset===0&&(this.midiPortChannelOffset+=16,this.midiPortChannelOffsets[A]=0),this.midiPortChannelOffsets[A]===void 0&&(this.synth.workletProcessorChannels.length {this.assignMIDIPort(e,A)}),this.duration=this.midiData.duration,this.firstNoteTime=Ce(this.midiData.firstNoteOn,this.midiData),m(`%cTotal song time: ${ft(Math.ceil(this.duration)).time}`,r.recognized),this.post(wA.songChange,[new Oe(this.midiData),this.songIndex]),this.synth.resetAllControllers(),this.duration<=1&&(U(`%cVery short song: (${ft(Math.round(this.duration)).time}). Disabling loop!`,r.warn),this.loop=!1),this.play(!0)}function Ms(t){this.songs=t.reduce((A,e)=>{if(e.duration)return A.push(e),A;try{A.push(new _e(e.binary,e.altName||""))}catch(s){return this.post(wA.midiError,s.message),A}return A},[]),!(this.songs.length<1)&&(this.songIndex=0,this.songs.length>1&&(this.loop=!1),this.loadNewSequence(this.songs[this.songIndex]))}function Ns(){if(this.songs.length===1){this.currentTime=0;return}this.songIndex++,this.songIndex%=this.songs.length,this.loadNewSequence(this.songs[this.songIndex])}function bs(){if(this.songs.length===1){this.currentTime=0;return}this.songIndex--,this.songIndex<0&&(this.songIndex=this.songs.length-1),this.loadNewSequence(this.songs[this.songIndex])}var KA=new Int16Array(127);KA[p.mainVolume]=100;KA[p.expressionController]=127;KA[p.pan]=64;KA[p.releaseTime]=64;KA[p.brightness]=64;KA[p.effects1Depth]=0;function Ls(t,A=void 0){this.oneTickToSeconds=60/(120*this.midiData.timeDivision),this.synth.resetAllControllers(),this.sendMIDIReset(),this._resetTimers();let e=this.synth.workletProcessorChannels.length,s=Array(e).fill(8192),n=[];for(let C=0;C C===p.dataDecrement||C===p.dataIncrement||C===p.dataEntryMsb||C===p.dataDecrement||C===p.lsbForControl6DataEntry||C===p.RPNLsb||C===p.RPNMsb||C===p.NRPNLsb||C===p.NRPNMsb||C===p.bankSelect||C===p.lsbForControl0BankSelect||C===p.resetAllControllers,i=[];for(let C=0;C =A)break}else if(this.playedTime>=t)break;let B=we(c.messageStatusByte),d=B.channel+(this.midiPortChannelOffsets[this.midiPorts[C]]||0);switch(B.status){case F.noteOn:case F.noteOff:case F.keySignature:break;case F.pitchBend:s[d]=c.messageData[1]<<7|c.messageData[0];break;case F.programChange:let u=n[d];u.program=c.messageData[0],u.actualBank=u.bank;break;case F.controllerChange:let l=c.messageData[0];if(o(l)){let D=c.messageData[1];if(l===p.bankSelect){n[d].bank=D;break}this.sendMIDIMessages?this.sendMIDICC(d,l,D):this.synth.controllerChange(d,l,D)}else i[d]===void 0&&(i[d]=Array.from(KA)),i[d][l]=c.messageData[1];break;default:this._processEvent(c,C);break}this.eventIndex[C]++,C=this._findFirstEventIndex();let h=this.tracks[C][this.eventIndex[C]];if(h===void 0)return this.stop(),!1;this.playedTime+=this.oneTickToSeconds*(h.ticks-c.ticks)}if(this.sendMIDIMessages){for(let C=0;C >7,s[C]&127),i[C]!==void 0&&i[C].forEach((c,B)=>{c!==KA[B]&&!o(B)&&this.sendMIDICC(C,B,c)}),n[C].program>=0&&n[C].actualBank>=0){let c=n[C].actualBank;this.sendMIDICC(C,p.bankSelect,c),this.sendMIDIProgramChange(C,n[C].program)}}else for(let C=0;C >7,s[C]&127),i[C]!==void 0&&i[C].forEach((c,B)=>{c!==KA[B]&&!o(B)&&this.synth.controllerChange(C,B,c)}),n[C].program>=0&&n[C].actualBank>=0){let c=n[C].actualBank;this.synth.controllerChange(C,p.bankSelect,c),this.synth.programChange(C,n[C].program)}return!0}function Us(t=!1){if(this.midiData!==void 0){if(t){this.currentTime=0;return}if(this.currentTime>=this.duration){this.currentTime=0;return}this.paused&&(this._recalculateStartTime(this.pausedTime),this.pausedTime=void 0),this.sendMIDIMessages||this.playingNotes.forEach(A=>{this.synth.noteOn(A.channel,A.midiNote,A.velocity,!1,!0)}),this.setProcessHandler()}}function Ts(t){this.stop(),this.playingNotes=[],this.pausedTime=void 0,this.post(wA.timeChange,currentTime-Ce(t,this.midiData));let A=this._playTo(0,t);this._recalculateStartTime(this.playedTime),A&&this.play()}function Hs(t){this.absoluteStartTime=currentTime-t/this._playbackRate}function Ys(t,A){switch(t){default:break;case bA.loadNewSongList:this.loadNewSongList(A);break;case bA.pause:this.pause();break;case bA.play:this.play(A);break;case bA.stop:this.stop();break;case bA.setTime:this.currentTime=A;break;case bA.changeMIDIMessageSending:this.sendMIDIMessages=A;break;case bA.setPlaybackRate:this.playbackRate=A;break;case bA.setLoop:this.loop=A;break;case bA.changeSong:A?this.nextSong():this.previousSong();break;case bA.getMIDI:this.post(wA.getMIDI,this.midiData);break;case bA.setSkipToFirstNote:this._skipToFirstNoteOn=A;break}}function Js(t,A=void 0){this.synth.enableEventSystem&&this.synth.post({messageType:pA.sequencerSpecific,messageData:{messageType:t,messageData:A}})}function vs(t){this.post(wA.midiEvent,t)}function qs(t,A,e){t%=16,this.sendMIDIMessages&&this.sendMIDIMessage([F.controllerChange|t,A,e])}function Ps(t,A){t%=16,this.sendMIDIMessages&&this.sendMIDIMessage([F.programChange|t,A])}function Ks(t,A,e){t%=16,this.sendMIDIMessages&&this.sendMIDIMessage([F.pitchBend|t,e,A])}function Vs(){if(this.sendMIDIMessages){this.sendMIDIMessage([F.reset]);for(let t=0;t this.duration||A<0){this._skipToFirstNoteOn?this.setTimeTicks(this.midiData.firstNoteOn-1):this.setTimeTicks(0);return}if(this._skipToFirstNoteOn&&A Os?440*Math.pow(2,(t-6900)/1200):wt[~~t-ze]}var Rt=-1660,bo=1600,Ft=new Float32Array((bo-Rt)*100+1);for(let t=0;t .5?1:0,s?e*2-1:e;case QA.concave:return s?(e=e*2-1,e<0?1-Ee[~~(e*-gA)]-1:Ee[~~e*gA]):Ee[~~(e*gA)];case QA.convex:return s?(e=e*2-1,e<0?1-Be[~~(e*-gA)]-1:Be[~~(e*gA)]):Be[~~(e*gA)]}}var Gt=1,xt=new Float32Array(1e3);for(let t=0;t =e.loopEnd;)s-=o;let C=~~s,c=C+1;for(;c>=e.loopEnd;)c-=o;let B=s-C,d=n[c],h=n[C];A[i]=h+(d-h)*B,s+=e.playbackStep*t.currentTuningCalculated}}else{if(e.loopingMode===2&&!t.isInRelease)return;for(let o=0;o =e.end){t.finished=!0;return}let c=s-i,B=n[C],d=n[i];A[o]=d+(B-d)*c,s+=e.playbackStep*t.currentTuningCalculated}}t.sample.cursor=s}function Xs(t,A){let e=t.sample,s=e.cursor,n=e.loopEnd-e.loopStart,o=e.sampleData;if(t.sample.isLooping)for(let i=0;i =e.loopEnd;)s-=n;let C=~~s+1;for(;C>=e.loopEnd;)C-=n;A[i]=o[C],s+=e.playbackStep*t.currentTuningCalculated}else{if(e.loopingMode===2&&!t.isInRelease)return;for(let i=0;i =e.end){t.finished=!0;return}A[i]=o[C],s+=e.playbackStep*t.currentTuningCalculated}}e.cursor=s}function Ws(t,A){let e=t.sample,s=e.cursor,n=e.sampleData;if(e.isLooping){let o=e.loopEnd-e.loopStart;for(let i=0;i =e.loopEnd;)s-=o;let C=~~s,c=C+1,B=c+1,d=B+1,h=s-C;c>=e.loopEnd&&(c-=o),B>=e.loopEnd&&(B-=o),d>=e.loopEnd&&(d-=o);let u=n[C],l=n[c],D=n[B],S=n[d],w=.5*(D-u),y=u-2.5*l+2*D-.5*S,N=.5*(S-u)+1.5*(l-D);A[i]=((N*h+y)*h+w)*h+l,s+=e.playbackStep*t.currentTuningCalculated}}else{if(e.loopingMode===2&&!t.isInRelease)return;for(let o=0;o =e.end||c>=e.end||B>=e.end){t.finished=!0;return}let h=n[i],u=n[C],l=n[c],D=n[B],S=.5*(l-h),w=h-2.5*u+2*l-.5*D,y=.5*(D-h)+1.5*(u-l);A[o]=((y*d+w)*d+S)*d+u,s+=e.playbackStep*t.currentTuningCalculated}}t.sample.cursor=s}function _s(t,A,e,s,n,o,i,C,c){if(!isNaN(e[0])){if(i>0){let B=o[0],d=o[1];i=Math.min(i,1e3);let h=i/1300,u=t*h,l=A*h;for(let D=0;D 0){let B=C[0],d=C[1];c=Math.min(c,1e3);let h=c/1300,u=t*h,l=A*h;for(let D=0;D 0)for(let B=0;B 0)for(let B=0;B 13499&&A.filter.reasonanceCb===0)return;let n=A.filter;(n.cutoffCents!==s||n.reasonanceCb!==A.modulatedGenerators[g.initialFilterQ])&&(n.cutoffCents=s,n.reasonanceCb=A.modulatedGenerators[g.initialFilterQ],t.calculateCoefficients(A));for(let o=0;o =Mt}currentSampleTime=0;sampleRate;currentAttenuationDb=JA;state=0;releaseStartDb=JA;releaseStartTimeSamples=0;currentReleaseGain=1;attackDuration=0;decayDuration=0;releaseDuration=0;attenuation=0;attenuationTarget=0;sustainDbRelative=0;delayEnd=0;attackEnd=0;holdEnd=0;decayEnd=0;static startRelease(A){A.volumeEnvelope.releaseStartTimeSamples=A.volumeEnvelope.currentSampleTime,A.volumeEnvelope.currentReleaseGain=VA(A.volumeEnvelope.currentAttenuationDb),t.recalculate(A)}static recalculate(A){let e=A.volumeEnvelope,s=B=>Math.max(0,Math.floor(HA(B)*e.sampleRate));e.attenuationTarget=Math.max(0,Math.min(A.modulatedGenerators[g.initialAttenuation],1440))/10,e.sustainDbRelative=Math.min(JA,A.modulatedGenerators[g.sustainVolEnv]/10);let n=Math.min(JA,e.sustainDbRelative);e.attackDuration=s(A.modulatedGenerators[g.attackVolEnv]);let o=A.modulatedGenerators[g.decayVolEnv],i=(60-A.targetKey)*A.modulatedGenerators[g.keyNumToVolEnvDecay],C=n/JA;e.decayDuration=s(o+i)*C,e.releaseDuration=s(A.modulatedGenerators[g.releaseVolEnv]),e.delayEnd=s(A.modulatedGenerators[g.delayVolEnv]),e.attackEnd=e.attackDuration+e.delayEnd;let c=(60-A.targetKey)*A.modulatedGenerators[g.keyNumToVolEnvHold];if(e.holdEnd=s(A.modulatedGenerators[g.holdVolEnv]+c)+e.attackEnd,e.decayEnd=e.decayDuration+e.holdEnd,e.state===0&&e.attackEnd===0&&(e.state=2),A.isInRelease){let B=Math.max(0,Math.min(JA,e.sustainDbRelative)),d=B/JA;switch(e.decayDuration=s(o+i)*d,e.state){case 0:e.releaseStartDb=JA;break;case 1:let h=1-(e.attackEnd-e.releaseStartTimeSamples)/e.attackDuration;e.releaseStartDb=20*Math.log10(h)*-1;break;case 2:e.releaseStartDb=0;break;case 3:e.releaseStartDb=(1-(e.decayEnd-e.releaseStartTimeSamples)/e.decayDuration)*B;break;case 4:e.releaseStartDb=B;break}e.releaseStartDb=Math.max(0,Math.min(e.releaseStartDb,JA)),e.releaseStartDb>=Mt&&(A.finished=!0),e.currentReleaseGain=VA(e.releaseStartDb)}}static apply(A,e,s,n){let o=A.volumeEnvelope,i=s/10,C=n;if(A.isInRelease){let B=o.currentSampleTime-o.releaseStartTimeSamples;if(B>=o.releaseDuration){for(let h=0;h =e.length)return;o.state++;case 1:for(;o.currentSampleTime =e.length)return}o.state++;case 2:for(;o.currentSampleTime =e.length)return;o.state++;case 3:for(;o.currentSampleTime =e.length)return;o.state++;case 4:for(o.canEndOnSilentSustain&&o.sustainDbRelative>=Mt&&(A.finished=!0);;)if(o.attenuation+=(o.attenuationTarget-o.attenuation)*C,e[c]*=VA(o.sustainDbRelative+i+o.attenuation),o.currentAttenuationDb=o.sustainDbRelative,o.currentSampleTime++,++c>=e.length)return}}};var js=Math.PI/2,$s=.05;function An(t,A,e,s,n,o){if(A.isInRelease||currentTime>=A.releaseStartTime&&(A.isInRelease=!0,LA.startRelease(A),YA.startRelease(A),A.sample.loopingMode===3&&(A.sample.isLooping=!1)),A.modulatedGenerators[g.initialAttenuation]>2500){A.isInRelease&&(A.finished=!0);return}let i=A.targetKey,C=A.modulatedGenerators[g.fineTune]+t.customControllers[IA.channelTuning]+t.customControllers[IA.channelTransposeFine]+t.customControllers[IA.masterTuning]+t.channelOctaveTuning[A.midiNote%12]+t.keyCentTuning[A.midiNote],c=A.modulatedGenerators[g.coarseTune]+t.customControllers[IA.channelTuningSemitones],B=this.tunings[t.preset.program]?.[i];B?.midiNote>=0&&(i=B.midiNote,C+=B.centTuning),C+=(i-A.sample.rootKey)*A.modulatedGenerators[g.scaleTuning];let d=A.modulatedGenerators[g.vibLfoToPitch];if(d!==0){let Z=A.startTime+HA(A.modulatedGenerators[g.delayVibLFO]),CA=Fe(A.modulatedGenerators[g.freqVibLFO]),oA=je(Z,CA,currentTime);C+=oA*(d*t.customControllers[IA.modulationMultiplier])}let h=A.modulatedGenerators[g.initialFilterFc],u=A.modulatedGenerators[g.modLfoToPitch],l=A.modulatedGenerators[g.modLfoToVolume],D=A.modulatedGenerators[g.modLfoToFilterFc],S=0;if(u+D+l!==0){let Z=A.startTime+HA(A.modulatedGenerators[g.delayModLFO]),CA=Fe(A.modulatedGenerators[g.freqModLFO]),oA=je(Z,CA,currentTime);C+=oA*(u*t.customControllers[IA.modulationMultiplier]),S=-oA*l,h+=oA*D}if(t.channelVibrato.depth>0){let Z=je(A.startTime+t.channelVibrato.delay,t.channelVibrato.rate,currentTime);Z&&(C+=Z*t.channelVibrato.depth)}let w=A.modulatedGenerators[g.modEnvToPitch],y=A.modulatedGenerators[g.modEnvToFilterFc],N=YA.getValue(A,currentTime);h+=N*y,C+=N*w;let G=~~(C+c*100);G!==A.currentTuningCents&&(A.currentTuningCents=G,A.currentTuningCalculated=Math.pow(2,G/1200));let K=(Math.max(-500,Math.min(500,A.modulatedGenerators[g.pan]))+500)/1e3,W=new Float32Array(e.length);switch(this.interpolationType){case he.linear:default:Zs(A,W);break;case he.nearestNeighbor:Xs(A,W);break;case he.fourthOrder:Ws(A,W)}Qe.apply(A,W,h),LA.apply(A,W,S,this.volumeEnvelopeSmoothingFactor),A.currentPan+=(K-A.currentPan)*this.panSmoothingFactor;let I=Math.cos(js*A.currentPan)*this.panLeft,nA=Math.sin(js*A.currentPan)*this.panRight,j=this.oneOutputMode?0:A.modulatedGenerators[g.reverbEffectsSend],J=this.oneOutputMode?0:A.modulatedGenerators[g.chorusEffectsSend];_s(I,nA,W,e,s,n,j,o,J)}function Uo(t,A){let e=0;return t.drumChannel&&(e+=5),A.isInRelease&&(e-=5),e+=A.velocity/25,e-=A.volumeEnvelope.state,A.isInRelease&&(e-=5),e-=A.volumeEnvelope.currentAttenuationDb/50,e}function en(t){let A=[];for(let s of this.workletProcessorChannels)for(let n of s.voices)if(!n.finished){let o=Uo(s,n);A.push({channel:s,voice:n,priority:o})}A.sort((s,n)=>s.priority-n.priority);let e=A.slice(0,t);for(let{channel:s,voice:n}of e){let o=s.voices.indexOf(n);o>-1&&s.voices.splice(o,1)}}function tn(t){t.releaseStartTime=currentTime,t.releaseStartTime-t.startTime nn=t);var To=function(t){var A,e,s,n,o,i,C,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",B="",d=0;t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");do n=c.indexOf(t.charAt(d++)),o=c.indexOf(t.charAt(d++)),i=c.indexOf(t.charAt(d++)),C=c.indexOf(t.charAt(d++)),A=n<<2|o>>4,e=(15&o)<<4|i>>2,s=(3&i)<<6|C,B+=String.fromCharCode(A),i!==64&&(B+=String.fromCharCode(e)),C!==64&&(B+=String.fromCharCode(s));while(d 1&&(I.thisProgram=process.argv[1].replace(/\\/g,"/")),I.arguments=process.argv.slice(2),typeof module<"u",process.on("uncaughtException",function(a){if(!(a instanceof ye))throw a}),process.on("unhandledRejection",function(a,E){process.exit(1)}),I.quit=function(a){process.exit(a)},I.inspect=function(){return"[Emscripten Module object]"}):CA?(typeof read<"u"&&(I.read=function(E){return read(E)}),I.readBinary=function(E){var Q;return typeof readbuffer=="function"?new Uint8Array(readbuffer(E)):(_A(typeof(Q=read(E,"binary"))=="object"),Q)},typeof scriptArgs<"u"?I.arguments=scriptArgs:typeof arguments<"u"&&(I.arguments=arguments),typeof quit=="function"&&(I.quit=function(a){quit(a)})):(j||J)&&(j?document.currentScript&&(oA=document.currentScript.src):oA=self.location.href,oA=oA.indexOf("blob:")!==0?oA.split("/").slice(0,-1).join("/")+"/":"",I.read=function(E){var Q=new XMLHttpRequest;return Q.open("GET",E,!1),Q.send(null),Q.responseText},J&&(I.readBinary=function(E){var Q=new XMLHttpRequest;return Q.open("GET",E,!1),Q.responseType="arraybuffer",Q.send(null),new Uint8Array(Q.response)}),I.readAsync=function(E,Q,f){var R=new XMLHttpRequest;R.open("GET",E,!0),R.responseType="arraybuffer",R.onload=function(){if(R.status==200||R.status==0&&R.response){Q(R.response);return}f()},R.onerror=f,R.send(null)},I.setWindowTitle=function(a){document.title=a});var Me=I.print||(typeof console<"u"?console.log.bind(console):typeof print<"u"?print:null),RA=I.printErr||(typeof printErr<"u"?printErr:typeof console<"u"&&console.warn.bind(console)||Me);for(t in nA)nA.hasOwnProperty(t)&&(I[t]=nA[t]);function Ne(a){var E=l;return l=l+a+15&-16,E}function Kt(a){var E=c[G>>2],Q=E+a+15&-16;return c[G>>2]=Q,Q>=BA&&!As()?(c[G>>2]=E,0):E}function Vt(a,E){return E||(E=16),a=Math.ceil(a/E)*E}function uo(a){switch(a){case"i1":case"i8":return 1;case"i16":return 2;case"i32":case"float":return 4;case"i64":case"double":return 8;default:if(a[a.length-1]==="*")return 4;if(a[0]!=="i")return 0;var E=parseInt(a.substr(1));return _A(E%8==0),E/8}}function fe(a){fe.shown||(fe.shown={}),fe.shown[a]||(fe.shown[a]=1,RA(a))}nA=void 0;var fo={"f64-rem":function(a,E){return a%E},debugger:function(){}},rt=[];function Po(a,E){for(var Q=0,f=Q;f >>0)+4294967296*+(E>>>0):+(a>>>0)+4294967296*+(0|E)}function at(a,E,Q){return Q&&Q.length?I["dynCall_"+a].apply(null,[E].concat(Q)):I["dynCall_"+a].call(null,E)}var be=0,Ot=0;function _A(a,E){a||ZA("Assertion failed: "+E)}function Zt(a){var E=I["_"+a];return _A(E,"Cannot call unknown function "+a+", make sure it is exported"),E}var Xt={stackSave:function(){ct()},stackRestore:function(){Qt()},arrayToC:function(a){var E,Q,f=Je(a.length);return E=a,Q=f,n.set(E,Q),f},stringToC:function(a){var E=0;if(a!=null&&a!==0){var Q=(a.length<<2)+1;E=Je(Q),zt(a,E,Q)}return E}},mo={string:Xt.stringToC,array:Xt.arrayToC};function Wt(a,E,Q,f,R){var q=Zt(a),_=[],M=0;if(f)for(var hA=0;hA>0]=E;break;case"i16":i[a>>1]=E;break;case"i32":c[a>>2]=E;break;case"i64":tempI64=[E>>>0,+wo(tempDouble=E)>=1?tempDouble>0?(0|Ro(+os(tempDouble/4294967296),4294967295))>>>0:~~+Fo((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0],c[a>>2]=tempI64[0],c[a+4>>2]=tempI64[1];break;case"float":d[a>>2]=E;break;case"double":h[a>>3]=E;break;default:ZA("invalid type for setValue: "+Q)}}function Zo(a,E,Q){switch((E=E||"i8").charAt(E.length-1)==="*"&&(E="i32"),E){case"i1":case"i8":return n[a>>0];case"i16":return i[a>>1];case"i32":case"i64":return c[a>>2];case"float":return d[a>>2];case"double":return h[a>>3];default:ZA("invalid type for getValue: "+E)}return null}function Xo(a,E,Q,f){typeof a=="number"?(q=!0,_=a):(q=!1,_=a.length);var R=typeof E=="string"?E:null;if(M=Q==4?f:[typeof Ye=="function"?Ye:Ne,Je,Ne,Kt][Q===void 0?2:Q](Math.max(_,R?1:E.length)),q){for(f=M,_A((3&M)==0),hA=M+(-4&_);f >2]=0;for(hA=M+_;f >0]=0;return M}if(R==="i8")return a.subarray||a.slice?o.set(a,M):o.set(new Uint8Array(a),M),M;for(var q,_,M,hA,rA,iA,tA,v=0;v<_;){var mA=a[v];if((rA=R||E[v])===0){v++;continue}rA=="i64"&&(rA="i32"),po(M+v,mA,rA),tA!==rA&&(iA=uo(rA),tA=rA),v+=iA}return M}function Wo(a){return D?Bt?Ye(a):Kt(a):Ne(a)}function Le(a,E){if(E===0||!a)return"";for(var Q,f,R,q=0,_=0;q|=f=o[a+_>>0],(f!=0||E)&&(_++,!E||_!=E););E||(E=_);var M="";if(q<128){for(;E>0;)R=String.fromCharCode.apply(String,o.subarray(a,a+Math.min(E,1024))),M=M?M+R:R,a+=1024,E-=1024;return M}return Q=a,function(rA,iA){for(var tA=iA;rA[tA];)++tA;if(tA-iA>16&&rA.subarray&&_t)return _t.decode(rA.subarray(iA,tA));for(var v,mA,GA,xA,MA,ee,NA="";;){if(!(v=rA[iA++]))return NA;if(!(128&v)){NA+=String.fromCharCode(v);continue}if(mA=63&rA[iA++],(224&v)==192){NA+=String.fromCharCode((31&v)<<6|mA);continue}if(GA=63&rA[iA++],(240&v)==224?v=(15&v)<<12|mA<<6|GA:(xA=63&rA[iA++],(248&v)==240?v=(7&v)<<18|mA<<12|GA<<6|xA:(MA=63&rA[iA++],v=(252&v)==248?(3&v)<<24|mA<<18|GA<<12|xA<<6|MA:(1&v)<<30|mA<<24|GA<<18|xA<<12|MA<<6|(ee=63&rA[iA++]))),v<65536)NA+=String.fromCharCode(v);else{var Se=v-65536;NA+=String.fromCharCode(55296|Se>>10,56320|1023&Se)}}}(o,Q)}function _o(a){for(var E="";;){var Q=n[a++>>0];if(!Q)return E;E+=String.fromCharCode(Q)}}function zo(a,E){return function(f,R,q){for(var _=0;_ >0]=f.charCodeAt(_);q||(n[R>>0]=0)}(a,E,!1)}var _t=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function Ue(a,E,Q,f){if(!(f>0))return 0;for(var R=Q,q=Q+f-1,_=0;_ =55296&&M<=57343&&(M=65536+((1023&M)<<10)|1023&a.charCodeAt(++_)),M<=127){if(Q>=q)break;E[Q++]=M}else if(M<=2047){if(Q+1>=q)break;E[Q++]=192|M>>6,E[Q++]=128|63&M}else if(M<=65535){if(Q+2>=q)break;E[Q++]=224|M>>12,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}else if(M<=2097151){if(Q+3>=q)break;E[Q++]=240|M>>18,E[Q++]=128|M>>12&63,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}else if(M<=67108863){if(Q+4>=q)break;E[Q++]=248|M>>24,E[Q++]=128|M>>18&63,E[Q++]=128|M>>12&63,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}else{if(Q+5>=q)break;E[Q++]=252|M>>30,E[Q++]=128|M>>24&63,E[Q++]=128|M>>18&63,E[Q++]=128|M>>12&63,E[Q++]=128|M>>6&63,E[Q++]=128|63&M}}return E[Q]=0,Q-R}function zt(a,E,Q){return Ue(a,o,E,Q)}function Te(a){for(var E=0,Q=0;Q =55296&&f<=57343&&(f=65536+((1023&f)<<10)|1023&a.charCodeAt(++Q)),f<=127?++E:f<=2047?E+=2:f<=65535?E+=3:f<=2097151?E+=4:f<=67108863?E+=5:E+=6}return E}var jt=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function jo(a){for(var E=a,Q=E>>1;i[Q];)++Q;if((E=Q<<1)-a>32&&jt)return jt.decode(o.subarray(a,E));for(var f=0,R="";;){var q=i[a+2*f>>1];if(q==0)return R;++f,R+=String.fromCharCode(q)}}function $o(a,E,Q){if(Q===void 0&&(Q=2147483647),Q<2)return 0;for(var f=E,R=(Q-=2)<2*a.length?Q/2:a.length,q=0;q >1]=_,E+=2}return i[E>>1]=0,E-f}function Ar(a){return 2*a.length}function er(a){for(var E=0,Q="";;){var f=c[a+4*E>>2];if(f==0)return Q;if(++E,f>=65536){var R=f-65536;Q+=String.fromCharCode(55296|R>>10,56320|1023&R)}else Q+=String.fromCharCode(f)}}function tr(a,E,Q){if(Q===void 0&&(Q=2147483647),Q<4)return 0;for(var f=E,R=f+Q-4,q=0;q =55296&&_<=57343&&(_=65536+((1023&_)<<10)|1023&a.charCodeAt(++q)),c[E>>2]=_,(E+=4)+4>R)break}return c[E>>2]=0,E-f}function sr(a){for(var E=0,Q=0;Q =55296&&f<=57343&&++Q,E+=4}return E}function nr(a){var E=Te(a)+1,Q=Ye(E);return Q&&Ue(a,n,Q,E),Q}function or(a){var E=Te(a)+1,Q=Je(E);return Ue(a,n,Q,E),Q}function rr(a){return a}function ir(){var a,E=function(){var f=Error();if(!f.stack){try{throw Error(0)}catch(R){f=R}if(!f.stack)return"(no stack trace available)"}return f.stack.toString()}();return I.extraStackTrace&&(E+=` +`+I.extraStackTrace()),(a=E).replace(/__Z[\w\d_]+/g,function(Q){var f,R=f=Q;return Q===R?Q:Q+" ["+R+"]"})}function It(a,E){return a%E>0&&(a+=E-a%E),a}function $t(a){I.buffer=s=a}function gt(){I.HEAP8=n=new Int8Array(s),I.HEAP16=i=new Int16Array(s),I.HEAP32=c=new Int32Array(s),I.HEAPU8=o=new Uint8Array(s),I.HEAPU16=C=new Uint16Array(s),I.HEAPU32=B=new Uint32Array(s),I.HEAPF32=d=new Float32Array(s),I.HEAPF64=h=new Float64Array(s)}function As(){var a=I.usingWasm?65536:16777216,E=2147483648-a;if(c[G>>2]>E)return!1;var Q=BA;for(BA=Math.max(BA,16777216);BA >2];)BA=BA<=536870912?It(2*BA,a):Math.min(It((3*BA+2147483648)/4,a),E);var f=I.reallocBuffer(BA);return f&&f.byteLength==BA?($t(f),gt(),!0):(BA=Q,!1)}u=l=S=w=y=N=G=0,D=!1,I.reallocBuffer||(I.reallocBuffer=function(a){try{if(ArrayBuffer.transfer)E=ArrayBuffer.transfer(s,a);else{var E,Q=n;E=new ArrayBuffer(a),new Int8Array(E).set(Q)}}catch{return!1}return!!Go(E)&&E});try{(K=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get))(new ArrayBuffer(4))}catch{K=function(E){return E.byteLength}}var Ct=I.TOTAL_STACK||5242880,BA=I.TOTAL_MEMORY||16777216;function yo(){return BA}function me(a){for(;a.length>0;){var E=a.shift();if(typeof E=="function"){E();continue}var Q=E.func;typeof Q=="number"?E.arg===void 0?I.dynCall_v(Q):I.dynCall_vi(Q,E.arg):Q(E.arg===void 0?null:E.arg)}}BA =0?a:E<=32?2*Math.abs(1< =f&&(E<=32||a>f)&&(a=-2*f+a),a}var wo=Math.abs,Fo=Math.ceil,os=Math.floor,Ro=Math.min,Ae=0,ht=null,pe=null;function hr(a){return a}I.preloadedImages={},I.preloadedAudios={};var rs="data:application/octet-stream;base64,";function He(a){return String.prototype.startsWith?a.startsWith(rs):a.indexOf(rs)===0}(function(){var E="main.wast",Q="main.wasm",f="main.temp.asm.js";He(E)||(E=fA(E)),He(Q)||(Q=fA(Q)),He(f)||(f=fA(f));var R={global:null,env:null,asm2wasm:fo,parent:I},q=null;function _(tA){return tA}function M(){try{if(I.wasmBinary)return new Uint8Array(I.wasmBinary);if(I.readBinary)return I.readBinary(Q);throw"both async and sync fetching of the wasm failed"}catch(tA){ZA(tA)}}I.asmPreload=I.asm;var hA=I.reallocBuffer,rA=function(tA){tA=It(tA,I.usingWasm?65536:16777216);var v=I.buffer.byteLength;if(I.usingWasm)try{var mA=I.wasmMemory.grow((tA-v)/65536);return mA!==-1?I.buffer=I.wasmMemory.buffer:null}catch{return null}};I.reallocBuffer=function(tA){return iA==="asmjs"?hA(tA):rA(tA)};var iA="";I.asm=function(tA,v,mA){var GA;if(!(v=GA=v).table){var xA,MA=I.wasmTableSize;MA===void 0&&(MA=1024);var ee=I.wasmMaxTableSize;typeof WebAssembly=="object"&&typeof WebAssembly.Table=="function"?ee!==void 0?v.table=new WebAssembly.Table({initial:MA,maximum:ee,element:"anyfunc"}):v.table=new WebAssembly.Table({initial:MA,element:"anyfunc"}):v.table=Array(MA),I.wasmTable=v.table}return v.memoryBase||(v.memoryBase=I.STATIC_BASE),v.tableBase||(v.tableBase=0),xA=function(Se,oe,ut){if(typeof WebAssembly!="object")return RA("no native wasm support detected"),!1;if(!(I.wasmMemory instanceof WebAssembly.Memory))return RA("no native wasm Memory in use"),!1;function ve(vA,qA){if((q=vA.exports).memory){var De,dt,Is;De=q.memory,dt=I.buffer,De.byteLength 0?Q:Te(a)+1,R=Array(f),q=Ue(a,R,0,R.length);return E&&(R.length=q),R}function ur(a){for(var E=[],Q=0;Q 255&&(f&=255),E.push(String.fromCharCode(f))}return E.join("")}l+=16,G=Ne(4),y=(S=w=Vt(l))+Ct,N=Vt(y),c[G>>2]=N,D=!0,I.wasmTableSize=4,I.wasmMaxTableSize=4,I.asmGlobalArg={},I.asmLibraryArg={abort:ZA,assert:_A,enlargeMemory:As,getTotalMemory:yo,abortOnCannotGrowMemory:function(){ZA("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+BA+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")},invoke_iii:function(E,Q,f){var R=ct();try{return I.dynCall_iii(E,Q,f)}catch(q){if(Qt(R),typeof q!="number"&&q!=="longjmp")throw q;I.setThrew(1,0)}},___assert_fail:function(E,Q,f,R){ZA("Assertion failed: "+Le(E)+", at: "+[Q?Le(Q):"unknown filename",f,R?Le(R):"unknown function"])},___setErrNo:function(E){return I.___errno_location&&(c[I.___errno_location()>>2]=E),E},_abort:function(){I.abort()},_emscripten_memcpy_big:function(E,Q,f){return o.set(o.subarray(Q,Q+f),E),E},_llvm_floor_f64:os,DYNAMICTOP_PTR:G,tempDoublePtr:kA,ABORT:be,STACKTOP:w,STACK_MAX:y};var is=I.asm(I.asmGlobalArg,I.asmLibraryArg,s);I.asm=is,I.___errno_location=function(){return I.asm.___errno_location.apply(null,arguments)};var Go=I._emscripten_replace_memory=function(){return I.asm._emscripten_replace_memory.apply(null,arguments)};I._free=function(){return I.asm._free.apply(null,arguments)};var Ye=I._malloc=function(){return I.asm._malloc.apply(null,arguments)};I._memcpy=function(){return I.asm._memcpy.apply(null,arguments)},I._memset=function(){return I.asm._memset.apply(null,arguments)},I._sbrk=function(){return I.asm._sbrk.apply(null,arguments)},I._stb_vorbis_js_channels=function(){return I.asm._stb_vorbis_js_channels.apply(null,arguments)},I._stb_vorbis_js_close=function(){return I.asm._stb_vorbis_js_close.apply(null,arguments)},I._stb_vorbis_js_decode=function(){return I.asm._stb_vorbis_js_decode.apply(null,arguments)},I._stb_vorbis_js_open=function(){return I.asm._stb_vorbis_js_open.apply(null,arguments)},I._stb_vorbis_js_sample_rate=function(){return I.asm._stb_vorbis_js_sample_rate.apply(null,arguments)},I.establishStackSpace=function(){return I.asm.establishStackSpace.apply(null,arguments)},I.getTempRet0=function(){return I.asm.getTempRet0.apply(null,arguments)},I.runPostSets=function(){return I.asm.runPostSets.apply(null,arguments)},I.setTempRet0=function(){return I.asm.setTempRet0.apply(null,arguments)},I.setThrew=function(){return I.asm.setThrew.apply(null,arguments)};var Je=I.stackAlloc=function(){return I.asm.stackAlloc.apply(null,arguments)},Qt=I.stackRestore=function(){return I.asm.stackRestore.apply(null,arguments)},ct=I.stackSave=function(){return I.asm.stackSave.apply(null,arguments)};function ye(a){this.name="ExitStatus",this.message="Program terminated with exit("+a+")",this.status=a}function lt(a){a=a||I.arguments,!(Ae>0)&&(function(){if(I.preRun)for(typeof I.preRun=="function"&&(I.preRun=[I.preRun]);I.preRun.length;)Do(I.preRun.shift());me(es)}(),!(Ae>0)&&(I.calledRun||(I.setStatus?(I.setStatus("Running..."),setTimeout(function(){setTimeout(function(){I.setStatus("")},1),E()},1)):E())));function E(){!I.calledRun&&(I.calledRun=!0,be||(Bt||(Bt=!0,me(Et)),me(ts),I.onRuntimeInitialized&&I.onRuntimeInitialized(),function(){if(I.postRun)for(typeof I.postRun=="function"&&(I.postRun=[I.postRun]);I.postRun.length;)ko(I.postRun.shift());me(ns)}()))}}function dr(a,E){(!E||!I.noExitRuntime||a!==0)&&(I.noExitRuntime||(be=!0,Ot=a,w=W,me(ss),So=!0,I.onExit&&I.onExit(a)),I.quit(a,new ye(a)))}function ZA(a){throw I.onAbort&&I.onAbort(a),a!==void 0?(Me(a),RA(a),a=JSON.stringify(a)):a="",be=!0,Ot=1,"abort("+a+"). Build with -s ASSERTIONS=1 for more info."}if(I.dynCall_iii=function(){return I.asm.dynCall_iii.apply(null,arguments)},I.asm=is,I.ccall=Wt,I.cwrap=function(E,Q,f,R){var q=(f=f||[]).every(function(_){return _==="number"});return Q!=="string"&&q&&!R?Zt(E):function(){return Wt(E,Q,f,arguments,R)}},ye.prototype=Error(),ye.prototype.constructor=ye,pe=function a(){I.calledRun||lt(),I.calledRun||(pe=a)},I.run=lt,I.abort=ZA,I.preInit)for(typeof I.preInit=="function"&&(I.preInit=[I.preInit]);I.preInit.length>0;)I.preInit.pop()();I.noExitRuntime=!0,lt(),I.onRuntimeInitialized=()=>{sn=!0,nn()},OA.decode=function(a){return function(Q){if(!sn)throw Error("Not initialized");var f={};function R(oe){return new Int32Array(I.HEAPU8.buffer,oe,1)[0]}function q(oe,ut){var ve=new ArrayBuffer(ut*Float32Array.BYTES_PER_ELEMENT),re=new Float32Array(ve);return re.set(new Float32Array(I.HEAPU8.buffer,oe,ut)),re}f.open=I.cwrap("stb_vorbis_js_open","number",[]),f.close=I.cwrap("stb_vorbis_js_close","void",["number"]),f.channels=I.cwrap("stb_vorbis_js_channels","number",["number"]),f.sampleRate=I.cwrap("stb_vorbis_js_sample_rate","number",["number"]),f.decode=I.cwrap("stb_vorbis_js_decode","number",["number","number","number","number","number"]);var _,M,hA,rA,iA=f.open(),tA=(_=Q,M=Q.byteLength,hA=I._malloc(M),(rA=new Uint8Array(I.HEAPU8.buffer,hA,M)).set(new Uint8Array(_,0,M)),rA),v=I._malloc(4),mA=I._malloc(4),GA=f.decode(iA,tA.byteOffset,tA.byteLength,v,mA);if(I._free(tA.byteOffset),GA<0)throw f.close(iA),I._free(v),Error("stbvorbis decode failed: "+GA);for(var xA=f.channels(iA),MA=Array(xA),ee=new Int32Array(I.HEAPU32.buffer,R(v),xA),NA=0;NA =0&&(s=this.workletProcessorChannels[e]),t.messageType){case eA.noteOn:this.noteOn(e,A[0],A[1],A[2]);break;case eA.noteOff:this.noteOff(e,A);break;case eA.pitchWheel:this.pitchWheel(e,A[0],A[1]);break;case eA.ccChange:this.controllerChange(e,A[0],A[1],A[2]);break;case eA.customcCcChange:s.customControllers[A[0]]=A[1];break;case eA.killNote:this.killNote(e,A);break;case eA.programChange:this.programChange(e,A[0],A[1]);break;case eA.channelPressure:this.channelPressure(e,A);break;case eA.polyPressure:this.polyPressure(e,A[0],A[1]);break;case eA.ccReset:e===UA?this.resetAllControllers():this.resetControllers(e);break;case eA.systemExclusive:this.systemExclusive(A);break;case eA.setChannelVibrato:if(e===UA)for(let i=0;i {let e=(A.midiControllers[EA+P.pitchWheelRange]>>7)+(A.midiControllers[EA+P.pitchWheelRange]&127)/127;return{voicesAmount:A.voices.length,pitchBend:A.midiControllers[EA+P.pitchWheel],pitchBendRangeSemitones:e,isMuted:A.isMuted,isDrum:A.drumChannel}});this.post({messageType:pA.channelProperties,messageData:t})}function Ho(t,A,e){let s=t,n=A<<7|e;return t===127&&A===127&&e===127?{midiNote:-1,centTuning:null}:{midiNote:s,centTuning:n*.0061}}function In(t,A=0){let e=t[0];if(!(this.deviceID!==UA&&t[1]!==127&&this.deviceID!==t[1]))switch(e){default:U(`%cUnrecognized SysEx: %c${lA(t)}`,r.warn,r.unrecognized);break;case 126:case 127:switch(t[2]){case 4:let n;switch(t[3]){case 1:let o=t[5]<<7|t[4];this.setMIDIVolume(o/16384),m(`%cMaster Volume. Volume: %c${o}`,r.info,r.value);break;case 2:let C=((t[5]<<7|t[4])-8192)/8192;this.setMasterPan(C),m(`%cMaster Pan. Pan: %c${C}`,r.info,r.value);break;case 3:let c=(t[5]<<7|t[6])-8192;n=Math.floor(c/81.92),this.setMasterTuning(n),m(`%cMaster Fine Tuning. Cents: %c${n}`,r.info,r.value);break;case 4:n=(t[5]-64)*100,this.setMasterTuning(n),m(`%cMaster Coarse Tuning. Cents: %c${n}`,r.info,r.value);break;default:U(`%cUnrecognized MIDI Device Control Real-time message: %c${lA(t)}`,r.warn,r.unrecognized)}break;case 9:t[3]===1?(m("%cGM system on",r.info),this.system="gm"):t[3]===3?(m("%cGM2 system on",r.info),this.system="gm2"):(m("%cGM system off, defaulting to GS",r.info),this.system="gs");break;case 8:switch(t[3]){case 2:case 7:let o=4;t[3]===7&&o++;let i=t[o++],C=t[o++];for(let B=0;B >1&1)===1&&this.setOctaveTuning(15+A,c);for(let B=0;B<7;B++)(t[5]>>B&1)===1&&this.setOctaveTuning(7+B+A,c);for(let B=0;B<7;B++)(t[6]>>B&1)===1&&this.setOctaveTuning(B+A,c);m(`%cMIDI Octave Scale ${t[3]===8?"(1 byte)":"(2 bytes)"} tuning via Tuning: %c${c.join(" ")}`,r.info,r.value);break;default:U(`%cUnrecognized MIDI Tuning standard message: %c${lA(t)}`,r.warn,r.unrecognized);break}break;default:U(`%cUnrecognized MIDI Realtime/non realtime message: %c${lA(t)}`,r.warn,r.unrecognized)}break;case 65:let s=function(){U(`%cUnrecognized Roland %cGS %cSysEx: %c${lA(t)}`,r.warn,r.recognized,r.warn,r.unrecognized)};if(t[2]===66&&t[3]===18){let n=t[7];if(t[6]===127){n===0?(m("%cGS Reset received!",r.info),this.resetAllControllers(!1),this.system="gs"):n===127&&(m("%cGS system off, switching to GM2",r.info),this.resetAllControllers(!1),this.system="gm2");return}else if(t[4]===64){if((t[5]&16)>0){let o=[9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15][t[5]&15]+A;switch(t[6]){default:s();break;case 21:let i=n>0&&t[5]>>4;this.setDrums(o,i),m(`%cChannel %c${o}%c ${i?"is now a drum channel":"now isn't a drum channel"}%c via: %c${lA(t)}`,r.info,r.value,r.recognized,r.info,r.value);return;case 22:let C=n-64;this.transposeChannel(o,C),m(`%cChannel %c${o}%c pitch shift. Semitones %c${C}%c, with %c${lA(t)}`,r.info,r.recognized,r.info,r.value,r.info,r.value);return;case 28:let c=n;c===0&&(c=Math.floor(Math.random()*128)),this.controllerChange(o,p.pan,c);break;case 33:this.controllerChange(o,p.effects3Depth,n);break;case 34:this.controllerChange(o,p.effects1Depth,n);break;case 64:case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:case 73:case 74:case 75:let B=t.length-9,d=new Int8Array(12);for(let u=0;u=this.workletProcessorChannels.length)return;let o=t[6];switch(t[5]){case 1:this.controllerChange(n,p.bankSelect,o);break;case 2:this.controllerChange(n,p.lsbForControl0BankSelect,o);break;case 3:this.programChange(n,o);break;case 8:let i=this.workletProcessorChannels[n];if(i.drumChannel)return;let C=o-64;i.channelTransposeKeyShift=C;break;case 11:this.controllerChange(n,p.mainVolume,o);break;case 14:let c=o;c===0&&(c=Math.floor(Math.random()*127)),this.controllerChange(n,p.pan,c);break;case 19:this.controllerChange(n,p.effects1Depth,o);break;case 18:this.controllerChange(n,p.effects3Depth,o);break;default:U(`%cUnrecognized Yamaha XG Part Setup: %c${t[5].toString(16).toUpperCase()}`,r.warn,r.unrecognized)}}else this.system==="xg"&&U(`%cUnrecognized Yamaha XG SysEx: %c${lA(t)}`,r.warn,r.unrecognized);else this.system==="xg"&&U(`%cUnrecognized Yamaha SysEx: %c${lA(t)}`,r.warn,r.unrecognized);break}}function gn(t,A,e){if(A.transformAmount===0)return A.currentValue=0,0;let s;if(A.sourceUsesCC)s=t[A.sourceIndex];else{let c=A.sourceIndex+EA;switch(A.sourceIndex){case P.noController:s=16383;break;case P.noteOnKeyNum:s=e.midiNote<<7;break;case P.noteOnVelocity:s=e.velocity<<7;break;case P.polyPressure:s=e.pressure<<7;break;default:s=t[c];break}}let n=dA[A.sourceCurveType][A.sourcePolarity][A.sourceDirection][s],o;if(A.secSrcUsesCC)o=t[A.secSrcIndex];else{let c=A.secSrcIndex+EA;switch(A.secSrcIndex){case P.noController:o=16383;break;case P.noteOnKeyNum:o=e.midiNote<<7;break;case P.noteOnVelocity:o=e.velocity<<7;break;case P.polyPressure:o=e.pressure<<7;break;default:o=t[c]}}let i=dA[A.secSrcCurveType][A.secSrcPolarity][A.secSrcDirection][o],C=n*i*A.transformAmount;return A.transformType===2&&(C=Math.abs(C)),A.currentValue=C,C}function XA(t,A,e=-1,s=0){let n=t.modulators,o=t.generators,i=t.modulatedGenerators;if(YA.recalculate(t),e===-1){i.set(o),n.forEach(B=>{let d=L[B.modulatorDestination],h=i[B.modulatorDestination]+gn(A,B,t);i[B.modulatorDestination]=Math.max(d.min,Math.min(h,d.max))}),LA.recalculate(t);return}let C=new Set([g.initialAttenuation,g.delayVolEnv,g.attackVolEnv,g.holdVolEnv,g.decayVolEnv,g.sustainVolEnv,g.releaseVolEnv,g.keyNumToVolEnvHold,g.keyNumToVolEnvDecay]),c=new Set;n.forEach(B=>{if(B.sourceUsesCC===e&&B.sourceIndex===s||B.secSrcUsesCC===e&&B.secSrcIndex===s){let d=B.modulatorDestination;c.has(d)||(i[d]=o[d],gn(A,B,t),n.forEach(h=>{if(h.modulatorDestination===d){let u=L[B.modulatorDestination],l=i[B.modulatorDestination]+h.currentValue;i[B.modulatorDestination]=Math.max(u.min,Math.min(l,u.max))}}),c.add(d))}}),[...c].some(B=>C.has(B))&&LA.recalculate(t)}var dA=[];for(let t=0;t<4;t++){dA[t]=[[new Float32Array(gA),new Float32Array(gA)],[new Float32Array(gA),new Float32Array(gA)]];for(let A=0;A 200&&e<40||this.highPerformanceMode&&e<10||i.isMuted)return;let C=A+i.channelTransposeKeyShift;if(A>127||A<0)return;let c=i.preset.program;this.tunings[c]?.[A]?.midiNote>=0&&(C=this.tunings[c]?.[A].midiNote),i.velocityOverride>0&&(e=i.velocityOverride);let B=this.getWorkletVoices(t,C,e,i,o,s),d=i.voices;B.forEach(h=>{let u=h.generators[g.exclusiveClass];u!==0&&d.forEach(G=>{G.generators[g.exclusiveClass]===u&&(this.releaseVoice(G),G.modulatedGenerators[g.releaseVolEnv]=-7e3,G.modulatedGenerators[g.releaseModEnv]=-7e3,LA.recalculate(G),YA.recalculate(G))}),XA(h,i.midiControllers);let l=h.modulatedGenerators[g.startAddrsOffset]+h.modulatedGenerators[g.startAddrsCoarseOffset]*32768,D=h.modulatedGenerators[g.endAddrOffset]+h.modulatedGenerators[g.endAddrsCoarseOffset]*32768,S=h.modulatedGenerators[g.startloopAddrsOffset]+h.modulatedGenerators[g.startloopAddrsCoarseOffset]*32768,w=h.modulatedGenerators[g.endloopAddrsOffset]+h.modulatedGenerators[g.endloopAddrsCoarseOffset]*32768,y=h.sample,N=G=>Math.max(0,Math.min(y.sampleData.length-1,G));if(y.cursor=N(y.cursor+l),y.end=N(y.end+D),y.loopStart=N(y.loopStart+S),y.loopEnd=N(y.loopEnd+w),y.loopEnd this.voiceCap&&this.voiceKilling(B.length),d.push(...B),n&&(this.sendChannelProperties(),this.callEvent("noteon",{midiNote:A,channel:t,velocity:e}))}function En(t,A){if(A>127||A<0){U("Received a noteOn for note",A,"Ignoring.");return}let e=A+this.workletProcessorChannels[t].channelTransposeKeyShift,s=this.workletProcessorChannels[t].preset.program;if(this.tunings[s]?.[A]?.midiNote>=0&&(e=this.tunings[s]?.[A].midiNote),this.highPerformanceMode&&!this.workletProcessorChannels[t].drumChannel){this.killNote(t,e);return}this.workletProcessorChannels[t].voices.forEach(o=>{o.midiNote!==e||o.isInRelease===!0||(this.workletProcessorChannels[t].holdPedal?this.workletProcessorChannels[t].sustainedVoices.push(o):this.releaseVoice(o))}),this.callEvent("noteoff",{midiNote:A,channel:t})}function Bn(t,A){this.workletProcessorChannels[t].voices.forEach(e=>{e.midiNote===A&&(e.modulatedGenerators[g.releaseVolEnv]=-12e3,this.releaseVoice(e))})}function hn(t,A=!1){let e=this.workletProcessorChannels[t].voices;A?(e.length=0,this.workletProcessorChannels[t].sustainedVoices.length=0,this.sendChannelProperties()):(e.forEach(s=>{s.isInRelease||this.releaseVoice(s)}),this.workletProcessorChannels[t].sustainedVoices.forEach(s=>{this.releaseVoice(s)}))}function Qn(t=!1){m("%cStop all received!",r.info);for(let A=0;A XA(n,this.workletProcessorChannels[t].midiControllers,0,P.pitchWheel)),this.sendChannelProperties()}function yn(t,A){let e=this.workletProcessorChannels[t];e.midiControllers[EA+P.channelPressure]=A<<7,this.workletProcessorChannels[t].voices.forEach(s=>XA(s,e.midiControllers,0,P.channelPressure)),this.callEvent("channelpressure",{channel:t,pressure:A})}function Sn(t,A,e){this.workletProcessorChannels[t].voices.forEach(s=>{s.midiNote===A&&(s.pressure=e,XA(s,this.workletProcessorChannels[t].midiControllers,0,P.polyPressure))}),this.callEvent("polypressure",{channel:t,midiNote:A,pressure:e})}function Dn(t,A){if(A.length!==12)throw new Error("Tuning is not the length of 12.");this.workletProcessorChannels[t].channelOctaveTuning=A}function kn(t,A,e,s=!1){let n=this.workletProcessorChannels[t];if(n===void 0){U(`Trying to access channel ${t} which does not exist... ignoring!`);return}if(A>127){if(!s)return;switch(A){default:return;case Dt.velocityOverride:n.velocityOverride=e}}if(A>=p.lsbForControl1ModulationWheel&&A<=p.lsbForControl13EffectControl2&&A!==p.lsbForControl6DataEntry){let o=A-32;if(n.lockedControllers[o])return;n.midiControllers[o]=n.midiControllers[o]&16256|e&127,n.voices.forEach(i=>XA(i,n.midiControllers,1,o))}switch(A){case p.allNotesOff:this.stopAll(t);break;case p.allSoundOff:this.stopAll(t,!0);break;case p.bankSelect:let o=e;if(!s){switch(this.system){case"gm":m(`%cIgnoring the Bank Select (${e}), as the synth is in GM mode.`,r.info);return;case"xg":o===120||o===126||o===127?this.setDrums(t,!0):t%16!==SA&&this.setDrums(t,!1);break;case"gm2":o===120&&(n.drumChannel=!0,this.callEvent("drumchange",{channel:t,isDrumChannel:!0}))}n.drumChannel&&(o=128),o===128&&!n.drumChannel&&(o=n.midiControllers[p.bankSelect])}n.midiControllers[p.bankSelect]=o;break;case p.lsbForControl0BankSelect:this.system==="xg"?n.drumChannel||e!==127&&(n.midiControllers[p.bankSelect]=e):this.system==="gm2"&&(n.midiControllers[p.bankSelect]=e);break;case p.RPNLsb:n.RPValue=n.RPValue<<7|e,n.dataEntryState=uA.RPFine;break;case p.RPNMsb:n.RPValue=e,n.dataEntryState=uA.RPCoarse;break;case p.NRPNMsb:n.NRPCoarse=e,n.dataEntryState=uA.NRPCoarse;break;case p.NRPNLsb:n.NRPFine=e,n.dataEntryState=uA.NRPFine;break;case p.dataEntryMsb:this.dataEntryCoarse(t,e);break;case p.lsbForControl6DataEntry:this.dataEntryFine(t,e);break;case p.resetAllControllers:this.resetControllers(t);break;case p.sustainPedal:e>=64?n.holdPedal=!0:(n.holdPedal=!1,n.sustainedVoices.forEach(i=>{this.releaseVoice(i)}),n.sustainedVoices=[]);break;default:if(n.lockedControllers[A])return;n.midiControllers[A]=e<<7,n.voices.forEach(i=>XA(i,n.midiControllers,1,A)),this.callEvent("controllerchange",{channel:t,controllerNumber:A,controllerValue:e});break}}function wn(t){this.midiVolume=t,this.setMasterPan(this.pan)}function Fn(t){this.masterGain=t*bt,this.setMasterPan(this.pan)}function Rn(t){this.pan=t,t=t/2+.5,this.panLeft=(1-t)*this.currentGain,this.panRight=t*this.currentGain}function Gn(t,A){A&&this.stopAll(t,!0),this.workletProcessorChannels[t].isMuted=A,this.sendChannelProperties(),this.callEvent("mutechannel",{channel:t,isMuted:A})}function xn(t){this.workletProcessorChannels[t].lockGSNRPNParams=!0,this.workletProcessorChannels[t].channelVibrato.rate=0,this.workletProcessorChannels[t].channelVibrato.delay=0,this.workletProcessorChannels[t].channelVibrato.depth=0}function Mn(t,A,e,s){this.workletProcessorChannels[t].lockGSNRPNParams||(this.workletProcessorChannels[t].channelVibrato.rate=e,this.workletProcessorChannels[t].channelVibrato.delay=s,this.workletProcessorChannels[t].channelVibrato.depth=A)}function Nn(t,A){let e=this.workletProcessorChannels[t],s=()=>{e.channelVibrato.delay===0&&e.channelVibrato.rate===0&&e.channelVibrato.depth===0&&(e.channelVibrato.depth=50,e.channelVibrato.rate=8,e.channelVibrato.delay=.6)};switch(e.dataEntryState){default:case uA.Idle:break;case uA.NRPFine:if(this.system!=="gs"||e.lockGSNRPNParams)return;switch(e.NRPCoarse){default:if(A===64)return;U(`%cUnrecognized NRPN for %c${t}%c: %c(0x${e.NRPCoarse.toString(16).toUpperCase()} 0x${e.NRPFine.toString(16).toUpperCase()})%c data value: %c${A}`,r.warn,r.recognized,r.warn,r.unrecognized,r.warn,r.value);break;case 1:switch(e.NRPFine){default:if(A===64)return;U(`%cUnrecognized NRPN for %c${t}%c: %c(0x${e.NRPCoarse.toString(16)} 0x${e.NRPFine.toString(16)})%c data value: %c${A}`,r.warn,r.recognized,r.warn,r.unrecognized,r.warn,r.value);break;case 8:if(A===64)return;s(),e.channelVibrato.rate=A/64*8,m(`%cVibrato rate for %c${t}%c is now set to %c${A} = ${e.channelVibrato.rate}%cHz.`,r.info,r.recognized,r.info,r.value,r.info);break;case 9:if(A===64)return;s(),e.channelVibrato.depth=A/2,m(`%cVibrato depth for %c${t}%c is now set to %c${A} = ${e.channelVibrato.depth}%c cents range of detune.`,r.info,r.recognized,r.info,r.value,r.info);break;case 10:if(A===64)return;s(),e.channelVibrato.delay=A/64/3,m(`%cVibrato delay for %c${t}%c is now set to %c${A} = ${e.channelVibrato.delay}%c seconds.`,r.info,r.recognized,r.info,r.value,r.info);break;case 32:let i=A;this.controllerChange(t,p.brightness,A),m(`%cFilter cutoff for %c${t}%c is now set to %c${i}`,r.info,r.recognized,r.info,r.value)}break;case 24:let n=A-64;e.keyCentTuning[e.NRPFine]=n*100,m(`%cGS drum key tuning. MIDI note: %c${e.NRPFine}%c semitones: %c${n}`,r.info,r.recognized,r.info,r.value);break;case 29:let o=A;this.controllerChange(t,p.effects1Depth,o),m(`%cGS Drum reverb for %c${t}%c: %c${o}`,r.info,r.recognized,r.info,r.value);break}break;case uA.RPCoarse:case uA.RPFine:switch(e.RPValue){default:U(`%cUnrecognized RPN for %c${t}%c: %c(0x${e.RPValue.toString(16)})%c data value: %c${A}`,r.warn,r.recognized,r.warn,r.unrecognized,r.warn,r.value);break;case 0:e.midiControllers[EA+P.pitchWheelRange]=A<<7,m(`%cChannel ${t} bend range. Semitones: %c${A}`,r.info,r.value);break;case 2:this.setChannelTuningSemitones(t,A-64);break;case 1:this.setChannelTuning(t,A-64,!1);break;case 5:this.setModulationDepth(t,A*100);break;case 16383:this.resetParameters(t);break}}}function bn(t,A){let e=this.workletProcessorChannels[t];switch(e.dataEntryState){default:break;case uA.RPCoarse:case uA.RPFine:switch(e.RPValue){default:break;case 0:if(A===0)break;e.midiControllers[EA+P.pitchWheelRange]|=A;let s=(e.midiControllers[EA+P.pitchWheelRange]>>7)+A/127;m(`%cChannel ${t} bend range. Semitones: %c${s}`,r.info,r.value);break;case 1:let o=e.customControllers[IA.channelTuning]<<7|A;this.setChannelTuning(t,o*.01220703125);break;case 5:let C=e.customControllers[IA.modulationMultiplier]*50+A/128*100;this.setModulationDepth(t,C);break;case 16383:this.resetParameters(t);break}}}function Ln(t=!0){t&&m("%cResetting all controllers!",r.info),this.callEvent("allcontrollerreset",void 0);for(let A=0;A {this.workletProcessorChannels[A].lockedControllers[n]&&this.callEvent("controllerchange",{channel:A,controllerNumber:n,controllerValue:this.workletProcessorChannels[A].midiControllers[n]>>7})};if(s(p.mainVolume),s(p.pan),s(p.expressionController),s(p.modulationWheel),s(p.effects3Depth),s(p.effects1Depth),s(p.brightness),this.workletProcessorChannels[A].lockedControllers[EA+P.pitchWheel]){let n=this.workletProcessorChannels[A].midiControllers[EA+P.pitchWheel],o=n>>7,i=n&127;this.callEvent("pitchwheel",{channel:A,MSB:o,LSB:i})}}this.tunings=[],this.tunings=[];for(let A=0;A<127;A++)this.tunings.push([]);this.setMIDIVolume(1),this.system=Ve}function Un(t){let A=this.workletProcessorChannels[t],s=A.lockedControllers.reduce((o,i,C)=>(i&&o.push(C),o),[]).map(o=>({ccNum:o,ccVal:A.midiControllers[o]}));A.channelOctaveTuning.fill(0),A.keyCentTuning.fill(0),A.midiControllers.set(PA),A.channelVibrato={rate:0,depth:0,delay:0},A.holdPedal=!1,s.forEach(o=>{A.midiControllers[o.ccNum]=o.ccVal});let n=A.customControllers[IA.channelTransposeFine];A.customControllers.set(St),A.customControllers[IA.channelTransposeFine]=n,this.resetParameters(t)}function Tn(t){let A=this.workletProcessorChannels[t];A.NRPCoarse=0,A.NRPFine=0,A.RPValue=0,A.dataEntryState=uA.Idle}function Hn(){let t=4;for(let s of this.instruments)t+=s.instrumentZones.reduce((n,o)=>(o.generators=o.generators.filter(i=>i.generatorType!==g.sampleID&&i.generatorType!==g.keyRange&&i.generatorType!==g.velRange),(o.velRange.max!==127||o.velRange.min!==0)&&o.generators.unshift({generatorType:g.velRange,generatorValue:o.velRange.max<<8|o.velRange.min}),(o.keyRange.max!==127||o.keyRange.min!==0)&&o.generators.unshift({generatorType:g.keyRange,generatorValue:o.keyRange.max<<8|o.keyRange.min}),o.isGlobal||o.generators.push({generatorType:g.sampleID,generatorValue:this.samples.indexOf(o.sample)}),o.generators.length*4+n),0);let A=new H(t),e=0;for(let s of this.instruments)for(let n of s.instrumentZones){n.generatorZoneStartIndex=e;for(let o of n.generators)Y(A,o.generatorType),Y(A,o.generatorValue),e++}return cA(A,0),sA(new AA("igen",A.length,A))}function Yn(t,A,e,s,n){let o=this.samples.map((B,d)=>{e&&B.compressSample(s,n);let h=B.getRawData();return m(`%cEncoded sample %c${d}. ${B.sampleName}%c of %c${this.samples.length}`,r.info,r.recognized,r.info,r.recognized),h}),i=this.samples.reduce((B,d,h)=>B+o[h].length+46,0),C=new H(i);this.samples.forEach((B,d)=>{let h=o[d],u,l,D=h.length;B.isCompressed?(u=C.currentIndex,l=u+h.length):(u=C.currentIndex/2,l=u+h.length/2,D+=46),t.push(u),C.set(h,C.currentIndex),C.currentIndex+=D,A.push(l)});let c=sA(new AA("smpl",C.length,C),new H([115,100,116,97]));return sA(new AA("LIST",c.length,c))}function Jn(t,A){let s=new H(46*(this.samples.length+1));return this.samples.forEach((n,o)=>{FA(s,n.sampleName,20);let i=t[o];cA(s,i);let C=A[o];cA(s,C);let c=n.sampleLoopStartIndex+i,B=n.sampleLoopEndIndex+i;n.isCompressed&&(c-=i,B-=i),cA(s,c),cA(s,B),cA(s,n.sampleRate),s[s.currentIndex++]=n.samplePitch,s[s.currentIndex++]=n.samplePitchCorrection,Y(s,n.sampleLink),Y(s,n.sampleType)}),FA(s,"EOS",46),sA(new AA("shdr",s.length,s))}function vn(){let t=10;for(let s of this.instruments)t+=s.instrumentZones.reduce((n,o)=>o.modulators.length*10+n,0);let A=new H(t),e=0;for(let s of this.instruments)for(let n of s.instrumentZones){n.modulatorZoneStartIndex=e;for(let o of n.modulators)Y(A,o.sourceEnum),Y(A,o.modulatorDestination),Y(A,o.transformAmount),Y(A,o.secondarySourceEnum),Y(A,o.transformType),e++}return ge(A,0,10),sA(new AA("imod",A.length,A))}function qn(){let t=this.instruments.reduce((o,i)=>i.instrumentZones.length*4+o,4),A=new H(t),e=0,s=0,n=0;for(let o of this.instruments){o.instrumentZoneIndex=e;for(let i of o.instrumentZones)i.zoneID=e,Y(A,s),Y(A,n),s+=i.generators.length,n+=i.modulators.length,e++}return Y(A,s),Y(A,n),sA(new AA("ibag",A.length,A))}function Pn(){let t=this.instruments.length*22+22,A=new H(t),e=0,s=0;for(let n of this.instruments)FA(A,n.instrumentName,20),Y(A,e),e+=n.instrumentZones.length,n.instrumentID=s,s++;return FA(A,"EOI",20),Y(A,e),sA(new AA("inst",A.length,A))}function Kn(){let t=4;for(let s of this.presets)t+=s.presetZones.reduce((n,o)=>(o.generators=o.generators.filter(i=>i.generatorType!==g.instrument&&i.generatorType!==g.keyRange&&i.generatorType!==g.velRange),(o.velRange.max!==127||o.velRange.min!==0)&&o.generators.unshift({generatorType:g.velRange,generatorValue:o.velRange.max<<8|o.velRange.min}),(o.keyRange.max!==127||o.keyRange.min!==0)&&o.generators.unshift({generatorType:g.keyRange,generatorValue:o.keyRange.max<<8|o.keyRange.min}),o.isGlobal||o.generators.push({generatorType:g.instrument,generatorValue:this.instruments.indexOf(o.instrument)}),o.generators.length*4+n),0);let A=new H(t),e=0;for(let s of this.presets)for(let n of s.presetZones){n.generatorZoneStartIndex=e;for(let o of n.generators)Y(A,o.generatorType),Y(A,o.generatorValue);e+=n.generators.length}return Y(A,0),Y(A,0),sA(new AA("pgen",A.length,A))}function Vn(){let t=10;for(let s of this.presets)t+=s.presetZones.reduce((n,o)=>o.modulators.length*10+n,0);let A=new H(t),e=0;for(let s of this.presets)for(let n of s.presetZones){n.modulatorZoneStartIndex=e;for(let o of n.modulators)Y(A,o.sourceEnum),Y(A,o.modulatorDestination),Y(A,o.transformAmount),Y(A,o.secondarySourceEnum),Y(A,o.transformType),e++}return ge(A,0,10),sA(new AA("pmod",A.length,A))}function On(){let t=this.presets.reduce((o,i)=>i.presetZones.length*4+o,4),A=new H(t),e=0,s=0,n=0;for(let o of this.presets){o.presetZoneStartIndex=e;for(let i of o.presetZones)i.zoneID=e,Y(A,s),Y(A,n),s+=i.generators.length,n+=i.modulators.length,e++}return Y(A,s),Y(A,n),sA(new AA("pbag",A.length,A))}function Zn(){let t=this.presets.length*38+38,A=new H(t),e=0;for(let s of this.presets)FA(A,s.presetName,20),Y(A,s.program),Y(A,s.bank),Y(A,e),cA(A,s.library),cA(A,s.genre),cA(A,s.morphology),e+=s.presetZones.length;return FA(A,"EOP",20),Y(A,0),Y(A,0),Y(A,e),cA(A,0),cA(A,0),cA(A,0),sA(new AA("phdr",A.length,A))}var Yo={compress:!1,compressionQuality:.5,compressionFunction:void 0};function Xn(t=Yo){if(t.compress&&typeof t.compressionFunction!="function")throw new TypeError("No compression function supplied but compression enabled.");yA("%cSaving soundfont...",r.info),m(`%cCompression: %c${t?.compress||"false"}%c quality: %c${t?.compressionQuality||"none"}`,r.info,r.recognized,r.info,r.recognized),m("%cWriting INFO...",r.info);let A=[];this.soundFontInfo.ISFT="SpessaSynth",t?.compress&&(this.soundFontInfo.ifil="3.0");for(let[K,W]of Object.entries(this.soundFontInfo))if(K==="ifil"||K==="iver"){let I=parseInt(W.split(".")[0]),nA=parseInt(W.split(".")[1]),j=new H(4);Y(j,I),Y(j,nA),A.push(sA(new AA(K,4,j)))}else if(K==="DMOD")A.push(sA(new AA(K,W.length,W)));else{let I=new H(W.length);FA(I,W),A.push(sA(new AA(K,W.length,I)))}let e=ke([new H([73,78,70,79]),...A]),s=sA(new AA("LIST",e.length,e));m("%cWriting SDTA...",r.info);let n=[],o=[],i=Yn.call(this,n,o,t?.compress,t?.compressionQuality||.5,t.compressionFunction);m("%cWriting PDTA...",r.info),m("%cWriting SHDR...",r.info);let C=Jn.call(this,n,o);m("%cWriting IGEN...",r.info);let c=Hn.call(this);m("%cWriting IMOD...",r.info);let B=vn.call(this);m("%cWriting IBAG...",r.info);let d=qn.call(this);m("%cWriting INST...",r.info);let h=Pn.call(this),u=Kn.call(this);m("%cWriting PMOD...",r.info);let l=Vn.call(this);m("%cWriting PBAG...",r.info);let D=On.call(this);m("%cWriting PHDR...",r.info);let S=Zn.call(this),w=ke([new H([112,100,116,97]),S,D,l,u,h,d,B,c,C]),y=sA(new AA("LIST",w.length,w));m("%cWriting the output file...",r.info);let N=ke([new H([115,102,98,107]),s,i,y]),G=sA(new AA("RIFF",N.length,N));return m(`%cSaved succesfully! Final file size: %c${G.length}`,r.info,r.recognized),X(),G}var ne=class t{constructor(A=void 0){this.soundFontInfo={},this.presets=[],this.samples=[],this.instruments=[],this.defaultModulators=Pe.map(e=>$.copy(e)),A?.presets&&(this.presets.push(...A.presets),this.soundFontInfo=A.info)}removeUnusedElements(){this.instruments.forEach(A=>{A.useCount<1&&A.instrumentZones.forEach(e=>{e.isGlobal||e.sample.useCount--})}),this.instruments=this.instruments.filter(A=>A.useCount>0),this.samples=this.samples.filter(A=>A.useCount>0)}deleteInstrument(A){if(A.useCount>0)throw new Error(`Cannot delete an instrument that has ${A.useCount} usages.`);this.instruments.splice(this.instruments.indexOf(A),1),A.deleteInstrument(),this.removeUnusedElements()}deleteSample(A){if(A.useCount>0)throw new Error(`Cannot delete sample that has ${A.useCount} usages.`);this.samples.splice(this.samples.indexOf(A),1),this.removeUnusedElements()}deletePreset(A){A.deletePreset(),this.presets.splice(this.presets.indexOf(A),1),this.removeUnusedElements()}getPresetNoFallback(A,e,s=!1){let n=this.presets.find(o=>o.bank===A&&o.program===e);if(n)return n;if(s!==!1)return A===128?this.presets.find(o=>o.bank===128):this.presets.find(o=>o.program===e)}setSampleIDOffset(A){this.presets.forEach(e=>e.sampleIDOffset=A)}getPreset(A,e){let s=this.presets.find(n=>n.bank===A&&n.program===e);return s||(A===128?(s=this.presets.find(n=>n.bank===128&&n.program===e),s||(s=this.presets.find(n=>n.bank===128))):s=this.presets.find(n=>n.program===e&&n.bank!==128),s&&U(`%cPreset ${A}.${e} not found. Replaced with %c${s.presetName} (${s.bank}.${s.program})`,r.warn,r.recognized)),s||(U(`Preset ${e} not found. Defaulting to`,this.presets[0].presetName),s=this.presets[0]),s}getPresetByName(A){let e=this.presets.find(s=>s.presetName===A);return e||(U("Preset not found. Defaulting to:",this.presets[0].presetName),e=this.presets[0]),e}static mergeSoundfonts(...A){let e=A.shift(),s=e.presets;for(;A.length;)A.shift().presets.forEach(o=>{s.find(i=>i.bank===o.bank&&i.program===o.program)===void 0&&s.push(o)});return new t({presets:s,info:e.soundFontInfo})}};ne.prototype.write=Xn;function Wn(t){yA("%cLoading instruments...",r.info);for(let A=0;A A.deleteZone()),this.presetZones.length=0}deleteZone(A){this.presetZones[A].deleteZone(),this.presetZones.splice(A,1)}preload(A,e){for(let s=A;s {o.sample.isSampleLoaded||o.sample.getAudioData()})}preloadSpecific(A,e){this.getSamplesAndGenerators(A,e).forEach(s=>{s.sample.isSampleLoaded||s.sample.getAudioData()})}getSamplesAndGenerators(A,e){let s=this.foundSamplesAndGenerators[A][e];if(s)return s;if(this.presetZones.length<1)return[];function n(h,u,l){return l>=h&&l<=u}function o(h,u){h.push(...u.filter(l=>!h.find(D=>D.generatorType===l.generatorType)))}function i(h,u){h.push(...u.filter(l=>!h.find(D=>$.isIdentical(l,D))))}let C=[],c=this.presetZones[0].isGlobal?[...this.presetZones[0].generators]:[],B=this.presetZones[0].isGlobal?[...this.presetZones[0].modulators]:[];return this.presetZones.filter(h=>n(h.keyRange.min,h.keyRange.max,A)&&n(h.velRange.min,h.velRange.max,e)&&!h.isGlobal).forEach(h=>{if(h.instrument.instrumentZones.length<1)return;let u=h.generators,l=h.modulators,D=h.instrument.instrumentZones[0].isGlobal?[...h.instrument.instrumentZones[0].generators]:[],S=h.instrument.instrumentZones[0].isGlobal?[...h.instrument.instrumentZones[0].modulators]:[];h.instrument.instrumentZones.filter(y=>n(y.keyRange.min,y.keyRange.max,A)&&n(y.velRange.min,y.velRange.max,e)&&!y.isGlobal).forEach(y=>{let N=[...y.generators],G=[...y.modulators];o(u,c),o(N,D),i(l,B),i(G,S),i(G,this.defaultModulators);let K=[...G];for(let W=0;W $.isIdentical(I,j));nA!==-1?K[nA]=K[nA].sumTransform(I):K.push(I)}C.push({instrumentGenerators:N,presetGenerators:u,modulators:K,sample:y.sample,sampleID:y.generators.find(W=>W.generatorType===g.sampleID).generatorValue})})}),this.foundSamplesAndGenerators[A][e]=C,C}};var Re=class{velRange={min:0,max:127};keyRange={min:0,max:127};isGlobal=!1;generators=[];modulators=[]};var $A=class extends Re{sample=void 0;useCount=0;deleteZone(){this.useCount--,!this.isGlobal&&this.sample.useCount--}},le=class extends Re{instrument=void 0;deleteZone(){this.isGlobal||this.instrument.removeUseCount()}};var ue=class{constructor(){this.instrumentName="",this.instrumentZones=[],this._useCount=0}addUseCount(){this._useCount++,this.instrumentZones.forEach(A=>A.useCount++)}removeUseCount(){this._useCount--;for(let A=0;A A.deleteZone()),this.instrumentZones.length=0}safeDeleteZone(A){return this.instrumentZones[A].useCount--,this.instrumentZones[A].useCount<1?(this.deleteZone(A),!0):!1}deleteZone(A){this.instrumentZones[A].deleteZone(),this.instrumentZones.splice(A,1)}};var $e=class extends ce{constructor(A,e){super(Pe),this.program=e&127,this.bank=A>>8&127,A>>31&&(this.bank=128),this.DLSInstrument=new ue,this.DLSInstrument.addUseCount();let n=new le;n.instrument=this.DLSInstrument,this.presetZones=[n]}};function _n(t){this.verifyHeader(t,"LIST"),this.verifyText(V(t.chunkData,4),"ins ");let A=[];for(;t.chunkData.length>t.chunkData.currentIndex;)A.push(O(t.chunkData));let e=A.find(l=>l.header==="insh");if(!e)throw X(),new Error("No instrument header!");let s=k(e.chunkData,4),n=k(e.chunkData,4),o=k(e.chunkData,4),i=new $e(n,o),C="unnamedPreset",c=DA(A,"INFO");if(c){let l=O(c.chunkData);for(;l.header!=="INAM";)l=O(c.chunkData);C=V(l.chunkData,l.chunkData.length).trim()}i.presetName=C,i.DLSInstrument.instrumentName=C,te(`%cParsing %c"${C}"%c...`,r.info,r.recognized,r.info);let B=DA(A,"lrgn");if(!B)throw X(),new Error("No region list!");let d=new $A;d.isGlobal=!0;let h=DA(A,"lart"),u=DA(A,"lar2");this.readLart(h,u,d),i.DLSInstrument.instrumentZones.push(d);for(let l=0;l >10&15;y===QA.linear&&w!==QA.linear&&(y=w);let N=s>>14&1,G=s>>15&1;i===g.initialAttenuation&&(G=!G),h=TA(y,N,G,C.isCC,C.enum)}let u=s>>4&15,l=s>>8&1,D=s>>9&1,S=TA(u,l,D,d.isCC,d.enum);if(c){let w=S;S=h,h=w}return new $({srcEnum:h,secSrcEnum:S,dest:i,transform:0,amt:n})}function Lt(t,A){let e=t.chunkData,s=[],n=[];k(e,4);let o=k(e,4);for(let i=0;i>16;if(C===0&&c===0&&d===0){let l;switch(B){case x.pan:l=new b(g.pan,u);break;case x.gain:l=new b(g.initialAttenuation,-u*10/.4);break;case x.filterCutoff:l=new b(g.initialFilterFc,u);break;case x.filterQ:l=new b(g.initialFilterQ,u);break;case x.modLfoFreq:l=new b(g.freqModLFO,u);break;case x.modLfoDelay:l=new b(g.delayModLFO,u);break;case x.vibLfoFreq:l=new b(g.freqVibLFO,u);break;case x.vibLfoDelay:l=new b(g.delayVibLFO,u);break;case x.volEnvDelay:l=new b(g.delayVolEnv,u);break;case x.volEnvAttack:l=new b(g.attackVolEnv,u);break;case x.volEnvHold:l=new b(g.holdVolEnv,u);break;case x.volEnvDecay:l=new b(g.decayVolEnv,u);break;case x.volEnvRelease:l=new b(g.releaseVolEnv,u);break;case x.volEnvSustain:let D=(1e3-u)/10;l=new b(g.sustainVolEnv,D*10);break;case x.modEnvDelay:l=new b(g.delayModEnv,u);break;case x.modEnvAttack:l=new b(g.attackModEnv,u);break;case x.modEnvHold:l=new b(g.holdModEnv,u);break;case x.modEnvDecay:l=new b(g.decayModEnv,u);break;case x.modEnvRelease:l=new b(g.releaseModEnv,u);break;case x.modEnvSustain:let S=1e3-u;l=new b(g.sustainModEnv,S);break;case x.reverbSend:l=new b(g.reverbEffectsSend,u);break;case x.chorusSend:l=new b(g.chorusEffectsSend,u);break;case x.pitch:let w=Math.floor(u/100),y=Math.floor(u-w*100);l=new b(g.fineTune,y),s.push(new b(g.coarseTune,w));break}l&&s.push(l)}else{let l=!0;if(c===z.none)if(C===z.modLfo&&B===x.pitch)s.push(new b(g.modLfoToPitch,u));else if(C===z.modLfo&&B===x.gain)s.push(new b(g.modLfoToVolume,u));else if(C===z.modLfo&&B===x.filterCutoff)s.push(new b(g.modLfoToFilterFc,u));else if(C===z.vibratoLfo&&B===x.pitch)s.push(new b(g.vibLfoToPitch,u));else if(C===z.modEnv&&B===x.pitch)s.push(new b(g.modEnvToPitch,u));else if(C===z.modEnv&&B===x.filterCutoff)s.push(new b(g.modEnvToFilterFc,u));else if(C===z.keyNum&&B===x.volEnvHold){s.push(new b(g.keyNumToVolEnvHold,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.holdVolEnv&&(S.generatorValue+=D)})}else if(C===z.keyNum&&B===x.volEnvDecay){s.push(new b(g.keyNumToVolEnvDecay,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.decayVolEnv&&(S.generatorValue+=D)})}else if(C===z.keyNum&&B===x.modEnvHold){s.push(new b(g.keyNumToModEnvHold,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.holdModEnv&&(S.generatorValue+=D)})}else if(C===z.keyNum&&B===x.modEnvDecay){s.push(new b(g.keyNumToModEnvDecay,u/-128));let D=Math.round(60/128*u);s.forEach(S=>{S.generatorType===g.decayModEnv&&(S.generatorValue+=D)})}else l=!1;else l=!1;if(l===!1){let D=jn(C,c,B,d,u);D?(n.push(D),m("%cSucceeded converting to SF2 Modulator!",r.recognized)):U("Failed converting to SF2 Modulator!")}}}return n.find(i=>i.modulatorDestination===g.reverbEffectsSend)===void 0&&n.push(new $({srcEnum:219,dest:g.reverbEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),n.find(i=>i.modulatorDestination===g.chorusEffectsSend)===void 0&&n.push(new $({srcEnum:221,dest:g.chorusEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),A&&n.push(new $({srcEnum:129,dest:g.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0}),new $({srcEnum:13,dest:g.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0})),{modulators:n,generators:s}}function $n(t,A,e){if(t)for(;t.chunkData.currentIndex t.chunkData.currentIndex;)A.push(O(t.chunkData));let e=A.find(j=>j.header==="rgnh"),s=k(e.chunkData,2),n=k(e.chunkData,2),o=k(e.chunkData,2),i=k(e.chunkData,2),C=new At({min:s,max:n},{min:o,max:i});k(e.chunkData,2);let c=k(e.chunkData,2);c!==0&&C.generators.push(new b(g.exclusiveClass,c));let B=DA(A,"lart"),d=DA(A,"lar2");this.readLart(B,d,C),C.isGlobal=!1;let h=A.find(j=>j.header==="wsmp");k(h.chunkData,4);let u=k(h.chunkData,2),l=jA(h.chunkData[h.chunkData.currentIndex++],h.chunkData[h.chunkData.currentIndex++]),S=(k(h.chunkData,4)|0)/-655360;k(h.chunkData,4);let w=k(h.chunkData,4),y,N={start:0,end:0};if(w===0)y=0;else{k(h.chunkData,4),k(h.chunkData,4)===0?y=1:y=3,N.start=k(h.chunkData,4);let J=k(h.chunkData,4);N.end=N.start+J}let G=A.find(j=>j.header==="wlnk");if(G===void 0)return;k(G.chunkData,2),k(G.chunkData,2),k(G.chunkData,4);let K=k(G.chunkData,4),W=this.samples[K];if(W===void 0)throw new Error("Invalid sample ID!");let nA=(S||W.sampleDbAttenuation)*10/.4;return C.setWavesample(nA,y,N,u,W,K,l),C}var de=class{constructor(A,e,s,n,o,i,C,c){this.sampleName=A,this.sampleRate=e,this.samplePitch=s,this.samplePitchCorrection=n,this.sampleLink=o,this.sampleType=i,this.sampleLoopStartIndex=C,this.sampleLoopEndIndex=c,this.isCompressed=(i&16)>0,this.compressedData=void 0,this.useCount=0}getRawData(){let A=new Error("Not implemented");throw A.name="NotImplementedError",A}compressSample(A,e){if(!this.isCompressed)try{this.compressedData=e([this.getAudioData()],1,this.sampleRate,A),this.sampleType|=16,this.isCompressed=!0}catch{U(`Failed to compress ${this.sampleName}. Leaving as uncompressed!`),this.isCompressed=!1,this.compressedData=void 0,this.sampleType&=-17}}getAudioData(){let A=new Error("Not implemented");throw A.name="NotImplementedError",A}};var et=class extends de{constructor(A,e,s,n,o,i,C,c){super(A,e,s,n,0,1,o,i-1),this.sampleData=C,this.sampleDbAttenuation=c}getAudioData(){return this.sampleData}sampleDbAttenuation;sampleData;getRawData(){if(this.isCompressed){if(!this.compressedData)throw new Error("Compressed but no data??");return this.compressedData}let A=new Uint8Array(this.sampleData.length*2);for(let e=0;e >8&255}return A}};function eo(t){yA("%cLoading Wave samples...",r.recognized);let A=0;for(;t.chunkData.currentIndex J.header==="fmt ");if(!n)throw new Error("No fmt chunk in the wave file!");if(k(n.chunkData,2)!==1)throw new Error("Only PCM format in WAVE is supported.");if(k(n.chunkData,2)!==1)throw new Error("Only mono samples are supported.");let C=k(n.chunkData,4);k(n.chunkData,4),k(n.chunkData,2);let c=k(n.chunkData,2),B=c/8,d=Math.pow(2,B*8-1),h=Math.pow(2,B*8),u,l=!1;c===8?(u=255,l=!0):u=d;let D=s.find(J=>J.header==="data");if(!D)throw new Error("No data chunk in the wave chunk!");let S=D.size/B,w=new Float32Array(S);for(let J=0;J =d&&(Z-=h),w[J]=Z/u)}let y=60,N=0,G=0,K=w.length-1,W=0,I=s.find(J=>J.header==="wsmp");if(I){if(k(I.chunkData,4),y=k(I.chunkData,2),N=jA(I.chunkData[I.chunkData.currentIndex++],I.chunkData[I.chunkData.currentIndex++]),W=(k(I.chunkData,4)|0)/-655360,k(I.chunkData,4),k(I.chunkData,4)===1){k(I.chunkData,8),G=k(I.chunkData,4);let CA=k(I.chunkData,4);K=G+CA}}else U("No wsmp chunk in wave... using sane defaults.");let nA=DA(s,"INFO"),j=`Unnamed ${A}`;if(nA){let J=O(nA.chunkData);for(;J.header!=="INAM"&&nA.chunkData.currentIndex c.header==="colh");if(!o)throw X(),new Error("No colh chunk!");this.instrumentAmount=k(o.chunkData,4),m(`%cInstruments amount: %c${this.instrumentAmount}`,r.info,r.recognized);let i=SA(s,"wvpl");this.readDLSSamples(i);let C=SA(s,"lins");if(!C)throw X(),new Error("No lins chunk!");this.readDLSInstrumentList(C),this.presets.sort((c,B)=>c.program-B.program+(c.bank-B.bank)),m(`%cParsing finished! %c"${this.soundFontInfo.INAM||"UNNAMED"}"%c has %c${this.presets.length} %cpresets, - %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info),X()}verifyHeader(A,e){if(A.header.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid DLS chunk header! Expected "${e.toLowerCase()}" got "${A.header.toLowerCase()}"`)}verifyText(A,e){if(A.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid DLS soundfont! Expected "${e.toLowerCase()}" got "${A.toLowerCase()}"`)}};WA.prototype.readDLSInstrumentList=Xn;WA.prototype.readDLSInstrument=Wn;WA.prototype.readRegion=$n;WA.prototype.readLart=jn;WA.prototype.readDLSSamples=Ao;var Ht=class extends de{constructor(A,e,s,n,o,i,C,c,B,d,h,u,l){super(A,i,C,c,B,d,n-e/2,o-e/2),this.sampleName=A,this.sampleStartIndex=e,this.sampleEndIndex=s,this.isSampleLoaded=!1,this.sampleID=u,this.sampleLength=this.sampleEndIndex-this.sampleStartIndex,this.sampleDataArray=h,this.sampleData=new Float32Array(0),this.isCompressed&&(this.sampleLoopStartIndex+=this.sampleStartIndex/2,this.sampleLoopEndIndex+=this.sampleStartIndex/2,this.sampleLength=99999999),this.isDataRaw=l}getRawData(){let A=this.sampleDataArray;if(this.isCompressed){if(this.compressedData)return this.compressedData;let e=A.currentIndex;return A.slice(this.sampleStartIndex/2+e,this.sampleEndIndex/2+e)}else{if(!this.isDataRaw)throw new Error("Writing SF2Pack samples is not supported.");let e=A.currentIndex;return A.slice(e+this.sampleStartIndex,e+this.sampleEndIndex)}}decodeVorbis(){if(this.sampleLength<1)return;let A=this.sampleDataArray,e=A.currentIndex,s=A.slice(this.sampleStartIndex/2+e,this.sampleEndIndex/2+e);this.sampleData=new Float32Array(0);let n=OA.decode(s.buffer);this.sampleData=n.data[0]}getAudioData(){return this.isSampleLoaded?this.sampleData:this.sampleLength<1?new Float32Array(1):this.isCompressed?(this.decodeVorbis(),this.isSampleLoaded=!0,this.sampleData):this.isDataRaw?this.loadUncompressedData():this.getUncompressedReadyData()}loadUncompressedData(){if(this.isCompressed)return L("Trying to load a compressed sample via loadUncompressedData()... aborting!"),new Float32Array(0);let A=new Float32Array(this.sampleLength/2),e=this.sampleDataArray.currentIndex,s=new Int16Array(this.sampleDataArray.slice(e+this.sampleStartIndex,e+this.sampleEndIndex).buffer);for(let n=0;n t.chunkData.currentIndex;){let o=qo(n,t.chunkData,A,e);s.push(o),n++}return s.length>1&&s.pop(),s}function qo(t,A,e,s){let n=V(A,20),o=k(A,4)*2,i=k(A,4)*2,C=k(A,4),c=k(A,4),B=k(A,4),d=A[A.currentIndex++];d===255&&(d=60);let h=us(A[A.currentIndex++]),u=k(A,2),l=k(A,2);return new Ht(n,o,i,C,c,B,d,h,u,l,e,t,s)}var Yt=class extends ue{constructor(A){super(),this.instrumentName=V(A.chunkData,20).trim(),this.instrumentZoneIndex=k(A.chunkData,2),this.instrumentZonesAmount=0}getInstrumentZones(A,e){this.instrumentZonesAmount=A;for(let s=this.instrumentZoneIndex;s t.chunkData.currentIndex;){let s=new Yt(t);if(e.length>0){let n=s.instrumentZoneIndex-e[e.length-1].instrumentZoneIndex;e[e.length-1].getInstrumentZones(n,A)}e.push(s)}return e.length>1&&e.pop(),e}var Jt=class extends $A{constructor(A){super(),this.generatorZoneStartIndex=k(A,2),this.modulatorZoneStartIndex=k(A,2),this.modulatorZoneSize=0,this.generatorZoneSize=0,this.isGlobal=!0}setZoneSize(A,e){this.modulatorZoneSize=A,this.generatorZoneSize=e}getGenerators(A){for(let e=this.generatorZoneStartIndex;e s.generatorType===g.sampleID);e&&(this.sample=A[e.generatorValue],this.isGlobal=!1,this.sample.useCount++)}getKeyRange(){let A=this.generators.find(e=>e.generatorType===g.keyRange);A&&(this.keyRange.min=A.generatorValue&127,this.keyRange.max=A.generatorValue>>8&127)}getVelRange(){let A=this.generators.find(e=>e.generatorType===g.velRange);A&&(this.velRange.min=A.generatorValue&127,this.velRange.max=A.generatorValue>>8&127)}};function so(t,A,e,s){let n=[];for(;t.chunkData.length>t.chunkData.currentIndex;){let o=new Jt(t.chunkData);if(n.length>0){let i=o.modulatorZoneStartIndex-n[n.length-1].modulatorZoneStartIndex,C=o.generatorZoneStartIndex-n[n.length-1].generatorZoneStartIndex;n[n.length-1].setZoneSize(i,C),n[n.length-1].getGenerators(A),n[n.length-1].getModulators(e),n[n.length-1].getSample(s),n[n.length-1].getKeyRange(),n[n.length-1].getVelRange()}n.push(o)}return n.length>1&&n.pop(),n}var vt=class extends le{constructor(A){super(),this.generatorZoneStartIndex=k(A,2),this.modulatorZoneStartIndex=k(A,2),this.modulatorZoneSize=0,this.generatorZoneSize=0,this.isGlobal=!0}setZoneSize(A,e){this.modulatorZoneSize=A,this.generatorZoneSize=e}getGenerators(A){for(let e=this.generatorZoneStartIndex;e s.generatorType===g.instrument);e&&(this.instrument=A[e.generatorValue],this.instrument.addUseCount(),this.isGlobal=!1)}getKeyRange(){let A=this.generators.find(e=>e.generatorType===g.keyRange);A&&(this.keyRange.min=A.generatorValue&127,this.keyRange.max=A.generatorValue>>8&127)}getVelRange(){let A=this.generators.find(e=>e.generatorType===g.velRange);A&&(this.velRange.min=A.generatorValue&127,this.velRange.max=A.generatorValue>>8&127)}};function no(t,A,e,s){let n=[];for(;t.chunkData.length>t.chunkData.currentIndex;){let o=new vt(t.chunkData);if(n.length>0){let i=o.modulatorZoneStartIndex-n[n.length-1].modulatorZoneStartIndex,C=o.generatorZoneStartIndex-n[n.length-1].generatorZoneStartIndex;n[n.length-1].setZoneSize(i,C),n[n.length-1].getGenerators(A),n[n.length-1].getModulators(e),n[n.length-1].getInstrument(s),n[n.length-1].getKeyRange(),n[n.length-1].getVelRange()}n.push(o)}return n.length>1&&n.pop(),n}var qt=class extends ce{constructor(A,e){super(e),this.presetName=V(A.chunkData,20).trim().replace(/\d{3}:\d{3}/,""),this.program=k(A.chunkData,2),this.bank=k(A.chunkData,2),this.presetZoneStartIndex=k(A.chunkData,2),this.library=k(A.chunkData,4),this.genre=k(A.chunkData,4),this.morphology=k(A.chunkData,4),this.presetZonesAmount=0}getPresetZones(A,e){this.presetZonesAmount=A;for(let s=this.presetZoneStartIndex;s t.chunkData.currentIndex;){let n=new qt(t,e);if(s.length>0){let o=n.presetZoneStartIndex-s[s.length-1].presetZoneStartIndex;s[s.length-1].getPresetZones(o,A)}s.push(n)}return s.length>1&&s.pop(),s}var st=class extends ne{constructor(A,e=!0){if(super(),e&&console.warn("Using the constructor directly is deprecated. Use loadSoundFont instead."),this.dataArray=new H(A),te("%cParsing SoundFont...",r.info),!this.dataArray)throw X(),new TypeError("No data!");let s=O(this.dataArray,!1);this.verifyHeader(s,"riff");let n=V(this.dataArray,4).toLowerCase();if(n!=="sfbk"&&n!=="sfpk")throw X(),new SyntaxError(`Invalid soundFont! Expected "sfbk" or "sfpk" got "${n}"`);let o=n==="sfpk",i=O(this.dataArray);for(this.verifyHeader(i,"list"),V(i.chunkData,4);i.chunkData.length>i.chunkData.currentIndex;){let Z=O(i.chunkData),CA;switch(Z.header.toLowerCase()){case"ifil":case"iver":CA=`${k(Z.chunkData,2)}.${k(Z.chunkData,2)}`,this.soundFontInfo[Z.header]=CA;break;case"icmt":CA=V(Z.chunkData,Z.chunkData.length,void 0,!1),this.soundFontInfo[Z.header]=CA;break;case"dmod":let oA=Ke(Z);oA.pop(),CA=`Modulators: ${oA.length}`;let fA=this.defaultModulators;this.defaultModulators=oA,this.defaultModulators.push(...fA.filter(Me=>!this.defaultModulators.find(RA=>$.isIdentical(Me,RA)))),this.soundFontInfo[Z.header]=Z.chunkData;break;default:CA=V(Z.chunkData,Z.chunkData.length),this.soundFontInfo[Z.header]=CA}m(`%c"${Z.header}": %c"${CA}"`,r.info,r.recognized)}let C=O(this.dataArray,!1);this.verifyHeader(C,"list"),this.verifyText(V(this.dataArray,4),"sdta"),m("%cVerifying smpl chunk...",r.warn);let c=O(this.dataArray,!1);this.verifyHeader(c,"smpl");let B;if(o){m("%cSF2Pack detected, attempting to decode the smpl chunk...",r.info);try{B=OA.decode(this.dataArray.buffer.slice(this.dataArray.currentIndex,this.dataArray.currentIndex+C.size-12)).data[0]}catch(Z){throw X(),new Error(`SF2Pack Ogg Vorbis decode error: ${Z}`)}m(`%cDecoded the smpl chunk! Length: %c${B.length}`,r.info,r.value)}else B=this.dataArray,this.sampleDataStartIndex=this.dataArray.currentIndex;m(`%cSkipping sample chunk, length: %c${C.size-12}`,r.info,r.value),this.dataArray.currentIndex+=C.size-12,m("%cLoading preset data chunk...",r.warn);let d=O(this.dataArray);this.verifyHeader(d,"list"),V(d.chunkData,4);let h=O(d.chunkData);this.verifyHeader(h,"phdr");let u=O(d.chunkData);this.verifyHeader(u,"pbag");let l=O(d.chunkData);this.verifyHeader(l,"pmod");let D=O(d.chunkData);this.verifyHeader(D,"pgen");let S=O(d.chunkData);this.verifyHeader(S,"inst");let w=O(d.chunkData);this.verifyHeader(w,"ibag");let y=O(d.chunkData);this.verifyHeader(y,"imod");let N=O(d.chunkData);this.verifyHeader(N,"igen");let G=O(d.chunkData);this.verifyHeader(G,"shdr"),this.dataArray.currentIndex=this.sampleDataStartIndex,this.samples.push(...eo(G,B,!o));let K=pt(N),W=Ke(y),I=so(w,K,W,this.samples);this.instruments=to(S,I);let nA=pt(D),j=Ke(l),J=no(u,nA,j,this.instruments);this.presets.push(...oo(h,J,this.defaultModulators)),this.presets.sort((Z,CA)=>Z.program-CA.program+(Z.bank-CA.bank)),m(`%cParsing finished! %c"${this.soundFontInfo.INAM}"%c has %c${this.presets.length} %cpresets, - %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info),X(),o&&delete this.dataArray}verifyHeader(A,e){if(A.header.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid chunk header! Expected "${e.toLowerCase()}" got "${A.header.toLowerCase()}"`)}verifyText(A,e){if(A.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid soundFont! Expected "${e.toLowerCase()}" got "${A.toLowerCase()}"`)}};function Ge(t){let A=t.slice(8,12),e=new H(A);return V(e,4,void 0,!1).toLowerCase()==="dls "?new WA(t):new st(t,!1)}function ro(t,A,e=!1){let s=this.workletProcessorChannels[t];if(s===void 0){L(`Trying to access channel ${t} which does not exist... ignoring!`);return}if(s.lockPreset)return;let n=s.drumChannel?128:s.midiControllers[p.bankSelect],o,i;if(this.overrideSoundfont){let C=n===128?128:n-this.soundfontBankOffset,c=this.overrideSoundfont.getPresetNoFallback(C,A);c?(o=n,i=c,s.presetUsesOverride=!0):(i=this.soundfontManager.getPreset(n,A),o=i.bank,s.presetUsesOverride=!1)}else i=this.soundfontManager.getPreset(n,A),o=i.bank,s.presetUsesOverride=!1;this.setPreset(t,i),this.callEvent("programchange",{channel:t,program:i.program,bank:o,userCalled:e})}function io(t,A){if(this.overrideSoundfont){let e=t===128?128:t-this.soundfontBankOffset,s=this.overrideSoundfont.getPresetNoFallback(e,A);if(s)return s}return this.soundfontManager.getPreset(t,A)}function ao(t,A){if(!this.workletProcessorChannels[t].lockPreset){delete this.workletProcessorChannels[t].preset,this.workletProcessorChannels[t].preset=A,this.workletProcessorChannels[t].cachedVoices=[];for(let e=0;e<128;e++)this.workletProcessorChannels[t].cachedVoices.push([])}}function Io(t,A){let e=this.workletProcessorChannels[t];e.lockPreset||e.drumChannel!==A&&(A?(e.channelTransposeKeyShift=0,e.drumChannel=!0,this.setPreset(t,this.getPreset(128,e.preset.program))):(e.drumChannel=!1,this.setPreset(t,this.getPreset(e.midiControllers[p.bankSelect],e.preset.program))),e.presetUsesOverride=!1,this.callEvent("drumchange",{channel:t,isDrumChannel:e.drumChannel}),this.sendChannelProperties())}function go(){let t=this.soundfontManager.getPresetList();this.overrideSoundfont!==void 0&&this.overrideSoundfont.presets.forEach(A=>{let e=A.bank===128?128:A.bank+this.soundfontBankOffset,s=t.find(n=>n.bank===e&&n.program===A.program);s!==void 0?s.presetName=A.presetName:t.push({presetName:A.presetName,bank:e,program:A.program})}),this.callEvent("presetlistchange",t)}function Co(t=!0,A=!0){this.stopAllChannels(!0),A&&(delete this.overrideSoundfont,this.overrideSoundfont=void 0),this.defaultPreset=this.getPreset(0,0),this.drumPreset=this.getPreset(128,0);for(let e=0;e {this.programChange(s,e.preset.program)}),this.post({messageType:pA.ready,messageData:void 0}),this.sendPresetList(),m("%cSpessaSynth is ready!",r.recognized)}function Bo(t,A){this.soundfontBankOffset=A,this.reloadSoundFont(t,!0),this.overrideSoundfont.samples.forEach(e=>e.getAudioData()),this._snapshot!==void 0&&(this.applySynthesizerSnapshot(this._snapshot),this.resetAllControllers())}function ho(){let A={channelSnapshots:this.workletProcessorChannels.map(e=>({program:e.preset.program,bank:e.preset.bank,lockPreset:e.lockPreset,patchName:e.preset.presetName,midiControllers:e.midiControllers,lockedControllers:e.lockedControllers,customControllers:e.customControllers,channelVibrato:e.channelVibrato,lockVibrato:e.lockGSNRPNParams,channelTransposeKeyShift:e.channelTransposeKeyShift,channelOctaveTuning:e.channelOctaveTuning,keyCentTuning:e.keyCentTuning,velocityOverride:e.velocityOverride,isMuted:e.isMuted,drumChannel:e.drumChannel})),mainVolume:this.midiVolume,pan:this.pan,transposition:this.transposition,system:this.system,interpolation:this.interpolationType};this.post({messageType:pA.synthesizerSnapshot,messageData:A})}function Qo(t){for(this.system=t.system,this.setMasterGain(t.mainVolume),this.setMasterPan(t.pan),this.transposeAllChannels(t.transposition),this.interpolationType=t.interpolation;this.workletProcessorChannels.length {let s=this.workletProcessorChannels[e];this.muteChannel(e,A.isMuted),this.setDrums(e,A.drumChannel),s.midiControllers=A.midiControllers,s.lockedControllers=A.lockedControllers,s.customControllers=A.customControllers,s.channelVibrato=A.channelVibrato,s.lockGSNRPNParams=A.lockVibrato,s.channelTransposeKeyShift=A.channelTransposeKeyShift,s.channelOctaveTuning=A.channelOctaveTuning,s.velocityOverride=A.velocityOverride,s.lockPreset=!1,s.midiControllers[p.bankSelect]=A.bank,this.programChange(e,A.program),s.lockPreset=A.lockPreset}),m("%cFinished restoring controllers!",r.info)}var nt=class{constructor(A,e){this.ready=e,this.totalSoundfontOffset=0,this.reloadManager(A)}_assingSampleOffsets(){let A=0;this.soundfontList.forEach(e=>{e.soundfont.setSampleIDOffset(A),A+=e.soundfont.samples.length}),this.totalSoundfontOffset=A}generatePresetList(){this._assingSampleOffsets();let A={};for(let e=this.soundfontList.length-1;e>=0;e--){let s=this.soundfontList[e],n=new Set;for(let o of s.soundfont.presets){let i=`${o.bank+s.bankOffset}-${o.program}`;n.has(i)||(n.add(i),A[i]=o.presetName)}}this.presetList=[];for(let[e,s]of Object.entries(A)){let n=e.split("-");this.presetList.push({presetName:s,program:parseInt(n[1]),bank:parseInt(n[0])})}}handleMessage(A,e){switch(A){case Ie.addNewSoundFont:this.addNewSoundFont(e[0],e[1],e[2]);break;case Ie.reloadSoundFont:this.reloadManager(e);break;case Ie.deleteSoundFont:this.deleteSoundFont(e);break;case Ie.rearrangeSoundFonts:this.rearrangeSoundFonts(e)}}getPresetList(){return this.presetList.slice()}reloadManager(A){let e=Ge(A);this.soundfontList=[],this.soundfontList.push({id:"main",bankOffset:0,soundfont:e}),this.generatePresetList(),this.ready()}deleteSoundFont(A){if(this.soundfontList.length===0){L("1 soundfont left. Aborting!");return}let e=this.soundfontList.findIndex(s=>s.id===A);if(e===-1){L(`No soundfont with id of "${A}" found. Aborting!`);return}delete this.soundfontList[e].soundfont.presets,delete this.soundfontList[e].soundfont.instruments,delete this.soundfontList[e].soundfont.samples,this.soundfontList.splice(e,1),this.generatePresetList()}addNewSoundFont(A,e,s){if(this.soundfontList.find(n=>n.id===e)!==void 0)throw new Error("Cannot overwrite the existing soundfont. Use soundfontManager.delete(id) instead.");this.soundfontList.push({id:e,soundfont:Ge(A),bankOffset:s}),this.generatePresetList(),this.ready()}rearrangeSoundFonts(A){this.soundfontList.sort((e,s)=>A.indexOf(e.id)-A.indexOf(s.id)),this.generatePresetList()}getPreset(A,e){if(this.soundfontList.length<1)throw new Error("No soundfonts! This should never happen.");for(let s of this.soundfontList){let n=s.soundfont.getPresetNoFallback(A-s.bankOffset,e);if(n!==void 0)return n}if(A!==128){for(let s of this.soundfontList){let n=s.soundfont.presets.find(o=>o.program===e);if(n)return n}return this.soundfontList[0].soundfont.presets[0]}else{for(let s of this.soundfontList){let n=s.soundfont.presets.find(o=>o.bank===128);if(n)return n}return this.soundfontList[0].soundfont.presets[0]}}};var ot=class{constructor(A,e,s,n,o,i,C,c){this.sampleData=A,this.playbackStep=e,this.cursor=s,this.rootKey=n,this.loopStart=o,this.loopEnd=i,this.end=C,this.loopingMode=c,this.isLooping=this.loopingMode===1||this.loopingMode===3}sampleData;playbackStep=0;cursor=0;rootKey=0;loopStart=0;loopEnd=0;end=0;loopingMode=0;isLooping=!1},xe=class t{constructor(A,e,s,n,o,i,C,c,B){this.sample=e,this.generators=c,this.modulatedGenerators=new Int16Array(c),this.modulators=B,this.velocity=n,this.midiNote=s,this.channelNumber=o,this.startTime=i,this.targetKey=C,this.volumeEnvelope=new LA(A,c[g.sustainVolEnv])}sample;filter=new Qe;generators;modulators=[];modulatedGenerators;finished=!1;isInRelease=!1;channelNumber=0;velocity=0;midiNote=0;pressure=0;targetKey=0;modulationEnvelope=new YA;volumeEnvelope;startTime=0;releaseStartTime=1/0;currentTuningCents=0;currentTuningCalculated=1;currentPan=.5;static copy(A,e){let s=A.sample,n=new ot(s.sampleData,s.playbackStep,s.cursor,s.rootKey,s.loopStart,s.loopEnd,s.end,s.loopingMode);return new t(A.volumeEnvelope.sampleRate,n,A.midiNote,A.velocity,A.channelNumber,e,A.targetKey,A.generators,A.modulators.map(o=>$.copy(o)))}};function co(t,A,e,s,n,o=!1){let i,C=s.cachedVoices[A][e];return C!==void 0?C.map(c=>xe.copy(c,n)):(i=s.preset.getSamplesAndGenerators(A,e).reduce((B,d)=>{if(d.sample.sampleData===void 0)return L(`Discarding invalid sample: ${d.sample.sampleName}`),B;let h=new Int16Array(60);for(let N=0;N<60;N++)h[N]=ds(N,d.presetGenerators,d.instrumentGenerators);h[g.initialAttenuation]=Math.floor(h[g.initialAttenuation]*.4);let u=d.sample.samplePitch;h[g.overridingRootKey]>-1&&(u=h[g.overridingRootKey]);let l=A;h[g.keyNum]>-1&&(l=h[g.keyNum]);let D=d.sample.sampleLoopStartIndex,S=d.sample.sampleLoopEndIndex,w=h[g.sampleModes],y=new ot(d.sample.getAudioData(),d.sample.sampleRate/sampleRate*Math.pow(2,d.sample.samplePitchCorrection/1200),0,u,D,S,Math.floor(d.sample.sampleData.length)-1,w);return h[g.velocity]>-1&&(e=h[g.velocity]),o&&ls([{Sample:d.sample.sampleName,Generators:h,Modulators:d.modulators.map(N=>N.debugString()),Velocity:e,TargetKey:l,MidiNote:A,WorkletSample:y}]),B.push(new xe(sampleRate,y,A,e,t,n,l,h,d.modulators.map(N=>$.copy(N)))),B},[]),s.cachedVoices[A][e]=i.map(B=>xe.copy(B,n)),i)}var Lt=.03,Ut=1,T=class extends AudioWorkletProcessor{constructor(A){super(),this.oneOutputMode=A.processorOptions?.startRenderingData?.oneOutput===!0,this._outputsAmount=this.oneOutputMode?1:A.processorOptions.midiChannels,this.enableEventSystem=A.processorOptions.enableEventSystem,this.deviceID=UA,this.interpolationType=he.fourthOrder,this.processTickCallback=void 0,this.sequencer=new aA(this),this.transposition=0,this.tunings=[];for(let e=0;e<127;e++)this.tunings.push([]);this.soundfontBankOffset=0,this.masterGain=Ut,this.midiVolume=1,this.voiceCap=ys,this.pan=0,this.panLeft=.5*this.currentGain,this.highPerformanceMode=!1,this.overrideSoundfont=void 0,this.panRight=.5*this.currentGain;try{this.soundfontManager=new nt(A.processorOptions.soundfont,this.postReady.bind(this))}catch(e){throw this.post({messageType:pA.soundfontError,messageData:e}),e}this.sendPresetList(),this.defaultPreset=this.getPreset(0,0),this.drumPreset=this.getPreset(128,0),this.workletProcessorChannels=[];for(let e=0;e this.handleMessage(e.data),A.processorOptions.startRenderingData&&(this._snapshot!==void 0&&(this.applySynthesizerSnapshot(this._snapshot),this.resetAllControllers()),m("%cRendering enabled! Starting render.",r.info),A.processorOptions.startRenderingData.parsedMIDI&&(A.processorOptions.startRenderingData?.loopCount!==void 0?(this.sequencer.loopCount=A.processorOptions.startRenderingData?.loopCount,this.sequencer.loop=!0):this.sequencer.loop=!1,this.sequencer.loadNewSongList([A.processorOptions.startRenderingData.parsedMIDI]))),OA.isInitialized.then(()=>{this.postReady(),m("%cSpessaSynth is ready!",r.recognized)})}post(A){this.enableEventSystem&&this.port.postMessage(A)}postReady(){this.enableEventSystem&&this.port.postMessage({messageType:pA.ready,messageData:void 0})}get currentGain(){return this.masterGain*this.midiVolume}debugMessage(){m({channels:this.workletProcessorChannels,voicesAmount:this.totalVoicesAmount,outputAmount:this._outputsAmount,dumpedSamples:this.workletDumpedSamplesList})}process(A,e){this.processTickCallback&&this.processTickCallback();let s=0;return this.workletProcessorChannels.forEach((n,o)=>{if(n.voices.length<1||n.isMuted)return;let i,C,c,B,d;if(this.oneOutputMode){let u=e[0];i=o%16*2,C=u[i],c=u[i+1]}else i=o%this._outputsAmount+2,C=e[i][0],c=e[i][1],B=e[0],d=e[1];let h=n.voices;n.voices=[],h.forEach(u=>{this.renderVoice(n,u,C,c,B,d),u.finished||n.voices.push(u)}),s+=n.voices.length}),s!==this.totalVoicesAmount&&(this.totalVoicesAmount=s,this.sendChannelProperties()),!0}};T.prototype.renderVoice=$s;T.prototype.releaseVoice=en;T.prototype.voiceKilling=An;T.prototype.getWorkletVoices=co;T.prototype.handleMessage=nn;T.prototype.sendChannelProperties=rn;T.prototype.callEvent=on;T.prototype.systemExclusive=an;T.prototype.noteOn=gn;T.prototype.noteOff=Cn;T.prototype.polyPressure=yn;T.prototype.killNote=En;T.prototype.stopAll=Bn;T.prototype.stopAllChannels=hn;T.prototype.muteChannel=Rn;T.prototype.setVibrato=xn;T.prototype.disableAndLockGSNRPN=Gn;T.prototype.dataEntryCoarse=Mn;T.prototype.dataEntryFine=Nn;T.prototype.createWorkletChannel=fs;T.prototype.controllerChange=Dn;T.prototype.channelPressure=pn;T.prototype.resetAllControllers=bn;T.prototype.resetControllers=Ln;T.prototype.resetParameters=Un;T.prototype.setMasterGain=wn;T.prototype.setMasterPan=Fn;T.prototype.setMIDIVolume=kn;T.prototype.transposeAllChannels=Qn;T.prototype.transposeChannel=cn;T.prototype.setChannelTuning=ln;T.prototype.setChannelTuningSemitones=un;T.prototype.setMasterTuning=dn;T.prototype.setModulationDepth=fn;T.prototype.pitchWheel=mn;T.prototype.setOctaveTuning=Sn;T.prototype.programChange=ro;T.prototype.getPreset=io;T.prototype.setPreset=ao;T.prototype.setDrums=Io;T.prototype.reloadSoundFont=Eo;T.prototype.clearSoundFont=Co;T.prototype.setEmbeddedSoundFont=Bo;T.prototype.sendPresetList=go;T.prototype.sendSynthesizerSnapshot=ho;T.prototype.applySynthesizerSnapshot=Qo;registerProcessor(ps,T);m("%cProcessor succesfully registered!",r.recognized); +`+this.soundFontInfo.ISBJ,delete this.soundFontInfo.ISBJ);for(let[c,B]of Object.entries(this.soundFontInfo))m(`%c"${c}": %c"${B}"`,r.info,r.recognized);let o=s.find(c=>c.header==="colh");if(!o)throw X(),new Error("No colh chunk!");this.instrumentAmount=k(o.chunkData,4),m(`%cInstruments amount: %c${this.instrumentAmount}`,r.info,r.recognized);let i=DA(s,"wvpl");this.readDLSSamples(i);let C=DA(s,"lins");if(!C)throw X(),new Error("No lins chunk!");this.readDLSInstrumentList(C),this.presets.sort((c,B)=>c.program-B.program+(c.bank-B.bank)),m(`%cParsing finished! %c"${this.soundFontInfo.INAM||"UNNAMED"}"%c has %c${this.presets.length} %cpresets, + %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info),X()}verifyHeader(A,e){if(A.header.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid DLS chunk header! Expected "${e.toLowerCase()}" got "${A.header.toLowerCase()}"`)}verifyText(A,e){if(A.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid DLS soundfont! Expected "${e.toLowerCase()}" got "${A.toLowerCase()}"`)}};WA.prototype.readDLSInstrumentList=Wn;WA.prototype.readDLSInstrument=_n;WA.prototype.readRegion=Ao;WA.prototype.readLart=$n;WA.prototype.readDLSSamples=eo;var Ut=class extends de{constructor(A,e,s,n,o,i,C,c,B,d,h,u,l){super(A,i,C,c,B,d,n-e/2,o-e/2),this.sampleName=A,this.sampleStartIndex=e,this.sampleEndIndex=s,this.isSampleLoaded=!1,this.sampleID=u,this.sampleLength=this.sampleEndIndex-this.sampleStartIndex,this.sampleDataArray=h,this.sampleData=new Float32Array(0),this.isCompressed&&(this.sampleLoopStartIndex+=this.sampleStartIndex/2,this.sampleLoopEndIndex+=this.sampleStartIndex/2,this.sampleLength=99999999),this.isDataRaw=l}getRawData(){let A=this.sampleDataArray;if(this.isCompressed){if(this.compressedData)return this.compressedData;let e=A.currentIndex;return A.slice(this.sampleStartIndex/2+e,this.sampleEndIndex/2+e)}else{if(!this.isDataRaw)throw new Error("Writing SF2Pack samples is not supported.");let e=A.currentIndex;return A.slice(e+this.sampleStartIndex,e+this.sampleEndIndex)}}decodeVorbis(){if(this.sampleLength<1)return;let A=this.sampleDataArray,e=A.currentIndex,s=A.slice(this.sampleStartIndex/2+e,this.sampleEndIndex/2+e);this.sampleData=new Float32Array(0);let n=OA.decode(s.buffer);this.sampleData=n.data[0]}getAudioData(){return this.isSampleLoaded?this.sampleData:this.sampleLength<1?new Float32Array(1):this.isCompressed?(this.decodeVorbis(),this.isSampleLoaded=!0,this.sampleData):this.isDataRaw?this.loadUncompressedData():this.getUncompressedReadyData()}loadUncompressedData(){if(this.isCompressed)return U("Trying to load a compressed sample via loadUncompressedData()... aborting!"),new Float32Array(0);let A=new Float32Array(this.sampleLength/2),e=this.sampleDataArray.currentIndex,s=new Int16Array(this.sampleDataArray.slice(e+this.sampleStartIndex,e+this.sampleEndIndex).buffer);for(let n=0;n t.chunkData.currentIndex;){let o=qo(n,t.chunkData,A,e);s.push(o),n++}return s.length>1&&s.pop(),s}function qo(t,A,e,s){let n=V(A,20),o=k(A,4)*2,i=k(A,4)*2,C=k(A,4),c=k(A,4),B=k(A,4),d=A[A.currentIndex++];d===255&&(d=60);let h=Fs(A[A.currentIndex++]),u=k(A,2),l=k(A,2);return new Ut(n,o,i,C,c,B,d,h,u,l,e,t,s)}var Tt=class extends b{constructor(A){super();let e=A.currentIndex;this.generatorType=A[e+1]<<8|A[e],this.generatorValue=jA(A[e+2],A[e+3]),A.currentIndex+=4}};function Ht(t){let A=[];for(;t.chunkData.length>t.chunkData.currentIndex;)A.push(new Tt(t.chunkData));return A.length>1&&A.pop(),A}var Yt=class extends ue{constructor(A){super(),this.instrumentName=V(A.chunkData,20).trim(),this.instrumentZoneIndex=k(A.chunkData,2),this.instrumentZonesAmount=0}getInstrumentZones(A,e){this.instrumentZonesAmount=A;for(let s=this.instrumentZoneIndex;s t.chunkData.currentIndex;){let s=new Yt(t);if(e.length>0){let n=s.instrumentZoneIndex-e[e.length-1].instrumentZoneIndex;e[e.length-1].getInstrumentZones(n,A)}e.push(s)}return e.length>1&&e.pop(),e}var Jt=class extends $A{constructor(A){super(),this.generatorZoneStartIndex=k(A,2),this.modulatorZoneStartIndex=k(A,2),this.modulatorZoneSize=0,this.generatorZoneSize=0,this.isGlobal=!0}setZoneSize(A,e){this.modulatorZoneSize=A,this.generatorZoneSize=e}getGenerators(A){for(let e=this.generatorZoneStartIndex;e s.generatorType===g.sampleID);e&&(this.sample=A[e.generatorValue],this.isGlobal=!1,this.sample.useCount++)}getKeyRange(){let A=this.generators.find(e=>e.generatorType===g.keyRange);A&&(this.keyRange.min=A.generatorValue&127,this.keyRange.max=A.generatorValue>>8&127)}getVelRange(){let A=this.generators.find(e=>e.generatorType===g.velRange);A&&(this.velRange.min=A.generatorValue&127,this.velRange.max=A.generatorValue>>8&127)}};function no(t,A,e,s){let n=[];for(;t.chunkData.length>t.chunkData.currentIndex;){let o=new Jt(t.chunkData);if(n.length>0){let i=o.modulatorZoneStartIndex-n[n.length-1].modulatorZoneStartIndex,C=o.generatorZoneStartIndex-n[n.length-1].generatorZoneStartIndex;n[n.length-1].setZoneSize(i,C),n[n.length-1].getGenerators(A),n[n.length-1].getModulators(e),n[n.length-1].getSample(s),n[n.length-1].getKeyRange(),n[n.length-1].getVelRange()}n.push(o)}return n.length>1&&n.pop(),n}var vt=class extends le{constructor(A){super(),this.generatorZoneStartIndex=k(A,2),this.modulatorZoneStartIndex=k(A,2),this.modulatorZoneSize=0,this.generatorZoneSize=0,this.isGlobal=!0}setZoneSize(A,e){this.modulatorZoneSize=A,this.generatorZoneSize=e}getGenerators(A){for(let e=this.generatorZoneStartIndex;e s.generatorType===g.instrument);e&&(this.instrument=A[e.generatorValue],this.instrument.addUseCount(),this.isGlobal=!1)}getKeyRange(){let A=this.generators.find(e=>e.generatorType===g.keyRange);A&&(this.keyRange.min=A.generatorValue&127,this.keyRange.max=A.generatorValue>>8&127)}getVelRange(){let A=this.generators.find(e=>e.generatorType===g.velRange);A&&(this.velRange.min=A.generatorValue&127,this.velRange.max=A.generatorValue>>8&127)}};function oo(t,A,e,s){let n=[];for(;t.chunkData.length>t.chunkData.currentIndex;){let o=new vt(t.chunkData);if(n.length>0){let i=o.modulatorZoneStartIndex-n[n.length-1].modulatorZoneStartIndex,C=o.generatorZoneStartIndex-n[n.length-1].generatorZoneStartIndex;n[n.length-1].setZoneSize(i,C),n[n.length-1].getGenerators(A),n[n.length-1].getModulators(e),n[n.length-1].getInstrument(s),n[n.length-1].getKeyRange(),n[n.length-1].getVelRange()}n.push(o)}return n.length>1&&n.pop(),n}var qt=class extends ce{constructor(A,e){super(e),this.presetName=V(A.chunkData,20).trim().replace(/\d{3}:\d{3}/,""),this.program=k(A.chunkData,2),this.bank=k(A.chunkData,2),this.presetZoneStartIndex=k(A.chunkData,2),this.library=k(A.chunkData,4),this.genre=k(A.chunkData,4),this.morphology=k(A.chunkData,4),this.presetZonesAmount=0}getPresetZones(A,e){this.presetZonesAmount=A;for(let s=this.presetZoneStartIndex;s t.chunkData.currentIndex;){let n=new qt(t,e);if(s.length>0){let o=n.presetZoneStartIndex-s[s.length-1].presetZoneStartIndex;s[s.length-1].getPresetZones(o,A)}s.push(n)}return s.length>1&&s.pop(),s}var Pt=class extends ${constructor(A){super({srcEnum:k(A,2),dest:k(A,2),amt:jA(A[A.currentIndex++],A[A.currentIndex++]),secSrcEnum:k(A,2),transform:k(A,2)})}};function tt(t){let A=[];for(;t.chunkData.length>t.chunkData.currentIndex;)A.push(new Pt(t.chunkData));return A}var st=class extends ne{constructor(A,e=!0){if(super(),e&&console.warn("Using the constructor directly is deprecated. Use loadSoundFont instead."),this.dataArray=new H(A),te("%cParsing SoundFont...",r.info),!this.dataArray)throw X(),new TypeError("No data!");let s=O(this.dataArray,!1);this.verifyHeader(s,"riff");let n=V(this.dataArray,4).toLowerCase();if(n!=="sfbk"&&n!=="sfpk")throw X(),new SyntaxError(`Invalid soundFont! Expected "sfbk" or "sfpk" got "${n}"`);let o=n==="sfpk",i=O(this.dataArray);for(this.verifyHeader(i,"list"),V(i.chunkData,4);i.chunkData.length>i.chunkData.currentIndex;){let Z=O(i.chunkData),CA;switch(Z.header.toLowerCase()){case"ifil":case"iver":CA=`${k(Z.chunkData,2)}.${k(Z.chunkData,2)}`,this.soundFontInfo[Z.header]=CA;break;case"icmt":CA=V(Z.chunkData,Z.chunkData.length,void 0,!1),this.soundFontInfo[Z.header]=CA;break;case"dmod":let oA=tt(Z);oA.pop(),CA=`Modulators: ${oA.length}`;let fA=this.defaultModulators;this.defaultModulators=oA,this.defaultModulators.push(...fA.filter(Me=>!this.defaultModulators.find(RA=>$.isIdentical(Me,RA)))),this.soundFontInfo[Z.header]=Z.chunkData;break;default:CA=V(Z.chunkData,Z.chunkData.length),this.soundFontInfo[Z.header]=CA}m(`%c"${Z.header}": %c"${CA}"`,r.info,r.recognized)}let C=O(this.dataArray,!1);this.verifyHeader(C,"list"),this.verifyText(V(this.dataArray,4),"sdta"),m("%cVerifying smpl chunk...",r.warn);let c=O(this.dataArray,!1);this.verifyHeader(c,"smpl");let B;if(o){m("%cSF2Pack detected, attempting to decode the smpl chunk...",r.info);try{B=OA.decode(this.dataArray.buffer.slice(this.dataArray.currentIndex,this.dataArray.currentIndex+C.size-12)).data[0]}catch(Z){throw X(),new Error(`SF2Pack Ogg Vorbis decode error: ${Z}`)}m(`%cDecoded the smpl chunk! Length: %c${B.length}`,r.info,r.value)}else B=this.dataArray,this.sampleDataStartIndex=this.dataArray.currentIndex;m(`%cSkipping sample chunk, length: %c${C.size-12}`,r.info,r.value),this.dataArray.currentIndex+=C.size-12,m("%cLoading preset data chunk...",r.warn);let d=O(this.dataArray);this.verifyHeader(d,"list"),V(d.chunkData,4);let h=O(d.chunkData);this.verifyHeader(h,"phdr");let u=O(d.chunkData);this.verifyHeader(u,"pbag");let l=O(d.chunkData);this.verifyHeader(l,"pmod");let D=O(d.chunkData);this.verifyHeader(D,"pgen");let S=O(d.chunkData);this.verifyHeader(S,"inst");let w=O(d.chunkData);this.verifyHeader(w,"ibag");let y=O(d.chunkData);this.verifyHeader(y,"imod");let N=O(d.chunkData);this.verifyHeader(N,"igen");let G=O(d.chunkData);this.verifyHeader(G,"shdr"),this.dataArray.currentIndex=this.sampleDataStartIndex,this.samples.push(...to(G,B,!o));let K=Ht(N),W=tt(y),I=no(w,K,W,this.samples);this.instruments=so(S,I);let nA=Ht(D),j=tt(l),J=oo(u,nA,j,this.instruments);this.presets.push(...ro(h,J,this.defaultModulators)),this.presets.sort((Z,CA)=>Z.program-CA.program+(Z.bank-CA.bank)),m(`%cParsing finished! %c"${this.soundFontInfo.INAM}"%c has %c${this.presets.length} %cpresets, + %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info,r.recognized,r.info),X(),o&&delete this.dataArray}verifyHeader(A,e){if(A.header.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid chunk header! Expected "${e.toLowerCase()}" got "${A.header.toLowerCase()}"`)}verifyText(A,e){if(A.toLowerCase()!==e.toLowerCase())throw X(),new SyntaxError(`Invalid soundFont! Expected "${e.toLowerCase()}" got "${A.toLowerCase()}"`)}};function Ge(t){let A=t.slice(8,12),e=new H(A);return V(e,4,void 0,!1).toLowerCase()==="dls "?new WA(t):new st(t,!1)}function io(t,A,e=!1){let s=this.workletProcessorChannels[t];if(s===void 0){U(`Trying to access channel ${t} which does not exist... ignoring!`);return}if(s.lockPreset)return;let n=s.drumChannel?128:s.midiControllers[p.bankSelect],o,i;if(this.overrideSoundfont){let C=n===128?128:n-this.soundfontBankOffset,c=this.overrideSoundfont.getPresetNoFallback(C,A);c?(o=n,i=c,s.presetUsesOverride=!0):(i=this.soundfontManager.getPreset(n,A),o=i.bank,s.presetUsesOverride=!1)}else i=this.soundfontManager.getPreset(n,A),o=i.bank,s.presetUsesOverride=!1;this.setPreset(t,i),this.callEvent("programchange",{channel:t,program:i.program,bank:o,userCalled:e})}function ao(t,A){if(this.overrideSoundfont){let e=t===128?128:t-this.soundfontBankOffset,s=this.overrideSoundfont.getPresetNoFallback(e,A);if(s)return s}return this.soundfontManager.getPreset(t,A)}function Io(t,A){if(!this.workletProcessorChannels[t].lockPreset){delete this.workletProcessorChannels[t].preset,this.workletProcessorChannels[t].preset=A,this.workletProcessorChannels[t].cachedVoices=[];for(let e=0;e<128;e++)this.workletProcessorChannels[t].cachedVoices.push([])}}function go(t,A){let e=this.workletProcessorChannels[t];e.lockPreset||e.drumChannel!==A&&(A?(e.channelTransposeKeyShift=0,e.drumChannel=!0,this.setPreset(t,this.getPreset(128,e.preset.program))):(e.drumChannel=!1,this.setPreset(t,this.getPreset(e.midiControllers[p.bankSelect],e.preset.program))),e.presetUsesOverride=!1,this.callEvent("drumchange",{channel:t,isDrumChannel:e.drumChannel}),this.sendChannelProperties())}function Co(){let t=this.soundfontManager.getPresetList();this.overrideSoundfont!==void 0&&this.overrideSoundfont.presets.forEach(A=>{let e=A.bank===128?128:A.bank+this.soundfontBankOffset,s=t.find(n=>n.bank===e&&n.program===A.program);s!==void 0?s.presetName=A.presetName:t.push({presetName:A.presetName,bank:e,program:A.program})}),this.callEvent("presetlistchange",t)}function Eo(t=!0,A=!0){this.stopAllChannels(!0),A&&(delete this.overrideSoundfont,this.overrideSoundfont=void 0),this.defaultPreset=this.getPreset(0,0),this.drumPreset=this.getPreset(128,0);for(let e=0;e {this.programChange(s,e.preset.program)}),this.post({messageType:pA.ready,messageData:void 0}),this.sendPresetList(),m("%cSpessaSynth is ready!",r.recognized)}function ho(t,A){this.soundfontBankOffset=A,this.reloadSoundFont(t,!0),this.overrideSoundfont.samples.forEach(e=>e.getAudioData()),this._snapshot!==void 0&&(this.applySynthesizerSnapshot(this._snapshot),this.resetAllControllers())}function Qo(){let A={channelSnapshots:this.workletProcessorChannels.map(e=>({program:e.preset.program,bank:e.preset.bank,lockPreset:e.lockPreset,patchName:e.preset.presetName,midiControllers:e.midiControllers,lockedControllers:e.lockedControllers,customControllers:e.customControllers,channelVibrato:e.channelVibrato,lockVibrato:e.lockGSNRPNParams,channelTransposeKeyShift:e.channelTransposeKeyShift,channelOctaveTuning:e.channelOctaveTuning,keyCentTuning:e.keyCentTuning,velocityOverride:e.velocityOverride,isMuted:e.isMuted,drumChannel:e.drumChannel})),mainVolume:this.midiVolume,pan:this.pan,transposition:this.transposition,system:this.system,interpolation:this.interpolationType};this.post({messageType:pA.synthesizerSnapshot,messageData:A})}function co(t){for(this.system=t.system,this.setMasterGain(t.mainVolume),this.setMasterPan(t.pan),this.transposeAllChannels(t.transposition),this.interpolationType=t.interpolation;this.workletProcessorChannels.length {let s=this.workletProcessorChannels[e];this.muteChannel(e,A.isMuted),this.setDrums(e,A.drumChannel),s.midiControllers=A.midiControllers,s.lockedControllers=A.lockedControllers,s.customControllers=A.customControllers,s.channelVibrato=A.channelVibrato,s.lockGSNRPNParams=A.lockVibrato,s.channelTransposeKeyShift=A.channelTransposeKeyShift,s.channelOctaveTuning=A.channelOctaveTuning,s.velocityOverride=A.velocityOverride,s.lockPreset=!1,s.midiControllers[p.bankSelect]=A.bank,this.programChange(e,A.program),s.lockPreset=A.lockPreset}),m("%cFinished restoring controllers!",r.info)}var nt=class{constructor(A,e){this.ready=e,this.totalSoundfontOffset=0,this.reloadManager(A)}_assingSampleOffsets(){let A=0;this.soundfontList.forEach(e=>{e.soundfont.setSampleIDOffset(A),A+=e.soundfont.samples.length}),this.totalSoundfontOffset=A}generatePresetList(){this._assingSampleOffsets();let A={};for(let e=this.soundfontList.length-1;e>=0;e--){let s=this.soundfontList[e],n=new Set;for(let o of s.soundfont.presets){let i=`${o.bank+s.bankOffset}-${o.program}`;n.has(i)||(n.add(i),A[i]=o.presetName)}}this.presetList=[];for(let[e,s]of Object.entries(A)){let n=e.split("-");this.presetList.push({presetName:s,program:parseInt(n[1]),bank:parseInt(n[0])})}}handleMessage(A,e){switch(A){case Ie.addNewSoundFont:this.addNewSoundFont(e[0],e[1],e[2]);break;case Ie.reloadSoundFont:this.reloadManager(e);break;case Ie.deleteSoundFont:this.deleteSoundFont(e);break;case Ie.rearrangeSoundFonts:this.rearrangeSoundFonts(e)}}getPresetList(){return this.presetList.slice()}reloadManager(A){let e=Ge(A);this.soundfontList=[],this.soundfontList.push({id:"main",bankOffset:0,soundfont:e}),this.generatePresetList(),this.ready()}deleteSoundFont(A){if(this.soundfontList.length===0){U("1 soundfont left. Aborting!");return}let e=this.soundfontList.findIndex(s=>s.id===A);if(e===-1){U(`No soundfont with id of "${A}" found. Aborting!`);return}delete this.soundfontList[e].soundfont.presets,delete this.soundfontList[e].soundfont.instruments,delete this.soundfontList[e].soundfont.samples,this.soundfontList.splice(e,1),this.generatePresetList()}addNewSoundFont(A,e,s){if(this.soundfontList.find(n=>n.id===e)!==void 0)throw new Error("Cannot overwrite the existing soundfont. Use soundfontManager.delete(id) instead.");this.soundfontList.push({id:e,soundfont:Ge(A),bankOffset:s}),this.generatePresetList(),this.ready()}rearrangeSoundFonts(A){this.soundfontList.sort((e,s)=>A.indexOf(e.id)-A.indexOf(s.id)),this.generatePresetList()}getPreset(A,e){if(this.soundfontList.length<1)throw new Error("No soundfonts! This should never happen.");for(let s of this.soundfontList){let n=s.soundfont.getPresetNoFallback(A-s.bankOffset,e);if(n!==void 0)return n}if(A!==128){for(let s of this.soundfontList){let n=s.soundfont.presets.find(o=>o.program===e);if(n)return n}return this.soundfontList[0].soundfont.presets[0]}else{for(let s of this.soundfontList){let n=s.soundfont.presets.find(o=>o.bank===128);if(n)return n}return this.soundfontList[0].soundfont.presets[0]}}};var ot=class{constructor(A,e,s,n,o,i,C,c){this.sampleData=A,this.playbackStep=e,this.cursor=s,this.rootKey=n,this.loopStart=o,this.loopEnd=i,this.end=C,this.loopingMode=c,this.isLooping=this.loopingMode===1||this.loopingMode===3}sampleData;playbackStep=0;cursor=0;rootKey=0;loopStart=0;loopEnd=0;end=0;loopingMode=0;isLooping=!1},xe=class t{constructor(A,e,s,n,o,i,C,c,B){this.sample=e,this.generators=c,this.modulatedGenerators=new Int16Array(c),this.modulators=B,this.velocity=n,this.midiNote=s,this.channelNumber=o,this.startTime=i,this.targetKey=C,this.volumeEnvelope=new LA(A,c[g.sustainVolEnv])}sample;filter=new Qe;generators;modulators=[];modulatedGenerators;finished=!1;isInRelease=!1;channelNumber=0;velocity=0;midiNote=0;pressure=0;targetKey=0;modulationEnvelope=new YA;volumeEnvelope;startTime=0;releaseStartTime=1/0;currentTuningCents=0;currentTuningCalculated=1;currentPan=.5;static copy(A,e){let s=A.sample,n=new ot(s.sampleData,s.playbackStep,s.cursor,s.rootKey,s.loopStart,s.loopEnd,s.end,s.loopingMode);return new t(A.volumeEnvelope.sampleRate,n,A.midiNote,A.velocity,A.channelNumber,e,A.targetKey,A.generators,A.modulators.map(o=>$.copy(o)))}};function lo(t,A,e,s,n,o=!1){let i,C=s.cachedVoices[A][e];return C!==void 0?C.map(c=>xe.copy(c,n)):(i=s.preset.getSamplesAndGenerators(A,e).reduce((B,d)=>{if(d.sample.sampleData===void 0)return U(`Discarding invalid sample: ${d.sample.sampleName}`),B;let h=new Int16Array(60);for(let N=0;N<60;N++)h[N]=ds(N,d.presetGenerators,d.instrumentGenerators);h[g.initialAttenuation]=Math.floor(h[g.initialAttenuation]*.4);let u=d.sample.samplePitch;h[g.overridingRootKey]>-1&&(u=h[g.overridingRootKey]);let l=A;h[g.keyNum]>-1&&(l=h[g.keyNum]);let D=d.sample.sampleLoopStartIndex,S=d.sample.sampleLoopEndIndex,w=h[g.sampleModes],y=new ot(d.sample.getAudioData(),d.sample.sampleRate/sampleRate*Math.pow(2,d.sample.samplePitchCorrection/1200),0,u,D,S,Math.floor(d.sample.sampleData.length)-1,w);return h[g.velocity]>-1&&(e=h[g.velocity]),o&&us([{Sample:d.sample.sampleName,Generators:h,Modulators:d.modulators.map(N=>N.debugString()),Velocity:e,TargetKey:l,MidiNote:A,WorkletSample:y}]),B.push(new xe(sampleRate,y,A,e,t,n,l,h,d.modulators.map(N=>$.copy(N)))),B},[]),s.cachedVoices[A][e]=i.map(B=>xe.copy(B,n)),i)}var Nt=.03,bt=1,T=class extends AudioWorkletProcessor{constructor(A){super(),this.oneOutputMode=A.processorOptions?.startRenderingData?.oneOutput===!0,this._outputsAmount=this.oneOutputMode?1:A.processorOptions.midiChannels,this.enableEventSystem=A.processorOptions.enableEventSystem,this.deviceID=UA,this.interpolationType=he.fourthOrder,this.processTickCallback=void 0,this.sequencer=new aA(this),this.transposition=0,this.tunings=[];for(let e=0;e<127;e++)this.tunings.push([]);this.soundfontBankOffset=0,this.masterGain=bt,this.midiVolume=1,this.voiceCap=ys,this.pan=0,this.panLeft=.5*this.currentGain,this.highPerformanceMode=!1,this.overrideSoundfont=void 0,this.panRight=.5*this.currentGain;try{this.soundfontManager=new nt(A.processorOptions.soundfont,this.postReady.bind(this))}catch(e){throw this.post({messageType:pA.soundfontError,messageData:e}),e}this.sendPresetList(),this.defaultPreset=this.getPreset(0,0),this.drumPreset=this.getPreset(128,0),this.workletProcessorChannels=[];for(let e=0;e this.handleMessage(e.data),A.processorOptions.startRenderingData&&(this._snapshot!==void 0&&(this.applySynthesizerSnapshot(this._snapshot),this.resetAllControllers()),m("%cRendering enabled! Starting render.",r.info),A.processorOptions.startRenderingData.parsedMIDI&&(A.processorOptions.startRenderingData?.loopCount!==void 0?(this.sequencer.loopCount=A.processorOptions.startRenderingData?.loopCount,this.sequencer.loop=!0):this.sequencer.loop=!1,this.sequencer.loadNewSongList([A.processorOptions.startRenderingData.parsedMIDI]))),OA.isInitialized.then(()=>{this.postReady(),m("%cSpessaSynth is ready!",r.recognized)})}post(A){this.enableEventSystem&&this.port.postMessage(A)}postReady(){this.enableEventSystem&&this.port.postMessage({messageType:pA.ready,messageData:void 0})}get currentGain(){return this.masterGain*this.midiVolume}debugMessage(){m({channels:this.workletProcessorChannels,voicesAmount:this.totalVoicesAmount,outputAmount:this._outputsAmount,dumpedSamples:this.workletDumpedSamplesList})}process(A,e){this.processTickCallback&&this.processTickCallback();let s=0;return this.workletProcessorChannels.forEach((n,o)=>{if(n.voices.length<1||n.isMuted)return;let i,C,c,B,d;if(this.oneOutputMode){let u=e[0];i=o%16*2,C=u[i],c=u[i+1]}else i=o%this._outputsAmount+2,C=e[i][0],c=e[i][1],B=e[0],d=e[1];let h=n.voices;n.voices=[],h.forEach(u=>{this.renderVoice(n,u,C,c,B,d),u.finished||n.voices.push(u)}),s+=n.voices.length}),s!==this.totalVoicesAmount&&(this.totalVoicesAmount=s,this.sendChannelProperties()),!0}};T.prototype.renderVoice=An;T.prototype.releaseVoice=tn;T.prototype.voiceKilling=en;T.prototype.getWorkletVoices=lo;T.prototype.handleMessage=on;T.prototype.sendChannelProperties=an;T.prototype.callEvent=rn;T.prototype.systemExclusive=In;T.prototype.noteOn=Cn;T.prototype.noteOff=En;T.prototype.polyPressure=Sn;T.prototype.killNote=Bn;T.prototype.stopAll=hn;T.prototype.stopAllChannels=Qn;T.prototype.muteChannel=Gn;T.prototype.setVibrato=Mn;T.prototype.disableAndLockGSNRPN=xn;T.prototype.dataEntryCoarse=Nn;T.prototype.dataEntryFine=bn;T.prototype.createWorkletChannel=fs;T.prototype.controllerChange=kn;T.prototype.channelPressure=yn;T.prototype.resetAllControllers=Ln;T.prototype.resetControllers=Un;T.prototype.resetParameters=Tn;T.prototype.setMasterGain=Fn;T.prototype.setMasterPan=Rn;T.prototype.setMIDIVolume=wn;T.prototype.transposeAllChannels=cn;T.prototype.transposeChannel=ln;T.prototype.setChannelTuning=un;T.prototype.setChannelTuningSemitones=dn;T.prototype.setMasterTuning=fn;T.prototype.setModulationDepth=mn;T.prototype.pitchWheel=pn;T.prototype.setOctaveTuning=Dn;T.prototype.programChange=io;T.prototype.getPreset=ao;T.prototype.setPreset=Io;T.prototype.setDrums=go;T.prototype.reloadSoundFont=Bo;T.prototype.clearSoundFont=Eo;T.prototype.setEmbeddedSoundFont=ho;T.prototype.sendPresetList=Co;T.prototype.sendSynthesizerSnapshot=Qo;T.prototype.applySynthesizerSnapshot=co;registerProcessor(ps,T);m("%cProcessor succesfully registered!",r.recognized); diff --git a/src/spessasynth_lib/synthetizer/worklet_system/message_protocol/message_sending.js b/src/spessasynth_lib/synthetizer/worklet_system/message_protocol/message_sending.js index 9f4dcd07..db3f7950 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/message_protocol/message_sending.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/message_protocol/message_sending.js @@ -1,6 +1,7 @@ import { returnMessageType } from './worklet_message.js' import { NON_CC_INDEX_OFFSET } from '../worklet_utilities/worklet_processor_channel.js' -import { modulatorSources } from '../../../soundfont/read_sf2/modulators.js' + +import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js"; /** * Calls synth event from the worklet side diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/data_entry.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/data_entry.js index d73c6fd0..c3b57783 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/data_entry.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/data_entry.js @@ -5,8 +5,8 @@ import { dataEntryStates, NON_CC_INDEX_OFFSET, } from '../worklet_utilities/worklet_processor_channel.js' -import { modulatorSources } from '../../../soundfont/read_sf2/modulators.js' import { SpessaSynthInfo, SpessaSynthWarn } from '../../../utils/loggin.js' +import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js"; /** * Executes a data entry for an NRP for a sc88pro NRP (because touhou yes) and RPN tuning diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_off.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_off.js index 9ebc3b85..5b7a5d38 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_off.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_off.js @@ -1,6 +1,6 @@ -import { generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { consoleColors } from '../../../utils/other.js' import { SpessaSynthInfo, SpessaSynthWarn } from '../../../utils/loggin.js' +import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; /** * Release a note diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_on.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_on.js index 46aaf93a..76a13487 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_on.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/note_on.js @@ -1,7 +1,7 @@ -import { generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { computeModulators } from '../worklet_utilities/worklet_modulator.js' import { WorkletVolumeEnvelope } from '../worklet_utilities/volume_envelope.js' import { WorkletModulationEnvelope } from '../worklet_utilities/modulation_envelope.js' +import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; /** * Append the voices diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/reset_controllers.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/reset_controllers.js index ccb5182c..958a1182 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/reset_controllers.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/reset_controllers.js @@ -7,8 +7,8 @@ import { NON_CC_INDEX_OFFSET, resetArray, } from '../worklet_utilities/worklet_processor_channel.js' -import { modulatorSources } from '../../../soundfont/read_sf2/modulators.js' import { SpessaSynthInfo } from '../../../utils/loggin.js' +import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js"; /** * @this {SpessaSynthProcessor} diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/tuning_control.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/tuning_control.js index d62fb603..8491235f 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/tuning_control.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/tuning_control.js @@ -1,8 +1,8 @@ import { customControllers, NON_CC_INDEX_OFFSET } from '../worklet_utilities/worklet_processor_channel.js' import { consoleColors } from '../../../utils/other.js' -import { modulatorSources } from '../../../soundfont/read_sf2/modulators.js' import { computeModulators } from '../worklet_utilities/worklet_modulator.js' import { SpessaSynthInfo } from '../../../utils/loggin.js' +import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js"; /** * Transposes all channels by given amount of semitones diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/voice_control.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/voice_control.js index d4a78141..de036ba6 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/voice_control.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_methods/voice_control.js @@ -1,4 +1,3 @@ -import { generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { absCentsToHz, timecentsToSeconds } from '../worklet_utilities/unit_converter.js' import { getLFOValue } from '../worklet_utilities/lfo.js' import { customControllers } from '../worklet_utilities/worklet_processor_channel.js' @@ -13,6 +12,7 @@ import { panVoice } from '../worklet_utilities/stereo_panner.js' import { WorkletLowpassFilter } from '../worklet_utilities/lowpass_filter.js' import { MIN_NOTE_LENGTH } from '../main_processor.js' import { WorkletVolumeEnvelope } from '../worklet_utilities/volume_envelope.js' +import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; const HALF_PI = Math.PI / 2; diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js index 5f718a8b..e4dafe71 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js @@ -1,5 +1,5 @@ -import { generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { absCentsToHz, decibelAttenuationToGain } from './unit_converter.js' +import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; /** * lowpass_filter.js diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js index 0c0ccc90..d9fa9900 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js @@ -1,7 +1,7 @@ import { timecentsToSeconds } from './unit_converter.js' -import { generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { getModulatorCurveValue } from './modulator_curves.js' -import { modulatorCurveTypes } from '../../../soundfont/read_sf2/modulators.js' +import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; +import { modulatorCurveTypes } from "../../../soundfont/basic_soundfont/modulator.js"; /** * modulation_envelope.js diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulator_curves.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulator_curves.js index 17db8753..09322684 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulator_curves.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/modulator_curves.js @@ -1,4 +1,4 @@ -import { modulatorCurveTypes } from '../../../soundfont/read_sf2/modulators.js' +import { modulatorCurveTypes } from "../../../soundfont/basic_soundfont/modulator.js"; /** * modulator_curves.js diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/volume_envelope.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/volume_envelope.js index 7bfa6ed1..8e1f6256 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/volume_envelope.js @@ -1,5 +1,6 @@ import { decibelAttenuationToGain, timecentsToSeconds } from './unit_converter.js' -import { generatorTypes } from '../../../soundfont/read_sf2/generators.js' + +import { generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; /** * volume_envelope.js diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js index 99b37d0b..682577aa 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js @@ -1,9 +1,10 @@ -import { Modulator, modulatorSources } from '../../../soundfont/read_sf2/modulators.js' + import { getModulatorCurveValue, MOD_PRECOMPUTED_LENGTH } from './modulator_curves.js' import { NON_CC_INDEX_OFFSET } from './worklet_processor_channel.js' -import { generatorLimits, generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { WorkletVolumeEnvelope } from './volume_envelope.js' import { WorkletModulationEnvelope } from './modulation_envelope.js' +import { generatorLimits, generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; +import { Modulator, modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js"; /** * worklet_modulator.js diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js index 2ba33bd7..27245252 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js @@ -1,5 +1,6 @@ import { midiControllers } from '../../../midi_parser/midi_message.js' -import { modulatorSources } from '../../../soundfont/read_sf2/modulators.js' + +import { modulatorSources } from "../../../soundfont/basic_soundfont/modulator.js"; /** * @typedef {Object} WorkletProcessorChannel * @property {Int16Array} midiControllers - array of MIDI controller values + the values used by modulators as source (pitch bend, bend range etc.) diff --git a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_voice.js b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_voice.js index 4b03bd68..25b9e084 100644 --- a/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +++ b/src/spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_voice.js @@ -3,7 +3,6 @@ * purpose: prepares workletvoices from sample and generator data and manages sample dumping * note: sample dumping means sending it over to the AudioWorkletGlobalScope */ -import { Modulator } from '../../../soundfont/read_sf2/modulators.js' class WorkletSample { @@ -101,11 +100,12 @@ class WorkletSample isLooping = false; } -import { addAndClampGenerator, generatorTypes } from '../../../soundfont/read_sf2/generators.js' import { SpessaSynthTable, SpessaSynthWarn } from '../../../utils/loggin.js' import { WorkletLowpassFilter } from './lowpass_filter.js' import { WorkletVolumeEnvelope } from './volume_envelope.js' import { WorkletModulationEnvelope } from './modulation_envelope.js' +import { addAndClampGenerator, generatorTypes } from "../../../soundfont/basic_soundfont/generator.js"; +import { Modulator } from "../../../soundfont/basic_soundfont/modulator.js"; /** diff --git a/src/website/js/synthesizer_ui/methods/create_channel_controller.js b/src/website/js/synthesizer_ui/methods/create_channel_controller.js index 658604b5..7de65fe9 100644 --- a/src/website/js/synthesizer_ui/methods/create_channel_controller.js +++ b/src/website/js/synthesizer_ui/methods/create_channel_controller.js @@ -37,7 +37,8 @@ import { import { NON_CC_INDEX_OFFSET } from '../../../../spessasynth_lib/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js' -import { modulatorSources } from '../../../../spessasynth_lib/soundfont/read_sf2/modulators.js' + +import { modulatorSources } from "../../../../spessasynth_lib/soundfont/basic_soundfont/modulator.js"; export const ICON_SIZE = 32; diff --git a/src/website/minified/demo_main.min.js b/src/website/minified/demo_main.min.js index 9a6ba371..ae196b4b 100644 --- a/src/website/minified/demo_main.min.js +++ b/src/website/minified/demo_main.min.js @@ -1,4 +1,4 @@ -var EC=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,l)=>(typeof require<"u"?require:n)[l]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var J3=class extends Uint8Array{constructor(n){super(n),this.currentIndex=0}currentIndex};function vr(o){let n=o.reduce((u,S)=>u+S.length,0),l=new J3(n),g=0;for(let u of o)l.set(u,g),g+=u.length;return l}function E$(o){o=Math.floor(o);let n=Math.floor(o/60),l=Math.round(o-n*60);return{minutes:n,seconds:l,time:`${n.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`}}function FB(o){return o.trim().replaceAll(".mid","").replaceAll(".rmi","").replaceAll("_"," ")}var _1={warn:"color: orange;",unrecognized:"color: red;",info:"color: aqua;",recognized:"color: lime",value:"color: yellow; background-color: black;"};var Ei=class{constructor(n,l,g){this.ticks=n,this.messageStatusByte=l,this.messageData=g}};var K3={noteOff:128,noteOn:144,polyPressure:160,controllerChange:176,programChange:192,channelPressure:208,pitchBend:224,systemExclusive:240,timecode:241,songPosition:242,songSelect:243,tuneRequest:246,clock:248,start:250,continue:251,stop:252,activeSensing:254,reset:255,sequenceNumber:0,text:1,copyright:2,trackName:3,instrumentName:4,lyric:5,marker:6,cuePoint:7,programName:8,midiChannelPrefix:32,midiPort:33,endOfTrack:47,setTempo:81,smpteOffset:84,timeSignature:88,keySignature:89,sequenceSpecific:127};function XQ(o){let n=o&240,l=o&15,g=-1,u=o;return n>=128&&n<=224&&(g=l,u=n),{status:u,channel:g}}var t6={bankSelect:0,modulationWheel:1,breathController:2,footController:4,portamentoTime:5,dataEntryMsb:6,mainVolume:7,balance:8,pan:10,expressionController:11,effectControl1:12,effectControl2:13,generalPurposeController1:16,generalPurposeController2:17,generalPurposeController3:18,generalPurposeController4:19,lsbForControl0BankSelect:32,lsbForControl1ModulationWheel:33,lsbForControl2BreathController:34,lsbForControl4FootController:36,lsbForControl5PortamentoTime:37,lsbForControl6DataEntry:38,lsbForControl7MainVolume:39,lsbForControl8Balance:40,lsbForControl10Pan:42,lsbForControl11ExpressionController:43,lsbForControl12EffectControl1:44,lsbForControl13EffectControl2:45,sustainPedal:64,portamentoOnOff:65,sostenutoPedal:66,softPedal:67,legatoFootswitch:68,hold2Pedal:69,soundVariation:70,timbreHarmonicContent:71,releaseTime:72,attackTime:73,brightness:74,soundController6:75,soundController7:76,soundController8:77,soundController9:78,soundController10:79,generalPurposeController5:80,generalPurposeController6:81,generalPurposeController7:82,generalPurposeController8:83,portamentoControl:84,effects1Depth:91,effects2Depth:92,effects3Depth:93,effects4Depth:94,effects5Depth:95,dataIncrement:96,dataDecrement:97,NRPNLsb:98,NRPNMsb:99,RPNLsb:100,RPNMsb:101,allSoundOff:120,resetAllControllers:121,localControlOnOff:122,allNotesOff:123,omniModeOff:124,omniModeOn:125,monoModeOn:126,polyModeOn:127};var mC=class{constructor(){this.events={noteoff:{},noteon:{},pitchwheel:{},controllerchange:{},programchange:{},channelpressure:{},polypressure:{},drumchange:{},stopall:{},newchannel:{},mutechannel:{},presetlistchange:{},allcontrollerreset:{},soundfonterror:{}}}addEvent(n,l,g){this.events[n][l]=g}removeEvent(n,l){delete this.events[n][l]}callEvent(n,l){this.events[n]&&Object.values(this.events[n]).forEach(g=>g(l))}};var MB={nodesAmount:4,defaultDelay:.03,delayVariation:.01,stereoDifference:.02,oscillatorFrequency:.3,oscillatorFrequencyVariation:.05,oscillatorGain:.003},CC=class{constructor(n,l=MB){let g=n.context;this.input=new ChannelSplitterNode(g,{numberOfOutputs:2});let u=new ChannelMergerNode(g,{numberOfInputs:2}),S=[],r0=[],E0=l.oscillatorFrequency,m0=l.defaultDelay;for(let g0=0;g0 {let S=await u.arrayBuffer();l.buffer=await o.decodeAudioData(S)})}return l}var c8={noteOff:0,noteOn:1,ccChange:2,programChange:3,channelPressure:4,polyPressure:5,killNote:6,ccReset:7,setChannelVibrato:8,soundFontManager:9,stopAll:10,killNotes:11,muteChannel:12,addNewChannel:13,customcCcChange:14,debugMessage:15,systemExclusive:16,setMasterParameter:17,setDrums:18,pitchWheel:19,transpose:20,highPerformanceMode:21,lockController:22,sequencerSpecific:23,requestSynthesizerSnapshot:24,setLogLevel:25},Qm={mainVolume:0,masterPan:1,voicesCap:2,interpolationType:3},mi=-1,m$={channelProperties:0,eventCall:1,reportedCurrentTime:2,sequencerSpecific:3,synthesizerSnapshot:4,ready:5,soundfontError:6,identify:7};var wb=!1,kb=!0,TB=!1;function Y5(...o){wb&&console.info(...o)}function R4(...o){kb&&console.warn(...o)}function gn(...o){TB&&console.group(...o)}function ni(...o){TB&&console.groupCollapsed(...o)}function i4(){TB&&console.groupEnd()}var ty={chorusEnabled:!0,chorusConfig:MB,reverbEnabled:!0,reverbImpulseResponse:void 0};var ym={reloadSoundFont:0,addNewSoundFont:2,deleteSoundFont:3,rearrangeSoundFonts:4};var BC=class{constructor(n){this.soundfontList=[{id:"main",bankOffset:0}],this._port=n.worklet.port,this.synth=n}_sendToWorklet(n,l){this._port.postMessage({messageType:c8.soundFontManager,messageData:[n,l]})}async addNewSoundFont(n,l,g=0){if(this.soundfontList.find(u=>u.id===l)!==void 0)throw new Error("Cannot overwrite the existing soundfont. Use soundfontManager.delete(id) instead.");this._sendToWorklet(ym.addNewSoundFont,[n,l,g]),await new Promise(u=>this.synth.resolveWhenReady=u),this.soundfontList.push({id:l,bankOffset:g})}deleteSoundFont(n){if(this.soundfontList.length===0){R4("1 soundfont left. Aborting!");return}if(this.soundfontList.findIndex(l=>l.id===n)===-1){R4(`No soundfont with id of "${n}" found. Aborting!`);return}this._sendToWorklet(ym.deleteSoundFont,n)}rearrangeSoundFonts(n){this._sendToWorklet(ym.rearrangeSoundFonts,n),this.soundfontList.sort((l,g)=>n.indexOf(l.id)-n.indexOf(g.id))}async reloadManager(n){this._sendToWorklet(ym.reloadSoundFont,n),await new Promise(l=>this.synth.resolveWhenReady=l)}};function o3(o,n){let l=0;for(let g=0;g >>0}function l7(o,n,l){for(let g=0;g >g*8&255}function Q9(o,n){o[o.currentIndex++]=n&255,o[o.currentIndex++]=n>>8}function c7(o,n){l7(o,n,4)}function RA(o,n){let l=n<<8|o;return l>32767?l-65536:l}function iy(o){return o>127?o-256:o}function Ie(o,n,l=void 0,g=!0){if(l){let u=o.slice(o.currentIndex,o.currentIndex+n);return o.currentIndex+=n,new TextDecoder(l.replace(/[^\x20-\x7E]/g,"")).decode(u.buffer)}else{let u=!1,S="";for(let r0=0;r0 127){if(g){u=!0;continue}else if(E0===0){u=!0;continue}}S+=String.fromCharCode(E0)}}return S}}function xA(o,n=0){let l=o.length;n>0&&(l=n);let g=new J3(l);return g7(g,o,n),g}function g7(o,n,l=0){l>0&&n.length>l&&(n=n.slice(0,l));for(let g=0;g n.length)for(let g=0;g l.header!=="LIST"?!1:(l.chunkData.currentIndex=0,Ie(l.chunkData,4)===n))}var v1={INVALID:-1,startAddrsOffset:0,endAddrOffset:1,startloopAddrsOffset:2,endloopAddrsOffset:3,startAddrsCoarseOffset:4,modLfoToPitch:5,vibLfoToPitch:6,modEnvToPitch:7,initialFilterFc:8,initialFilterQ:9,modLfoToFilterFc:10,modEnvToFilterFc:11,endAddrsCoarseOffset:12,modLfoToVolume:13,unused1:14,chorusEffectsSend:15,reverbEffectsSend:16,pan:17,unused2:18,unused3:19,unused4:20,delayModLFO:21,freqModLFO:22,delayVibLFO:23,freqVibLFO:24,delayModEnv:25,attackModEnv:26,holdModEnv:27,decayModEnv:28,sustainModEnv:29,releaseModEnv:30,keyNumToModEnvHold:31,keyNumToModEnvDecay:32,delayVolEnv:33,attackVolEnv:34,holdVolEnv:35,decayVolEnv:36,sustainVolEnv:37,releaseVolEnv:38,keyNumToVolEnvHold:39,keyNumToVolEnvDecay:40,instrument:41,reserved1:42,keyRange:43,velRange:44,startloopAddrsCoarseOffset:45,keyNum:46,velocity:47,initialAttenuation:48,reserved2:49,endloopAddrsCoarseOffset:50,coarseTune:51,fineTune:52,sampleID:53,sampleModes:54,reserved3:55,scaleTuning:56,exclusiveClass:57,overridingRootKey:58,unused5:59,endOper:60},l9=[];l9[v1.startAddrsOffset]={min:0,max:32768,def:0};l9[v1.endAddrOffset]={min:-32768,max:32768,def:0};l9[v1.startloopAddrsOffset]={min:-32768,max:32768,def:0};l9[v1.endloopAddrsOffset]={min:-32768,max:32768,def:0};l9[v1.startAddrsCoarseOffset]={min:0,max:32768,def:0};l9[v1.modLfoToPitch]={min:-12e3,max:12e3,def:0};l9[v1.vibLfoToPitch]={min:-12e3,max:12e3,def:0};l9[v1.modEnvToPitch]={min:-12e3,max:12e3,def:0};l9[v1.initialFilterFc]={min:1500,max:13500,def:13500};l9[v1.initialFilterQ]={min:0,max:960,def:0};l9[v1.modLfoToFilterFc]={min:-12e3,max:12e3,def:0};l9[v1.modEnvToFilterFc]={min:-12e3,max:12e3,def:0};l9[v1.endAddrsCoarseOffset]={min:-32768,max:32768,def:0};l9[v1.modLfoToVolume]={min:-960,max:960,def:0};l9[v1.chorusEffectsSend]={min:0,max:1e3,def:0};l9[v1.reverbEffectsSend]={min:0,max:1e3,def:0};l9[v1.pan]={min:-500,max:500,def:0};l9[v1.delayModLFO]={min:-12e3,max:5e3,def:-12e3};l9[v1.freqModLFO]={min:-16e3,max:4500,def:0};l9[v1.delayVibLFO]={min:-12e3,max:5e3,def:-12e3};l9[v1.freqVibLFO]={min:-16e3,max:4500,def:0};l9[v1.delayModEnv]={min:-32768,max:5e3,def:-32768};l9[v1.attackModEnv]={min:-32768,max:8e3,def:-32768};l9[v1.holdModEnv]={min:-12e3,max:5e3,def:-12e3};l9[v1.decayModEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.sustainModEnv]={min:0,max:1e3,def:0};l9[v1.releaseModEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.keyNumToModEnvHold]={min:-1200,max:1200,def:0};l9[v1.keyNumToModEnvDecay]={min:-1200,max:1200,def:0};l9[v1.delayVolEnv]={min:-12e3,max:5e3,def:-12e3};l9[v1.attackVolEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.holdVolEnv]={min:-12e3,max:5e3,def:-12e3};l9[v1.decayVolEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.sustainVolEnv]={min:0,max:1440,def:0};l9[v1.releaseVolEnv]={min:-7200,max:8e3,def:-12e3};l9[v1.keyNumToVolEnvHold]={min:-1200,max:1200,def:0};l9[v1.keyNumToVolEnvDecay]={min:-1200,max:1200,def:0};l9[v1.startloopAddrsCoarseOffset]={min:-32768,max:32768,def:0};l9[v1.keyNum]={min:-1,max:127,def:-1};l9[v1.velocity]={min:-1,max:127,def:-1};l9[v1.initialAttenuation]={min:-250,max:1440,def:0};l9[v1.endloopAddrsCoarseOffset]={min:-32768,max:32768,def:0};l9[v1.coarseTune]={min:-120,max:120,def:0};l9[v1.fineTune]={min:-12700,max:12700,def:0};l9[v1.scaleTuning]={min:0,max:1200,def:100};l9[v1.exclusiveClass]={min:0,max:99999,def:0};l9[v1.overridingRootKey]={min:-1,max:127,def:-1};var X6=class{constructor(n=v1.INVALID,l=0){if(this.generatorType=n,l===void 0)throw new Error("No value provided.");let g=l9[n];this.generatorValue=Math.round(l),g!==void 0&&(this.generatorValue=Math.max(g.min,Math.min(g.max,this.generatorValue)))}generatorType=v1.INVALID;generatorValue=0};var NB=class extends X6{constructor(n){super();let l=n.currentIndex;this.generatorType=n[l+1]<<8|n[l],this.generatorValue=RA(n[l+2],n[l+3]),n.currentIndex+=4}};function GB(o){let n=[];for(;o.chunkData.length>o.chunkData.currentIndex;)n.push(new NB(o.chunkData));return n.length>1&&n.pop(),n}var Ft={noController:0,noteOnVelocity:2,noteOnKeyNum:3,polyPressure:10,channelPressure:13,pitchWheel:14,pitchWheelRange:16,link:127},Gn={linear:0,concave:1,convex:2,switch:3},vb=[];for(let o=0;o<4;o++)vb.push([[],[]]);var me=class o{constructor(n){n.srcEnum?(this.sourceEnum=n.srcEnum,this.modulatorDestination=n.dest,this.secondarySourceEnum=n.secSrcEnum,this.transformAmount=n.amt,this.transformType=n.transform):(this.sourceEnum=o3(n,2),this.modulatorDestination=o3(n,2),this.transformAmount=RA(n[n.currentIndex++],n[n.currentIndex++]),this.secondarySourceEnum=o3(n,2),this.transformType=o3(n,2)),this.modulatorDestination>58&&(this.modulatorDestination=v1.INVALID),this.sourcePolarity=this.sourceEnum>>9&1,this.sourceDirection=this.sourceEnum>>8&1,this.sourceUsesCC=this.sourceEnum>>7&1,this.sourceIndex=this.sourceEnum&127,this.sourceCurveType=this.sourceEnum>>10&3,this.secSrcPolarity=this.secondarySourceEnum>>9&1,this.secSrcDirection=this.secondarySourceEnum>>8&1,this.secSrcUsesCC=this.secondarySourceEnum>>7&1,this.secSrcIndex=this.secondarySourceEnum&127,this.secSrcCurveType=this.secondarySourceEnum>>10&3}currentValue=0;static copy(n){return new o({srcEnum:n.sourceEnum,secSrcEnum:n.secondarySourceEnum,transform:n.transformType,amt:n.transformAmount,dest:n.modulatorDestination})}static isIdentical(n,l){return n.sourceEnum===l.sourceEnum&&n.modulatorDestination===l.modulatorDestination&&n.secondarySourceEnum===l.secondarySourceEnum&&n.transformType===l.transformType}sumTransform(n){return new o({srcEnum:this.sourceEnum,secSrcEnum:this.secondarySourceEnum,dest:this.modulatorDestination,transform:this.transformType,amt:this.transformAmount+n.transformAmount})}debugString(){function n(u,S){return Object.keys(u).find(r0=>u[r0]===S)}let l=n(Gn,this.sourceCurveType);l+=this.sourcePolarity===0?" unipolar ":" bipolar ",l+=this.sourceDirection===0?"forwards ":"backwards ",this.sourceUsesCC?l+=n(t6,this.sourceIndex):l+=n(Ft,this.sourceIndex);let g=n(Gn,this.secSrcCurveType);return g+=this.secSrcPolarity===0?" unipolar ":" bipolar ",g+=this.secSrcCurveType===0?"forwards ":"backwards ",this.secSrcUsesCC?g+=n(t6,this.secSrcIndex):g+=n(Ft,this.secSrcIndex),`Modulator: +var EC=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,l)=>(typeof require<"u"?require:n)[l]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var J3=class extends Uint8Array{constructor(n){super(n),this.currentIndex=0}currentIndex};function vr(o){let n=o.reduce((u,S)=>u+S.length,0),l=new J3(n),g=0;for(let u of o)l.set(u,g),g+=u.length;return l}function E$(o){o=Math.floor(o);let n=Math.floor(o/60),l=Math.round(o-n*60);return{minutes:n,seconds:l,time:`${n.toString().padStart(2,"0")}:${l.toString().padStart(2,"0")}`}}function FB(o){return o.trim().replaceAll(".mid","").replaceAll(".rmi","").replaceAll("_"," ")}var _1={warn:"color: orange;",unrecognized:"color: red;",info:"color: aqua;",recognized:"color: lime",value:"color: yellow; background-color: black;"};var Ei=class{constructor(n,l,g){this.ticks=n,this.messageStatusByte=l,this.messageData=g}};var K3={noteOff:128,noteOn:144,polyPressure:160,controllerChange:176,programChange:192,channelPressure:208,pitchBend:224,systemExclusive:240,timecode:241,songPosition:242,songSelect:243,tuneRequest:246,clock:248,start:250,continue:251,stop:252,activeSensing:254,reset:255,sequenceNumber:0,text:1,copyright:2,trackName:3,instrumentName:4,lyric:5,marker:6,cuePoint:7,programName:8,midiChannelPrefix:32,midiPort:33,endOfTrack:47,setTempo:81,smpteOffset:84,timeSignature:88,keySignature:89,sequenceSpecific:127};function ey(o){let n=o&240,l=o&15,g=-1,u=o;return n>=128&&n<=224&&(g=l,u=n),{status:u,channel:g}}var t6={bankSelect:0,modulationWheel:1,breathController:2,footController:4,portamentoTime:5,dataEntryMsb:6,mainVolume:7,balance:8,pan:10,expressionController:11,effectControl1:12,effectControl2:13,generalPurposeController1:16,generalPurposeController2:17,generalPurposeController3:18,generalPurposeController4:19,lsbForControl0BankSelect:32,lsbForControl1ModulationWheel:33,lsbForControl2BreathController:34,lsbForControl4FootController:36,lsbForControl5PortamentoTime:37,lsbForControl6DataEntry:38,lsbForControl7MainVolume:39,lsbForControl8Balance:40,lsbForControl10Pan:42,lsbForControl11ExpressionController:43,lsbForControl12EffectControl1:44,lsbForControl13EffectControl2:45,sustainPedal:64,portamentoOnOff:65,sostenutoPedal:66,softPedal:67,legatoFootswitch:68,hold2Pedal:69,soundVariation:70,timbreHarmonicContent:71,releaseTime:72,attackTime:73,brightness:74,soundController6:75,soundController7:76,soundController8:77,soundController9:78,soundController10:79,generalPurposeController5:80,generalPurposeController6:81,generalPurposeController7:82,generalPurposeController8:83,portamentoControl:84,effects1Depth:91,effects2Depth:92,effects3Depth:93,effects4Depth:94,effects5Depth:95,dataIncrement:96,dataDecrement:97,NRPNLsb:98,NRPNMsb:99,RPNLsb:100,RPNMsb:101,allSoundOff:120,resetAllControllers:121,localControlOnOff:122,allNotesOff:123,omniModeOff:124,omniModeOn:125,monoModeOn:126,polyModeOn:127};var mC=class{constructor(){this.events={noteoff:{},noteon:{},pitchwheel:{},controllerchange:{},programchange:{},channelpressure:{},polypressure:{},drumchange:{},stopall:{},newchannel:{},mutechannel:{},presetlistchange:{},allcontrollerreset:{},soundfonterror:{}}}addEvent(n,l,g){this.events[n][l]=g}removeEvent(n,l){delete this.events[n][l]}callEvent(n,l){this.events[n]&&Object.values(this.events[n]).forEach(g=>g(l))}};var MB={nodesAmount:4,defaultDelay:.03,delayVariation:.01,stereoDifference:.02,oscillatorFrequency:.3,oscillatorFrequencyVariation:.05,oscillatorGain:.003},CC=class{constructor(n,l=MB){let g=n.context;this.input=new ChannelSplitterNode(g,{numberOfOutputs:2});let u=new ChannelMergerNode(g,{numberOfInputs:2}),S=[],r0=[],E0=l.oscillatorFrequency,m0=l.defaultDelay;for(let g0=0;g0 {let S=await u.arrayBuffer();l.buffer=await o.decodeAudioData(S)})}return l}var c8={noteOff:0,noteOn:1,ccChange:2,programChange:3,channelPressure:4,polyPressure:5,killNote:6,ccReset:7,setChannelVibrato:8,soundFontManager:9,stopAll:10,killNotes:11,muteChannel:12,addNewChannel:13,customcCcChange:14,debugMessage:15,systemExclusive:16,setMasterParameter:17,setDrums:18,pitchWheel:19,transpose:20,highPerformanceMode:21,lockController:22,sequencerSpecific:23,requestSynthesizerSnapshot:24,setLogLevel:25},Qm={mainVolume:0,masterPan:1,voicesCap:2,interpolationType:3},mi=-1,m$={channelProperties:0,eventCall:1,reportedCurrentTime:2,sequencerSpecific:3,synthesizerSnapshot:4,ready:5,soundfontError:6,identify:7};var kb=!1,vb=!0,TB=!1;function Y5(...o){kb&&console.info(...o)}function R4(...o){vb&&console.warn(...o)}function gn(...o){TB&&console.group(...o)}function ni(...o){TB&&console.groupCollapsed(...o)}function i4(){TB&&console.groupEnd()}var iy={chorusEnabled:!0,chorusConfig:MB,reverbEnabled:!0,reverbImpulseResponse:void 0};var ym={reloadSoundFont:0,addNewSoundFont:2,deleteSoundFont:3,rearrangeSoundFonts:4};var BC=class{constructor(n){this.soundfontList=[{id:"main",bankOffset:0}],this._port=n.worklet.port,this.synth=n}_sendToWorklet(n,l){this._port.postMessage({messageType:c8.soundFontManager,messageData:[n,l]})}async addNewSoundFont(n,l,g=0){if(this.soundfontList.find(u=>u.id===l)!==void 0)throw new Error("Cannot overwrite the existing soundfont. Use soundfontManager.delete(id) instead.");this._sendToWorklet(ym.addNewSoundFont,[n,l,g]),await new Promise(u=>this.synth.resolveWhenReady=u),this.soundfontList.push({id:l,bankOffset:g})}deleteSoundFont(n){if(this.soundfontList.length===0){R4("1 soundfont left. Aborting!");return}if(this.soundfontList.findIndex(l=>l.id===n)===-1){R4(`No soundfont with id of "${n}" found. Aborting!`);return}this._sendToWorklet(ym.deleteSoundFont,n)}rearrangeSoundFonts(n){this._sendToWorklet(ym.rearrangeSoundFonts,n),this.soundfontList.sort((l,g)=>n.indexOf(l.id)-n.indexOf(g.id))}async reloadManager(n){this._sendToWorklet(ym.reloadSoundFont,n),await new Promise(l=>this.synth.resolveWhenReady=l)}};var v1={INVALID:-1,startAddrsOffset:0,endAddrOffset:1,startloopAddrsOffset:2,endloopAddrsOffset:3,startAddrsCoarseOffset:4,modLfoToPitch:5,vibLfoToPitch:6,modEnvToPitch:7,initialFilterFc:8,initialFilterQ:9,modLfoToFilterFc:10,modEnvToFilterFc:11,endAddrsCoarseOffset:12,modLfoToVolume:13,unused1:14,chorusEffectsSend:15,reverbEffectsSend:16,pan:17,unused2:18,unused3:19,unused4:20,delayModLFO:21,freqModLFO:22,delayVibLFO:23,freqVibLFO:24,delayModEnv:25,attackModEnv:26,holdModEnv:27,decayModEnv:28,sustainModEnv:29,releaseModEnv:30,keyNumToModEnvHold:31,keyNumToModEnvDecay:32,delayVolEnv:33,attackVolEnv:34,holdVolEnv:35,decayVolEnv:36,sustainVolEnv:37,releaseVolEnv:38,keyNumToVolEnvHold:39,keyNumToVolEnvDecay:40,instrument:41,reserved1:42,keyRange:43,velRange:44,startloopAddrsCoarseOffset:45,keyNum:46,velocity:47,initialAttenuation:48,reserved2:49,endloopAddrsCoarseOffset:50,coarseTune:51,fineTune:52,sampleID:53,sampleModes:54,reserved3:55,scaleTuning:56,exclusiveClass:57,overridingRootKey:58,unused5:59,endOper:60},l9=[];l9[v1.startAddrsOffset]={min:0,max:32768,def:0};l9[v1.endAddrOffset]={min:-32768,max:32768,def:0};l9[v1.startloopAddrsOffset]={min:-32768,max:32768,def:0};l9[v1.endloopAddrsOffset]={min:-32768,max:32768,def:0};l9[v1.startAddrsCoarseOffset]={min:0,max:32768,def:0};l9[v1.modLfoToPitch]={min:-12e3,max:12e3,def:0};l9[v1.vibLfoToPitch]={min:-12e3,max:12e3,def:0};l9[v1.modEnvToPitch]={min:-12e3,max:12e3,def:0};l9[v1.initialFilterFc]={min:1500,max:13500,def:13500};l9[v1.initialFilterQ]={min:0,max:960,def:0};l9[v1.modLfoToFilterFc]={min:-12e3,max:12e3,def:0};l9[v1.modEnvToFilterFc]={min:-12e3,max:12e3,def:0};l9[v1.endAddrsCoarseOffset]={min:-32768,max:32768,def:0};l9[v1.modLfoToVolume]={min:-960,max:960,def:0};l9[v1.chorusEffectsSend]={min:0,max:1e3,def:0};l9[v1.reverbEffectsSend]={min:0,max:1e3,def:0};l9[v1.pan]={min:-500,max:500,def:0};l9[v1.delayModLFO]={min:-12e3,max:5e3,def:-12e3};l9[v1.freqModLFO]={min:-16e3,max:4500,def:0};l9[v1.delayVibLFO]={min:-12e3,max:5e3,def:-12e3};l9[v1.freqVibLFO]={min:-16e3,max:4500,def:0};l9[v1.delayModEnv]={min:-32768,max:5e3,def:-32768};l9[v1.attackModEnv]={min:-32768,max:8e3,def:-32768};l9[v1.holdModEnv]={min:-12e3,max:5e3,def:-12e3};l9[v1.decayModEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.sustainModEnv]={min:0,max:1e3,def:0};l9[v1.releaseModEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.keyNumToModEnvHold]={min:-1200,max:1200,def:0};l9[v1.keyNumToModEnvDecay]={min:-1200,max:1200,def:0};l9[v1.delayVolEnv]={min:-12e3,max:5e3,def:-12e3};l9[v1.attackVolEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.holdVolEnv]={min:-12e3,max:5e3,def:-12e3};l9[v1.decayVolEnv]={min:-12e3,max:8e3,def:-12e3};l9[v1.sustainVolEnv]={min:0,max:1440,def:0};l9[v1.releaseVolEnv]={min:-7200,max:8e3,def:-12e3};l9[v1.keyNumToVolEnvHold]={min:-1200,max:1200,def:0};l9[v1.keyNumToVolEnvDecay]={min:-1200,max:1200,def:0};l9[v1.startloopAddrsCoarseOffset]={min:-32768,max:32768,def:0};l9[v1.keyNum]={min:-1,max:127,def:-1};l9[v1.velocity]={min:-1,max:127,def:-1};l9[v1.initialAttenuation]={min:-250,max:1440,def:0};l9[v1.endloopAddrsCoarseOffset]={min:-32768,max:32768,def:0};l9[v1.coarseTune]={min:-120,max:120,def:0};l9[v1.fineTune]={min:-12700,max:12700,def:0};l9[v1.scaleTuning]={min:0,max:1200,def:100};l9[v1.exclusiveClass]={min:0,max:99999,def:0};l9[v1.overridingRootKey]={min:-1,max:127,def:-1};var W6=class{constructor(n=v1.INVALID,l=0){if(this.generatorType=n,l===void 0)throw new Error("No value provided.");let g=l9[n];this.generatorValue=Math.round(l),g!==void 0&&(this.generatorValue=Math.max(g.min,Math.min(g.max,this.generatorValue)))}generatorType=v1.INVALID;generatorValue=0};var Ft={noController:0,noteOnVelocity:2,noteOnKeyNum:3,polyPressure:10,channelPressure:13,pitchWheel:14,pitchWheelRange:16,link:127},Gn={linear:0,concave:1,convex:2,switch:3},oe=class o{constructor(n){this.sourceEnum=n.srcEnum,this.modulatorDestination=n.dest,this.secondarySourceEnum=n.secSrcEnum,this.transformAmount=n.amt,this.transformType=n.transform,this.modulatorDestination>58&&(this.modulatorDestination=v1.INVALID),this.sourcePolarity=this.sourceEnum>>9&1,this.sourceDirection=this.sourceEnum>>8&1,this.sourceUsesCC=this.sourceEnum>>7&1,this.sourceIndex=this.sourceEnum&127,this.sourceCurveType=this.sourceEnum>>10&3,this.secSrcPolarity=this.secondarySourceEnum>>9&1,this.secSrcDirection=this.secondarySourceEnum>>8&1,this.secSrcUsesCC=this.secondarySourceEnum>>7&1,this.secSrcIndex=this.secondarySourceEnum&127,this.secSrcCurveType=this.secondarySourceEnum>>10&3}currentValue=0;static copy(n){return new o({srcEnum:n.sourceEnum,secSrcEnum:n.secondarySourceEnum,transform:n.transformType,amt:n.transformAmount,dest:n.modulatorDestination})}static isIdentical(n,l){return n.sourceEnum===l.sourceEnum&&n.modulatorDestination===l.modulatorDestination&&n.secondarySourceEnum===l.secondarySourceEnum&&n.transformType===l.transformType}sumTransform(n){return new o({srcEnum:this.sourceEnum,secSrcEnum:this.secondarySourceEnum,dest:this.modulatorDestination,transform:this.transformType,amt:this.transformAmount+n.transformAmount})}debugString(){function n(u,S){return Object.keys(u).find(r0=>u[r0]===S)}let l=n(Gn,this.sourceCurveType);l+=this.sourcePolarity===0?" unipolar ":" bipolar ",l+=this.sourceDirection===0?"forwards ":"backwards ",this.sourceUsesCC?l+=n(t6,this.sourceIndex):l+=n(Ft,this.sourceIndex);let g=n(Gn,this.secSrcCurveType);return g+=this.secSrcPolarity===0?" unipolar ":" bipolar ",g+=this.secSrcCurveType===0?"forwards ":"backwards ",this.secSrcUsesCC?g+=n(t6,this.secSrcIndex):g+=n(Ft,this.secSrcIndex),`Modulator: Source: ${l} Secondary source: ${g} Destination: ${n(v1,this.modulatorDestination)} @@ -6,12 +6,12 @@ var EC=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,l)=>( Transform type: ${this.transformType} -`}};function Nn(o,n,l,g,u){return o<<10|n<<9|l<<8|g<<7|u}var UB=960,PB=Gn.concave,pC=[new me({srcEnum:Nn(PB,0,1,0,Ft.noteOnVelocity),dest:v1.initialAttenuation,amt:UB,secSrcEnum:0,transform:0}),new me({srcEnum:129,dest:v1.vibLfoToPitch,amt:50,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(PB,0,1,1,t6.mainVolume),dest:v1.initialAttenuation,amt:UB,secSrcEnum:0,transform:0}),new me({srcEnum:13,dest:v1.vibLfoToPitch,amt:50,secSrcEnum:0,transform:0}),new me({srcEnum:526,dest:v1.fineTune,amt:12700,secSrcEnum:16,transform:0}),new me({srcEnum:650,dest:v1.pan,amt:1e3,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(PB,0,1,1,t6.expressionController),dest:v1.initialAttenuation,amt:UB,secSrcEnum:0,transform:0}),new me({srcEnum:219,dest:v1.reverbEffectsSend,amt:750,secSrcEnum:0,transform:0}),new me({srcEnum:221,dest:v1.chorusEffectsSend,amt:750,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(Gn.linear,0,0,0,Ft.polyPressure),dest:v1.vibLfoToPitch,amt:50,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(Gn.linear,0,0,1,t6.effects2Depth),dest:v1.modLfoToVolume,amt:24,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(Gn.linear,1,0,1,t6.releaseTime),dest:v1.releaseVolEnv,amt:1200,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(Gn.linear,1,0,1,t6.brightness),dest:v1.initialFilterFc,amt:4e3,secSrcEnum:0,transform:0}),new me({srcEnum:Nn(Gn.linear,1,0,1,t6.timbreHarmonicContent),dest:v1.initialFilterQ,amt:250,secSrcEnum:0,transform:0})];function QC(o){let n=[];for(;o.chunkData.length>o.chunkData.currentIndex;)n.push(new me(o.chunkData));return n}var C$=128,Sb=147,LA=new Int16Array(Sb).fill(0);LA[t6.mainVolume]=12800;LA[t6.expressionController]=16256;LA[t6.pan]=8192;LA[t6.releaseTime]=8192;LA[t6.brightness]=8192;LA[t6.timbreHarmonicContent]=8192;LA[C$+Ft.pitchWheel]=8192;LA[C$+Ft.pitchWheelRange]=256;var yC={channelTuning:0,channelTransposeFine:1,modulationMultiplier:2,masterTuning:3,channelTuningSemitones:4},bb=Object.keys(yC).length,Db=new Float32Array(bb);Db[yC.modulationMultiplier]=1;var ny={velocityOverride:128};var _b="spessasynth-worklet-system",OB=350,Di=9,Rb=16;var ch=class{constructor(n,l,g=!0,u=void 0,S=ty){Y5("%cInitializing SpessaSynth synthesizer...",_1.info),this.context=n.context;let r0=u?.oneOutput===!0;this.eventHandler=new mC,this._voiceCap=OB,this._outputsAmount=Rb,this.channelsAmount=this._outputsAmount,this.resolveWhenReady=void 0,this.isReady=new Promise(g0=>this.resolveWhenReady=g0),this.channelProperties=[];for(let g0=0;g0 this.handleMessage(g0.data),this.soundfontManager=new BC(this),this._snapshotCallback=void 0,this.sequencerCallbackFunction=void 0,S.reverbEnabled&&!r0&&(this.reverbProcessor=ey(this.context,S.reverbImpulseResponse),this.reverbProcessor.connect(n),this.worklet.connect(this.reverbProcessor,0)),S.chorusEnabled&&!r0&&(this.chorusProcessor=new CC(n,S.chorusConfig),this.worklet.connect(this.chorusProcessor.input,1)),r0)this.worklet.connect(n,0);else for(let g0=2;g0 {this.channelsAmount++})}get voiceCap(){return this._voiceCap}set voiceCap(n){this._setMasterParam(Qm.voicesCap,n),this._voiceCap=n}set highPerformanceMode(n){this._highPerformanceMode=n}get highPerformanceMode(){return this._highPerformanceMode}setLogLevel(n,l,g,u){this.post({channelNumber:mi,messageType:c8.setLogLevel,messageData:[n,l,g,u]})}_setMasterParam(n,l){this.post({channelNumber:mi,messageType:c8.setMasterParameter,messageData:[n,l]})}setInterpolationType(n){this._setMasterParam(Qm.interpolationType,n)}handleMessage(n){let l=n.messageData;switch(n.messageType){case m$.channelProperties:this.channelProperties=l,this._voicesAmount=this.channelProperties.reduce((g,u)=>g+u.voicesAmount,0);break;case m$.eventCall:this.eventHandler.callEvent(l.eventName,l.eventData);break;case m$.sequencerSpecific:this.sequencerCallbackFunction&&this.sequencerCallbackFunction(l.messageType,l.messageData);break;case m$.synthesizerSnapshot:this._snapshotCallback&&this._snapshotCallback(l);break;case m$.ready:this.resolveWhenReady();break;case m$.soundfontError:R4(new Error(l)),this.eventHandler.callEvent("soundfonterror",l);break}}async getSynthesizerSnapshot(){return new Promise(n=>{this._snapshotCallback=l=>{this._snapshotCallback=void 0,n(l)},this.post({messageType:c8.requestSynthesizerSnapshot,messageData:void 0,channelNumber:mi})})}addNewChannel(n=!0){this.channelProperties.push({voicesAmount:0,pitchBend:0,pitchBendRangeSemitones:0,isMuted:!1,isDrum:!1}),n&&this.post({channelNumber:0,messageType:c8.addNewChannel,messageData:null})}setVibrato(n,l){this.post({channelNumber:n,messageType:c8.setChannelVibrato,messageData:l})}connectIndividualOutputs(n){if(n.length!==this._outputsAmount)throw new Error(`input nodes amount differs from the system's outputs amount! - Expected ${this._outputsAmount} got ${n.length}`);for(let l=0;l 127||l<0)throw new Error(`Invalid controller number: ${l}`);g=Math.floor(g),l=Math.floor(l),this.post({channelNumber:n,messageType:c8.ccChange,messageData:[l,g,u]})}resetControllers(){this.post({channelNumber:mi,messageType:c8.ccReset,messageData:void 0})}channelPressure(n,l){this.post({channelNumber:n,messageType:c8.channelPressure,messageData:l})}polyPressure(n,l,g){this.post({channelNumber:n,messageType:c8.polyPressure,messageData:[l,g]})}post(n){this.worklet.port.postMessage(n)}pitchWheel(n,l,g){this.post({channelNumber:n,messageType:c8.pitchWheel,messageData:[l,g]})}transpose(n){this.transposeChannel(mi,n,!1)}transposeChannel(n,l,g=!1){this.post({channelNumber:n,messageType:c8.transpose,messageData:[l,g]})}setMainVolume(n){this._setMasterParam(Qm.mainVolume,n)}setMasterPan(n){this._setMasterParam(Qm.masterPan,n)}setPitchBendRange(n,l){this.controllerChange(n,t6.RPNMsb,0),this.controllerChange(n,t6.dataEntryMsb,l),this.controllerChange(n,t6.RPNMsb,127),this.controllerChange(n,t6.RPNLsb,127),this.controllerChange(n,t6.dataEntryMsb,0)}programChange(n,l,g=!1){this.post({channelNumber:n,messageType:c8.programChange,messageData:[l,g]})}velocityOverride(n,l){this.post({channelNumber:n,messageType:c8.ccChange,messageData:[ny.velocityOverride,l,!0]})}lockController(n,l,g){this.post({channelNumber:n,messageType:c8.lockController,messageData:[l,g]})}muteChannel(n,l){this.post({channelNumber:n,messageType:c8.muteChannel,messageData:l})}async reloadSoundFont(n){R4("reloadSoundFont is deprecated. Please use the soundfontManager property instead."),await this.soundfontManager.reloadManager(n)}systemExclusive(n){this.post({channelNumber:mi,messageType:c8.systemExclusive,messageData:Array.from(n)})}setDrums(n,l){this.post({channelNumber:n,messageType:c8.setDrums,messageData:l})}sendMessage(n){let l=XQ(n[0]);switch(l.status){case K3.noteOn:let g=n[2];g>0?this.noteOn(l.channel,n[1],g):this.noteOff(l.channel,n[1]);break;case K3.noteOff:this.noteOff(l.channel,n[1]);break;case K3.pitchBend:this.pitchWheel(l.channel,n[2],n[1]);break;case K3.controllerChange:this.controllerChange(l.channel,n[1],n[2]);break;case K3.programChange:this.programChange(l.channel,n[1]);break;case K3.polyPressure:this.polyPressure(l.channel,n[0],n[1]);break;case K3.channelPressure:this.channelPressure(l.channel,n[1]);break;case K3.systemExclusive:this.systemExclusive(new J3(n.slice(1)));break;case K3.reset:this.stopAll(!0),this.resetControllers();break;default:break}}get currentTime(){return this.context.currentTime}get voicesAmount(){return this._voicesAmount}reverbateEverythingBecauseWhyNot(){for(let n=0;n {this.pressedKeys.delete(g),this.releaseNote(g,this.channel),this.synth.noteOff(this.channel,g)},n=(g,u)=>{let S;if(Sr)S=127;else{let E0=this.keys[0].getBoundingClientRect();if(this.keyboard.classList.contains("sideways")){let m0=u.clientX-E0.left,g0=E0.width;S=Math.floor((g0-m0)/g0*127)}else{let m0=u.clientY-E0.top,g0=E0.height;S=Math.floor(m0/g0*127)}}this.synth.noteOn(this.channel,g,S,this.enableDebugging)},l=g=>{let u=g.touches?Array.from(g.touches):[g],S=new Set;u.forEach(r0=>{let E0=document.elementFromPoint(r0.clientX,r0.clientY),m0=parseInt(E0.id.replace("note",""));S.add(m0),!(isNaN(m0)||m0<0||this.pressedKeys.has(m0))&&(this.pressedKeys.add(m0),n(m0,r0))}),this.pressedKeys.forEach(r0=>{S.has(r0)||o(r0)})};Sr||(document.addEventListener("mousedown",g=>{this.mouseHeld=!0,l(g)}),document.addEventListener("mouseup",()=>{this.mouseHeld=!1,this.pressedKeys.forEach(g=>{o(g)})}),this.keyboard.onmousemove=g=>{this.mouseHeld&&l(g)},this.keyboard.onmouseleave=()=>{this.pressedKeys.forEach(g=>{o(g)})}),this.keyboard.ontouchstart=l.bind(this),this.keyboard.ontouchend=l.bind(this),this.keyboard.ontouchmove=l.bind(this)}var sy=20,wm=class{constructor(n,l){this.mouseHeld=!1,this.pressedKeys=new Set,this.mode="light",this.enableDebugging=!1,this.sizeChangeAnimationId=-1,this.modeChangeAnimationId=-1,this._keyRange={min:0,max:127},document.addEventListener("keydown",g=>{g.key==="Shift"&&(this.synth.controllerChange(this.channel,t6.sustainPedal,127),this.keyboard.style.filter="brightness(0.5)")}),document.addEventListener("keyup",g=>{g.key==="Shift"&&(this.synth.controllerChange(this.channel,t6.sustainPedal,0),this.keyboard.style.filter="")}),this.synth=l,this.channel=0,this.channelColors=n,this._shown=!0,this._createKeyboard(),this.synth.eventHandler.addEvent("noteon","keyboard-note-on",g=>{this.pressNote(g.midiNote,g.channel,g.velocity)}),this.synth.eventHandler.addEvent("noteoff","keyboard-note-off",g=>{this.releaseNote(g.midiNote,g.channel)}),this.synth.eventHandler.addEvent("stopall","keyboard-stop-all",()=>{this.clearNotes()}),this.synth.eventHandler.addEvent("mutechannel","keyboard-mute-channel",g=>{if(g.isMuted)for(let u=0;u<128;u++)this.releaseNote(u,g.channel)})}set shown(n){n===!0?this.keyboard.style.display="":this.keyboard.style.display="none",this._shown=n}get shown(){return this._shown}_createKeyboard(){this.keyboard=document.getElementById("keyboard"),this.keyboard.innerHTML="",this.keys=[],this.keyColors=[];for(let n=this._keyRange.min;n =0&&(S=l(n-1)),n<127&&(r0=l(n+1)),r0&&S?g.classList.add("between_sharps"):S?g.classList.add("left_sharp"):r0&&g.classList.add("right_sharp")}return g}toggleMode(n=!0){if(this.mode==="light"?this.mode="dark":this.mode="light",!n){this.keys.forEach(g=>{g.classList.contains("flat_key")&&g.classList.toggle("flat_dark_key")});return}this.modeChangeAnimationId&&clearTimeout(this.modeChangeAnimationId),this.keyboard.classList.add("mode_transform"),document.body.scrollHeight<=window.innerHeight&&document.body.classList.add("no_scroll"),this.modeChangeAnimationId=setTimeout(()=>{this.keys.forEach(g=>{g.classList.contains("flat_key")&&g.classList.toggle("flat_dark_key")}),this.keyboard.classList.remove("mode_transform"),setTimeout(()=>document.body.classList.remove("no_scroll"),500)},500)}get keyRange(){return this._keyRange}set keyRange(n){if(n.max===void 0||n.min===void 0)throw new TypeError("No min or max property!");if(n.min>n.max){let l=n.min;n.min=n.max,n.max=l}n.min=Math.max(0,n.min),n.max=Math.min(127,n.max),this.setKeyRange(n,!0)}setKeyRange(n,l=!0){Math.abs(n.max-n.min)<12&&(n.min-=6,n.max=n.min+12);let u=900/(n.max-n.min+5),S=document.styleSheets[0].cssRules,r0;for(let E0 of S)if(E0.selectorText==="#keyboard .key"){r0=E0;break}if(r0.style.setProperty("--pressed-transform-skew",`${8e-4/(u/7)}`),l){this.sizeChangeAnimationId&&clearTimeout(this.sizeChangeAnimationId);let E0=getComputedStyle(this.keyboard),m0=parseFloat(E0.getPropertyValue("--current-min-height").replace(/[^\d.]+/g,"")),g0=this.keyboard.getBoundingClientRect().height,u1=u/m0,R=g0*u1-g0,X0=(this._keyRange.min+this._keyRange.max)/2,F0=(n.min+n.max)/2;this._keyRange=n;let b1=this.keys.find(Y2=>Y2.classList.contains("sharp_key")).getBoundingClientRect().width,l2=(X0-F0)*b1,y1=parseFloat(E0.getPropertyValue("--key-border-radius").replace(/[^\d.]+/g,""));this.keyboard.style.marginTop=`${R}px`,this.keyboard.style.transition="",this.keyboard.style.transform=`scale(${u1}) translateX(${l2}px)`,this.keyboard.style.setProperty("--key-border-radius",`${y1/u1}vmin`),this.sizeChangeAnimationId=setTimeout(()=>{this.keyboard.style.setProperty("--current-min-height",`${u}`),this.keyboard.style.transition="none",this.keyboard.style.transform="",this.keyboard.style.marginTop="",this.keyboard.style.setProperty("--key-border-radius",""),this._createKeyboard(),setTimeout(()=>this.keyboard.style.transition="",75)},500)}else this.keyboard.style.setProperty("--current-min-height",`${u}`),this._keyRange=n,this._createKeyboard()}selectChannel(n){this.channel=n}pressNote(n,l,g){let u=this.keys[n-this._keyRange.min];if(u===void 0)return;u.classList.add("pressed");let S=u.classList.contains("sharp_key"),r0=g/127,E0=this.channelColors[l%16].match(/\d+(\.\d+)?/g).map(parseFloat),m0;if(!S&&this.mode==="light"?m0=`rgba(${E0.slice(0,3).map(u1=>255-(255-u1)*r0).join(", ")}, ${E0[3]})`:m0=`rgba(${E0.slice(0,3).map(u1=>u1*r0).join(", ")}, ${E0[3]})`,u.style.background=m0,this.mode==="dark"){let g0=sy*r0;u.style.boxShadow=`${m0} 0px 0px ${g0}px ${g0/5}px`}this.keyColors[n-this._keyRange.min].push(this.channelColors[l%16])}releaseNote(n,l){let g=this.keys[n-this._keyRange.min];if(g===void 0)return;l%=this.channelColors.length;let u=this.keyColors[n-this._keyRange.min];if(!u)return;let S=u.findLastIndex(r0=>r0===this.channelColors[l]);S!==-1&&(u.splice(S,1),g.style.background=u[u.length-1],this.mode==="dark"&&(g.style.boxShadow=`0px 0px ${sy}px ${u[u.length-1]}`),u.length<1&&(g.classList.remove("pressed"),g.style.background="",g.style.boxShadow=""))}clearNotes(){this.keys.forEach((n,l)=>{n.classList.remove("pressed"),n.style.background="",n.style.boxShadow="",this.keyColors[l]=[]})}};wm.prototype._handlePointers=ry;function B$(o,n){let l=o.replace(/[^\d,]/g,"").split(",");return`rgb(${n(parseInt(l[0]))}, ${n(parseInt(l[1]))}, ${n(parseInt(l[2]))})`}var Lb="#000";function oy(o,n,l){o.forEach(g=>{if(g.pressedProgress===0)return;n.fillStyle=g.color;let u=g.pressedProgress*g.velocity;if(n.globalAlpha=.5*u,l){n.fillRect(g.xPos,g.yPos-g.height*u,g.width,g.height*(u*2+1)),n.globalAlpha=1;return}n.fillRect(g.xPos-g.width*u,g.yPos,g.width*(u*2+1),g.height),n.globalAlpha=1}),o.forEach(g=>{n.fillStyle=g.color,n.save(),n.translate(g.xPos,g.yPos),n.fillRect(0,0,g.width,g.height),n.restore(),n.strokeStyle=Lb,n.lineWidth=g.stroke,n.strokeRect(g.xPos,g.yPos,g.width,g.height)})}var HB=!1;function Ay(o=!0,n=!1){let l=(this.seq===void 0||this?.seq?.paused===!0)&&this.synth.voicesAmount===0&&!n;if(!this.renderBool||l)if(HB){o&&requestAnimationFrame(this.render.bind(this));return}else HB=!0;else HB=!1;if(o&&this.drawingContext.clearRect(0,0,this.canvas.width,this.canvas.height),this.renderAnalysers&&!this.synth.highPerformanceMode&&this.renderWaveforms(),this.renderNotes&&this.noteTimes){let S=this.computeNotePositions(this.synth.highPerformanceMode);this.synth.highPerformanceMode||oy(S,this.drawingContext,this.sideways)}let g=performance.now()-this.frameTimeStart;this.frameTimeStart=performance.now();let u=1e3/g;this.drawingContext.textBaseline="hanging",this.drawingContext.textAlign="end",this.drawingContext.font=`${wC}px system-ui`,this.drawingContext.fillStyle="white",this.drawingContext.strokeStyle="white",this.drawingContext.fillText(`${this.notesOnScreen} notes`,this.canvas.width,wC*2+5),this.drawingContext.fillText(this.version,this.canvas.width,5),this.drawingContext.fillText(Math.round(u).toString()+" FPS",this.canvas.width,wC+5),this.onRender&&this.onRender(),o&&requestAnimationFrame(this.render.bind(this))}function ay(o=!1){this.notesOnScreen=0;let n=this.sideways?this.canvas.height:this.canvas.width,l=this.sideways?this.canvas.width:this.canvas.height,g=this.keyRange.max-this.keyRange.min,u=n/(g+1),S=u-Q$*2,r0=this.noteFallingTimeMs/1e3,E0=this.noteAfterTriggerTimeMs/1e3,m0=this.seq.currentHighResolutionTime,g0=m0-E0,u1=r0+E0,R=g0+u1,X0=ly/u1,F0=[];this.synth.channelProperties.forEach(l2=>{if(this.showVisualPitch){let y1=l2.pitchBend-8192+this.visualPitchBendOffset;F0.push(l2.pitchBendRangeSemitones*(y1/8192*u))}else F0.push(0)});let b1=[];return this.noteTimes.forEach((l2,y1)=>{if(l2.renderStartIndex>=l2.notes.length||!this.renderChannels[y1])return;let Y2=l2.renderStartIndex,T2=l2.notes,K2=T2[Y2],i3=-1;for(;K2.start<=R&&(Y2++,!(this.notesOnScreen>cy));){let n3=K2.start+K2.length;if(n3>g0&&K2.length>0){let A0=K2.length/u1*l-Q$*2;if(this.notesOnScreen<1e3||A0>X0){i3===-1&&(i3=Y2-1);let y5=(K2.start-g0)/u1*l,M3;if(this._notesFall?M3=l-A0-y5+Q$:M3=y5+Q$,K2.midiNote this.keyRange.max){if(Y2>=T2.length)break;K2=T2[Y2];continue}let $3=K2.midiNote-this.keyRange.min,w6=u*$3+Q$,s6,o9,K4,n4;if(this.sideways?(s6=M3,o9=w6,n4=S,K4=A0):(o9=M3,s6=w6,K4=S,n4=A0),this.notesOnScreen++,o)this.drawingContext.fillStyle=this.plainColors[y1],this.drawingContext.fillRect(s6+p$+Q$,o9+p$,K4-p$*2,n4-p$*2);else{let K6;if(K2.start>m0||n3 =T2.length)break;K2=T2[Y2]}i3>-1&&(l2.renderStartIndex=i3)}),b1.sort((l2,y1)=>y1.height-l2.height),b1}function gy(){let o=this.canvas.width/4,n=this.canvas.height/4;this.channelAnalysers.forEach((l,g)=>{let u=g%4,S=Math.floor(g/4),r0=!1;for(let R=g;R 0){r0=!0;break}if(!r0){let R=this.canvas.width/4,X0=this.canvas.height/4,F0=R*u,b1=X0*S+X0/2;this.drawingContext.lineWidth=this.lineThickness,this.drawingContext.strokeStyle=this.channelColors[g],this.drawingContext.beginPath(),this.drawingContext.moveTo(F0,b1),this.drawingContext.lineTo(F0+R,b1),this.drawingContext.stroke();return}let E0=new Float32Array(l.frequencyBinCount);l.getFloatTimeDomainData(E0);let m0=o*u,g0=n*S+n/2,u1=this.waveMultiplier*n;if(this.drawingContext.lineWidth=this.lineThickness,this.drawingContext.strokeStyle=this.channelColors[g],this.drawingContext.beginPath(),this._stabilizeWaveforms){let R=E0.length/4,X0=o/R,F0=Math.floor(R/2),b1=E0.length-F0;for(let T2=b1;T2>=1;T2--)if(E0[T2-1]<0&&E0[T2]>=0){b1=T2;break}let l2=m0,y1=b1-F0,Y2=b1+F0;for(let T2=y1;T2 {this.renderChannels[n.channel]=!n.isMuted}),this.updateFftSize()}function uy(){for(let o=0;o 4096?this.delayNode.delayTime.value=u/this.synth.context.sampleRate/2:this.delayNode.delayTime.value=0)}}function dy(o){o.connectIndividualOutputs(this.channelAnalysers),o.eventHandler.addEvent("drumchange","renderer-drum-change",()=>{this.updateFftSize()})}function Iy(){for(let o of this.channelAnalysers)o.disconnect();Y5("%cAnalysers disconnected!",_1.recognized)}function Ey(o){this.seq=o,this.seq.addOnTimeChangeEvent(()=>this.resetIndexes(),"renderer-time-change"),this.seq.addOnSongChangeEvent(async n=>{if(this.calculateNoteTimes(await this.seq.getMIDI()),this.resetIndexes(),n.RMIDInfo?.IPIC!==void 0){let l=new Blob([n.RMIDInfo?.IPIC.buffer]),g=URL.createObjectURL(l),u=this.canvas.classList.contains("light_mode")?0:.9;this.canvas.style.background=`linear-gradient(rgba(0, 0, 0, ${u}), rgba(0, 0, 0, ${u})), center center / cover url("${g}")`}else this.canvas.style.background=""},"renderer-song-change")}function my(){this.noteTimes&&this.noteTimes.forEach(o=>o.renderStartIndex=0)}function qB(o,n){let l=0;for(let g=8*(n-1);g>=0;g-=8)l|=o[o.currentIndex++]< >>0}function km(o,n){let l=new Array(n).fill(0);for(let g=n-1;g>=0;g--)l[g]=o&255,o>>=8;return l}var gh=.02;function Cy(o){function n(g0){return g0.messageData=new J3(g0.messageData.buffer),g0.messageData.currentIndex=0,6e7/qB(g0.messageData,3)}let l=[],u=o.tracks.flat();u.sort((g0,u1)=>g0.ticks-u1.ticks);for(let g0=0;g0<16;g0++)l.push({renderStartIndex:0,notes:[]});let S=0,r0=60/(120*o.timeDivision),E0=0,m0=0;for(;E0 >4,R=g0.messageStatusByte&15;if(u1===8){let X0=l[R].notes.findLast(F0=>F0.midiNote===g0.messageData[0]&&F0.length===-1);if(X0){let F0=S-X0.start;X0.length=F0 F0.midiNote===g0.messageData[0]&&F0.length===-1);if(X0){let F0=S-X0.start;X0.length=F0 =u.length)break;S+=r0*(u[E0].ticks-g0.ticks)}m0>0&&l.forEach((g0,u1)=>g0.notes.filter(R=>R.length===-1).forEach(R=>{let X0=S-R.start;R.length=X0 {let l=this.drawingContext.createLinearGradient(0,0,this.canvas.width/128,0);return l.addColorStop(0,B$(n,g=>g*vC)),l.addColorStop(1,n),l}),this.darkerColors=this.plainColors.map(n=>{let l=this.drawingContext.createLinearGradient(0,0,this.canvas.width/128,0);return l.addColorStop(0,B$(n,g=>g*vC*kC)),l.addColorStop(1,B$(n,g=>g*kC)),l}),this.sidewaysChannelColors=this.plainColors.map(n=>{let l=this.drawingContext.createLinearGradient(0,0,0,this.canvas.width/128);return l.addColorStop(0,B$(n,g=>g*vC)),l.addColorStop(1,n),l}),this.sidewaysDarkerColors=this.plainColors.map(n=>{let l=this.drawingContext.createLinearGradient(0,0,0,this.canvas.width/128);return l.addColorStop(0,B$(n,g=>g*vC*kC)),l.addColorStop(1,B$(n,g=>g*kC)),l})}toggleDarkMode(){this.canvas.classList.toggle("light_mode")}onRender;get normalAnalyserFft(){return this._normalAnalyserFft}set normalAnalyserFft(n){this._normalAnalyserFft=n,this.updateFftSize()}get drumAnalyserFft(){return this._drumAnalyserFft}set drumAnalyserFft(n){this._drumAnalyserFft=n,this.updateFftSize()}get renderBool(){return this._renderBool}set renderBool(n){this._renderBool=n,n===!0?this.connectChannelAnalysers(this.synth):this.disconnectChannelAnalysers()}get keyRange(){return this._keyRange}set keyRange(n){if(n.max===void 0||n.min===void 0)throw new TypeError("No min or max property!");if(n.min>n.max){let l=n.min;n.min=n.max,n.max=l}n.min=Math.max(0,n.min),n.max=Math.min(127,n.max),this._keyRange=n}};_i.prototype.render=Ay;_i.prototype.computeNotePositions=ay;_i.prototype.createChannelAnalysers=fy;_i.prototype.updateFftSize=uy;_i.prototype.connectChannelAnalysers=dy;_i.prototype.disconnectChannelAnalysers=Iy;_i.prototype.connectSequencer=Ey;_i.prototype.calculateNoteTimes=Cy;_i.prototype.resetIndexes=my;_i.prototype.renderWaveforms=gy;function SC(o){let n=[o&127];for(o>>=7;o>0;)n.unshift(o&127|128),o>>=7;return n}function bC(o){let n=[];for(let u of o.tracks){let S=[],r0=0,E0;for(let m0 of u){let g0=m0.ticks-r0,u1;m0.messageStatusByte<=K3.keySignature||m0.messageStatusByte===K3.sequenceSpecific?u1=[255,m0.messageStatusByte,...SC(m0.messageData.length),...m0.messageData]:m0.messageStatusByte===K3.systemExclusive?u1=[240,...SC(m0.messageData.length),...m0.messageData]:(u1=[],E0!==m0.messageStatusByte&&(E0=m0.messageStatusByte,u1.push(m0.messageStatusByte)),u1.push(...m0.messageData)),S.push(...SC(g0)),S.push(...u1),r0+=g0}n.push(new Uint8Array(S))}function l(u,S){for(let r0=0;r0 {o.tracks.forEach((b1,l2)=>{if(o.midiPorts[l2]===F0)for(let y1=b1.length-1;y1>=0;y1--)b1[y1].messageStatusByte>=128&&b1[y1].messageStatusByte<240&&(b1[y1].messageStatusByte&15)===X0&&b1.splice(y1,1)})};g.forEach(X0=>{let F0=X0%16,b1=X0-F0,l2=o.midiPortChannelOffsets.findIndex(y1=>y1===b1);S(F0,l2),Y5(`%cRemoving channel %c${X0}%c!`,_1.info,_1.recognized,_1.info)});let r0=!1,E0="gs",m0=[],g0=[];o.tracks.forEach((X0,F0)=>{X0.forEach(b1=>{let l2=b1.messageStatusByte&240;l2===K3.controllerChange?m0.push({track:F0,message:b1,channel:b1.messageStatusByte&15}):l2===K3.programChange?g0.push({track:F0,message:b1,channel:b1.messageStatusByte&15}):b1.messageStatusByte===K3.systemExclusive&&(b1.messageData[0]===67&&b1.messageData[2]===76&&b1.messageData[5]===126&&b1.messageData[6]===0?(Y5("%cXG system on detected",_1.info),E0="xg",r0=!0):b1.messageData[0]===67&&b1.messageData[2]===76&&b1.messageData[3]===8&&b1.messageData[5]===3&&g0.push({track:F0,message:b1,channel:b1.messageData[4]}))})});let u1=(X0,F0,b1)=>o.tracks.reduce((l2,y1,Y2)=>{if(o.usedChannelsOnTrack[Y2].has(X0)&&o.midiPorts[Y2]===F0){let T2;b1?T2=y1.findIndex(K2=>(K2.messageStatusByte&240)===K3.noteOn):T2=y1.findIndex(K2=>K2.messageStatusByte>128&&K2.messageStatusByte<240&&(K2.messageStatusByte&15)===X0&&!(K2.messageStatusByte&K3.controllerChange===240&&(K2.messageData[0]===t6.resetAllControllers||K2.messageData[0]===t6.allNotesOff||K2.messageData[0]===t6.allSoundOff))),T2!==-1&&l2.push({index:T2,track:Y2})}return l2},[]),R=(X0,F0,b1)=>{let l2=m0.filter(y1=>y1.channel===X0&&y1.message.messageData[0]===b1&&o.midiPorts[y1.track]===F0);for(let y1=0;y1 {let F0=X0.channel,b1=F0%16,l2=F0-b1,y1=o.midiPortChannelOffsets.findIndex(A0=>A0===l2),Y2=X0.controllerValue,T2=X0.controllerNumber;R(b1,y1,T2),Y5(`%cNo controller %c${T2}%c on channel %c${F0}%c found. Adding it!`,_1.info,_1.unrecognized,_1.info,_1.value,_1.info);let K2=u1(b1,y1,!0);if(K2.length===0){R4("Program change but no notes... ignoring!");return}let i3=K2.reduce((A0,y5)=>o.tracks[y5.track][y5.index].ticks {let F0=X0.channel%16,b1=X0.channel-F0,l2=o.midiPortChannelOffsets.findIndex($3=>$3===b1),y1=X0.isDrum?0:X0.bank,Y2=X0.program,T2=g0.filter($3=>o.midiPorts[$3.track]===l2&&$3.channel===F0);if(R(F0,l2,t6.bankSelect),R(F0,l2,t6.lsbForControl0BankSelect),(X0.isDrum||y1>0)&&!r0&&(o.tracks.forEach($3=>{for(let w6=0;w6<$3.length;w6++){let s6=$3[w6];if(s6.messageStatusByte===K3.systemExclusive)if(s6.messageData[0]===65&&s6.messageData[2]===66&&s6.messageData[6]===127){r0=!0,Y5("%cGS on detected!",_1.recognized);break}else s6.messageData[0]===126&&s6.messageData[2]===9&&(Y5("%cGM/2 on detected, removing!",_1.info),$3.splice(w6,1),w6--)}}),!r0)){let $3=0;o.tracks[0][0].messageStatusByte===K3.trackName&&$3++,o.tracks[0].splice($3,0,YB(0)),Y5("%cGS on not detected. Adding it.",_1.info),r0=!0}for(let $3 of T2)o.tracks[$3.track].splice(o.tracks[$3.track].indexOf($3.message),1);let K2=u1(F0,l2,b1>0);if(K2.length===0){R4("Program change but no notes... ignoring!");return}let i3=K2.reduce(($3,w6)=>o.tracks[w6.track][w6.index].ticks {if(o.midiPorts[T2]!==b1||!o.usedChannelsOnTrack[T2].has(F0))return;let K2=K3.noteOn|F0,i3=K3.noteOff|F0,n3=K3.polyPressure|F0;Y2.forEach(A0=>{A0.messageStatusByte!==K2&&A0.messageStatusByte!==i3&&A0.messageStatusByte!==n3||(A0.messageData[0]=Math.max(0,Math.min(127,A0.messageData[0]+l2)))})}),y1!==0){let Y2=o.tracks.find((s6,o9)=>o.usedChannelsOnTrack[o9].has(X0.channel));if(Y2===void 0){R4(`Channel ${X0.channel} unused but transpose requested???`);continue}let T2=K3.noteOn|X0.channel%16,K2=Y2.findIndex(s6=>s6.messageStatusByte===T2);if(K2===-1){R4(`No notes on channel ${X0.channel} but transpose requested???`);continue}let i3=Y2[K2].ticks,n3=y1*64+64,A0=K3.controllerChange|X0.channel%16,y5=new Ei(i3,A0,new J3([t6.RPNMsb,0])),M3=new Ei(i3,A0,new J3([t6.RPNLsb,1])),$3=new Ei(i3,A0,new J3([t6.dataEntryMsb,n3])),w6=new Ei(i3,A0,new J3([t6.lsbForControl6DataEntry,0]));Y2.splice(K2,0,w6),Y2.splice(K2,0,$3),Y2.splice(K2,0,M3),Y2.splice(K2,0,y5)}}i4()}function hh(o,n){let l=[],g=[],u=[],S=[];n.channelSnapshots.forEach((r0,E0)=>{if(r0.isMuted){g.push(E0);return}let m0=r0.channelTransposeKeyShift+r0.customControllers[yC.channelTransposeFine]/100;m0!==0&&l.push({channel:E0,keyShift:m0}),r0.lockPreset&&u.push({channel:E0,program:r0.program,bank:r0.bank,isDrum:r0.drumChannel}),r0.lockedControllers.forEach((g0,u1)=>{if(!g0||u1>127||u1===t6.bankSelect)return;let R=r0.midiControllers[u1]>>7;S.push({channel:E0,controllerNumber:u1,controllerValue:R})})}),Ub(o,u,S,g,l)}var Mt={name:"INAM",album:"IPRD",artist:"IART",genre:"IGNR",picture:"IPIC",copyright:"ICOP",creationDate:"ICRD",comment:"ICMT",engineer:"IENG",software:"ISFT",encoding:"IENC",midiEncoding:"MENC",bankOffset:"DBNK"},FA="utf-8",Pb="Created using SpessaSynth";function py(o,n,l,g=0,u="Shift_JIS",S={},r0=!0){if(gn("%cWriting the RMIDI File...",_1.info),Y5(`%cConfiguration: Bank offset: %c${g}%c, encoding: %c${u}`,_1.info,_1.value,_1.info,_1.value),Y5("metadata",S),Y5("Initial bank offset",n.bankOffset),r0){let Y2=function(){let n3=0,A0=1/0;return n.tracks.forEach((y5,M3)=>{l2[M3]>=y5.length||y5[l2[M3]].ticks A0>n3?A0:n3),i3=[];for(let n3=0;n3 0;){let n3=Y2(),A0=n.tracks[n3];if(l2[n3]>=A0.length){y1--;continue}let y5=A0[l2[n3]];l2[n3]++;let M3=n.midiPortChannelOffsets[T2[n3]];if(y5.messageStatusByte===K3.midiPort){T2[n3]=y5.messageData[0];continue}let $3=y5.messageStatusByte&240;if($3!==K3.controllerChange&&$3!==K3.programChange&&$3!==K3.systemExclusive)continue;if($3===K3.systemExclusive){if(y5.messageData[0]!==65||y5.messageData[2]!==66||y5.messageData[3]!==18||y5.messageData[4]!==64||!(y5.messageData[5]&16)||y5.messageData[6]!==21){y5.messageData[0]===67&&y5.messageData[2]===76&&y5.messageData[5]===126&&y5.messageData[6]===0?F0="xg":y5.messageData[0]===65&&y5.messageData[2]===66&&y5.messageData[6]===127?F0="gs":y5.messageData[0]===126&&y5.messageData[2]===9&&(F0="gm",b1.push({tNum:n3,e:y5}));continue}let o9=[9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15][y5.messageData[5]&15]+M3;i3[o9].drums=!!(y5.messageData[7]>0&&y5.messageData[5]>>4);continue}let w6=(y5.messageStatusByte&15)+M3,s6=i3[w6];if($3===K3.programChange){s6.drums?l.presets.findIndex(n4=>n4.program===y5.messageData[0]&&n4.bank===128)===-1&&(y5.messageData[0]=l.presets.find(n4=>n4.bank===128)?.program||0):l.presets.findIndex(n4=>n4.program===y5.messageData[0]&&n4.bank!==128)===-1&&(y5.messageData[0]=l.presets.find(n4=>n4.bank!==128)?.program||0),s6.program=y5.messageData[0];let o9=Math.max(0,s6.lastBank?.messageData[1]-n.bankOffset),K4=s6.drums?128:o9;if(s6.lastBank===void 0)continue;if(F0==="xg"&&s6.drums&&(i3[w6].lastBank.messageData[1]=127),l.presets.findIndex(n4=>n4.bank===K4&&n4.program===y5.messageData[0])===-1){let n4=l.presets.find(K6=>K6.program===y5.messageData[0])?.bank+g||g;s6.lastBank.messageData[1]=n4,Y5(`%cNo preset %c${K4}:${y5.messageData[0]}%c. Changing bank to ${n4}.`,_1.info,_1.recognized,_1.info)}else{let K6=(K4===128?F0==="xg"?127:0:o9)+g;s6.lastBank.messageData[1]=K6,Y5(`%cPreset %c${K4}:${y5.messageData[0]}%c exists. Changing bank to ${K6}.`,_1.info,_1.recognized,_1.info)}continue}y5.messageData[0]===t6.bankSelect&&(s6.hasBankSelect=!0,F0==="xg"&&(s6.drums=y5.messageData[1]===120||y5.messageData[1]===126||y5.messageData[1]===127),s6.lastBank=y5)}if(i3.forEach((n3,A0)=>{if(n3.hasBankSelect===!0)return;let y5=A0%16,M3=K3.programChange|y5,$3=Math.floor(A0/16)*16,w6=n.midiPortChannelOffsets.indexOf($3),s6=n.tracks.find((K6,We)=>n.midiPorts[We]===w6&&n.usedChannelsOnTrack[We].has(y5));if(s6===void 0)return;let o9=s6.findIndex(K6=>K6.messageStatusByte===M3);if(o9===-1){let K6=s6.findIndex(Ji=>Ji.messageStatusByte>128&&Ji.messageStatusByte<240&&(Ji.messageStatusByte&15)===y5);if(K6===-1)return;let We=s6[K6].ticks,On=l.getPreset(0,0).program;s6.splice(K6,0,new Ei(We,K3.programChange|y5,new J3([On]))),o9=K6}Y5(`%cAdding bank select for %c${A0}`,_1.info,_1.recognized);let K4=s6[o9].ticks,n4=l.getPreset(0,n3.program)?.bank+g||g;s6.splice(o9,0,new Ei(K4,K3.controllerChange|y5,new J3([t6.bankSelect,n4])))}),F0!=="gs"&&F0!=="xg"){for(let A0 of b1)n.tracks[A0.tNum].splice(n.tracks[A0.tNum].indexOf(A0.e),1);let n3=0;n.tracks[0][0].messageStatusByte===K3.trackName&&n3++,n.tracks[0].splice(n3,0,YB(0))}}let E0=new J3(bC(n).buffer),m0=[xA("INFO")],g0=new TextEncoder;if(m0.push(Ze(Mt.software,g0.encode("SpessaSynth"),!0)),S.name!==void 0?(m0.push(Ze(Mt.name,g0.encode(S.name),!0)),u=FA):m0.push(Ze(Mt.name,n.rawMidiName,!0)),S.creationDate!==void 0)u=FA,m0.push(Ze(Mt.creationDate,g0.encode(S.creationDate),!0));else{let F0=new Date().toLocaleString(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric"});m0.push(Ze(Mt.creationDate,xA(F0),!0))}if(S.comment!==void 0&&(u=FA,m0.push(Ze(Mt.comment,g0.encode(S.comment)))),S.engineer!==void 0&&m0.push(Ze(Mt.engineer,g0.encode(S.engineer),!0)),S.album!==void 0&&(u=FA,m0.push(Ze(Mt.album,g0.encode(S.album),!0))),S.artist!==void 0&&(u=FA,m0.push(Ze(Mt.artist,g0.encode(S.artist),!0))),S.genre!==void 0&&(u=FA,m0.push(Ze(Mt.genre,g0.encode(S.genre),!0))),S.picture!==void 0&&m0.push(Ze(Mt.picture,new Uint8Array(S.picture))),S.copyright!==void 0)u=FA,m0.push(Ze(Mt.copyright,g0.encode(S.copyright),!0));else{let F0=n.copyright.length>0?n.copyright:Pb;m0.push(Ze(Mt.copyright,xA(F0)))}let u1=new J3(2);l7(u1,g,2),m0.push(Ze(Mt.bankOffset,u1)),S.midiEncoding!==void 0&&(m0.push(Ze(Mt.midiEncoding,g0.encode(S.midiEncoding))),u=FA),m0.push(Ze(Mt.encoding,xA(u)));let R=vr(m0),X0=vr([xA("RMID"),Ze("data",E0),Ze("LIST",R),o]);return Y5("%cFinished!",_1.info),i4(),Ze("RIFF",X0)}function vm(o,n){let l=0;for(;o>0;){let g=n.tempoChanges.find(S=>S.ticks =128){this.MIDIout.send(g);return}break;case MA.songChange:let u=l[0];this.songIndex=l[1],this.midiData=u,this.hasDummyData=!1,this.absoluteStartTime=0,this.duration=this.midiData.duration,Object.entries(this.onSongChange).forEach(E0=>E0[1](u)),this.unpause();break;case MA.textEvent:let S=l;this.onTextEvent&&this.onTextEvent(S[0],S[1]);break;case MA.timeChange:let r0=this.synth.currentTime-l;Object.entries(this.onTimeChange).forEach(E0=>E0[1](r0)),this.unpause(),this._recalculateStartTime(r0);break;case MA.pause:this.pausedTime=this.currentTime,this.isFinished=l,this.isFinished&&Object.entries(this.onSongEnded).forEach(E0=>E0[1]());break;case MA.midiError:if(this.onError)this.onError(l);else throw new Error(l);return;case MA.getMIDI:this._getMIDIResolve&&this._getMIDIResolve(l)}}set playbackRate(n){this._sendMessage(Ri.setPlaybackRate,n),this.highResTimeOffset*=n/this._playbackRate,this._playbackRate=n}get playbackRate(){return this._playbackRate}addOnSongChangeEvent(n,l){this.onSongChange[l]=n,n(this.midiData)}addOnSongEndedEvent(n,l){this.onSongEnded[l]=n}addOnTimeChangeEvent(n,l){this.onTimeChange[l]=n}async getMIDI(){return new Promise(n=>{this._getMIDIResolve=n,this._sendMessage(Ri.getMIDI,void 0)})}loadNewSongList(n){this.pause(),this.midiData=Qy,this.hasDummyData=!0,this.duration=99999,this._sendMessage(Ri.loadNewSongList,n),this.songIndex=0,this.songsAmount=n.length,this.songsAmount>1&&(this.loop=!1)}nextSong(){this._sendMessage(Ri.changeSong,!0)}previousSong(){this._sendMessage(Ri.changeSong,!1)}get currentTime(){return this.pausedTime?this.pausedTime:(this.synth.currentTime-this.absoluteStartTime)*this._playbackRate}_recalculateStartTime(n){this.absoluteStartTime=this.synth.currentTime-n/this._playbackRate,this.highResTimeOffset=(this.synth.currentTime-performance.now()/1e3)*this._playbackRate}get currentHighResolutionTime(){if(this.pausedTime)return this.pausedTime;let n=this.highResTimeOffset,l=this.absoluteStartTime,g=(performance.now()/1e3-l)*this._playbackRate,u=n+g,S=this.currentTime,r0=.01*this._playbackRate,E0=S-u;return this.highResTimeOffset+=E0*r0,u=this.highResTimeOffset+g,u}set currentTime(n){this.unpause(),this._sendMessage(Ri.setTime,n)}connectMidiOutput(n){this.resetMIDIOut(),this.MIDIout=n,this._sendMessage(Ri.changeMIDIMessageSending,n!==void 0),this.currentTime-=.1}pause(){if(this.paused){R4("Already paused");return}this.pausedTime=this.currentTime,this._sendMessage(Ri.pause)}unpause(){this.pausedTime=void 0,this.isFinished=!1}get paused(){return this.pausedTime!==void 0}play(n=!1){this.isFinished&&(n=!0),this._recalculateStartTime(this.pausedTime||0),this.unpause(),this._sendMessage(Ri.play,n)}stop(){this._sendMessage(Ri.stop)}midiData;onSongChange={};onTextEvent;onTimeChange={};onSongEnded={}};var Sm=["Shift_JIS","windows-1250","utf-8","utf-16","utf-16le","utf-16be","latin1","ISO-8859-1","ISO-8859-2","ISO-8859-3","ISO-8859-4","ISO-8859-5","ISO-8859-6","ISO-8859-7","ISO-8859-8","ISO-8859-9","ISO-8859-10","ISO-8859-11","ISO-8859-13","ISO-8859-14","ISO-8859-15","ISO-8859-16","windows-1251","windows-1252","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-1258","EUC-JP","ISO-2022-JP","EUC-KR","Big5","GB18030"];function yy(o){return``}function uh(o,n){let l=document.createElement("div");return l.classList.add("control_buttons"),l.title=o,l.innerHTML=n,l}var e7={synthesizerUIShow:"s",settingsShow:"r",blackMidiMode:"b",midiPanic:"backspace",playPause:" ",toggleLoop:"l",toggleLyrics:"t",seekBackwards:"arrowleft",seekForwards:"arrowright",previousSong:"[",nextSong:"]",cinematicMode:"c",videoMode:"v"};function My(){navigator.mediaSession&&(navigator.mediaSession.metadata=new MediaMetadata({title:this.currentSongTitle,artist:"SpessaSynth"}),navigator.mediaSession.setActionHandler("play",()=>{this.seqPlay()}),navigator.mediaSession.setActionHandler("pause",()=>{this.seqPause()}),navigator.mediaSession.setActionHandler("stop",()=>{this.seq.currentTime=0,this.seqPause()}),navigator.mediaSession.setActionHandler("seekbackward",o=>{this.seq.currentTime-=o.seekOffset||10}),navigator.mediaSession.setActionHandler("seekforward",o=>{this.seq.currentTime+=o.seekOffset||10}),navigator.mediaSession.setActionHandler("seekto",o=>{this.seq.currentTime=o.seekTime}),navigator.mediaSession.setActionHandler("previoustrack",()=>{this.switchToPreviousSong()}),navigator.mediaSession.setActionHandler("nexttrack",()=>{this.switchToNextSong()}),navigator.mediaSession.playbackState="playing")}function Ty(o=!0){if(this.seq?.hasDummyData===!0)this.currentSongTitle=this.locale.getLocaleString("locale.synthInit.genericLoading");else{let n=this.infoDecoder.decode(this.seq.midiData.rawMidiName.buffer).replace(/\0$/,"");this.currentSongTitle=FB(n)}if(this.seq.midiData){let n=this.seq.midiData.lyrics;this.currentLyrics=new Uint8Array(n.reduce((g,u)=>g+u.length,0));let l=0;for(let g of n)this.currentLyrics.set(g,l),l+=g.length;this.currentLyricsString=this.decodeTextFix(this.currentLyrics.buffer)||this.locale.getLocaleString("locale.sequencerController.lyrics.noLyrics"),this.setLyricsText(""),o&&(this.rawOtherTextEvents=[])}if(document.getElementById("title").innerText=this.currentSongTitle,document.title=this.currentSongTitle+" - SpessaSynth",this.musicModeUI.setTitle(this.currentSongTitle),!!navigator.mediaSession)try{navigator.mediaSession.setPositionState({duration:this.seq.duration,playbackRate:this.seq.playbackRate,position:this.seq.currentTime})}catch{}}var Hb=parseFloat(getComputedStyle(document.body).fontSize);function Ny(){this.lyricsElement={};let o=document.createElement("div");o.classList.add("lyrics");let n=document.createElement("div");n.classList.add("lyrics_title_wrapper"),o.append(n),this.lyricsElement.titleWrapper=n;let l=document.createElement("h2");this.locale.bindObjectProperty(l,"textContent","locale.sequencerController.lyrics.title"),l.classList.add("lyrics_title"),n.appendChild(l),this.lyricsElement.title=l;let g=document.createElement("select");Sm.forEach(u1=>{let R=document.createElement("option");R.innerText=u1,R.value=u1,g.appendChild(R)}),g.value=this.encoding,g.onchange=()=>this.changeEncoding(g.value),g.classList.add("lyrics_selector"),this.encodingSelector=g,n.appendChild(g);let u=document.createElement("p");u.classList.add("lyrics_text"),o.appendChild(u);let S=document.createElement("span");S.classList.add("lyrics_text_highlight"),u.appendChild(S);let r0=document.createElement("span");r0.classList.add("lyrics_text_gray"),u.appendChild(r0);let E0=document.createElement("details"),m0=document.createElement("summary");this.locale.bindObjectProperty(m0,"textContent","locale.sequencerController.lyrics.otherText.title"),E0.appendChild(m0);let g0=document.createElement("div");g0.innerText="",E0.appendChild(g0),o.appendChild(E0),this.lyricsElement.text={highlight:S,gray:r0,main:u,other:g0},this.lyricsElement.mainDiv=o,this.lyricsElement.selector=g,this.controls.appendChild(o),this.requiresTextUpdate=!0}function Gy(o){let n=this.lyricsElement.text.highlight,l=this.lyricsElement.text.gray;l.innerText=this.currentLyricsString.replace(o,""),n.innerText=o,this.lyricsElement.text.main.scrollTo(0,n.offsetHeight-Hb*5)}function Uy(){let o="";for(let n of this.rawOtherTextEvents)o+=` ${Object.keys(K3).find(l=>K3[l]===n.type).replace(/([a-z])([A-Z])/g,"$1 $2")}:${this.decodeTextFix(n.data.buffer)}
`;this.lyricsElement.text.other.innerHTML=o}var Un=32,Oy="#ccc",Py="#555",qb="#333",Yb="#ddd",Jb="Shift_JIS",Ls=class{constructor(n,l,g){this.iconColor=Oy,this.iconDisabledColor=Py,this.controls=n,this.encoding=Jb,this.decoder=new TextDecoder(this.encoding),this.infoDecoder=new TextDecoder(this.encoding),this.hasInfoDecoding=!1,this.text="",this.requiresTextUpdate=!1,this.rawLyrics=[],this.rawOtherTextEvents=[],this.mode="dark",this.locale=l,this.currentSongTitle="",this.currentLyrics=new Uint8Array(0),this.currentLyricsString="",this.musicModeUI=g}toggleDarkMode(){if(this.mode==="dark"?(this.mode="light",this.iconColor=qb,this.iconDisabledColor=Yb):(this.mode="dark",this.iconColor=Oy,this.iconDisabledColor=Py),!this.seq){this.requiresThemeUpdate=!0;return}this.progressBar.classList.toggle("note_progress_light"),this.progressBarBackground.classList.toggle("note_progress_background_light"),this.lyricsElement.mainDiv.classList.toggle("lyrics_light"),this.lyricsElement.titleWrapper.classList.toggle("lyrics_light"),this.lyricsElement.selector.classList.toggle("lyrics_light")}seqPlay(n=!0){n&&this.seq.play(),this.playPause.innerHTML=y$(Un),this.createNavigatorHandler(),this.updateTitleAndMediaStatus(),navigator.mediaSession&&(navigator.mediaSession.playbackState="playing")}seqPause(n=!0){n&&this.seq.pause(),this.playPause.innerHTML=wy(Un),this.createNavigatorHandler(),this.updateTitleAndMediaStatus(),navigator.mediaSession&&(navigator.mediaSession.playbackState="paused")}switchToNextSong(){this.seq.nextSong(),this.createNavigatorHandler(),this.updateTitleAndMediaStatus()}switchToPreviousSong(){this.seq.previousSong(),this.createNavigatorHandler(),this.updateTitleAndMediaStatus()}decodeTextFix(n,l=!1){let g=0;for(;;)try{return this.decoder.decode(n)}catch{g++,this.changeEncoding(Sm[g]),this.encodingSelector.value=Sm[g]}}connectSequencer(n){this.seq=n,this.createControls(),this.setSliderInterval(),this.createNavigatorHandler(),this.updateTitleAndMediaStatus(),this.seq.onTextEvent=(l,g)=>{let u=this.decodeTextFix(l.buffer);switch(g){default:return;case K3.text:case K3.copyright:case K3.cuePoint:case K3.trackName:case K3.instrumentName:case K3.programName:case K3.marker:this.rawOtherTextEvents.push({type:g,data:l}),this.requiresTextUpdate=!0;return;case K3.lyric:this.text+=u,this.rawLyrics.push(...l),this.setLyricsText(this.text);break}},this.seq.addOnTimeChangeEvent(()=>{this.text="",this.rawLyrics=[],this.seqPlay(!1)},"sequi-time-change"),this.seq.addOnSongChangeEvent(l=>{if(this.createNavigatorHandler(),this.updateTitleAndMediaStatus(),this.seqPlay(!1),this.seq.songsAmount>1&&(this.seq.loop=!1,this.loopButton.firstElementChild.setAttribute("fill",this.iconDisabledColor)),this.hasInfoDecoding=this.seq.midiData.RMIDInfo?.[Mt.encoding]!==void 0,l.isEmbedded){let g=(E0,m0,g0,u1="")=>this.seq.midiData.RMIDInfo?.[E0]===void 0?m0:u1+g0.decode(this.seq.midiData.RMIDInfo?.[E0]).replace(/\0$/,""),u=new TextDecoder,S=g(Mt.midiEncoding,this.encoding,u),r0=g(Mt.encoding,"utf-8",u);this.infoDecoder=new TextDecoder(r0),this.changeEncoding(S)}},"sequi-song-change"),this.requiresThemeUpdate&&this.mode==="light"&&(this.mode="dark",this.toggleDarkMode())}changeEncoding(n){this.encoding=n,this.decoder=new TextDecoder(n),this.hasInfoDecoding||(this.infoDecoder=new TextDecoder(n)),this.updateOtherTextEvents(),this.text=this.decodeTextFix(new Uint8Array(this.rawLyrics).buffer),this.lyricsElement.selector.value=n,this.updateTitleAndMediaStatus(!1),this.setLyricsText(this.text)}createControls(){this.progressTime=document.createElement("p"),this.progressTime.id="note_time",this.progressTime.onclick=R=>{R.preventDefault();let X0=n.getBoundingClientRect(),F0=R.clientX-X0.left,b1=X0.width;this.seq.currentTime=F0/b1*this.seq.duration,g.innerHTML=y$(Un)},this.createLyrics();let n=document.createElement("div");n.id="note_progress_background",this.progressBarBackground=n,this.progressBar=document.createElement("div"),this.progressBar.id="note_progress",this.progressBar.min="0",this.progressBar.max=this.seq.duration.toString();let l=document.createElement("div"),g=uh("Play/Pause",y$(Un));this.playPause=g,this.locale.bindObjectProperty(g,"title","locale.sequencerController.playPause");let u=()=>{this.seq.paused?this.seqPlay():this.seqPause()};g.onclick=u;let S=uh("Previous song",by(Un));this.locale.bindObjectProperty(S,"title","locale.sequencerController.previousSong"),S.onclick=()=>this.switchToPreviousSong();let r0=uh("Next song",Sy(Un));this.locale.bindObjectProperty(r0,"title","locale.sequencerController.nextSong"),r0.onclick=()=>this.switchToNextSong();let E0=uh("Loop this",ky(Un));this.locale.bindObjectProperty(E0,"title","locale.sequencerController.loopThis");let m0=()=>{this.seq.loop?this.seq.loop=!1:(this.seq.loop=!0,this.seq.currentTime>=this.seq.duration&&(this.seq.currentTime=0)),E0.firstElementChild.setAttribute("fill",this.seq.loop?this.iconColor:this.iconDisabledColor)};E0.onclick=m0,this.loopButton=E0;let g0=uh("Show lyrics",vy(Un));this.locale.bindObjectProperty(g0,"title","locale.sequencerController.lyrics.show"),g0.firstElementChild.setAttribute("fill",this.iconDisabledColor);let u1=()=>{this.lyricsElement.mainDiv.classList.toggle("lyrics_show"),g0.firstElementChild.setAttribute("fill",this.lyricsElement.mainDiv.classList.contains("lyrics_show")?this.iconColor:this.iconDisabledColor)};g0.onclick=u1,document.addEventListener("keydown",R=>{switch(R.key.toLowerCase()){case e7.playPause:R.preventDefault(),u();break;case e7.toggleLoop:R.preventDefault(),m0();break;case e7.toggleLyrics:R.preventDefault(),u1();break;default:break}}),l.appendChild(S),l.appendChild(E0),l.appendChild(g),l.appendChild(g0),l.appendChild(r0),this.controls.appendChild(n),n.appendChild(this.progressBar),this.controls.appendChild(this.progressTime),this.controls.appendChild(l),document.addEventListener("keydown",R=>{switch(R.key.toLowerCase()){case e7.seekBackwards:R.preventDefault(),this.seq.currentTime-=5,g.innerHTML=y$(Un);break;case e7.seekForwards:R.preventDefault(),this.seq.currentTime+=5,g.innerHTML=y$(Un);break;case e7.previousSong:this.switchToPreviousSong();break;case e7.nextSong:this.switchToNextSong();break;default:if(!isNaN(parseFloat(R.key))){R.preventDefault();let X0=parseInt(R.key);0<=X0&&X0<=9&&(this.seq.currentTime=this.seq.duration*(X0/10),g.innerHTML=y$(Un))}break}})}_updateInterval(){this.progressBar.style.width=`${this.seq.currentTime/this.seq.duration*100}%`;let n=E$(this.seq.currentTime),l=E$(this.seq.duration);this.progressTime.innerText=`${n.time} / ${l.time}`,this.requiresTextUpdate&&(this.updateOtherTextEvents(),this.requiresTextUpdate=!1)}setSliderInterval(){setInterval(this._updateInterval.bind(this),100)}};Ls.prototype.createNavigatorHandler=My;Ls.prototype.updateTitleAndMediaStatus=Ty;Ls.prototype.createLyrics=Ny;Ls.prototype.setLyricsText=Gy;Ls.prototype.updateOtherTextEvents=Uy;function Hy(){this.controllers.forEach(o=>{o.voiceMeter.hide(),o.pitchWheel.hide(),o.pan.hide(),o.expression.hide(),o.volume.hide(),o.mod.hide(),o.chorus.hide(),o.reverb.hide(),o.brightness.hide(),o.preset.hide()})}function qy(){this.controllers.forEach(o=>{o.voiceMeter.show(),o.pitchWheel.show(),o.pan.show(),o.expression.show(),o.volume.show(),o.mod.show(),o.chorus.show(),o.reverb.show(),o.brightness.show(),o.preset.show()})}function Yy(){this.mainControllerDiv.classList.toggle("synthui_controller_light"),this.mainButtons.forEach(o=>{o.classList.toggle("synthui_button"),o.classList.toggle("synthui_button_light")}),this.mainMeters.forEach(o=>{o.toggleMode(!0)}),this.controllers.forEach(o=>{o.voiceMeter.toggleMode(),o.pitchWheel.toggleMode(),o.pan.toggleMode(),o.expression.toggleMode(),o.volume.toggleMode(),o.mod.toggleMode(),o.chorus.toggleMode(),o.reverb.toggleMode(),o.brightness.toggleMode(),o.preset.toggleMode(),o.drumsToggle.classList.toggle("mute_button_light"),o.muteButton.classList.toggle("mute_button_light")})}var hn=class{constructor(n="none",l,g,u,S=0,r0=100,E0=!1,m0=void 0,g0=void 0,u1=void 0){if(this.meterText="",g.bindObjectProperty(this,"meterText",l+".title"),this.min=S,this.max=r0,this.currentValue=-1,this.isShown=!0,this.isVisualValueSet=!0,this.isLocked=!1,this.lockCallback=g0,this.unlockCallback=u1,this.div=document.createElement("div"),this.div.classList.add("voice_meter"),this.div.classList.add("controller_element"),n!=="none"&&n!==""&&(this.div.style.borderColor=n),g.bindObjectProperty(this.div,"title",l+".description",u),this.bar=document.createElement("div"),this.bar.classList.add("voice_meter_bar"),this.bar.style.background=n,this.div.appendChild(this.bar),this.text=document.createElement("p"),this.text.classList.add("voice_meter_text"),this.div.appendChild(this.text),this.isActive=!1,E0){if(m0===void 0)throw new Error("No editable function given!");this.div.onmousedown=R=>{R.preventDefault(),R.button===0?this.isActive=!0:this.lockMeter()},this.div.onmousemove=R=>{if(!this.isActive)return;let X0=R.currentTarget.getBoundingClientRect(),F0=X0.left,b1=X0.width,l2=R.clientX-F0,y1=Math.max(0,Math.min(1,l2/b1));m0(y1*(r0-S)+S)},this.div.onmouseup=()=>this.isActive=!1,this.div.onmouseleave=R=>{this.div.onmousemove(R),this.isActive=!1},this.text.oncontextmenu=R=>{R.preventDefault()},this.div.onclick=R=>{R.preventDefault(),this.isActive=!0,this.div.onmousemove(R),this.isActive=!1},this.div.classList.add("editable")}}lockMeter(){this.lockCallback!==void 0&&(this.isLocked?(this.text.classList.remove("locked_meter"),this.unlockCallback()):(this.text.classList.add("locked_meter"),this.lockCallback()),this.isLocked=!this.isLocked)}toggleMode(n=!1){n&&(this.bar.classList.toggle("voice_meter_light_color"),this.div.classList.toggle("voice_meter_light_color")),this.text.classList.toggle("voice_meter_text_light")}show(){if(this.isShown=!0,!this.isVisualValueSet){let n=Math.max(0,Math.min((this.currentValue-this.min)/(this.max-this.min),1));this.bar.style.width=`${n*100}%`,this.text.textContent=this.meterText+(Math.round(this.currentValue*100)/100).toString(),this.isVisualValueSet=!0}}hide(){this.isShown=!1}update(n,l=!1){if(!(n===this.currentValue&&l===!1))if(this.currentValue=n,this.isShown){let g=Math.max(0,Math.min((n-this.min)/(this.max-this.min),1));this.bar.style.width=`${g*100}%`,this.text.textContent=this.meterText+(Math.round(n*100)/100).toString(),this.isVisualValueSet=!0}else this.isVisualValueSet=!1}};var Jy=["Acoustic Grand Piano","Bright Acoustic Piano","Electric Grand Piano","Honky-tonk Piano","Electric Piano 1","Electric Piano 2","Harpsichord","Clavi","Celesta","Glockenspiel","Music Box","Vibraphone","Marimba","Xylophone","Tubular Bells","Dulcimer","Drawbar Organ","Percussive Organ","Rock Organ","Church Organ","Reed Organ","Accordion","Harmonica","Tango Accordion","Acoustic Guitar (nylon)","Acoustic Guitar (steel)","Electric Guitar (jazz)","Electric Guitar (clean)","Electric Guitar (muted)","Overdriven Guitar","Distortion Guitar","Guitar Harmonics","Acoustic Bass","Electric Bass (finger)","Electric Bass (pick)","Fretless Bass","Slap Bass 1","Slap Bass 2","Synth Bass 1","Synth Bass 2","Violin","Viola","Cello","Contrabass","Tremolo Strings","Pizzicato Strings","Orchestral Harp","Timpani","String Ensemble 1","String Ensemble 2","Synth Strings 1","Synth Strings 2","Choir Aahs","VoiceGroup Oohs","Synth Choir","Orchestra Hit","Trumpet","Trombone","Tuba","Muted Trumpet","French Horn","Brass Section","Synth Brass 1","Synth Brass 2","Soprano Sax","Alto Sax","Tenor Sax","Baritone Sax","Oboe","English Horn","Bassoon","Clarinet","Piccolo","Flute","Recorder","Pan Flute","Blown Bottle","Shakuhachi","Whistle","Ocarina","Lead 1 (square)","Lead 2 (sawtooth)","Lead 3 (calliope)","Lead 4 (chiff)","Lead 5 (charang)","Lead 6 (voice)","Lead 7 (fifths)","Lead 8 (bass + lead)","Pad 1 (new age)","Pad 2 (warm)","Pad 3 (polysynth)","Pad 4 (choir)","Pad 5 (bowed)","Pad 6 (metallic)","Pad 7 (halo)","Pad 8 (sweep)","FX 1 (rain)","FX 2 (soundtrack)","FX 3 (crystal)","FX 4 (atmosphere)","FX 5 (brightness)","FX 6 (goblins)","FX 7 (echoes)","FX 8 (sci-fi)","Sitar","Banjo","Shamisen","Koto","Kalimba","Bagpipe","Fiddle","Shanai","Tinkle Bell","Agogo","Steel Drums","Woodblock","Taiko Drum","Melodic Tom","Synth Drum","Reverse Cymbal","Guitar Fret Noise","Breath Noise","Seashore","Bird Tweet","Telephone Ring","Attack Helicopter","Applause","Gunshot"];var xC=class{constructor(n,l,g,u,S=void 0,r0=void 0){this.isShown=!0,this.isReloaded=!0,this.elements=n.map(E0=>({name:E0.name,program:E0.program,bank:E0.bank,stringified:`${E0.bank.toString().padStart(3,"0")}:${E0.program.toString().padStart(3,"0")} ${E0.name}`})),this.elements.length>0?this.value=`${this.elements[0].bank}:${this.elements[0].program}`:this.value="",this.mainButton=document.createElement("button"),this.mainButton.classList.add("voice_selector"),this.mainButton.classList.add("controller_element"),l.bindObjectProperty(this.mainButton,"title",g+".description",u),this.locale=l,this.localePath=g,this.localeArgs=u,this.reload(),this.mainButton.onclick=()=>{this.showSelectionMenu()},this.editCallback=S,this.selectionMenu=void 0,this.lockCallback=r0,this.locked=!1,this.isWindowShown=!1}showSelectionMenu(){this.selectionMenu=document.createElement("div"),this.selectionMenu.classList.add("voice_selector_wrapper"),document.getElementsByClassName("spessasynth_main")[0].appendChild(this.selectionMenu);let n=document.createElement("div");n.classList.add("voice_selector_window");let l=document.createElement("h2");this.locale.bindObjectProperty(l,"textContent",this.localePath+".selectionPrompt",this.localeArgs),n.appendChild(l);let g=document.createElement("div");g.classList.add("voice_selector_search_wrapper"),n.appendChild(g);let u=document.createElement("input");u.type="text",this.locale.bindObjectProperty(u,"placeholder",this.localePath+".searchPrompt"),g.appendChild(u),u.onkeydown=E0=>E0.stopPropagation();let S=document.createElement("div");S.innerHTML=this.locked?RC(h7):qB(h7),this.locale.bindObjectProperty(S,"title",Ae+"channelController.presetReset.description",this.localeArgs),S.classList.add("voice_reset"),this.mainButton.classList.contains("voice_selector_light")&&S.classList.add("voice_reset_light"),S.onclick=()=>{this.locked=!this.locked,this.lockCallback(this.locked),this.mainButton.classList.toggle("locked_selector"),this.locked?S.innerHTML=RC(h7):S.innerHTML=qB(h7)},g.appendChild(S),this.presetLock=S;let r0=document.createElement("div");r0.classList.add("voice_selector_table_wrapper"),n.appendChild(r0),this.generateTable(r0,this.elements),u.oninput=E0=>{E0.stopPropagation();let m0=u.value,g0=this.elements.filter(u1=>u1.stringified.search(new RegExp(m0,"i"))>=0);g0.length!==this.elements.length&&(r0.replaceChildren(),this.generateTable(r0,g0))},n.onclick=E0=>{E0.stopPropagation()},this.selectionMenu.appendChild(n),this.selectionMenu.onclick=E0=>{E0.stopPropagation(),this.hideSelectionMenu()},this.isWindowShown=!0}generateTable(n,l){let g=document.createElement("table");g.classList.add("voice_selector_table");let u=parseInt(this.value.split(":")[0]),S=parseInt(this.value.split(":")[1]),r0=-20;for(let E0 of l){let m0=document.createElement("tr"),g0=E0.program;if(g0===S&&E0.bank===u&&(m0.classList.add("voice_selector_selected"),setTimeout(()=>{m0.scrollIntoView({behavior:"instant",block:"center",inline:"center"})},20)),m0.onclick=()=>{let l2=`${E0.bank}:${g0}`;if(this.value===l2){this.hideSelectionMenu();return}this.editCallback(l2),this.locked=!0,this.presetLock.innerHTML=RC(h7),this.hideSelectionMenu()},g0!==r0&&(r0=g0,E0.bank!==128)){let l2=document.createElement("tr"),y1=document.createElement("th");y1.colSpan="3",y1.textContent=Jy[r0],l2.appendChild(y1),g.appendChild(l2)}let u1=`${E0.program.toString().padStart(3,"0")}`,R=`${E0.bank.toString().padStart(3,"0")}`,X0=document.createElement("td");X0.classList.add("voice_selector_preset_name"),X0.textContent=E0.name;let F0=document.createElement("td");X0.classList.add("voice_selector_preset_program"),F0.textContent=u1;let b1=document.createElement("td");X0.classList.add("voice_selector_preset_program"),b1.textContent=R,m0.appendChild(b1),m0.appendChild(F0),m0.appendChild(X0),g.appendChild(m0)}n.appendChild(g)}hideSelectionMenu(){document.getElementsByClassName("spessasynth_main")[0].removeChild(this.selectionMenu),this.selectionMenu=void 0,this.isWindowShown=!1}toggleMode(){this.mainButton.classList.toggle("voice_selector_light")}reload(n=this.elements){if(this.elements=n.map(l=>({name:l.name,program:l.program,bank:l.bank,stringified:`${l.bank.toString().padStart(3,"0")}:${l.program.toString().padStart(3,"0")} ${l.name}`})),!this.isShown){this.isReloaded=!1;return}this.isReloaded=!0,this.elements.length>0&&(this.mainButton.textContent=this.getString(`${this.elements[0].bank}:${this.value.split(":")[1]}`))}set(n){if(this.value=n,this.isShown&&(this.isReloaded||this.reload(),this.mainButton.textContent=this.getString(this.value),this.isWindowShown)){let l=this.selectionMenu.getElementsByClassName("voice_selector_selected")[0];l!==void 0&&l.classList.remove("voice_selector_selected");let g=this.selectionMenu.getElementsByClassName("voice_selector_table")[0],u=parseInt(this.value.split(":")[0]),S=parseInt(this.value.split(":")[1]);for(let r0 of g.rows){if(r0.cells.length===1)continue;let E0=parseInt(r0.cells[0].textContent),m0=parseInt(r0.cells[1].textContent);E0===u&&m0===S&&(r0.classList.add("voice_selector_selected"),r0.scrollIntoView({behavior:"smooth",block:"center",inline:"center"}))}}}getString(n){let l=n.split(":"),g=parseInt(l[0]),u=parseInt(l[1]),S=this.elements.find(r0=>r0.bank===g&&r0.program===u);return g===128||this.elements.filter(r0=>r0.program===u&&r0.bank!==128).length<2?`${u}. ${S.name}`:`${g}:${u} ${S.name}`}show(){this.isShown=!0,this.isReloaded||this.reload(),this.mainButton.textContent=this.getString(this.value)}hide(){this.isShown=!1}};var h7=32;function Ky(o){this.soloChannels=new Set;let n=document.createElement("div");n.classList.add("channel_controller");let l=new hn(this.channelColors[o%this.channelColors.length],Ae+"channelController.voiceMeter",this.locale,[o+1],0,100);l.bar.classList.add("voice_meter_bar_smooth"),n.appendChild(l.div);let g=new hn(this.channelColors[o%this.channelColors.length],Ae+"channelController.pitchBendMeter",this.locale,[o+1],-8192,8191,!0,T2=>{let K2=g.isLocked;K2&&this.synth.lockController(o,C$+Ft.pitchWheel,!1),T2=Math.round(T2)+8192;let i3=T2>>7,n3=T2&127;this.synth.pitchWheel(o,i3,n3),K2&&this.synth.lockController(o,C$+Ft.pitchWheel,!0)},()=>this.synth.lockController(o,C$+Ft.pitchWheel,!0),()=>this.synth.lockController(o,C$+Ft.pitchWheel,!1));g.update(0),n.appendChild(g.div);let u=(T2,K2,i3)=>{i3.isLocked?(this.synth.lockController(o,T2,!1),this.synth.controllerChange(o,T2,K2),this.synth.lockController(o,T2,!0)):this.synth.controllerChange(o,T2,K2)},S=(T2,K2,i3)=>{let n3=new hn(this.channelColors[o%this.channelColors.length],Ae+K2,this.locale,[o+1],0,127,!0,A0=>u(T2,Math.round(A0),n3),()=>this.synth.lockController(o,T2,!0),()=>this.synth.lockController(o,T2,!1));return n3.update(i3),n3},r0=S(t6.pan,"channelController.panMeter",64);n.appendChild(r0.div);let E0=S(t6.expressionController,"channelController.expressionMeter",127);n.appendChild(E0.div);let m0=S(t6.mainVolume,"channelController.volumeMeter",100);n.appendChild(m0.div);let g0=S(t6.modulationWheel,"channelController.modulationWheelMeter",0);n.appendChild(g0.div);let u1=S(t6.effects3Depth,"channelController.chorusMeter",0);n.appendChild(u1.div);let R=S(t6.effects1Depth,"channelController.reverbMeter",0);n.appendChild(R.div);let X0=S(t6.brightness,"channelController.filterMeter",64);n.appendChild(X0.div);let F0=new hn(this.channelColors[o%this.channelColors.length],Ae+"channelController.transposeMeter",this.locale,[o+1],-36,36,!0,T2=>{T2=Math.round(T2),this.synth.transposeChannel(o,T2,!0),F0.update(T2)});F0.update(0),n.appendChild(F0.div);let b1=new xC([],this.locale,Ae+"channelController.presetSelector",[o+1],async T2=>{let K2=T2.split(":");this.synth.lockController(o,mi,!1),this.synth.controllerChange(o,t6.bankSelect,parseInt(K2[0]),!0),this.synth.programChange(o,parseInt(K2[1]),!0),b1.mainButton.classList.add("locked_selector"),this.synth.lockController(o,mi,!0)},T2=>this.synth.lockController(o,mi,T2));n.appendChild(b1.mainButton);let l2=document.createElement("div");l2.innerHTML=fh(h7),this.locale.bindObjectProperty(l2,"title",Ae+"channelController.soloButton.description",[o+1]),l2.classList.add("controller_element"),l2.classList.add("mute_button"),l2.onclick=()=>{if(this.soloChannels.has(o)?this.soloChannels.delete(o):this.soloChannels.add(o),this.soloChannels.size===0||this.soloChannels.size>=this.synth.channelsAmount){for(let T2=0;T2=this.synth.channelsAmount&&this.soloChannels.clear();return}for(let T2=0;T2 {if(y1.hasAttribute("is_muted")){y1.removeAttribute("is_muted");let T2=this.soloChannels.size===0||this.soloChannels.has(o);this.synth.muteChannel(o,!T2),y1.innerHTML=bm(h7)}else this.synth.muteChannel(o,!0),y1.setAttribute("is_muted","true"),y1.innerHTML=_y(h7)},n.appendChild(y1);let Y2=document.createElement("div");return Y2.innerHTML=o===bi?DC(h7):_C(h7),this.locale.bindObjectProperty(Y2,"title",Ae+"channelController.drumToggleButton.description",[o+1]),Y2.classList.add("controller_element"),Y2.classList.add("mute_button"),Y2.onclick=()=>{this.synth.setDrums(o,!this.synth.channelProperties[o].isDrum)},n.appendChild(Y2),{controller:n,voiceMeter:l,pitchWheel:g,pan:r0,expression:E0,volume:m0,mod:g0,chorus:u1,reverb:R,brightness:X0,preset:b1,drumsToggle:Y2,soloButton:l2,muteButton:y1,transpose:F0}}function Vy(){let o=this.uiDiv.getElementsByClassName("synthui_controller")[0];this.controllers=[];for(let n=0;n {this.synth.setMainVolume(Math.round(g0)/100),this.volumeController.update(g0)}),this.volumeController.bar.classList.add("voice_meter_bar_smooth"),this.volumeController.div.classList.add("main_controller_element"),this.volumeController.update(100),this.panController=new hn("",Ae+"mainPanMeter",this.locale,[],-1,1,!0,g0=>{this.synth.setMasterPan(g0),this.panController.update(g0)}),this.panController.bar.classList.add("voice_meter_bar_smooth"),this.panController.div.classList.add("main_controller_element"),this.panController.update(0),this.transposeController=new hn("",Ae+"mainTransposeMeter",this.locale,[],-12,12,!0,g0=>{this.synth.transpose(Math.round(g0*2)/2),this.transposeController.update(Math.round(g0*2)/2)}),this.transposeController.bar.classList.add("voice_meter_bar_smooth"),this.transposeController.div.classList.add("main_controller_element"),this.transposeController.update(0);let n=document.createElement("button");this.locale.bindObjectProperty(n,"textContent",Ae+"midiPanic.title"),this.locale.bindObjectProperty(n,"title",Ae+"midiPanic.description"),n.classList.add("synthui_button"),n.classList.add("main_controller_element"),n.onclick=()=>this.synth.stopAll(!0);let l=document.createElement("button");this.locale.bindObjectProperty(l,"textContent",Ae+"systemReset.title"),this.locale.bindObjectProperty(l,"title",Ae+"systemReset.description"),l.classList.add("synthui_button"),l.classList.add("main_controller_element"),l.onclick=()=>{this.controllers.forEach((g0,u1)=>{g0.pitchWheel.isLocked&&g0.pitchWheel.lockMeter(),g0.pan.isLocked&&g0.pan.lockMeter(),g0.expression.isLocked&&g0.expression.lockMeter(),g0.volume.isLocked&&g0.volume.lockMeter(),g0.mod.isLocked&&g0.mod.lockMeter(),g0.chorus.isLocked&&g0.chorus.lockMeter(),g0.reverb.isLocked&&g0.reverb.lockMeter(),g0.brightness.isLocked&&g0.brightness.lockMeter(),g0.preset.mainButton.classList.contains("locked_selector")&&(this.synth.lockController(u1,mi,!1),g0.preset.mainButton.classList.remove("locked_selector")),this.synth.transposeChannel(u1,0,!0),g0.transpose.update(0),g0.soloButton.innerHTML=fh(h7),g0.muteButton.innerHTML=bm(h7),this.synth.muteChannel(u1,!1)}),this.synth.resetControllers()};let g=document.createElement("button");this.locale.bindObjectProperty(g,"textContent",Ae+"blackMidiMode.title"),this.locale.bindObjectProperty(g,"title",Ae+"blackMidiMode.description"),g.classList.add("synthui_button"),g.classList.add("main_controller_element"),g.onclick=()=>{this.synth.highPerformanceMode=!this.synth.highPerformanceMode};let u=document.createElement("button");this.locale.bindObjectProperty(u,"textContent",Ae+"disableCustomVibrato.title"),this.locale.bindObjectProperty(u,"title",Ae+"disableCustomVibrato.description"),u.classList.add("synthui_button"),u.classList.add("main_controller_element"),u.onclick=()=>{this.synth.disableGSNRPparams(),u.parentNode.removeChild(u)};let S=document.createElement("a");S.href="https://github.com/spessasus/SpessaSynth/wiki/How-To-Use-App#synthesizer-controller",S.target="#",S.classList.add("main_controller_element"),S.classList.add("synthui_button"),this.locale.bindObjectProperty(S,"textContent",Ae+"helpButton.title"),this.locale.bindObjectProperty(S,"title",Ae+"helpButton.description");let r0=document.createElement("select");r0.classList.add("main_controller_element"),r0.classList.add("synthui_button"),this.locale.bindObjectProperty(r0,"title",Ae+"interpolation.description");{let g0=document.createElement("option");g0.value="0",this.locale.bindObjectProperty(g0,"textContent",Ae+"interpolation.linear"),r0.appendChild(g0);let u1=document.createElement("option");u1.value="1",this.locale.bindObjectProperty(u1,"textContent",Ae+"interpolation.nearestNeighbor"),r0.appendChild(u1);let R=document.createElement("option");R.value="2",R.selected=!0,this.locale.bindObjectProperty(R,"textContent",Ae+"interpolation.cubic"),r0.appendChild(R),r0.onchange=()=>{this.synth.setInterpolationType(parseInt(r0.value))}}let E0=document.createElement("div");E0.classList.add("synthui_controller"),this.uiDiv.appendChild(E0);let m0=document.createElement("button");this.locale.bindObjectProperty(m0,"textContent",Ae+"toggleButton.title"),this.locale.bindObjectProperty(m0,"title",Ae+"toggleButton.description"),m0.classList.add("synthui_button"),m0.onclick=()=>{this.hideOnDocClick=!1,this.toggleVisibility()},o.appendChild(this.volumeController.div),o.appendChild(this.panController.div),o.appendChild(this.transposeController.div),o.appendChild(n),o.appendChild(l),o.appendChild(g),o.appendChild(u),o.appendChild(S),o.appendChild(r0),this.mainMeters=[this.volumeController,this.panController,this.transposeController,this.voiceMeter],this.mainButtons=[n,l,g,u,m0,S,r0],this.uiDiv.appendChild(this.voiceMeter.div),this.uiDiv.appendChild(m0),E0.appendChild(o),this.mainControllerDiv=E0,this.mainControllerDiv.onclick=g0=>g0.stopPropagation(),document.addEventListener("click",()=>{if(!this.hideOnDocClick){this.hideOnDocClick=!0;return}E0.classList.remove("synthui_controller_show"),this.isShown=!1,this.hideControllers()})}function Zy(){let o=this.uiDiv.getElementsByClassName("synthui_controller")[0];this.synth.eventHandler.addEvent("programchange","synthui-program-change",n=>{this.controllers[n.channel].preset.set(`${n.bank}:${n.program}`)}),this.synth.eventHandler.addEvent("allcontrollerreset","synthui-all-controller-reset",()=>{for(let n of this.controllers)n.pan.update(64),n.mod.update(0),n.chorus.update(0),n.pitchWheel.update(0),n.expression.update(127),n.volume.update(100),n.reverb.update(0),n.brightness.update(64)}),this.synth.eventHandler.addEvent("controllerchange","synthui-controller-change",n=>{let l=n.controllerNumber,g=n.channel,u=n.controllerValue;switch(l){default:break;case t6.expressionController:this.controllers[g].expression.update(u);break;case t6.mainVolume:this.controllers[g].volume.update(u);break;case t6.pan:this.controllers[g].pan.update(u);break;case t6.modulationWheel:this.controllers[g].mod.update(u);break;case t6.effects3Depth:this.controllers[g].chorus.update(u);break;case t6.effects1Depth:this.controllers[g].reverb.update(u);break;case t6.brightness:this.controllers[g].brightness.update(u)}}),this.synth.eventHandler.addEvent("pitchwheel","synthui-pitch-wheel",n=>{let l=n.MSB<<7|n.LSB;this.controllers[n.channel].pitchWheel.update(l-8192)}),this.synth.eventHandler.addEvent("drumchange","synthui-drum-change",n=>{this.controllers[n.channel].drumsToggle.innerHTML=n.isDrumChannel?DC(32):_C(32),this.controllers[n.channel].preset.reload(n.isDrumChannel?this.percussionList:this.instrumentList)}),this.synth.eventHandler.addEvent("newchannel","synthui-new-channel",()=>{let n=this.createChannelController(this.controllers.length);this.controllers.push(n),o.appendChild(n.controller),this.hideControllers()})}var Ae="locale.synthesizerController.",On=class{constructor(n,l,g){this.channelColors=n;let u=l;this.uiDiv=document.createElement("div"),this.uiDiv.classList.add("wrapper"),u.appendChild(this.uiDiv),this.uiDiv.style.visibility="visible",this.isShown=!1,this.animationId=-1,this.locale=g,this.hideOnDocClick=!0}connectSynth(n){this.synth=n,this.getInstrumentList(),this.createMainSynthController(),this.createChannelControllers(),document.addEventListener("keydown",l=>{switch(l.key.toLowerCase()){case e7.synthesizerUIShow:l.preventDefault(),this.toggleVisibility();break;case e7.settingsShow:this.isShown=!0,this.toggleVisibility();break;case e7.blackMidiMode:l.preventDefault(),this.synth.highPerformanceMode=!this.synth.highPerformanceMode;break;case e7.midiPanic:l.preventDefault(),this.synth.stopAll(!0);break}}),this.locale.onLocaleChanged.push(()=>{this.voiceMeter.update(this.voiceMeter.currentValue,!0),this.volumeController.update(this.volumeController.currentValue,!0),this.panController.update(this.panController.currentValue,!0),this.panController.update(this.panController.currentValue,!0),this.transposeController.update(this.transposeController.currentValue,!0);for(let l of this.controllers)l.voiceMeter.update(l.voiceMeter.currentValue,!0),l.pitchWheel.update(l.pitchWheel.currentValue,!0),l.pan.update(l.pan.currentValue,!0),l.volume.update(l.volume.currentValue,!0),l.expression.update(l.expression.currentValue,!0),l.mod.update(l.mod.currentValue,!0),l.chorus.update(l.chorus.currentValue,!0),l.reverb.update(l.reverb.currentValue,!0),l.brightness.update(l.brightness.currentValue,!0),l.transpose.update(l.transpose.currentValue,!0)})}toggleVisibility(){this.animationId!==-1&&clearTimeout(this.animationId);let n=document.getElementsByClassName("synthui_controller")[0];this.isShown=!this.isShown,this.isShown?(n.style.display="block",document.getElementsByClassName("top_part")[0].classList.add("synthui_shown"),this.showControllers(),setTimeout(()=>{n.classList.add("synthui_controller_show")},75)):(document.getElementsByClassName("top_part")[0].classList.remove("synthui_shown"),this.hideControllers(),n.classList.remove("synthui_controller_show"),this.animationId=setTimeout(()=>{n.style.display="none"},200))}updateVoicesAmount(){this.voiceMeter.update(this.synth.voicesAmount),this.controllers.forEach((n,l)=>{let g=this.synth.channelProperties[l].voicesAmount;n.voiceMeter.update(g),g<1&&this.synth.voicesAmount>0?n.controller.classList.add("no_voices"):n.controller.classList.remove("no_voices")})}getInstrumentList(){this.synth.eventHandler.addEvent("presetlistchange","synthui-preset-list-change",n=>{let l=n;this.instrumentList=l.filter(g=>g.bank!==128).sort((g,u)=>g.program===u.program?g.bank-u.bank:g.program-u.program).map(g=>({name:g.presetName,bank:g.bank,program:g.program})),this.percussionList=l.filter(g=>g.bank===128).sort((g,u)=>g.program-u.program).map(g=>({name:g.presetName,bank:g.bank,program:g.program})),this.percussionList.length===0?this.percussionList=this.instrumentList:this.instrumentList.length===0&&(this.instrumentList=this.percussionList),this.controllers.forEach((g,u)=>{let S=this.synth.channelProperties[u].isDrum?this.percussionList:this.instrumentList;g.preset.reload(S),g.preset.set(`${S[0].bank}:${S[0].program}`)})})}};On.prototype.hideControllers=Hy;On.prototype.showControllers=qy;On.prototype.toggleDarkMode=Yy;On.prototype.createChannelController=Ky;On.prototype.createChannelControllers=Vy;On.prototype.createMainSynthController=zy;On.prototype.setEventListeners=Zy;var _m=null,LC=class{constructor(){}async createMIDIDeviceHandler(){if(this.selectedInput=_m,this.selectedOutput=_m,navigator.requestMIDIAccess)try{let n=await navigator.requestMIDIAccess({sysex:!0,software:!0});return this.inputs=n.inputs,this.outputs=n.outputs,Y5("%cMIDI handler created!",_1.recognized),!0}catch(n){return R4("Could not get MIDI Devices:",n),this.inputs=[],this.outputs=[],!1}else return R4("Web MIDI Api not supported!",_1.unrecognized),this.inputs=[],this.outputs=[],!1}connectMIDIOutputToSeq(n,l){this.selectedOutput=n,l.connectMidiOutput(n),Y5(`%cPlaying MIDI to %c${n.name}`,_1.info,_1.recognized)}disconnectSeqFromMIDI(n){this.selectedOutput=_m,n.connectMidiOutput(void 0),Y5("%cDisconnected from MIDI out.",_1.info)}connectDeviceToSynth(n,l){this.selectedInput=n,n.onmidimessage=g=>{l.sendMessage(g.data)},Y5(`%cListening for messages on %c${n.name}`,_1.info,_1.recognized)}disconnectDeviceFromSynth(n){this.selectedInput=_m,n.onmidimessage=void 0,Y5(`%cDisconnected from %c${n.name}`,_1.info,_1.recognized)}disconnectAllDevicesFromSynth(){this.selectedInput=_m;for(let n of this.inputs)n[1].onmidimessage=void 0}};var FC=class{constructor(n){window.addEventListener("message",l=>{if(typeof l.data!="string")return;let g=l.data.split(",");if(g[0]!=="midi")return;g.shift();let u=g.map(S=>parseInt(S,16));n.sendMessage(u)}),Y5("%cWeb MIDI Link handler created!",_1.recognized)}};var TA="midi range";function Wy(o,n,l){let g=0,u=this.htmlControls.keyboard,S=()=>{let r0=document.createElement("option");r0.value=g.toString(),this.locale.bindObjectProperty(r0,"textContent","locale.settings.keyboardSettings.selectedChannel.channelOption",[g+1]),r0.style.background=n.channelColors[g%n.channelColors.length],r0.style.color="rgb(0, 0, 0)",u.channelSelector.appendChild(r0),g++};for(let r0=0;r0 {o.selectChannel(parseInt(u.channelSelector.value))},u.sizeSelector.onchange=()=>{if(this.musicMode.visible){this.musicMode.setVisibility(!1,document.getElementById("keyboard_canvas_wrapper")),setTimeout(()=>{u.sizeSelector.value===TA?(this.autoKeyRange=!0,this?.sequi?.seq&&(o.keyRange=this.sequi.seq.midiData.keyRange,l.keyRange=this.sequi.seq.midiData.keyRange)):(this.autoKeyRange=!1,o.keyRange=this.keyboardSizes[u.sizeSelector.value],l.keyRange=this.keyboardSizes[u.sizeSelector.value]),this._saveSettings()},600);return}u.sizeSelector.value===TA?(this.autoKeyRange=!0,this?.sequi?.seq&&(o.keyRange=this.sequi.seq.midiData.keyRange,l.keyRange=this.sequi.seq.midiData.keyRange)):(this.autoKeyRange=!1,o.keyRange=this.keyboardSizes[u.sizeSelector.value],l.keyRange=this.keyboardSizes[u.sizeSelector.value]),this._saveSettings()},this.addSequencer=r0=>{r0.addOnSongChangeEvent(E0=>{this.autoKeyRange&&(o.keyRange=E0.keyRange,l.keyRange=E0.keyRange),E0.RMIDInfo?.IPIC!==void 0&&this.musicMode.visible===!1&&this.toggleMusicPlayerMode().then()},"settings-keyboard-handler-song-change")},n.synth.eventHandler.addEvent("newchannel","settings-new-channel",()=>{S()}),n.synth.eventHandler.addEvent("programchange","settings-keyboard-program-change",r0=>{r0.userCalled&&(o.selectChannel(r0.channel),u.channelSelector.value=r0.channel)}),n.synth.eventHandler.addEvent("mutechannel","settings-keuboard-mute-channel",r0=>{if(r0.isMuted&&r0.channel===o.channel){let E0=0;for(;n.synth.channelProperties[E0].isMuted;)E0++;E0 {if(this.musicMode.visible){this.musicMode.setVisibility(!1,document.getElementById("keyboard_canvas_wrapper")),setTimeout(()=>{o.toggleMode(),this._saveSettings()},600);return}o.toggleMode(),this._saveSettings()},u.showSelector.onclick=()=>{o.shown=!o.shown,this._saveSettings()}}var jy=` -`;function br(o){return o.parentElement.nextElementSibling}function jy(o){let n=o.getElementsByTagName("spessarange");for(let l of n)l.parentElement.insertBefore(VB(l,!0),l);for(;n.length>0;)n[0].parentNode.removeChild(n[0])}function VB(o,n=!0){let l=document.createElement("div");l.classList.add("settings_slider_wrapper");let g=o.getAttribute("min"),u=o.getAttribute("max"),S=o.getAttribute("value"),r0=o.getAttribute("units"),E0=o.getAttribute("input_id"),m0=document.createElement("input");m0.classList.add("settings_slider"),m0.type="range",m0.id=E0,m0.min=g,m0.max=u,m0.value=S;let g0;n&&(g0=document.createElement("span"),g0.textContent=S+r0);let u1=document.createElement("div");u1.classList.add("settings_visual_wrapper");let R=document.createElement("div");R.classList.add("settings_slider_progress"),u1.appendChild(R);let X0=document.createElement("div");return X0.classList.add("settings_slider_thumb"),u1.appendChild(X0),u1.appendChild(m0),m0.addEventListener("input",()=>{let F0=parseInt(u1.style.getPropertyValue("--visual-width").replace("%","")),b1=Math.round((m0.value-m0.min)/(m0.max-m0.min)*100);Math.abs((F0-b1)/100)>.05?u1.classList.add("settings_slider_transition"):u1.classList.remove("settings_slider_transition"),u1.style.setProperty("--visual-width",`${b1}%`)}),u1.style.setProperty("--visual-width",`${(m0.value-m0.min)/(m0.max-m0.min)*100}%`),l.appendChild(u1),n&&l.appendChild(g0),l}async function Xy(){let o=await window.savedSettings;if(!o.interface)return;Y5("Loading saved settings...",o);let n=this.htmlControls.renderer,l=this.renderer,g=o.renderer;l.noteFallingTimeMs=g.noteFallingTimeMs,n.noteTimeSlider.value=g.noteFallingTimeMs,n.noteTimeSlider.dispatchEvent(new Event("input")),br(n.noteTimeSlider).innerText=`${g.noteFallingTimeMs}ms`,n.analyserThicknessSlider.value=g.waveformThickness,n.analyserThicknessSlider.dispatchEvent(new Event("input")),l.lineThickness=g.waveformThickness,br(n.analyserThicknessSlider).innerText=`${g.waveformThickness}px`;let u=g.sampleSize;n.analyserFftSlider.value=Math.log2(u),n.analyserFftSlider.dispatchEvent(new Event("input")),l.normalAnalyserFft=u,l.drumAnalyserFft=Math.pow(2,Math.min(15,Math.log2(u)+2)),l.updateFftSize(),br(n.analyserFftSlider).innerText=`${u}`,l.waveMultiplier=g.amplifier,n.waveMultiplierSlizer.value=g.amplifier,n.waveMultiplierSlizer.dispatchEvent(new Event("input")),br(n.waveMultiplierSlizer).innerText=g.amplifier.toString();let S=this.htmlControls.renderer;l.renderAnalysers=g.renderWaveforms,S.analyserToggler.checked=g.renderWaveforms,l.renderNotes=g.renderNotes,S.noteToggler.checked=g.renderNotes,l.drawActiveNotes=g.drawActiveNotes,S.activeNoteToggler.checked=g.drawActiveNotes,l.showVisualPitch=g.showVisualPitch,S.visualPitchToggler.checked=g.showVisualPitch,l.stabilizeWaveforms=g.stabilizeWaveforms,S.stabilizeWaveformsToggler.checked=g.stabilizeWaveforms,l.keyRange=g.keyRange;let r0=this.htmlControls.keyboard,E0=this.midiKeyboard,m0=o.keyboard;E0.setKeyRange(m0.keyRange,!1),m0.autoRange?(r0.sizeSelector.value=TA,this.autoKeyRange=!0):(this.autoKeyRange=!1,r0.sizeSelector.value=Object.keys(this.keyboardSizes).find(g0=>this.keyboardSizes[g0].min===m0.keyRange.min&&this.keyboardSizes[g0].max===m0.keyRange.max)),m0.mode==="dark"&&(E0.toggleMode(!1),this.htmlControls.keyboard.modeSelector.checked=!0),m0.show===!1&&(E0.shown=!1,this.htmlControls.keyboard.showSelector.checked=!1),this.locale.changeGlobalLocale(o.interface.language,!0),setTimeout(()=>{this.htmlControls.interface.languageSelector.value=o.interface.language},100),o.interface.mode==="light"?(this._toggleDarkMode(),this.htmlControls.interface.themeSelector.checked=!1):this.htmlControls.interface.themeSelector.checked=!0,this.htmlControls.interface.layoutSelector.value=o.interface.layout||"downwards",this._changeLayout(o.interface.layout||"downwards")}function ew(){window.saveSettings&&window.saveSettings(this._serializeSettings())}function tw(){return{renderer:{noteFallingTimeMs:this.renderer.noteFallingTimeMs,waveformThickness:this.renderer.lineThickness,sampleSize:this.renderer.normalAnalyserFft,amplifier:this.renderer.waveMultiplier,renderWaveforms:this.renderer.renderAnalysers,renderNotes:this.renderer.renderNotes,drawActiveNotes:this.renderer.drawActiveNotes,showVisualPitch:this.renderer.showVisualPitch,stabilizeWaveforms:this.renderer.stabilizeWaveforms,keyRange:this.renderer.keyRange},keyboard:{selectedChannel:this.midiKeyboard.channel,keyRange:this.midiKeyboard.keyRange,mode:this.midiKeyboard.mode,autoRange:this.htmlControls.keyboard.sizeSelector.value===TA,show:this.htmlControls.keyboard.showSelector.checked===!0},midi:{input:this.midiDeviceHandler.selectedInput===null?null:this.midiDeviceHandler.selectedInput.name,output:this.midiDeviceHandler.selectedOutput===null?null:this.midiDeviceHandler.selectedOutput.name},interface:{mode:this.mode,language:this.htmlControls.interface.languageSelector.value,layout:this.htmlControls.interface.layoutSelector.value}}}function iw(){let o=this.htmlControls.interface.themeSelector;o.onclick=()=>{this._toggleDarkMode(),this._saveSettings()};let n=this.htmlControls.interface.languageSelector;for(let[g,u]of Object.entries(this.locales)){let S=document.createElement("option");S.value=g,S.textContent=u.localeName,n.appendChild(S)}n.onchange=()=>{this.locale.changeGlobalLocale(n.value),this._saveSettings()};let l=this.htmlControls.interface.layoutSelector;l.onchange=()=>{this._changeLayout(l.value),this._saveSettings(),l.blur()}}function nw(o){let n=document.getElementById("keyboard_canvas_wrapper"),l=document.getElementById("note_canvas"),g=document.getElementById("keyboard");switch(o){case"downwards":n.classList.remove("upwards"),n.classList.remove("left_to_right"),n.classList.remove("right_to_left"),l.classList.remove("sideways"),g.classList.remove("sideways"),this.renderer.direction="down",this.renderer.sideways=!1;break;case"upwards":n.classList.add("upwards"),n.classList.remove("left_to_right"),n.classList.remove("right_to_left"),l.classList.remove("sideways"),g.classList.remove("sideways"),this.renderer.direction="up",this.renderer.sideways=!1;break;case"left":n.classList.remove("upwards"),n.classList.add("left_to_right"),n.classList.remove("right_to_left"),l.classList.add("sideways"),g.classList.add("sideways"),this.renderer.direction="up",this.renderer.sideways=!0;break;case"right":n.classList.remove("upwards"),n.classList.remove("left_to_right"),n.classList.add("right_to_left"),l.classList.add("sideways"),g.classList.add("sideways"),this.renderer.direction="down",this.renderer.sideways=!0}}var TC={start:"#101010",end:"#212121"},NC={start:"#bbb",end:"#f0f0f0"},rw="#eee",sw="#333",GC={start:"#222",end:"#333"},UC={start:"#ccc",end:"#fff"},Dr=.2;function ow(){this.mode==="dark"?(this.mode="light",this.renderer.drawActiveNotes=!1):(this.renderer.drawActiveNotes=!0,this.mode="dark"),this.renderer.toggleDarkMode(),this.synthui.toggleDarkMode(),this.sequi.toggleDarkMode(),this.musicMode.toggleDarkMode(),document.getElementsByClassName("spessasynth_main")[0].classList.toggle("light_mode"),document.getElementsByClassName("top_part")[0].classList.toggle("top_part_light"),this.mainDiv.classList.toggle("settings_menu_light");let o=document.styleSheets[0].cssRules;for(let n of o)if(n.selectorText==="*"){this.mode==="dark"?(_r(sw,rw,Dr,n,"--font-color"),_r(UC.start,GC.start,Dr,n,"--top-buttons-color-start"),_r(UC.end,GC.end,Dr,n,"--top-buttons-color-end"),_r(NC.start,TC.start,Dr,n,"--top-color-start"),_r(NC.end,TC.end,Dr,n,"--top-color-end")):(_r(rw,sw,Dr,n,"--font-color"),_r(GC.start,UC.start,Dr,n,"--top-buttons-color-start"),_r(GC.end,UC.end,Dr,n,"--top-buttons-color-end"),_r(TC.start,NC.start,Dr,n,"--top-color-start"),_r(TC.end,NC.end,Dr,n,"--top-color-end"));break}document.body.style.background=this.mode==="dark"?"black":"white"}var dh={};function _r(o,n,l,g,u){dh[u]&&(clearInterval(dh[u]),dh[u]=void 0);function S(R){R.length===4&&(R=`#${R[1]}${R[1]}${R[2]}${R[2]}${R[3]}${R[3]}`);let X0=parseInt(R.slice(1),16);return{r:X0>>16&255,g:X0>>8&255,b:X0&255}}function r0(R,X0,F0){return R+(X0-R)*F0}let E0=S(o),m0=S(n),g0=performance.now()/1e3;function u1(){let X0=performance.now()/1e3-g0,F0=Math.min(X0/l,1),b1=Math.round(r0(E0.r,m0.r,F0)),l2=Math.round(r0(E0.g,m0.g,F0)),y1=Math.round(r0(E0.b,m0.b,F0));g.style.setProperty(u,`rgb(${b1}, ${l2}, ${y1})`),F0>=1&&(clearInterval(dh[u]),dh[u]=void 0)}dh[u]=setInterval(u1,1e3/60)}function Aw(o){let n=this.htmlControls.renderer;n.noteTimeSlider.addEventListener("input",()=>{o.noteFallingTimeMs=n.noteTimeSlider.value,br(n.noteTimeSlider).innerText=`${n.noteTimeSlider.value}ms`}),n.noteTimeSlider.onchange=()=>{this._saveSettings()},n.analyserThicknessSlider.addEventListener("input",()=>{o.lineThickness=parseInt(n.analyserThicknessSlider.value),br(n.analyserThicknessSlider).innerText=`${n.analyserThicknessSlider.value}px`}),n.analyserThicknessSlider.onchange=()=>{this._saveSettings()},n.analyserFftSlider.addEventListener("input",()=>{let l=Math.pow(2,parseInt(n.analyserFftSlider.value));o.normalAnalyserFft=l,o.drumAnalyserFft=Math.pow(2,Math.min(15,parseInt(n.analyserFftSlider.value)+2)),o.updateFftSize(),br(n.analyserFftSlider).innerText=`${l}`}),n.analyserFftSlider.onchange=()=>{this._saveSettings()},n.waveMultiplierSlizer.addEventListener("input",()=>{o.waveMultiplier=parseInt(n.waveMultiplierSlizer.value),br(n.waveMultiplierSlizer).innerText=n.waveMultiplierSlizer.value}),n.waveMultiplierSlizer.onchange=()=>{this._saveSettings()},n.analyserToggler.onclick=()=>{o.renderAnalysers=!o.renderAnalysers,this._saveSettings()},n.noteToggler.onclick=()=>{o.renderNotes=!o.renderNotes,this._saveSettings()},n.activeNoteToggler.onclick=()=>{o.drawActiveNotes=!o.drawActiveNotes,this._saveSettings()},n.visualPitchToggler.onclick=()=>{o.showVisualPitch=!o.showVisualPitch,this._saveSettings()},n.stabilizeWaveformsToggler.onclick=()=>{o.stabilizeWaveforms=!o.stabilizeWaveforms,this._saveSettings()}}function NA(o,n,l){if(n.textContent&&(o.textContent=n.textContent),n.translatePathTitle){if(!l)throw new Error("Translate path title provided but no locale provided.");l.bindObjectProperty(o,"textContent",n.translatePathTitle+".title"),l.bindObjectProperty(o,"title",n.translatePathTitle+".description")}}function aw(o,n){switch(o.type){case"button":let l=document.createElement("button");return NA(l,o,n),w$(o,[l]),l;case"text":let g=document.createElement("p");return NA(g,o,n),w$(o,[g]),g;case"input":let u=document.createElement("div");u.classList.add("notification_input_wrapper");let S=document.createElement("input");NA(S,o,n),S.addEventListener("keydown",Y2=>Y2.stopPropagation());let r0=document.createElement("label");return NA(r0,o,n),w$(o,[S,r0]),u.append(r0),u.appendChild(S),u;case"file":let E0=document.createElement("label");E0.classList.add("notification_input_wrapper");let m0=document.createElement("input");m0.type="file";let g0=document.createElement("label");g0.classList.add("notification_file_button"),NA(g0,o,n);let u1=document.createElement("label");return NA(u1,o,n),w$(o,[g0,m0,u1]),g0.appendChild(m0),E0.append(u1),E0.appendChild(g0),E0;case"progress":let R=document.createElement("div");R.classList.add("notification_progress_background");let X0=document.createElement("div");return X0.classList.add("notification_progress"),w$(o,[X0,R]),R.appendChild(X0),R;case"toggle":return Kb(o,n);case"range":let F0=document.createElement("input");F0.type="range";let b1=document.createElement("label");w$(o,[F0,b1]),NA(b1,o,n);let l2=VB(F0,!1),y1=document.createElement("div");return y1.classList.add("notification_slider_wrapper"),y1.appendChild(b1),y1.appendChild(l2),y1}}function w$(o,n){if(o.attributes)for(let[l,g]of Object.entries(o.attributes))for(let u of n)u.setAttribute(l,g)}function Kb(o,n){let l=document.createElement("label");l.classList.add("notification_switch_wrapper");let g=document.createElement("label");NA(g,o,n);let u=document.createElement("input");u.type="checkbox",w$(o,[g,u]);let S=document.createElement("div");S.classList.add("notification_switch"),S.appendChild(u);let r0=document.createElement("div");return r0.classList.add("notification_switch_slider"),S.appendChild(r0),l.appendChild(g),l.appendChild(S),l}var Vb=13,zb=0,PC={};function mt(o,n,l=Vb,g=!0,u=void 0,S=void 0){let r0=document.createElement("div"),E0=zb++;r0.classList.add("notification"),r0.innerHTML=` +`;function br(o){return o.parentElement.nextElementSibling}function Xy(o){let n=o.getElementsByTagName("spessarange");for(let l of n)l.parentElement.insertBefore(JB(l,!0),l);for(;n.length>0;)n[0].parentNode.removeChild(n[0])}function JB(o,n=!0){let l=document.createElement("div");l.classList.add("settings_slider_wrapper");let g=o.getAttribute("min"),u=o.getAttribute("max"),S=o.getAttribute("value"),r0=o.getAttribute("units"),E0=o.getAttribute("input_id"),m0=document.createElement("input");m0.classList.add("settings_slider"),m0.type="range",m0.id=E0,m0.min=g,m0.max=u,m0.value=S;let g0;n&&(g0=document.createElement("span"),g0.textContent=S+r0);let u1=document.createElement("div");u1.classList.add("settings_visual_wrapper");let R=document.createElement("div");R.classList.add("settings_slider_progress"),u1.appendChild(R);let X0=document.createElement("div");return X0.classList.add("settings_slider_thumb"),u1.appendChild(X0),u1.appendChild(m0),m0.addEventListener("input",()=>{let F0=parseInt(u1.style.getPropertyValue("--visual-width").replace("%","")),b1=Math.round((m0.value-m0.min)/(m0.max-m0.min)*100);Math.abs((F0-b1)/100)>.05?u1.classList.add("settings_slider_transition"):u1.classList.remove("settings_slider_transition"),u1.style.setProperty("--visual-width",`${b1}%`)}),u1.style.setProperty("--visual-width",`${(m0.value-m0.min)/(m0.max-m0.min)*100}%`),l.appendChild(u1),n&&l.appendChild(g0),l}async function ew(){let o=await window.savedSettings;if(!o.interface)return;Y5("Loading saved settings...",o);let n=this.htmlControls.renderer,l=this.renderer,g=o.renderer;l.noteFallingTimeMs=g.noteFallingTimeMs,n.noteTimeSlider.value=g.noteFallingTimeMs,n.noteTimeSlider.dispatchEvent(new Event("input")),br(n.noteTimeSlider).innerText=`${g.noteFallingTimeMs}ms`,n.analyserThicknessSlider.value=g.waveformThickness,n.analyserThicknessSlider.dispatchEvent(new Event("input")),l.lineThickness=g.waveformThickness,br(n.analyserThicknessSlider).innerText=`${g.waveformThickness}px`;let u=g.sampleSize;n.analyserFftSlider.value=Math.log2(u),n.analyserFftSlider.dispatchEvent(new Event("input")),l.normalAnalyserFft=u,l.drumAnalyserFft=Math.pow(2,Math.min(15,Math.log2(u)+2)),l.updateFftSize(),br(n.analyserFftSlider).innerText=`${u}`,l.waveMultiplier=g.amplifier,n.waveMultiplierSlizer.value=g.amplifier,n.waveMultiplierSlizer.dispatchEvent(new Event("input")),br(n.waveMultiplierSlizer).innerText=g.amplifier.toString();let S=this.htmlControls.renderer;l.renderAnalysers=g.renderWaveforms,S.analyserToggler.checked=g.renderWaveforms,l.renderNotes=g.renderNotes,S.noteToggler.checked=g.renderNotes,l.drawActiveNotes=g.drawActiveNotes,S.activeNoteToggler.checked=g.drawActiveNotes,l.showVisualPitch=g.showVisualPitch,S.visualPitchToggler.checked=g.showVisualPitch,l.stabilizeWaveforms=g.stabilizeWaveforms,S.stabilizeWaveformsToggler.checked=g.stabilizeWaveforms,l.keyRange=g.keyRange;let r0=this.htmlControls.keyboard,E0=this.midiKeyboard,m0=o.keyboard;E0.setKeyRange(m0.keyRange,!1),m0.autoRange?(r0.sizeSelector.value=TA,this.autoKeyRange=!0):(this.autoKeyRange=!1,r0.sizeSelector.value=Object.keys(this.keyboardSizes).find(g0=>this.keyboardSizes[g0].min===m0.keyRange.min&&this.keyboardSizes[g0].max===m0.keyRange.max)),m0.mode==="dark"&&(E0.toggleMode(!1),this.htmlControls.keyboard.modeSelector.checked=!0),m0.show===!1&&(E0.shown=!1,this.htmlControls.keyboard.showSelector.checked=!1),this.locale.changeGlobalLocale(o.interface.language,!0),setTimeout(()=>{this.htmlControls.interface.languageSelector.value=o.interface.language},100),o.interface.mode==="light"?(this._toggleDarkMode(),this.htmlControls.interface.themeSelector.checked=!1):this.htmlControls.interface.themeSelector.checked=!0,this.htmlControls.interface.layoutSelector.value=o.interface.layout||"downwards",this._changeLayout(o.interface.layout||"downwards")}function tw(){window.saveSettings&&window.saveSettings(this._serializeSettings())}function iw(){return{renderer:{noteFallingTimeMs:this.renderer.noteFallingTimeMs,waveformThickness:this.renderer.lineThickness,sampleSize:this.renderer.normalAnalyserFft,amplifier:this.renderer.waveMultiplier,renderWaveforms:this.renderer.renderAnalysers,renderNotes:this.renderer.renderNotes,drawActiveNotes:this.renderer.drawActiveNotes,showVisualPitch:this.renderer.showVisualPitch,stabilizeWaveforms:this.renderer.stabilizeWaveforms,keyRange:this.renderer.keyRange},keyboard:{selectedChannel:this.midiKeyboard.channel,keyRange:this.midiKeyboard.keyRange,mode:this.midiKeyboard.mode,autoRange:this.htmlControls.keyboard.sizeSelector.value===TA,show:this.htmlControls.keyboard.showSelector.checked===!0},midi:{input:this.midiDeviceHandler.selectedInput===null?null:this.midiDeviceHandler.selectedInput.name,output:this.midiDeviceHandler.selectedOutput===null?null:this.midiDeviceHandler.selectedOutput.name},interface:{mode:this.mode,language:this.htmlControls.interface.languageSelector.value,layout:this.htmlControls.interface.layoutSelector.value}}}function nw(){let o=this.htmlControls.interface.themeSelector;o.onclick=()=>{this._toggleDarkMode(),this._saveSettings()};let n=this.htmlControls.interface.languageSelector;for(let[g,u]of Object.entries(this.locales)){let S=document.createElement("option");S.value=g,S.textContent=u.localeName,n.appendChild(S)}n.onchange=()=>{this.locale.changeGlobalLocale(n.value),this._saveSettings()};let l=this.htmlControls.interface.layoutSelector;l.onchange=()=>{this._changeLayout(l.value),this._saveSettings(),l.blur()}}function rw(o){let n=document.getElementById("keyboard_canvas_wrapper"),l=document.getElementById("note_canvas"),g=document.getElementById("keyboard");switch(o){case"downwards":n.classList.remove("upwards"),n.classList.remove("left_to_right"),n.classList.remove("right_to_left"),l.classList.remove("sideways"),g.classList.remove("sideways"),this.renderer.direction="down",this.renderer.sideways=!1;break;case"upwards":n.classList.add("upwards"),n.classList.remove("left_to_right"),n.classList.remove("right_to_left"),l.classList.remove("sideways"),g.classList.remove("sideways"),this.renderer.direction="up",this.renderer.sideways=!1;break;case"left":n.classList.remove("upwards"),n.classList.add("left_to_right"),n.classList.remove("right_to_left"),l.classList.add("sideways"),g.classList.add("sideways"),this.renderer.direction="up",this.renderer.sideways=!0;break;case"right":n.classList.remove("upwards"),n.classList.remove("left_to_right"),n.classList.add("right_to_left"),l.classList.add("sideways"),g.classList.add("sideways"),this.renderer.direction="down",this.renderer.sideways=!0}}var MC={start:"#101010",end:"#212121"},TC={start:"#bbb",end:"#f0f0f0"},sw="#eee",ow="#333",NC={start:"#222",end:"#333"},GC={start:"#ccc",end:"#fff"},Dr=.2;function Aw(){this.mode==="dark"?(this.mode="light",this.renderer.drawActiveNotes=!1):(this.renderer.drawActiveNotes=!0,this.mode="dark"),this.renderer.toggleDarkMode(),this.synthui.toggleDarkMode(),this.sequi.toggleDarkMode(),this.musicMode.toggleDarkMode(),document.getElementsByClassName("spessasynth_main")[0].classList.toggle("light_mode"),document.getElementsByClassName("top_part")[0].classList.toggle("top_part_light"),this.mainDiv.classList.toggle("settings_menu_light");let o=document.styleSheets[0].cssRules;for(let n of o)if(n.selectorText==="*"){this.mode==="dark"?(_r(ow,sw,Dr,n,"--font-color"),_r(GC.start,NC.start,Dr,n,"--top-buttons-color-start"),_r(GC.end,NC.end,Dr,n,"--top-buttons-color-end"),_r(TC.start,MC.start,Dr,n,"--top-color-start"),_r(TC.end,MC.end,Dr,n,"--top-color-end")):(_r(sw,ow,Dr,n,"--font-color"),_r(NC.start,GC.start,Dr,n,"--top-buttons-color-start"),_r(NC.end,GC.end,Dr,n,"--top-buttons-color-end"),_r(MC.start,TC.start,Dr,n,"--top-color-start"),_r(MC.end,TC.end,Dr,n,"--top-color-end"));break}document.body.style.background=this.mode==="dark"?"black":"white"}var dh={};function _r(o,n,l,g,u){dh[u]&&(clearInterval(dh[u]),dh[u]=void 0);function S(R){R.length===4&&(R=`#${R[1]}${R[1]}${R[2]}${R[2]}${R[3]}${R[3]}`);let X0=parseInt(R.slice(1),16);return{r:X0>>16&255,g:X0>>8&255,b:X0&255}}function r0(R,X0,F0){return R+(X0-R)*F0}let E0=S(o),m0=S(n),g0=performance.now()/1e3;function u1(){let X0=performance.now()/1e3-g0,F0=Math.min(X0/l,1),b1=Math.round(r0(E0.r,m0.r,F0)),l2=Math.round(r0(E0.g,m0.g,F0)),y1=Math.round(r0(E0.b,m0.b,F0));g.style.setProperty(u,`rgb(${b1}, ${l2}, ${y1})`),F0>=1&&(clearInterval(dh[u]),dh[u]=void 0)}dh[u]=setInterval(u1,1e3/60)}function aw(o){let n=this.htmlControls.renderer;n.noteTimeSlider.addEventListener("input",()=>{o.noteFallingTimeMs=n.noteTimeSlider.value,br(n.noteTimeSlider).innerText=`${n.noteTimeSlider.value}ms`}),n.noteTimeSlider.onchange=()=>{this._saveSettings()},n.analyserThicknessSlider.addEventListener("input",()=>{o.lineThickness=parseInt(n.analyserThicknessSlider.value),br(n.analyserThicknessSlider).innerText=`${n.analyserThicknessSlider.value}px`}),n.analyserThicknessSlider.onchange=()=>{this._saveSettings()},n.analyserFftSlider.addEventListener("input",()=>{let l=Math.pow(2,parseInt(n.analyserFftSlider.value));o.normalAnalyserFft=l,o.drumAnalyserFft=Math.pow(2,Math.min(15,parseInt(n.analyserFftSlider.value)+2)),o.updateFftSize(),br(n.analyserFftSlider).innerText=`${l}`}),n.analyserFftSlider.onchange=()=>{this._saveSettings()},n.waveMultiplierSlizer.addEventListener("input",()=>{o.waveMultiplier=parseInt(n.waveMultiplierSlizer.value),br(n.waveMultiplierSlizer).innerText=n.waveMultiplierSlizer.value}),n.waveMultiplierSlizer.onchange=()=>{this._saveSettings()},n.analyserToggler.onclick=()=>{o.renderAnalysers=!o.renderAnalysers,this._saveSettings()},n.noteToggler.onclick=()=>{o.renderNotes=!o.renderNotes,this._saveSettings()},n.activeNoteToggler.onclick=()=>{o.drawActiveNotes=!o.drawActiveNotes,this._saveSettings()},n.visualPitchToggler.onclick=()=>{o.showVisualPitch=!o.showVisualPitch,this._saveSettings()},n.stabilizeWaveformsToggler.onclick=()=>{o.stabilizeWaveforms=!o.stabilizeWaveforms,this._saveSettings()}}function NA(o,n,l){if(n.textContent&&(o.textContent=n.textContent),n.translatePathTitle){if(!l)throw new Error("Translate path title provided but no locale provided.");l.bindObjectProperty(o,"textContent",n.translatePathTitle+".title"),l.bindObjectProperty(o,"title",n.translatePathTitle+".description")}}function $w(o,n){switch(o.type){case"button":let l=document.createElement("button");return NA(l,o,n),w$(o,[l]),l;case"text":let g=document.createElement("p");return NA(g,o,n),w$(o,[g]),g;case"input":let u=document.createElement("div");u.classList.add("notification_input_wrapper");let S=document.createElement("input");NA(S,o,n),S.addEventListener("keydown",Y2=>Y2.stopPropagation());let r0=document.createElement("label");return NA(r0,o,n),w$(o,[S,r0]),u.append(r0),u.appendChild(S),u;case"file":let E0=document.createElement("label");E0.classList.add("notification_input_wrapper");let m0=document.createElement("input");m0.type="file";let g0=document.createElement("label");g0.classList.add("notification_file_button"),NA(g0,o,n);let u1=document.createElement("label");return NA(u1,o,n),w$(o,[g0,m0,u1]),g0.appendChild(m0),E0.append(u1),E0.appendChild(g0),E0;case"progress":let R=document.createElement("div");R.classList.add("notification_progress_background");let X0=document.createElement("div");return X0.classList.add("notification_progress"),w$(o,[X0,R]),R.appendChild(X0),R;case"toggle":return Kb(o,n);case"range":let F0=document.createElement("input");F0.type="range";let b1=document.createElement("label");w$(o,[F0,b1]),NA(b1,o,n);let l2=JB(F0,!1),y1=document.createElement("div");return y1.classList.add("notification_slider_wrapper"),y1.appendChild(b1),y1.appendChild(l2),y1}}function w$(o,n){if(o.attributes)for(let[l,g]of Object.entries(o.attributes))for(let u of n)u.setAttribute(l,g)}function Kb(o,n){let l=document.createElement("label");l.classList.add("notification_switch_wrapper");let g=document.createElement("label");NA(g,o,n);let u=document.createElement("input");u.type="checkbox",w$(o,[g,u]);let S=document.createElement("div");S.classList.add("notification_switch"),S.appendChild(u);let r0=document.createElement("div");return r0.classList.add("notification_switch_slider"),S.appendChild(r0),l.appendChild(g),l.appendChild(S),l}var Vb=13,zb=0,UC={};function mt(o,n,l=Vb,g=!0,u=void 0,S=void 0){let r0=document.createElement("div"),E0=zb++;r0.classList.add("notification"),r0.innerHTML=`@@ -205,19 +205,19 @@ var EC=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,l)=>(`;let m0=document.createElement("div");if(m0.classList.add("notification_content"),S)for(let[u1,R]of Object.entries(S))m0.style[u1]=R;r0.appendChild(m0);for(let u1 of n){let R=aw(u1,u);u1.onClick&&(R.onclick=()=>u1.onClick({div:r0,id:E0},R)),m0.appendChild(R)}g?r0.getElementsByClassName("close_btn")[0].onclick=()=>{Ot(E0)}:r0.getElementsByClassName("close_btn")[0].style.display="none",setTimeout(()=>{r0.classList.add("drop")},75);let g0=setTimeout(()=>{Ot(E0)},l*1e3+75);return document.getElementsByClassName("notification_field")[0].appendChild(r0),PC[E0]={div:r0,timeout:g0},{div:r0,id:E0}}function Ot(o){let n=PC[o].div;clearTimeout(PC[o].timeout),n.classList.remove("drop"),setTimeout(()=>n.parentElement.removeChild(n),500),PC[o]=void 0}function $w(o,n,l){o.createMIDIDeviceHandler().then(g=>{g?(this._createMidiInputHandler(o,l.synth),this._createMidiOutputHandler(o,n)):(Sr||mt(this.locale.getLocaleString("locale.warnings.warning"),[{type:"text",textContent:this.locale.getLocaleString("locale.warnings.noMidiSupport")}]),document.getElementById("midi_settings").style.display="none")})}function lw(o,n){if(o.inputs.length<1)return;let l=this.htmlControls.midi.inputSelector;for(let g of o.inputs){let u=document.createElement("option");u.value=g[0],u.innerText=g[1].name,l.appendChild(u)}l.onchange=()=>{l.value==="-1"?o.disconnectAllDevicesFromSynth():o.connectDeviceToSynth(o.inputs.get(l.value),n),this._saveSettings()}}function cw(o,n){if(!o.outputs){setTimeout(()=>{this._createMidiOutputHandler(o,n)},1e3);return}if(o.outputs.length<1)return;let l=this.htmlControls.midi.outputSelector;for(let g of o.outputs){let u=document.createElement("option");u.value=g[0],u.innerText=g[1].name,l.appendChild(u)}l.onchange=()=>{n.seq&&(l.value==="-1"?o.disconnectSeqFromMIDI(n.seq):o.connectMIDIOutputToSeq(o.outputs.get(l.value),n.seq),this._saveSettings())}}var gw={title:"Renderer settings",noteFallingTime:{title:"Note falling time (miliseconds)",description:"How fast the notes fall (visually)"},waveformThickness:{title:"Waveform line thickness (px)",description:"How thick the waveform lines are"},waveformSampleSize:{title:"Waveform sample size",description:"How detailed the waveforms are (Note: high values might impact performance)"},waveformAmplifier:{title:"Waveform amplifier",description:"How vibrant the waveforms are"},toggleWaveformsRendering:{title:"Enable waveforms rendering",description:"Enable rendering the channel waveforms (colorful lines showing audio)"},toggleNotesRendering:{title:"Enable notes rendering",description:"Enable rendering of the falling notes when playing a MIDI file"},toggleDrawingActiveNotes:{title:"Enable drawing active notes",description:"Enable notes lighting up and glowing when they get pressed"},toggleDrawingVisualPitch:{title:"Enable drawing visual pitch",description:"Enable notes sliding left or right when the pitch wheel is applied"},toggleStabilizeWaveforms:{title:"Stabilize waveforms",description:"Enable oscilloscope triggering"}};var hw={title:"MIDI Keyboard settings",selectedChannel:{title:"Selected channel",description:"The channel keyboard sends messages to",channelOption:"Channel {0}"},keyboardSize:{title:"Keyboard size",description:"The range of keys shown on the keyboard. Adjusts the MIDI note size accordingly",full:"128 keys (full)",piano:"88 keys (piano)",fiveOctaves:"5 octaves",useSongKeyRange:"Use song's key range",twoOctaves:"Two octaves"},toggleTheme:{title:"Use dark theme",description:"Use the dark MIDI keyboard theme"},show:{title:"Show",description:"Show/hide MIDI keyboard"}};var fw={title:"MIDI settings",midiInput:{title:"MIDI input",description:"The port to listen on for MIDI messages",disabled:"Disabled"},midiOutput:{title:"MIDI output",description:"The port to play the MIDI file to",disabled:"Use SpessaSynth"}};var uw={toggleButton:"Settings",mainTitle:"Program settings",rendererSettings:gw,keyboardSettings:hw,midiSettings:fw,interfaceSettings:{title:"Interface settings",toggleTheme:{title:"Use dark theme",description:"Enable the dark theme for the interface"},selectLanguage:{title:"Language",description:"Change the program language"},layoutDirection:{title:"Layout direction",description:"The layout direction of the renderer and keyboard",values:{downwards:"Downwards",upwards:"Upwards",leftToRight:"Left to right",rightToLeft:"Right to left"}}}};var dw={toggleButton:{title:"Toggle music player mode",description:"Toggle the simplified UI version, hiding the keyboard and note visualizations"},currentlyPlaying:"Currently playing:",nothingPlaying:"Nothing is playing",nothingPlayingCopyright:"Upload a MIDI!"};var Iw={voiceMeter:{title:"Voices: ",description:"The current amount of voices playing on channel {0}"},pitchBendMeter:{title:"Pitch: ",description:"The current pitch bend applied to channel {0}"},panMeter:{title:"Pan: ",description:"The current stereo panning applied to channel {0} (right-click to lock)"},expressionMeter:{title:"Expression: ",description:"The current expression (loudness) of channel {0} (right-click to lock)"},volumeMeter:{title:"Volume: ",description:"The current volume of channel {0} (right-click to lock)"},modulationWheelMeter:{title:"Mod wheel: ",description:"The current modulation (usually vibrato) depth of channel {0} (right-click to lock)"},chorusMeter:{title:"Chorus: ",description:"The current level of chorus effect applied to channel {0} (right-click to lock)"},reverbMeter:{title:"Reverb: ",description:"The current level of reverb effect applied to channel {0} (right-click to lock)"},filterMeter:{title:"Filter: ",description:"The current level of low-pass filter cutoff applied to channel {0} (right-click to lock)"},transposeMeter:{title:"Transpose: ",description:"The current transposition (key shift) of channel {0}"},presetSelector:{description:"Change the patch (instrument) channel {0} is using",selectionPrompt:"Change instrument for channel {0}",searchPrompt:"Search..."},presetReset:{description:"Unlock channel {0} to allow program changes"},soloButton:{description:"Solo on channel {0}"},muteButton:{description:"Mute/unmute channel {0}"},drumToggleButton:{description:"Toggle drums on channel {0}"}};var Ew={toggleButton:{title:"Synthesizer controller",description:"Show the synthesizer controller"},mainVoiceMeter:{title:"Voices: ",description:"The total amount of voices currently playing"},mainVolumeMeter:{title:"Volume: ",description:"The current master volume of the synthesizer"},mainPanMeter:{title:"Pan: ",description:"The current master stereo panning of the synthesizer"},mainTransposeMeter:{title:"Transpose: ",description:"Transposes the synthesizer (in semitones or keys)"},midiPanic:{title:"MIDI Panic",description:"Stops all voices immediately"},systemReset:{title:"System reset",description:"Resets all controllers to their default values"},blackMidiMode:{title:"Black MIDI mode",description:"Toggles the High Performance Mode, simplifying the look and killing the notes faster"},disableCustomVibrato:{title:"Disable custom vibrato",description:"Disables the custom (NRPN) Vibrato permamently. Reload the website to reenable it"},helpButton:{title:"Help",description:"Opens an external website with the usage guide"},interpolation:{description:"Select the synthesizer's interpolation method",linear:"Linear Interpolation",nearestNeighbor:"Nearest neighbor",cubic:"Cubic Interpolation"},channelController:Iw};var mw={previousSong:"Previous song",nextSong:"Next song",loopThis:"Loop this song",playPause:"Play/pause",lyrics:{show:"Show lyrics",title:"Decoded text",noLyrics:"No lyrics available...",otherText:{title:"Other text"}}};var Cw={button:{title:"Save Audio",description:"Save the composition to various formats"},formats:{title:"Choose format",formats:{wav:{button:{title:"WAV audio (.wav)",description:"Export the song with modifications as a .wav audio file"},options:{title:"WAV export options",confirm:"Export",normalizeVolume:{title:"Normalize volume",description:"Keep the volume at the same level, no matter how loud or quiet the MIDI is. Recommended."},additionalTime:{title:"Additional time (s)",description:"Additional time at the end of the song to allow for the sound to fade. (seconds)"},separateChannels:{title:"Separate channels",description:"Save each channel as a separate file. Useful for things like oscilloscope viewers. Note that this disables reverb and chorus.",saving:{title:"Channel files",save:"Save channel {0}"}},loopCount:{title:"Loop count",description:"The amount of times to loop the song"}},exportMessage:{message:"Exporting WAV audio...",estimated:"Remaining:",convertWav:"Converting to wav..."}},midi:{button:{title:"MIDI (.mid)",description:"Export the MIDI file with the controller and instrument changes applied"}},soundfont:{button:{title:"SoundFont (.sf2)",description:"Export a SoundFont2 file"},options:{title:"SF export options",confirm:"Export",trim:{title:"Trim",description:"Export the soundfont trimmed to only use instruments and samples that the MIDI file uses"},compress:{title:"Compress",description:"Compress samples with lossy Ogg Vorbis compression if uncompressed. Significantly reduces the file size.If the soundfont was already compressed, it won't be uncompressed even if this option is disabled"},quality:{title:"Compression quality",description:"The quality of compression. Higher is better"}}},rmidi:{button:{title:"Embedded MIDI (.rmi)",description:"Export the modified MIDI with the embedded trimmed soundfont as a single file. Note that this format isn't widely supported"},progress:{title:"Exporting embeded MIDI...",loading:"Loading Soundfont and MIDI...",modifyingMIDI:"Modifying MIDI...",modifyingSoundfont:"Trimming Soundfont...",saving:"Saving RMIDI...",done:"Done!"},options:{title:"RMIDI export options",confirm:"Export",compress:{title:"Compress",description:"Compress the Soundfont with lossy Ogg Vorbis compression. Significantly reduces the file size. Recommended."},quality:{title:"Compression quality",description:"The quality of compression. Higher is better."},bankOffset:{title:"Bank offset",description:"The bank offset of the file. Value of 0 is recommended. Only change if you know what you're doing."},adjust:{title:"Adjust MIDI",description:"Adjusts the MIDI file to the SoundFont. Leave this on unless you know what you're doing."}}}},metadata:{songTitle:{title:"Title:",description:"The song's title"},album:{title:"Album:",description:"The song's album"},artist:{title:"Artist:",description:"The song's artist"},albumCover:{title:"Album cover:",description:"The song's album cover"},creationDate:{title:"Created:",description:"The song's creation date"},genre:{title:"Genre:",description:"The song's genre"},comment:{title:"Comment:",description:"The song's comment"},duration:{title:"Duration:",description:"The song's duration"}}}};var Bw={localeName:"English",titleMessage:"SpessaSynth: SoundFont2 Javascript Synthesizer",demoTitleMessage:"SpessaSynth: SoundFont2 Javascript Synthesizer Online Demo",synthInit:{genericLoading:"Loading...",loadingSoundfont:"Loading SoundFont...",loadingBundledSoundfont:"Loading bundled SoundFont...",startingSynthesizer:"Starting Synthesizer...",savingSoundfont:"Saving SoundFont for reuse...",noWebAudio:"Your browser does not support Web Audio.",done:"Ready!"},midiUploadButton:"Upload your MIDI files",exportAudio:Cw,yes:"Yes",no:"No",demoSoundfontUploadButton:"Upload the soundfont",demoGithubPage:"Project's page",demoSongButton:"Demo Song",credits:"Credits",dropPrompt:"Drop files here...",warnings:{outOfMemory:"Your browser ran out of memory. Consider using Firefox or SF3 soundfont instead. (see console for error).",noMidiSupport:"No MIDI ports detected, this functionality will be disabled.",chromeMobile:"SpessaSynth performs poorly on Chrome Mobile. Consider using Firefox Android instead.",warning:"Warning"},hideTopBar:{title:"Hide top bar",description:"Hide the top (title) bar to provide a more seamless experience"},convertDls:{title:"DLS Conversion",message:"Looks like you've uploaded a DLS file. Do you want to convert it to SF2?"},musicPlayerMode:dw,settings:uw,synthesizerController:Ew,sequencerController:mw};var pw={title:"Ustawienia wizualizacji",noteFallingTime:{title:"Czas spadania nut (ms)",description:"Jak szybko spadaj\u0105 z g\xF3ry nuty (w milisekundach)"},waveformThickness:{title:"Grubo\u015B\u0107 lini fal (px)",description:"Jak grube s\u0105 linie fal d\u017Awi\u0119kowych"},waveformSampleSize:{title:"Rozmiar pr\xF3bki fali",description:"Jak szczeg\xF3\u0142owe s\u0105 linei fal d\u017Awi\u0119kowcyh (Uwaga: wysokie warto\u015Bci mog\u0105 pogorszy\u0107 wydajno\u015B\u0107)"},waveformAmplifier:{title:"Wzmacniasz fal",description:"Jak '\u017Cywe' s\u0105 fale. Kontroluje ich amplitud\u0119"},toggleWaveformsRendering:{title:"W\u0142\u0105cz rysowanie fal",description:"W\u0142\u0105cz rysowanie fal d\u017Awi\u0119kowych (16-tu kolorowych linii z ty\u0142u)"},toggleNotesRendering:{title:"W\u0142\u0105cz rysowanie nut",description:"W\u0142\u0105cz rysowanie spadaj\u0105cych nut podczas odtwarzania pliku MIDI"},toggleDrawingActiveNotes:{title:"W\u0142\u0105cz rysowanie aktywnych nut",description:"W\u0142\u0105cz efekt pod\u015Bwietlania si\u0119 nut przy aktywacji"},toggleDrawingVisualPitch:{title:"W\u0142\u0105cz wizualizacj\u0119 wysoko\u015Bci tonu",description:"W\u0142\u0105cz przesuwanie nut w lewo lub w prawo gdy wysoko\u015B\u0107 nut jest zmieniana"},toggleStabilizeWaveforms:{title:"W\u0142\u0105cz stabilizacj\u0119 fal",description:"W\u0142\u0105cz stabilizowanie fal d\u017Awi\u0119kowych"}};var Qw={title:"Ustawienia pianina",selectedChannel:{title:"Wybrany kana\u0142",description:"Kana\u0142, do kt\xF3rego b\u0119dzie pod\u0142\u0105czone pianino",channelOption:"Kana\u0142 {0}"},keyboardSize:{title:"Rozmiar pianina",description:"Zakres klawiszy widocznych na pianine. Dostosowuje r\xF3wnie\u017C szeroko\u015B\u0107 wizualizowanych nut",full:"128 klawiszy (pe\u0142en zakres)",piano:"88 klawiszy (fortepian)",fiveOctaves:"5 oktaw",twoOctaves:"Dwie oktawy",useSongKeyRange:"U\u017Cyj zakresu utworu"},toggleTheme:{title:"W\u0142\u0105cz ciemny motyw",description:"W\u0142\u0105cz ciemny motyw wbudowanego pianina"},show:{title:"Poka\u017C",description:"Poka\u017C/ukryj pianino"}};var yw={title:"Ustawienia MIDI",midiInput:{title:"Wej\u015Bcie MIDI",description:"Port MIDI, kt\xF3ry b\u0119dzie nas\u0142uchiwany",disabled:"Wy\u0142\u0105czony"},midiOutput:{title:"Wyj\u015Bcie MIDI",description:"Port MIDI, do kt\xF3rego b\u0119dzie grany utw\xF3r",disabled:"U\u017Cyj SpessaSynth"}};var ww={toggleButton:"Ustawienia",mainTitle:"Ustawienia programu",rendererSettings:pw,keyboardSettings:Qw,midiSettings:yw,interfaceSettings:{title:"Ustawienia interfejsu",toggleTheme:{title:"W\u0142\u0105cz ciemny motyw",description:"W\u0142\u0105cz ciemny motyw programu"},selectLanguage:{title:"J\u0119zyk",description:"Zmie\u0144 j\u0119zyk programu"},layoutDirection:{title:"Uk\u0142ad",description:"Kierunek uk\u0142adu wizualizacji i pianina",values:{downwards:"W d\xF3\u0142",upwards:"W g\xF3r\u0119",leftToRight:"Od lewej do prawej",rightToLeft:"Od prawej do lewej"}}}};var kw={toggleButton:{title:"Prze\u0142\u0105cz tryb odtwarzania muzyki",description:"Prze\u0142\u0105cz uproszczon\u0105 wersj\u0119 interfejsu, ukrywaj\u0105c pianino i wizualizacj\u0119 nut"},currentlyPlaying:"Teraz gramy:",nothingPlaying:"Nic teraz nie gra",nothingPlayingCopyright:"Wgraj jakie\u015B MIDI!"};var vw={voiceMeter:{title:"D\u017Awi\u0119ki: ",description:"Aktualna ilo\u015B\u0107 d\u017Awi\u0119k\xF3w na kanale {0}"},pitchBendMeter:{title:"Wysoko\u015B\u0107: ",description:"Aktualna wysoko\u015B\u0107 tonu na kanale {0}"},panMeter:{title:"Stereo: ",description:"Aktualny efekt stereo na kanale {0} (kliknij prawym aby zablokowa\u0107)"},expressionMeter:{title:"Ekspresja: ",description:"Aktualna ekspresja (g\u0142o\u015Bno\u015Bc) kana\u0142u {0} (kliknij prawym aby zablokowa\u0107)"},volumeMeter:{title:"G\u0142o\u015Bno\u015B\u0107: ",description:"Aktualna g\u0142o\u015Bno\u015B\u0107 kana\u0142u {0} (kliknij prawym aby zablokowa\u0107)"},modulationWheelMeter:{title:"Modulacja: ",description:"Aktualna g\u0142\u0119boko\u015B\u0107 modulacji (zazwyczaj vibrato) kana\u0142u {0} (kliknij prawym aby zablokowa\u0107)"},chorusMeter:{title:"Ch\xF3r: ",description:"Aktualny efekt ch\xF3ru na kanale {0} (kliknij prawym aby zablokowa\u0107)"},reverbMeter:{title:"Pog\u0142os: ",description:"Aktualny efekt pog\u0142osu na kanale {0} (kliknij prawym aby zablokowa\u0107)"},filterMeter:{title:"Filtr: ",description:"Aktualny poziom filtra niskopasmowego na kanale {0} (kliknij prawym aby zablokowa\u0107)"},transposeMeter:{title:"Transpozycja: ",description:"Aktualna transpozycja (przesuni\u0119cie klawiszy) kana\u0142u {0}"},presetSelector:{description:"Zmie\u0144 patch (instrument), kt\xF3rego u\u017Cywa kana\u0142 {0}",selectionPrompt:"Zmie\u0144 instrument kana\u0142u {0}",searchPrompt:"Wyszukaj..."},presetReset:{description:"Odblokuj kana\u0142 {0}, aby program m\xF3g\u0142 go zmienia\u0107"},soloButton:{description:"Solo na kanale {0}"},muteButton:{description:"Wycisz/odcisz kana\u0142 {0}"},drumToggleButton:{description:"Prze\u0142\u0105cz perkusj\u0119 na kanale {0}"}};var Sw={toggleButton:{title:"Kontroler syntezatora",description:"Poka\u017C kontroler syntezatora"},mainVoiceMeter:{title:"D\u017Awi\u0119ki: ",description:"Ca\u0142kowita ilo\u015B\u0107 aktualnie odtwarzanych d\u017Awi\u0119k\xF3w"},mainVolumeMeter:{title:"G\u0142o\u015Bno\u015B\u0107: ",description:"Aktualna g\u0142o\u015Bno\u015B\u0107 syntezatora"},mainPanMeter:{title:"Stereo: ",description:"Aktualna pozycja stereo syntezatora"},mainTransposeMeter:{title:"Transpozycja: ",description:"Transpozycjonuje syntezator (w semitonach)"},midiPanic:{title:"MIDI Panic",description:"Zatrzymuje wszystkie d\u017Awi\u0119ki"},systemReset:{title:"Reset systemu",description:"Resetuje wszystkie kontroleru do ich domy\u015Blnych warto\u015Bci"},blackMidiMode:{title:"Tryb black MIDI",description:"Prze\u0142\u0105cza tryb wysokiej wydajno\u015Bci, upraszczaj\u0105c wygl\u0105d i pogarszaj\u0105c jako\u015B\u0107 d\u017Awi\u0119ku"},disableCustomVibrato:{title:"Wy\u0142\u0105cz niestandardowe vibrato",description:"Wy\u0142\u0105cza niestandardowe (NRPN) vibrato. Wymaga prze\u0142adowania strony aby je ponownie w\u0142\u0105czy\u0107"},helpButton:{title:"Pomoc",description:"Poka\u017C instrukcj\u0119 obs\u0142ugi"},interpolation:{description:"Wybierz metod\u0119 interpolacji",linear:"Interpolacja liniowa",nearestNeighbor:"Najbli\u017Cszy s\u0105siad",cubic:"Interpolacja Sze\u015Bcienna"},channelController:vw};var bw={previousSong:"Poprzedni utw\xF3r",nextSong:"Nast\u0119pny utw\xF3r",loopThis:"Odtwarzaj w p\u0119tli",playPause:"Odtw\xF3rz/wstrzymaj",lyrics:{show:"Poka\u017C tekst",title:"Odczytany tekst",noLyrics:"Brak dost\u0119pnego tekstu...",otherText:{title:"Inny tekst"}}};var Dw={button:{title:"Zapisz",description:"Zapisz w r\xF3\u017Cnych formatach"},formats:{title:"Wybierz format",formats:{wav:{button:{title:"Audio WAV (.wav)",description:"Eksportuj utw\xF3r ze zmianami jako plik audio .wav"},options:{title:"Opcje eksportu audio",confirm:"Eksportuj",normalizeVolume:{title:"Normalizuj g\u0142o\u015Bno\u015B\u0107",description:"Eksportuj audio z tak\u0105 sam\u0105 g\u0142o\u015Bno\u015Bci\u0105, niezale\u017Cnie od g\u0142o\u015Bno\u015Bci MIDI."},additionalTime:{title:"Dodatkowy czas (s)",description:"Dodatkowy czas na ko\u0144cu utworu aby pozwoli\u0107 na wyciszenie si\u0119 d\u017Awi\u0119ku. (sekundy)"},separateChannels:{title:"Rozdziel kana\u0142y",description:"Zapisz ka\u017Cdy kana\u0142 w osobnym pliuku. Przydatne dla rzeczy jak widok oscyloskopowy. Nale\u017Cy pami\u0119ta\u0107 \u017Ce to wy\u0142\u0105cza ekfet pog\u0142osu i ch\xF3ru",saving:{title:"Pliki audio kana\u0142\xF3w",save:"Zapisz kana\u0142 {0}"}},loopCount:{title:"Ilo\u015B\u0107 p\u0119tli",description:"Ilo\u015B\u0107 razy zap\u0119tlenia utworu"}},exportMessage:{message:"Eksportowanie audio...",estimated:"Pozosta\u0142o:",convertWav:"Konwertowanie do wav..."}},midi:{button:{title:"MIDI (.mid)",description:"Eksportuj plik MIDI wraz ze zmianami instrument\xF3w i kontroler\xF3w"}},soundfont:{button:{title:"SoundFont (.sf2)",description:"Eksportuj SoundFont"},options:{title:"Opcje eksportu soundfonta",confirm:"Eksportuj",trim:{title:"Zmniejsz",description:"Zmniejsz SoundFont aby zawiera\u0142 tylko klawisze u\u017Cyte w MIDI"},compress:{title:"Kompresuj",description:"Zkompresuj pr\xF3bki kt\xF3re nie s\u0105 zkompresowane przy u\u017Cyciu stratnego kodeka Ogg Vorbis. Znacznie zmniejsza rozmiar pliku.Je\u015Bli soundfont by\u0142 ju\u017C skompresowany, nie zostanie zdekompresowany nawet gdy ta opcja jest wy\u0142\u0105czona"},quality:{title:"Jako\u015B\u0107 kompresji",description:"Jako\u015B\u0107 skompresowanych pr\xF3bek. Im wy\u017Csza tym lepsza"}}},rmidi:{button:{title:"Osadzone MIDI (.rmi)",description:"Eksportuj zmodyfikowane MIDI wraz ze zmniejszonym soundfontem jako jeden plik. Uwaga: ten format nie jest szeroko wspierany"},progress:{title:"Exportowanie osadzonego MIDI...",loading:"Wczytywanie soundfonta i MIDI...",modifyingMIDI:"Modyfikowanie MIDI...",modifyingSoundfont:"Zmniejszanie Soundfonta...",saving:"Zapisywanie RMIDI...",done:"Gotowe!"},options:{title:"Opcje eksportu RMIDI",confirm:"Eksportuj",compress:{title:"Kompresuj",description:"Skompresuj osadzonego soundfonta za pomoc\u0105 stratnego kodeka Ogg Vorbis. Znacznie zmniejsza rozmiar pliku. Zalecane."},quality:{title:"Jako\u015B\u0107 kompresji",description:"Jako\u015B\u0107 skompresowanych pr\xF3bek. Im wy\u017Csza tym lepsza"},bankOffset:{title:"Przesuni\u0119cie banku",description:"Przesuni\u0119cie banku w pliku. Zalecane 0. Zmie\u0144 tylko je\u015Bli wiesz co robisz."},adjust:{title:"Dostosuj MIDI",description:"Dostosuj MIDI do SoundFonta. Pozostaw w\u0142\u0105czone, chyba \u017Ce wiesz co robisz."}}}},metadata:{songTitle:{title:"Tytu\u0142:",description:"Tytu\u0142 utworu"},album:{title:"Album:",description:"Album utworu"},artist:{title:"Tw\xF3rca:",description:"Tw\xF3rca utworu"},albumCover:{title:"Ok\u0142adka albumu:",description:"Ok\u0142adka albumu utworu"},creationDate:{title:"Stworzono:",description:"Data stworzenia utworu"},genre:{title:"Gatunek:",description:"Gatunek utworu"},comment:{title:"Komentarz:",description:"Komentarz do utworu"},duration:{title:"Czas trwania:",description:"Czas trwania utworu"}}}};var _w={localeName:"Polski",titleMessage:"SpessaSynth: JavaScriptowy Syntezator SoundFont2",demoTitleMessage:"SpessaSynth: JavaScriptowy Syntezator SoundFont2 Wersja Demo",synthInit:{genericLoading:"Wczytywanie...",loadingSoundfont:"Wczytywanie SoundFonta...",loadingBundledSoundfont:"Wczytywanie wbudowanego SoundFonta...",startingSynthesizer:"Uruchamianie syntezatora...",savingSoundfont:"Zapisywanie SoundFonta do przegl\u0105darki...",noWebAudio:"Twoja przegl\u0105darka nie wspiera Web Audio.",done:"Gotowe!"},midiUploadButton:"Wgraj Twoje pliki MIDI",midiRenderButton:{title:"Eksportuj audio",description:"Zapisz audio do pliku WAV lub MIDI"},exportAudio:Dw,yes:"Tak",no:"Nie",demoSoundfontUploadButton:"Wgraj SoundFonta",demoGithubPage:"Strona projektu",demoSongButton:"Piosenka demo",credits:"Tw\xF3rcy",dropPrompt:"Upu\u015B\u0107 pliki tutaj...",warnings:{outOfMemory:"Twojej przegl\u0105darce sko\u0144czy\u0142a si\u0119 pami\u0119\u0107. Rozwa\u017C u\u017Cycie Firefoxa albo plik\xF3w SF3. (Zobacz b\u0142\u0105d w konsoli)",noMidiSupport:"Nie wykryto MIDI. Korzystanie z port\xF3w MIDI nie b\u0119dzie dost\u0119pne.",chromeMobile:"SpessaSynth dzia\u0142a wolno na Chromie na telefon. Rozwa\u017C u\u017Cycie Firefoxa Android.",warning:"Uwaga"},hideTopBar:{title:"Ukryj g\xF3rny pasek",description:"Ukryj pasek tytu\u0142owy w celu poprawy widoczno\u015Bci na pionowych ekranach"},convertDls:{title:"Konwersja DLS",message:"Wygl\u0105da na to, \u017Ce wgra\u0142e\u015B plik DLS. Czy chcesz przekonwertowa\u0107 go do SF2?"},musicPlayerMode:kw,settings:ww,synthesizerController:Sw,sequencerController:bw};var Rw={title:"\u30EC\u30F3\u30C0\u30E9\u30FC\u8A2D\u5B9A",noteFallingTime:{title:"\u30CE\u30FC\u30C8\u306E\u843D\u4E0B\u6642\u9593\uFF08\u30DF\u30EA\u79D2\uFF09",description:"\u30CE\u30FC\u30C8\u304C\u843D\u3061\u308B\u901F\u3055\uFF08\u8996\u899A\u7684\u306B\uFF09"},waveformThickness:{title:"\u6CE2\u5F62\u306E\u7DDA\u306E\u592A\u3055\uFF08\u30D4\u30AF\u30BB\u30EB\uFF09",description:"\u6CE2\u5F62\u306E\u7DDA\u306E\u592A\u3055"},waveformSampleSize:{title:"\u6CE2\u5F62\u306E\u30B5\u30F3\u30D7\u30EB\u30B5\u30A4\u30BA",description:"\u6CE2\u5F62\u306E\u8A73\u7D30\u5EA6\uFF08\u6CE8\uFF1A\u9AD8\u3044\u5024\u306F\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u306B\u5F71\u97FF\u3092\u4E0E\u3048\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\uFF09"},waveformAmplifier:{title:"\u6CE2\u5F62\u306E\u5897\u5E45\u5668",description:"\u6CE2\u5F62\u306E\u9BAE\u3084\u304B\u3055"},toggleWaveformsRendering:{title:"\u6CE2\u5F62\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u306E\u5207\u308A\u66FF\u3048",description:"\u30C1\u30E3\u30F3\u30CD\u30EB\u6CE2\u5F62\u306E\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u3092\u5207\u308A\u66FF\u3048\u307E\u3059\uFF08\u30AA\u30FC\u30C7\u30A3\u30AA\u3092\u8868\u793A\u3059\u308B\u30AB\u30E9\u30D5\u30EB\u306A\u7DDA\uFF09"},toggleNotesRendering:{title:"\u30CE\u30FC\u30C8\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u306E\u5207\u308A\u66FF\u3048",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u751F\u3059\u308B\u969B\u306E\u843D\u4E0B\u30CE\u30FC\u30C8\u306E\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},toggleDrawingActiveNotes:{title:"\u30A2\u30AF\u30C6\u30A3\u30D6\u30CE\u30FC\u30C8\u306E\u63CF\u753B\u3092\u5207\u308A\u66FF\u3048",description:"\u30CE\u30FC\u30C8\u304C\u62BC\u3055\u308C\u305F\u3068\u304D\u306B\u5149\u308A\u8F1D\u304F\u63CF\u753B\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},toggleDrawingVisualPitch:{title:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30D4\u30C3\u30C1\u63CF\u753B\u306E\u5207\u308A\u66FF\u3048",description:"\u30D4\u30C3\u30C1\u30DB\u30A4\u30FC\u30EB\u304C\u9069\u7528\u3055\u308C\u305F\u3068\u304D\u306B\u30CE\u30FC\u30C8\u304C\u5DE6\u53F3\u306B\u30B9\u30E9\u30A4\u30C9\u3059\u308B\u63CF\u753B\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},toggleStabilizeWaveforms:{title:"\u6CE2\u5F62\u3092\u5B89\u5B9A\u3055\u305B\u308B",description:"\u30AA\u30FC\u30C7\u30A3\u30AA\u6CE2\u5F62\u3092\u5B89\u5B9A\u3055\u305B\u308B\u8A2D\u5B9A\u3092\u5207\u308A\u66FF\u3048\u3001\u6CE2\u5F62\u3092\u56FA\u5B9A\u3057\u307E\u3059\u3002"}};var xw={title:"\u30AD\u30FC\u30DC\u30FC\u30C9\u8A2D\u5B9A",selectedChannel:{title:"\u9078\u629E\u3055\u308C\u305F\u30C1\u30E3\u30F3\u30CD\u30EB",description:"\u30AD\u30FC\u30DC\u30FC\u30C9\u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u9001\u4FE1\u3059\u308B\u30C1\u30E3\u30F3\u30CD\u30EB",channelOption:"\u30C1\u30E3\u30F3\u30CD\u30EB {0}"},keyboardSize:{title:"\u30AD\u30FC\u30DC\u30FC\u30C9\u30B5\u30A4\u30BA",description:"\u30AD\u30FC\u30DC\u30FC\u30C9\u306B\u8868\u793A\u3055\u308C\u308B\u30AD\u30FC\u306E\u7BC4\u56F2\u3002MIDI\u30CE\u30FC\u30C8\u306E\u30B5\u30A4\u30BA\u306B\u5FDC\u3058\u3066\u8ABF\u6574\u3055\u308C\u307E\u3059",full:"128\u30AD\u30FC\uFF08\u5168\u4F53\uFF09",piano:"88\u30AD\u30FC\uFF08\u30D4\u30A2\u30CE\uFF09",fiveOctaves:"5\u30AA\u30AF\u30BF\u30FC\u30D6",useSongKeyRange:"\u66F2\u306E\u30AD\u30FC\u7BC4\u56F2\u3092\u4F7F\u7528",twoOctaves:"\u30AA\u30AF\u30BF\u30FC\u30D6"},toggleTheme:{title:"\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048",description:"\u30AD\u30FC\u30DC\u30FC\u30C9\u306E\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},show:{title:"\u8868\u793A",description:"MIDI\u30AD\u30FC\u30DC\u30FC\u30C9\u3092\u8868\u793A/\u975E\u8868\u793A"}};var Lw={title:"MIDI\u8A2D\u5B9A",midiInput:{title:"MIDI\u5165\u529B",description:"MIDI\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D7\u4FE1\u3059\u308B\u30DD\u30FC\u30C8",disabled:"\u7121\u52B9"},midiOutput:{title:"MIDI\u51FA\u529B",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u751F\u3059\u308B\u30DD\u30FC\u30C8",disabled:"SpessaSynth\u3092\u4F7F\u7528"}};var Fw={toggleButton:"\u8A2D\u5B9A",mainTitle:"\u30D7\u30ED\u30B0\u30E9\u30E0\u8A2D\u5B9A",rendererSettings:Rw,keyboardSettings:xw,midiSettings:Lw,interfaceSettings:{title:"\u30A4\u30F3\u30BF\u30FC\u30D5\u30A7\u30FC\u30B9\u8A2D\u5B9A",toggleTheme:{title:"\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048",description:"\u30D7\u30ED\u30B0\u30E9\u30E0\u306E\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},selectLanguage:{title:"\u8A00\u8A9E",description:"\u30D7\u30ED\u30B0\u30E9\u30E0\u306E\u8A00\u8A9E\u3092\u5909\u66F4\u3057\u307E\u3059"},layoutDirection:{title:"\u30EC\u30A4\u30A2\u30A6\u30C8\u306E\u65B9\u5411",description:"\u30EC\u30F3\u30C0\u30E9\u30FC\u3068\u30AD\u30FC\u30DC\u30FC\u30C9\u306E\u30EC\u30A4\u30A2\u30A6\u30C8\u65B9\u5411",values:{downwards:"\u4E0B\u5411\u304D",upwards:"\u4E0A\u5411\u304D",leftToRight:"\u5DE6\u304B\u3089\u53F3",rightToLeft:"\u53F3\u304B\u3089\u5DE6"}}}};var Mw={toggleButton:{title:"\u97F3\u697D\u30D7\u30EC\u30A4\u30E4\u30FC\u30E2\u30FC\u30C9\u306E\u5207\u308A\u66FF\u3048",description:"\u7C21\u7565\u5316\u3055\u308C\u305FUI\u30D0\u30FC\u30B8\u30E7\u30F3\u306B\u5207\u308A\u66FF\u3048\u3001\u30AD\u30FC\u30DC\u30FC\u30C9\u3068\u30CE\u30FC\u30C8\u306E\u8996\u899A\u5316\u3092\u96A0\u3057\u307E\u3059"},currentlyPlaying:"\u518D\u751F\u4E2D:",nothingPlaying:"\u518D\u751F\u3057\u3066\u3044\u308B\u3082\u306E\u306F\u3042\u308A\u307E\u305B\u3093",nothingPlayingCopyright:"MIDI\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u304F\u3060\u3055\u3044\uFF01"};var Tw={voiceMeter:{title:"\u30DC\u30A4\u30B9: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3067\u518D\u751F\u4E2D\u306E\u30DC\u30A4\u30B9\u306E\u73FE\u5728\u306E\u6570"},pitchBendMeter:{title:"\u30D4\u30C3\u30C1: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30D4\u30C3\u30C1\u30D9\u30F3\u30C9"},panMeter:{title:"\u30D1\u30F3: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30B9\u30C6\u30EC\u30AA\u30D1\u30F3\u30CB\u30F3\u30B0\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},expressionMeter:{title:"\u30A8\u30AF\u30B9\u30D7\u30EC\u30C3\u30B7\u30E7\u30F3: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u8868\u73FE\uFF08\u97F3\u91CF\uFF09\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},volumeMeter:{title:"\u30DC\u30EA\u30E5\u30FC\u30E0: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u97F3\u91CF\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},modulationWheelMeter:{title:"\u30E2\u30B8\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\u30DB\u30A4\u30FC\u30EB: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u30E2\u30B8\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\uFF08\u901A\u5E38\u306F\u30D3\u30D6\u30E9\u30FC\u30C8\uFF09\u306E\u6DF1\u3055\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},chorusMeter:{title:"\u30B3\u30FC\u30E9\u30B9: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30B3\u30FC\u30E9\u30B9\u30A8\u30D5\u30A7\u30AF\u30C8\u306E\u30EC\u30D9\u30EB\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},reverbMeter:{title:"\u30EA\u30D0\u30FC\u30D6: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30EA\u30D0\u30FC\u30D6\u30A8\u30D5\u30A7\u30AF\u30C8\u306E\u30EC\u30D9\u30EB\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},filterMeter:{title:"\u30D5\u30A3\u30EB\u30BF\u30FC: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u30ED\u30FC\u30D1\u30B9\u30D5\u30A3\u30EB\u30BF\u30FC\u306E\u30AB\u30C3\u30C8\u30AA\u30D5\u306E\u73FE\u5728\u306E\u30EC\u30D9\u30EB (\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF)"},transposeMeter:{title:"\u30C8\u30E9\u30F3\u30B9\u30DD\u30FC\u30BA: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u79FB\u8ABF\uFF08\u30AD\u30FC\u30B7\u30D5\u30C8\uFF09"},presetSelector:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u304C\u4F7F\u7528\u3059\u308B\u30D1\u30C3\u30C1\uFF08\u697D\u5668\uFF09\u3092\u5909\u66F4",selectionPrompt:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u697D\u5668\u3092\u5909\u66F4\u3059\u308B",searchPrompt:"\u691C\u7D22..."},presetReset:{description:"\u30D7\u30ED\u30B0\u30E9\u30E0\u5909\u66F4\u3092\u8A31\u53EF\u3059\u308B\u305F\u3081\u306B\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u30ED\u30C3\u30AF\u3092\u89E3\u9664"},soloButton:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3092\u5358\u72EC\u518D\u751F"},muteButton:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3092\u30DF\u30E5\u30FC\u30C8/\u30DF\u30E5\u30FC\u30C8\u89E3\u9664"},drumToggleButton:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3067\u30C9\u30E9\u30E0\u3092\u5207\u308A\u66FF\u3048"}};var Nw={toggleButton:{title:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC\u3092\u8868\u793A"},mainVoiceMeter:{title:"\u30DC\u30A4\u30B9: ",description:"\u73FE\u5728\u518D\u751F\u4E2D\u306E\u30DC\u30A4\u30B9\u306E\u7DCF\u6570"},mainVolumeMeter:{title:"\u30DC\u30EA\u30E5\u30FC\u30E0: ",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u306E\u73FE\u5728\u306E\u30DE\u30B9\u30BF\u30FC\u30DC\u30EA\u30E5\u30FC\u30E0"},mainPanMeter:{title:"\u30D1\u30F3: ",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u306E\u73FE\u5728\u306E\u30DE\u30B9\u30BF\u30FC\u30B9\u30C6\u30EC\u30AA\u30D1\u30F3\u30CB\u30F3\u30B0"},mainTransposeMeter:{title:"\u30C8\u30E9\u30F3\u30B9\u30DD\u30FC\u30BA: ",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u3092\u79FB\u8ABF\u3057\u307E\u3059\uFF08\u30BB\u30DF\u30C8\u30FC\u30F3\u307E\u305F\u306F\u30AD\u30FC\uFF09"},midiPanic:{title:"MIDI\u30D1\u30CB\u30C3\u30AF",description:"\u3059\u3079\u3066\u306E\u30DC\u30A4\u30B9\u3092\u5373\u5EA7\u306B\u505C\u6B62"},systemReset:{title:"\u30B7\u30B9\u30C6\u30E0\u30EA\u30BB\u30C3\u30C8",description:"\u3059\u3079\u3066\u306E\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC\u3092\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u306B\u30EA\u30BB\u30C3\u30C8"},blackMidiMode:{title:"\u30D6\u30E9\u30C3\u30AFMIDI\u30E2\u30FC\u30C9",description:"\u9AD8\u6027\u80FD\u30E2\u30FC\u30C9\u3092\u5207\u308A\u66FF\u3048\u3001\u898B\u305F\u76EE\u3092\u7C21\u7D20\u5316\u3057\u3001\u30CE\u30FC\u30C8\u3092\u901F\u304F\u6D88\u53BB"},disableCustomVibrato:{title:"\u30AB\u30B9\u30BF\u30E0\u30D3\u30D6\u30E9\u30FC\u30C8\u3092\u7121\u52B9\u5316",description:"\u30AB\u30B9\u30BF\u30E0\uFF08NRPN\uFF09\u30D3\u30D6\u30E9\u30FC\u30C8\u3092\u6C38\u4E45\u306B\u7121\u52B9\u5316\u3002\u518D\u5EA6\u6709\u52B9\u5316\u3059\u308B\u306B\u306F\u30A6\u30A7\u30D6\u30B5\u30A4\u30C8\u3092\u30EA\u30ED\u30FC\u30C9"},helpButton:{title:"\u30D8\u30EB\u30D7",description:"\u4F7F\u7528\u30AC\u30A4\u30C9\u3092\u8868\u793A\u3057\u307E\u3059"},interpolation:{description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u306E\u88DC\u9593\u65B9\u6CD5\u3092\u9078\u629E",linear:"\u30EA\u30CB\u30A2",nearestNeighbor:"\u306A\u3057"},channelController:Tw};var Gw={previousSong:"\u524D\u306E\u66F2",nextSong:"\u6B21\u306E\u66F2",loopThis:"\u3053\u306E\u66F2\u3092\u30EB\u30FC\u30D7",playPause:"\u518D\u751F/\u4E00\u6642\u505C\u6B62",lyrics:{show:"\u6B4C\u8A5E\u3092\u8868\u793A",title:"\u30C7\u30B3\u30FC\u30C9\u3055\u308C\u305F\u30C6\u30AD\u30B9\u30C8",noLyrics:"\u6B4C\u8A5E\u304C\u3042\u308A\u307E\u305B\u3093...",otherText:{title:"\u305D\u306E\u4ED6\u306E\u30C6\u30AD\u30B9\u30C8"}}};var Uw={button:{title:"\u97F3\u58F0\u3092\u4FDD\u5B58",description:"\u97F3\u58F0\u3092WAV\u3001MIDI\u3001SF2\u3001\u307E\u305F\u306FRMI\u30D5\u30A1\u30A4\u30EB\u3068\u3057\u3066\u4FDD\u5B58"},formats:{title:"\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3092\u9078\u629E",formats:{wav:{button:{title:"WAV\u97F3\u58F0 (.wav)",description:"\u5909\u66F4\u3092\u52A0\u3048\u305F\u66F2\u3092.wav\u30AA\u30FC\u30C7\u30A3\u30AA\u30D5\u30A1\u30A4\u30EB\u3068\u3057\u3066\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"},options:{title:"WAV\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u30AA\u30D7\u30B7\u30E7\u30F3",confirm:"\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8",normalizeVolume:{title:"\u97F3\u91CF\u306E\u6B63\u898F\u5316",description:"MIDI\u306E\u97F3\u91CF\u306B\u304B\u304B\u308F\u3089\u305A\u3001\u97F3\u91CF\u3092\u4E00\u5B9A\u306B\u4FDD\u3061\u307E\u3059\u3002\u63A8\u5968\u8A2D\u5B9A\u3067\u3059\u3002"},additionalTime:{title:"\u8FFD\u52A0\u6642\u9593\uFF08\u79D2\uFF09",description:"\u97F3\u304C\u30D5\u30A7\u30FC\u30C9\u30A2\u30A6\u30C8\u3059\u308B\u305F\u3081\u306B\u66F2\u306E\u6700\u5F8C\u306B\u8FFD\u52A0\u3059\u308B\u6642\u9593\u3067\u3059\u3002\uFF08\u79D2\uFF09"},separateChannels:{title:"\u30C1\u30E3\u30F3\u30CD\u30EB\u3092\u5206\u5272",description:"\u5404\u30C1\u30E3\u30F3\u30CD\u30EB\u3092\u5225\u3005\u306E\u30D5\u30A1\u30A4\u30EB\u3068\u3057\u3066\u4FDD\u5B58\u3057\u307E\u3059\u3002\u30AA\u30B7\u30ED\u30B9\u30B3\u30FC\u30D7\u30D3\u30E5\u30FC\u30A2\u306A\u3069\u306B\u4FBF\u5229\u3067\u3059\u3002\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3059\u308B\u3068\u30EA\u30D0\u30FC\u30D6\u3084\u30B3\u30FC\u30E9\u30B9\u304C\u7121\u52B9\u306B\u306A\u308A\u307E\u3059\u3002",saving:{title:"\u30C1\u30E3\u30F3\u30CD\u30EB\u30D5\u30A1\u30A4\u30EB",save:"\u30C1\u30E3\u30F3\u30CD\u30EB{0}\u3092\u4FDD\u5B58"}},loopCount:{title:"\u30EB\u30FC\u30D7\u56DE\u6570",description:"\u66F2\u3092\u30EB\u30FC\u30D7\u3059\u308B\u56DE\u6570"}},exportMessage:{message:"WAV\u97F3\u58F0\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u3059...",estimated:"\u6B8B\u308A\u6642\u9593:",convertWav:"WAV\u306B\u5909\u63DB\u4E2D..."}},midi:{button:{title:"MIDI (.mid)",description:"\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC\u3068\u697D\u5668\u306E\u5909\u66F4\u304C\u9069\u7528\u3055\u308C\u305FMIDI\u30D5\u30A1\u30A4\u30EB\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"}},soundfont:{button:{title:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8 (.sf2)",description:"SoundFont2\u30D5\u30A1\u30A4\u30EB\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"},options:{title:"SF\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u30AA\u30D7\u30B7\u30E7\u30F3",confirm:"\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8",trim:{title:"\u30C8\u30EA\u30DF\u30F3\u30B0",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3067\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u697D\u5668\u3068\u30B5\u30F3\u30D7\u30EB\u3060\u3051\u306B\u30C8\u30EA\u30DF\u30F3\u30B0\u3055\u308C\u305F\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"},compress:{title:"\u5727\u7E2E",description:"\u672A\u5727\u7E2E\u306E\u5834\u5408\u306F\u3001Ogg Vorbis\u306E\u30ED\u30B9\u5727\u7E2E\u3067\u30B5\u30F3\u30D7\u30EB\u3092\u5727\u7E2E\u3057\u307E\u3059\u3002\u30D5\u30A1\u30A4\u30EB\u30B5\u30A4\u30BA\u304C\u5927\u5E45\u306B\u524A\u6E1B\u3055\u308C\u307E\u3059\u3002\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u304C\u3059\u3067\u306B\u5727\u7E2E\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u3001\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3057\u3066\u3082\u518D\u5727\u7E2E\u3055\u308C\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093"},quality:{title:"\u5727\u7E2E\u54C1\u8CEA",description:"\u5727\u7E2E\u306E\u54C1\u8CEA\u3067\u3059\u3002\u9AD8\u3044\u307B\u3069\u826F\u3044\u3067\u3059"}}},rmidi:{button:{title:"\u57CB\u3081\u8FBC\u307FMIDI (.rmi)",description:"\u5909\u66F4\u3055\u308C\u305FMIDI\u3068\u30C8\u30EA\u30DF\u30F3\u30B0\u3055\u308C\u305F\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u30921\u3064\u306E\u30D5\u30A1\u30A4\u30EB\u306B\u57CB\u3081\u8FBC\u3093\u3067\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\u3053\u306E\u5F62\u5F0F\u306F\u5E83\u304F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u306B\u6CE8\u610F\u3057\u3066\u304F\u3060\u3055\u3044"},progress:{title:"\u57CB\u3081\u8FBC\u307E\u308C\u305FMIDI\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u4E2D...",loading:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3068MIDI\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D...",modifyingMIDI:"MIDI\u3092\u4FEE\u6B63\u4E2D...",modifyingSoundfont:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u30C8\u30EA\u30DF\u30F3\u30B0\u4E2D...",saving:"RMIDI\u3092\u4FDD\u5B58\u4E2D...",done:"\u5B8C\u4E86\u3057\u307E\u3057\u305F\uFF01"},options:{title:"RMIDI\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u30AA\u30D7\u30B7\u30E7\u30F3",confirm:"\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8",compress:{title:"\u5727\u7E2E",description:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092Ogg Vorbis\u306E\u30ED\u30B9\u5727\u7E2E\u3067\u5727\u7E2E\u3057\u307E\u3059\u3002\u30D5\u30A1\u30A4\u30EB\u30B5\u30A4\u30BA\u304C\u5927\u5E45\u306B\u524A\u6E1B\u3055\u308C\u307E\u3059\u3002\u63A8\u5968\u8A2D\u5B9A\u3067\u3059\u3002"},quality:{title:"\u5727\u7E2E\u54C1\u8CEA",description:"\u5727\u7E2E\u306E\u54C1\u8CEA\u3067\u3059\u3002\u9AD8\u3044\u307B\u3069\u826F\u3044\u3067\u3059\u3002"},bankOffset:{title:"\u30D0\u30F3\u30AF\u30AA\u30D5\u30BB\u30C3\u30C8",description:"\u30D5\u30A1\u30A4\u30EB\u306E\u30D0\u30F3\u30AF\u30AA\u30D5\u30BB\u30C3\u30C8\u3067\u3059\u30020\u306E\u5024\u304C\u63A8\u5968\u3055\u308C\u307E\u3059\u3002\u5909\u66F4\u306F\u614E\u91CD\u306B\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002"},adjust:{title:"MIDI\u3092\u8ABF\u6574",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u306B\u5408\u308F\u305B\u3066\u8ABF\u6574\u3057\u307E\u3059\u3002\u7279\u5225\u306A\u7406\u7531\u304C\u306A\u3044\u9650\u308A\u3001\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u30AA\u30F3\u306E\u307E\u307E\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}}}},metadata:{songTitle:{title:"\u30BF\u30A4\u30C8\u30EB:",description:"\u66F2\u306E\u30BF\u30A4\u30C8\u30EB"},album:{title:"\u30A2\u30EB\u30D0\u30E0:",description:"\u66F2\u306E\u30A2\u30EB\u30D0\u30E0"},artist:{title:"\u30A2\u30FC\u30C6\u30A3\u30B9\u30C8:",description:"\u66F2\u306E\u30A2\u30FC\u30C6\u30A3\u30B9\u30C8"},albumCover:{title:"\u30A2\u30EB\u30D0\u30E0\u30AB\u30D0\u30FC:",description:"\u66F2\u306E\u30A2\u30EB\u30D0\u30E0\u30AB\u30D0\u30FC"},creationDate:{title:"\u4F5C\u6210\u65E5:",description:"\u66F2\u306E\u4F5C\u6210\u65E5"},genre:{title:"\u30B8\u30E3\u30F3\u30EB:",description:"\u66F2\u306E\u30B8\u30E3\u30F3\u30EB"},comment:{title:"\u30B3\u30E1\u30F3\u30C8:",description:"\u66F2\u306E\u30B3\u30E1\u30F3\u30C8"},duration:{title:"\u9577\u3055:",description:"\u66F2\u306E\u9577\u3055"}}}};var Pw={localeName:"\u65E5\u672C\u8A9E",titleMessage:"SpessaSynth: SoundFont2 Javascript \u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC",demoTitleMessage:"SpessaSynth: SoundFont2 Javascript \u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC \u30AA\u30F3\u30E9\u30A4\u30F3\u30C7\u30E2",synthInit:{genericLoading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",loadingSoundfont:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...",loadingBundledSoundfont:"\u30D0\u30F3\u30C9\u30EB\u3055\u308C\u305F\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...",startingSynthesizer:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u3092\u8D77\u52D5\u3057\u3066\u3044\u307E\u3059...",savingSoundfont:"\u518D\u5229\u7528\u306E\u305F\u3081\u306B\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u4FDD\u5B58\u3057\u3066\u3044\u307E\u3059...",noWebAudio:"\u304A\u4F7F\u3044\u306E\u30D6\u30E9\u30A6\u30B6\u306FWeb Audio\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u305B\u3093\u3002",done:"\u6E96\u5099\u5B8C\u4E86\uFF01"},midiUploadButton:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",exportAudio:Uw,yes:"\u306F\u3044",no:"\u3044\u3044\u3048",demoSoundfontUploadButton:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",demoGithubPage:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30DA\u30FC\u30B8",demoSongButton:"\u30C7\u30E2\u30BD\u30F3\u30B0",credits:"\u30AF\u30EA\u30A8\u30A4\u30BF\u30FC",dropPrompt:"\u3053\u3053\u306B\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7...",warnings:{noMidiSupport:"\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u306FMIDI\u5165\u529B\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u3053\u306E\u6A5F\u80FD\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002Chrome\u307E\u305F\u306FFirefox\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",outOfMemory:`\u30D6\u30E9\u30A6\u30B6\u306E\u30E1\u30E2\u30EA\u304C\u4E0D\u8DB3\u3057\u307E\u3057\u305F\u3002Firefox\u3084SF3\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u306E\u4F7F\u7528\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002 + `;let m0=document.createElement("div");if(m0.classList.add("notification_content"),S)for(let[u1,R]of Object.entries(S))m0.style[u1]=R;r0.appendChild(m0);for(let u1 of n){let R=$w(u1,u);u1.onClick&&(R.onclick=()=>u1.onClick({div:r0,id:E0},R)),m0.appendChild(R)}g?r0.getElementsByClassName("close_btn")[0].onclick=()=>{Pt(E0)}:r0.getElementsByClassName("close_btn")[0].style.display="none",setTimeout(()=>{r0.classList.add("drop")},75);let g0=setTimeout(()=>{Pt(E0)},l*1e3+75);return document.getElementsByClassName("notification_field")[0].appendChild(r0),UC[E0]={div:r0,timeout:g0},{div:r0,id:E0}}function Pt(o){let n=UC[o].div;clearTimeout(UC[o].timeout),n.classList.remove("drop"),setTimeout(()=>n.parentElement.removeChild(n),500),UC[o]=void 0}function lw(o,n,l){o.createMIDIDeviceHandler().then(g=>{g?(this._createMidiInputHandler(o,l.synth),this._createMidiOutputHandler(o,n)):(Sr||mt(this.locale.getLocaleString("locale.warnings.warning"),[{type:"text",textContent:this.locale.getLocaleString("locale.warnings.noMidiSupport")}]),document.getElementById("midi_settings").style.display="none")})}function cw(o,n){if(o.inputs.length<1)return;let l=this.htmlControls.midi.inputSelector;for(let g of o.inputs){let u=document.createElement("option");u.value=g[0],u.innerText=g[1].name,l.appendChild(u)}l.onchange=()=>{l.value==="-1"?o.disconnectAllDevicesFromSynth():o.connectDeviceToSynth(o.inputs.get(l.value),n),this._saveSettings()}}function gw(o,n){if(!o.outputs){setTimeout(()=>{this._createMidiOutputHandler(o,n)},1e3);return}if(o.outputs.length<1)return;let l=this.htmlControls.midi.outputSelector;for(let g of o.outputs){let u=document.createElement("option");u.value=g[0],u.innerText=g[1].name,l.appendChild(u)}l.onchange=()=>{n.seq&&(l.value==="-1"?o.disconnectSeqFromMIDI(n.seq):o.connectMIDIOutputToSeq(o.outputs.get(l.value),n.seq),this._saveSettings())}}var hw={title:"Renderer settings",noteFallingTime:{title:"Note falling time (miliseconds)",description:"How fast the notes fall (visually)"},waveformThickness:{title:"Waveform line thickness (px)",description:"How thick the waveform lines are"},waveformSampleSize:{title:"Waveform sample size",description:"How detailed the waveforms are (Note: high values might impact performance)"},waveformAmplifier:{title:"Waveform amplifier",description:"How vibrant the waveforms are"},toggleWaveformsRendering:{title:"Enable waveforms rendering",description:"Enable rendering the channel waveforms (colorful lines showing audio)"},toggleNotesRendering:{title:"Enable notes rendering",description:"Enable rendering of the falling notes when playing a MIDI file"},toggleDrawingActiveNotes:{title:"Enable drawing active notes",description:"Enable notes lighting up and glowing when they get pressed"},toggleDrawingVisualPitch:{title:"Enable drawing visual pitch",description:"Enable notes sliding left or right when the pitch wheel is applied"},toggleStabilizeWaveforms:{title:"Stabilize waveforms",description:"Enable oscilloscope triggering"}};var fw={title:"MIDI Keyboard settings",selectedChannel:{title:"Selected channel",description:"The channel keyboard sends messages to",channelOption:"Channel {0}"},keyboardSize:{title:"Keyboard size",description:"The range of keys shown on the keyboard. Adjusts the MIDI note size accordingly",full:"128 keys (full)",piano:"88 keys (piano)",fiveOctaves:"5 octaves",useSongKeyRange:"Use song's key range",twoOctaves:"Two octaves"},toggleTheme:{title:"Use dark theme",description:"Use the dark MIDI keyboard theme"},show:{title:"Show",description:"Show/hide MIDI keyboard"}};var uw={title:"MIDI settings",midiInput:{title:"MIDI input",description:"The port to listen on for MIDI messages",disabled:"Disabled"},midiOutput:{title:"MIDI output",description:"The port to play the MIDI file to",disabled:"Use SpessaSynth"}};var dw={toggleButton:"Settings",mainTitle:"Program settings",rendererSettings:hw,keyboardSettings:fw,midiSettings:uw,interfaceSettings:{title:"Interface settings",toggleTheme:{title:"Use dark theme",description:"Enable the dark theme for the interface"},selectLanguage:{title:"Language",description:"Change the program language"},layoutDirection:{title:"Layout direction",description:"The layout direction of the renderer and keyboard",values:{downwards:"Downwards",upwards:"Upwards",leftToRight:"Left to right",rightToLeft:"Right to left"}}}};var Iw={toggleButton:{title:"Toggle music player mode",description:"Toggle the simplified UI version, hiding the keyboard and note visualizations"},currentlyPlaying:"Currently playing:",nothingPlaying:"Nothing is playing",nothingPlayingCopyright:"Upload a MIDI!"};var Ew={voiceMeter:{title:"Voices: ",description:"The current amount of voices playing on channel {0}"},pitchBendMeter:{title:"Pitch: ",description:"The current pitch bend applied to channel {0}"},panMeter:{title:"Pan: ",description:"The current stereo panning applied to channel {0} (right-click to lock)"},expressionMeter:{title:"Expression: ",description:"The current expression (loudness) of channel {0} (right-click to lock)"},volumeMeter:{title:"Volume: ",description:"The current volume of channel {0} (right-click to lock)"},modulationWheelMeter:{title:"Mod wheel: ",description:"The current modulation (usually vibrato) depth of channel {0} (right-click to lock)"},chorusMeter:{title:"Chorus: ",description:"The current level of chorus effect applied to channel {0} (right-click to lock)"},reverbMeter:{title:"Reverb: ",description:"The current level of reverb effect applied to channel {0} (right-click to lock)"},filterMeter:{title:"Filter: ",description:"The current level of low-pass filter cutoff applied to channel {0} (right-click to lock)"},transposeMeter:{title:"Transpose: ",description:"The current transposition (key shift) of channel {0}"},presetSelector:{description:"Change the patch (instrument) channel {0} is using",selectionPrompt:"Change instrument for channel {0}",searchPrompt:"Search..."},presetReset:{description:"Unlock channel {0} to allow program changes"},soloButton:{description:"Solo on channel {0}"},muteButton:{description:"Mute/unmute channel {0}"},drumToggleButton:{description:"Toggle drums on channel {0}"}};var mw={toggleButton:{title:"Synthesizer controller",description:"Show the synthesizer controller"},mainVoiceMeter:{title:"Voices: ",description:"The total amount of voices currently playing"},mainVolumeMeter:{title:"Volume: ",description:"The current master volume of the synthesizer"},mainPanMeter:{title:"Pan: ",description:"The current master stereo panning of the synthesizer"},mainTransposeMeter:{title:"Transpose: ",description:"Transposes the synthesizer (in semitones or keys)"},midiPanic:{title:"MIDI Panic",description:"Stops all voices immediately"},systemReset:{title:"System reset",description:"Resets all controllers to their default values"},blackMidiMode:{title:"Black MIDI mode",description:"Toggles the High Performance Mode, simplifying the look and killing the notes faster"},disableCustomVibrato:{title:"Disable custom vibrato",description:"Disables the custom (NRPN) Vibrato permamently. Reload the website to reenable it"},helpButton:{title:"Help",description:"Opens an external website with the usage guide"},interpolation:{description:"Select the synthesizer's interpolation method",linear:"Linear Interpolation",nearestNeighbor:"Nearest neighbor",cubic:"Cubic Interpolation"},channelController:Ew};var Cw={previousSong:"Previous song",nextSong:"Next song",loopThis:"Loop this song",playPause:"Play/pause",lyrics:{show:"Show lyrics",title:"Decoded text",noLyrics:"No lyrics available...",otherText:{title:"Other text"}}};var Bw={button:{title:"Save Audio",description:"Save the composition to various formats"},formats:{title:"Choose format",formats:{wav:{button:{title:"WAV audio (.wav)",description:"Export the song with modifications as a .wav audio file"},options:{title:"WAV export options",confirm:"Export",normalizeVolume:{title:"Normalize volume",description:"Keep the volume at the same level, no matter how loud or quiet the MIDI is. Recommended."},additionalTime:{title:"Additional time (s)",description:"Additional time at the end of the song to allow for the sound to fade. (seconds)"},separateChannels:{title:"Separate channels",description:"Save each channel as a separate file. Useful for things like oscilloscope viewers. Note that this disables reverb and chorus.",saving:{title:"Channel files",save:"Save channel {0}"}},loopCount:{title:"Loop count",description:"The amount of times to loop the song"}},exportMessage:{message:"Exporting WAV audio...",estimated:"Remaining:",convertWav:"Converting to wav..."}},midi:{button:{title:"MIDI (.mid)",description:"Export the MIDI file with the controller and instrument changes applied"}},soundfont:{button:{title:"SoundFont (.sf2)",description:"Export a SoundFont2 file"},options:{title:"SF export options",confirm:"Export",trim:{title:"Trim",description:"Export the soundfont trimmed to only use instruments and samples that the MIDI file uses"},compress:{title:"Compress",description:"Compress samples with lossy Ogg Vorbis compression if uncompressed. Significantly reduces the file size.If the soundfont was already compressed, it won't be uncompressed even if this option is disabled"},quality:{title:"Compression quality",description:"The quality of compression. Higher is better"}}},rmidi:{button:{title:"Embedded MIDI (.rmi)",description:"Export the modified MIDI with the embedded trimmed soundfont as a single file. Note that this format isn't widely supported"},progress:{title:"Exporting embeded MIDI...",loading:"Loading Soundfont and MIDI...",modifyingMIDI:"Modifying MIDI...",modifyingSoundfont:"Trimming Soundfont...",saving:"Saving RMIDI...",done:"Done!"},options:{title:"RMIDI export options",confirm:"Export",compress:{title:"Compress",description:"Compress the Soundfont with lossy Ogg Vorbis compression. Significantly reduces the file size. Recommended."},quality:{title:"Compression quality",description:"The quality of compression. Higher is better."},bankOffset:{title:"Bank offset",description:"The bank offset of the file. Value of 0 is recommended. Only change if you know what you're doing."},adjust:{title:"Adjust MIDI",description:"Adjusts the MIDI file to the SoundFont. Leave this on unless you know what you're doing."}}}},metadata:{songTitle:{title:"Title:",description:"The song's title"},album:{title:"Album:",description:"The song's album"},artist:{title:"Artist:",description:"The song's artist"},albumCover:{title:"Album cover:",description:"The song's album cover"},creationDate:{title:"Created:",description:"The song's creation date"},genre:{title:"Genre:",description:"The song's genre"},comment:{title:"Comment:",description:"The song's comment"},duration:{title:"Duration:",description:"The song's duration"}}}};var pw={localeName:"English",titleMessage:"SpessaSynth: SoundFont2 Javascript Synthesizer",demoTitleMessage:"SpessaSynth: SoundFont2 Javascript Synthesizer Online Demo",synthInit:{genericLoading:"Loading...",loadingSoundfont:"Loading SoundFont...",loadingBundledSoundfont:"Loading bundled SoundFont...",startingSynthesizer:"Starting Synthesizer...",savingSoundfont:"Saving SoundFont for reuse...",noWebAudio:"Your browser does not support Web Audio.",done:"Ready!"},midiUploadButton:"Upload your MIDI files",exportAudio:Bw,yes:"Yes",no:"No",demoSoundfontUploadButton:"Upload the soundfont",demoGithubPage:"Project's page",demoSongButton:"Demo Song",credits:"Credits",dropPrompt:"Drop files here...",warnings:{outOfMemory:"Your browser ran out of memory. Consider using Firefox or SF3 soundfont instead. (see console for error).",noMidiSupport:"No MIDI ports detected, this functionality will be disabled.",chromeMobile:"SpessaSynth performs poorly on Chrome Mobile. Consider using Firefox Android instead.",warning:"Warning"},hideTopBar:{title:"Hide top bar",description:"Hide the top (title) bar to provide a more seamless experience"},convertDls:{title:"DLS Conversion",message:"Looks like you've uploaded a DLS file. Do you want to convert it to SF2?"},musicPlayerMode:Iw,settings:dw,synthesizerController:mw,sequencerController:Cw};var Qw={title:"Ustawienia wizualizacji",noteFallingTime:{title:"Czas spadania nut (ms)",description:"Jak szybko spadaj\u0105 z g\xF3ry nuty (w milisekundach)"},waveformThickness:{title:"Grubo\u015B\u0107 lini fal (px)",description:"Jak grube s\u0105 linie fal d\u017Awi\u0119kowych"},waveformSampleSize:{title:"Rozmiar pr\xF3bki fali",description:"Jak szczeg\xF3\u0142owe s\u0105 linei fal d\u017Awi\u0119kowcyh (Uwaga: wysokie warto\u015Bci mog\u0105 pogorszy\u0107 wydajno\u015B\u0107)"},waveformAmplifier:{title:"Wzmacniasz fal",description:"Jak '\u017Cywe' s\u0105 fale. Kontroluje ich amplitud\u0119"},toggleWaveformsRendering:{title:"W\u0142\u0105cz rysowanie fal",description:"W\u0142\u0105cz rysowanie fal d\u017Awi\u0119kowych (16-tu kolorowych linii z ty\u0142u)"},toggleNotesRendering:{title:"W\u0142\u0105cz rysowanie nut",description:"W\u0142\u0105cz rysowanie spadaj\u0105cych nut podczas odtwarzania pliku MIDI"},toggleDrawingActiveNotes:{title:"W\u0142\u0105cz rysowanie aktywnych nut",description:"W\u0142\u0105cz efekt pod\u015Bwietlania si\u0119 nut przy aktywacji"},toggleDrawingVisualPitch:{title:"W\u0142\u0105cz wizualizacj\u0119 wysoko\u015Bci tonu",description:"W\u0142\u0105cz przesuwanie nut w lewo lub w prawo gdy wysoko\u015B\u0107 nut jest zmieniana"},toggleStabilizeWaveforms:{title:"W\u0142\u0105cz stabilizacj\u0119 fal",description:"W\u0142\u0105cz stabilizowanie fal d\u017Awi\u0119kowych"}};var yw={title:"Ustawienia pianina",selectedChannel:{title:"Wybrany kana\u0142",description:"Kana\u0142, do kt\xF3rego b\u0119dzie pod\u0142\u0105czone pianino",channelOption:"Kana\u0142 {0}"},keyboardSize:{title:"Rozmiar pianina",description:"Zakres klawiszy widocznych na pianine. Dostosowuje r\xF3wnie\u017C szeroko\u015B\u0107 wizualizowanych nut",full:"128 klawiszy (pe\u0142en zakres)",piano:"88 klawiszy (fortepian)",fiveOctaves:"5 oktaw",twoOctaves:"Dwie oktawy",useSongKeyRange:"U\u017Cyj zakresu utworu"},toggleTheme:{title:"W\u0142\u0105cz ciemny motyw",description:"W\u0142\u0105cz ciemny motyw wbudowanego pianina"},show:{title:"Poka\u017C",description:"Poka\u017C/ukryj pianino"}};var ww={title:"Ustawienia MIDI",midiInput:{title:"Wej\u015Bcie MIDI",description:"Port MIDI, kt\xF3ry b\u0119dzie nas\u0142uchiwany",disabled:"Wy\u0142\u0105czony"},midiOutput:{title:"Wyj\u015Bcie MIDI",description:"Port MIDI, do kt\xF3rego b\u0119dzie grany utw\xF3r",disabled:"U\u017Cyj SpessaSynth"}};var kw={toggleButton:"Ustawienia",mainTitle:"Ustawienia programu",rendererSettings:Qw,keyboardSettings:yw,midiSettings:ww,interfaceSettings:{title:"Ustawienia interfejsu",toggleTheme:{title:"W\u0142\u0105cz ciemny motyw",description:"W\u0142\u0105cz ciemny motyw programu"},selectLanguage:{title:"J\u0119zyk",description:"Zmie\u0144 j\u0119zyk programu"},layoutDirection:{title:"Uk\u0142ad",description:"Kierunek uk\u0142adu wizualizacji i pianina",values:{downwards:"W d\xF3\u0142",upwards:"W g\xF3r\u0119",leftToRight:"Od lewej do prawej",rightToLeft:"Od prawej do lewej"}}}};var vw={toggleButton:{title:"Prze\u0142\u0105cz tryb odtwarzania muzyki",description:"Prze\u0142\u0105cz uproszczon\u0105 wersj\u0119 interfejsu, ukrywaj\u0105c pianino i wizualizacj\u0119 nut"},currentlyPlaying:"Teraz gramy:",nothingPlaying:"Nic teraz nie gra",nothingPlayingCopyright:"Wgraj jakie\u015B MIDI!"};var Sw={voiceMeter:{title:"D\u017Awi\u0119ki: ",description:"Aktualna ilo\u015B\u0107 d\u017Awi\u0119k\xF3w na kanale {0}"},pitchBendMeter:{title:"Wysoko\u015B\u0107: ",description:"Aktualna wysoko\u015B\u0107 tonu na kanale {0}"},panMeter:{title:"Stereo: ",description:"Aktualny efekt stereo na kanale {0} (kliknij prawym aby zablokowa\u0107)"},expressionMeter:{title:"Ekspresja: ",description:"Aktualna ekspresja (g\u0142o\u015Bno\u015Bc) kana\u0142u {0} (kliknij prawym aby zablokowa\u0107)"},volumeMeter:{title:"G\u0142o\u015Bno\u015B\u0107: ",description:"Aktualna g\u0142o\u015Bno\u015B\u0107 kana\u0142u {0} (kliknij prawym aby zablokowa\u0107)"},modulationWheelMeter:{title:"Modulacja: ",description:"Aktualna g\u0142\u0119boko\u015B\u0107 modulacji (zazwyczaj vibrato) kana\u0142u {0} (kliknij prawym aby zablokowa\u0107)"},chorusMeter:{title:"Ch\xF3r: ",description:"Aktualny efekt ch\xF3ru na kanale {0} (kliknij prawym aby zablokowa\u0107)"},reverbMeter:{title:"Pog\u0142os: ",description:"Aktualny efekt pog\u0142osu na kanale {0} (kliknij prawym aby zablokowa\u0107)"},filterMeter:{title:"Filtr: ",description:"Aktualny poziom filtra niskopasmowego na kanale {0} (kliknij prawym aby zablokowa\u0107)"},transposeMeter:{title:"Transpozycja: ",description:"Aktualna transpozycja (przesuni\u0119cie klawiszy) kana\u0142u {0}"},presetSelector:{description:"Zmie\u0144 patch (instrument), kt\xF3rego u\u017Cywa kana\u0142 {0}",selectionPrompt:"Zmie\u0144 instrument kana\u0142u {0}",searchPrompt:"Wyszukaj..."},presetReset:{description:"Odblokuj kana\u0142 {0}, aby program m\xF3g\u0142 go zmienia\u0107"},soloButton:{description:"Solo na kanale {0}"},muteButton:{description:"Wycisz/odcisz kana\u0142 {0}"},drumToggleButton:{description:"Prze\u0142\u0105cz perkusj\u0119 na kanale {0}"}};var bw={toggleButton:{title:"Kontroler syntezatora",description:"Poka\u017C kontroler syntezatora"},mainVoiceMeter:{title:"D\u017Awi\u0119ki: ",description:"Ca\u0142kowita ilo\u015B\u0107 aktualnie odtwarzanych d\u017Awi\u0119k\xF3w"},mainVolumeMeter:{title:"G\u0142o\u015Bno\u015B\u0107: ",description:"Aktualna g\u0142o\u015Bno\u015B\u0107 syntezatora"},mainPanMeter:{title:"Stereo: ",description:"Aktualna pozycja stereo syntezatora"},mainTransposeMeter:{title:"Transpozycja: ",description:"Transpozycjonuje syntezator (w semitonach)"},midiPanic:{title:"MIDI Panic",description:"Zatrzymuje wszystkie d\u017Awi\u0119ki"},systemReset:{title:"Reset systemu",description:"Resetuje wszystkie kontroleru do ich domy\u015Blnych warto\u015Bci"},blackMidiMode:{title:"Tryb black MIDI",description:"Prze\u0142\u0105cza tryb wysokiej wydajno\u015Bci, upraszczaj\u0105c wygl\u0105d i pogarszaj\u0105c jako\u015B\u0107 d\u017Awi\u0119ku"},disableCustomVibrato:{title:"Wy\u0142\u0105cz niestandardowe vibrato",description:"Wy\u0142\u0105cza niestandardowe (NRPN) vibrato. Wymaga prze\u0142adowania strony aby je ponownie w\u0142\u0105czy\u0107"},helpButton:{title:"Pomoc",description:"Poka\u017C instrukcj\u0119 obs\u0142ugi"},interpolation:{description:"Wybierz metod\u0119 interpolacji",linear:"Interpolacja liniowa",nearestNeighbor:"Najbli\u017Cszy s\u0105siad",cubic:"Interpolacja Sze\u015Bcienna"},channelController:Sw};var Dw={previousSong:"Poprzedni utw\xF3r",nextSong:"Nast\u0119pny utw\xF3r",loopThis:"Odtwarzaj w p\u0119tli",playPause:"Odtw\xF3rz/wstrzymaj",lyrics:{show:"Poka\u017C tekst",title:"Odczytany tekst",noLyrics:"Brak dost\u0119pnego tekstu...",otherText:{title:"Inny tekst"}}};var _w={button:{title:"Zapisz",description:"Zapisz w r\xF3\u017Cnych formatach"},formats:{title:"Wybierz format",formats:{wav:{button:{title:"Audio WAV (.wav)",description:"Eksportuj utw\xF3r ze zmianami jako plik audio .wav"},options:{title:"Opcje eksportu audio",confirm:"Eksportuj",normalizeVolume:{title:"Normalizuj g\u0142o\u015Bno\u015B\u0107",description:"Eksportuj audio z tak\u0105 sam\u0105 g\u0142o\u015Bno\u015Bci\u0105, niezale\u017Cnie od g\u0142o\u015Bno\u015Bci MIDI."},additionalTime:{title:"Dodatkowy czas (s)",description:"Dodatkowy czas na ko\u0144cu utworu aby pozwoli\u0107 na wyciszenie si\u0119 d\u017Awi\u0119ku. (sekundy)"},separateChannels:{title:"Rozdziel kana\u0142y",description:"Zapisz ka\u017Cdy kana\u0142 w osobnym pliuku. Przydatne dla rzeczy jak widok oscyloskopowy. Nale\u017Cy pami\u0119ta\u0107 \u017Ce to wy\u0142\u0105cza ekfet pog\u0142osu i ch\xF3ru",saving:{title:"Pliki audio kana\u0142\xF3w",save:"Zapisz kana\u0142 {0}"}},loopCount:{title:"Ilo\u015B\u0107 p\u0119tli",description:"Ilo\u015B\u0107 razy zap\u0119tlenia utworu"}},exportMessage:{message:"Eksportowanie audio...",estimated:"Pozosta\u0142o:",convertWav:"Konwertowanie do wav..."}},midi:{button:{title:"MIDI (.mid)",description:"Eksportuj plik MIDI wraz ze zmianami instrument\xF3w i kontroler\xF3w"}},soundfont:{button:{title:"SoundFont (.sf2)",description:"Eksportuj SoundFont"},options:{title:"Opcje eksportu soundfonta",confirm:"Eksportuj",trim:{title:"Zmniejsz",description:"Zmniejsz SoundFont aby zawiera\u0142 tylko klawisze u\u017Cyte w MIDI"},compress:{title:"Kompresuj",description:"Zkompresuj pr\xF3bki kt\xF3re nie s\u0105 zkompresowane przy u\u017Cyciu stratnego kodeka Ogg Vorbis. Znacznie zmniejsza rozmiar pliku.Je\u015Bli soundfont by\u0142 ju\u017C skompresowany, nie zostanie zdekompresowany nawet gdy ta opcja jest wy\u0142\u0105czona"},quality:{title:"Jako\u015B\u0107 kompresji",description:"Jako\u015B\u0107 skompresowanych pr\xF3bek. Im wy\u017Csza tym lepsza"}}},rmidi:{button:{title:"Osadzone MIDI (.rmi)",description:"Eksportuj zmodyfikowane MIDI wraz ze zmniejszonym soundfontem jako jeden plik. Uwaga: ten format nie jest szeroko wspierany"},progress:{title:"Exportowanie osadzonego MIDI...",loading:"Wczytywanie soundfonta i MIDI...",modifyingMIDI:"Modyfikowanie MIDI...",modifyingSoundfont:"Zmniejszanie Soundfonta...",saving:"Zapisywanie RMIDI...",done:"Gotowe!"},options:{title:"Opcje eksportu RMIDI",confirm:"Eksportuj",compress:{title:"Kompresuj",description:"Skompresuj osadzonego soundfonta za pomoc\u0105 stratnego kodeka Ogg Vorbis. Znacznie zmniejsza rozmiar pliku. Zalecane."},quality:{title:"Jako\u015B\u0107 kompresji",description:"Jako\u015B\u0107 skompresowanych pr\xF3bek. Im wy\u017Csza tym lepsza"},bankOffset:{title:"Przesuni\u0119cie banku",description:"Przesuni\u0119cie banku w pliku. Zalecane 0. Zmie\u0144 tylko je\u015Bli wiesz co robisz."},adjust:{title:"Dostosuj MIDI",description:"Dostosuj MIDI do SoundFonta. Pozostaw w\u0142\u0105czone, chyba \u017Ce wiesz co robisz."}}}},metadata:{songTitle:{title:"Tytu\u0142:",description:"Tytu\u0142 utworu"},album:{title:"Album:",description:"Album utworu"},artist:{title:"Tw\xF3rca:",description:"Tw\xF3rca utworu"},albumCover:{title:"Ok\u0142adka albumu:",description:"Ok\u0142adka albumu utworu"},creationDate:{title:"Stworzono:",description:"Data stworzenia utworu"},genre:{title:"Gatunek:",description:"Gatunek utworu"},comment:{title:"Komentarz:",description:"Komentarz do utworu"},duration:{title:"Czas trwania:",description:"Czas trwania utworu"}}}};var Rw={localeName:"Polski",titleMessage:"SpessaSynth: JavaScriptowy Syntezator SoundFont2",demoTitleMessage:"SpessaSynth: JavaScriptowy Syntezator SoundFont2 Wersja Demo",synthInit:{genericLoading:"Wczytywanie...",loadingSoundfont:"Wczytywanie SoundFonta...",loadingBundledSoundfont:"Wczytywanie wbudowanego SoundFonta...",startingSynthesizer:"Uruchamianie syntezatora...",savingSoundfont:"Zapisywanie SoundFonta do przegl\u0105darki...",noWebAudio:"Twoja przegl\u0105darka nie wspiera Web Audio.",done:"Gotowe!"},midiUploadButton:"Wgraj Twoje pliki MIDI",midiRenderButton:{title:"Eksportuj audio",description:"Zapisz audio do pliku WAV lub MIDI"},exportAudio:_w,yes:"Tak",no:"Nie",demoSoundfontUploadButton:"Wgraj SoundFonta",demoGithubPage:"Strona projektu",demoSongButton:"Piosenka demo",credits:"Tw\xF3rcy",dropPrompt:"Upu\u015B\u0107 pliki tutaj...",warnings:{outOfMemory:"Twojej przegl\u0105darce sko\u0144czy\u0142a si\u0119 pami\u0119\u0107. Rozwa\u017C u\u017Cycie Firefoxa albo plik\xF3w SF3. (Zobacz b\u0142\u0105d w konsoli)",noMidiSupport:"Nie wykryto MIDI. Korzystanie z port\xF3w MIDI nie b\u0119dzie dost\u0119pne.",chromeMobile:"SpessaSynth dzia\u0142a wolno na Chromie na telefon. Rozwa\u017C u\u017Cycie Firefoxa Android.",warning:"Uwaga"},hideTopBar:{title:"Ukryj g\xF3rny pasek",description:"Ukryj pasek tytu\u0142owy w celu poprawy widoczno\u015Bci na pionowych ekranach"},convertDls:{title:"Konwersja DLS",message:"Wygl\u0105da na to, \u017Ce wgra\u0142e\u015B plik DLS. Czy chcesz przekonwertowa\u0107 go do SF2?"},musicPlayerMode:vw,settings:kw,synthesizerController:bw,sequencerController:Dw};var xw={title:"\u30EC\u30F3\u30C0\u30E9\u30FC\u8A2D\u5B9A",noteFallingTime:{title:"\u30CE\u30FC\u30C8\u306E\u843D\u4E0B\u6642\u9593\uFF08\u30DF\u30EA\u79D2\uFF09",description:"\u30CE\u30FC\u30C8\u304C\u843D\u3061\u308B\u901F\u3055\uFF08\u8996\u899A\u7684\u306B\uFF09"},waveformThickness:{title:"\u6CE2\u5F62\u306E\u7DDA\u306E\u592A\u3055\uFF08\u30D4\u30AF\u30BB\u30EB\uFF09",description:"\u6CE2\u5F62\u306E\u7DDA\u306E\u592A\u3055"},waveformSampleSize:{title:"\u6CE2\u5F62\u306E\u30B5\u30F3\u30D7\u30EB\u30B5\u30A4\u30BA",description:"\u6CE2\u5F62\u306E\u8A73\u7D30\u5EA6\uFF08\u6CE8\uFF1A\u9AD8\u3044\u5024\u306F\u30D1\u30D5\u30A9\u30FC\u30DE\u30F3\u30B9\u306B\u5F71\u97FF\u3092\u4E0E\u3048\u308B\u53EF\u80FD\u6027\u304C\u3042\u308A\u307E\u3059\uFF09"},waveformAmplifier:{title:"\u6CE2\u5F62\u306E\u5897\u5E45\u5668",description:"\u6CE2\u5F62\u306E\u9BAE\u3084\u304B\u3055"},toggleWaveformsRendering:{title:"\u6CE2\u5F62\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u306E\u5207\u308A\u66FF\u3048",description:"\u30C1\u30E3\u30F3\u30CD\u30EB\u6CE2\u5F62\u306E\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u3092\u5207\u308A\u66FF\u3048\u307E\u3059\uFF08\u30AA\u30FC\u30C7\u30A3\u30AA\u3092\u8868\u793A\u3059\u308B\u30AB\u30E9\u30D5\u30EB\u306A\u7DDA\uFF09"},toggleNotesRendering:{title:"\u30CE\u30FC\u30C8\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u306E\u5207\u308A\u66FF\u3048",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u751F\u3059\u308B\u969B\u306E\u843D\u4E0B\u30CE\u30FC\u30C8\u306E\u30EC\u30F3\u30C0\u30EA\u30F3\u30B0\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},toggleDrawingActiveNotes:{title:"\u30A2\u30AF\u30C6\u30A3\u30D6\u30CE\u30FC\u30C8\u306E\u63CF\u753B\u3092\u5207\u308A\u66FF\u3048",description:"\u30CE\u30FC\u30C8\u304C\u62BC\u3055\u308C\u305F\u3068\u304D\u306B\u5149\u308A\u8F1D\u304F\u63CF\u753B\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},toggleDrawingVisualPitch:{title:"\u30D3\u30B8\u30E5\u30A2\u30EB\u30D4\u30C3\u30C1\u63CF\u753B\u306E\u5207\u308A\u66FF\u3048",description:"\u30D4\u30C3\u30C1\u30DB\u30A4\u30FC\u30EB\u304C\u9069\u7528\u3055\u308C\u305F\u3068\u304D\u306B\u30CE\u30FC\u30C8\u304C\u5DE6\u53F3\u306B\u30B9\u30E9\u30A4\u30C9\u3059\u308B\u63CF\u753B\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},toggleStabilizeWaveforms:{title:"\u6CE2\u5F62\u3092\u5B89\u5B9A\u3055\u305B\u308B",description:"\u30AA\u30FC\u30C7\u30A3\u30AA\u6CE2\u5F62\u3092\u5B89\u5B9A\u3055\u305B\u308B\u8A2D\u5B9A\u3092\u5207\u308A\u66FF\u3048\u3001\u6CE2\u5F62\u3092\u56FA\u5B9A\u3057\u307E\u3059\u3002"}};var Lw={title:"\u30AD\u30FC\u30DC\u30FC\u30C9\u8A2D\u5B9A",selectedChannel:{title:"\u9078\u629E\u3055\u308C\u305F\u30C1\u30E3\u30F3\u30CD\u30EB",description:"\u30AD\u30FC\u30DC\u30FC\u30C9\u304C\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u9001\u4FE1\u3059\u308B\u30C1\u30E3\u30F3\u30CD\u30EB",channelOption:"\u30C1\u30E3\u30F3\u30CD\u30EB {0}"},keyboardSize:{title:"\u30AD\u30FC\u30DC\u30FC\u30C9\u30B5\u30A4\u30BA",description:"\u30AD\u30FC\u30DC\u30FC\u30C9\u306B\u8868\u793A\u3055\u308C\u308B\u30AD\u30FC\u306E\u7BC4\u56F2\u3002MIDI\u30CE\u30FC\u30C8\u306E\u30B5\u30A4\u30BA\u306B\u5FDC\u3058\u3066\u8ABF\u6574\u3055\u308C\u307E\u3059",full:"128\u30AD\u30FC\uFF08\u5168\u4F53\uFF09",piano:"88\u30AD\u30FC\uFF08\u30D4\u30A2\u30CE\uFF09",fiveOctaves:"5\u30AA\u30AF\u30BF\u30FC\u30D6",useSongKeyRange:"\u66F2\u306E\u30AD\u30FC\u7BC4\u56F2\u3092\u4F7F\u7528",twoOctaves:"\u30AA\u30AF\u30BF\u30FC\u30D6"},toggleTheme:{title:"\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048",description:"\u30AD\u30FC\u30DC\u30FC\u30C9\u306E\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},show:{title:"\u8868\u793A",description:"MIDI\u30AD\u30FC\u30DC\u30FC\u30C9\u3092\u8868\u793A/\u975E\u8868\u793A"}};var Fw={title:"MIDI\u8A2D\u5B9A",midiInput:{title:"MIDI\u5165\u529B",description:"MIDI\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u53D7\u4FE1\u3059\u308B\u30DD\u30FC\u30C8",disabled:"\u7121\u52B9"},midiOutput:{title:"MIDI\u51FA\u529B",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u518D\u751F\u3059\u308B\u30DD\u30FC\u30C8",disabled:"SpessaSynth\u3092\u4F7F\u7528"}};var Mw={toggleButton:"\u8A2D\u5B9A",mainTitle:"\u30D7\u30ED\u30B0\u30E9\u30E0\u8A2D\u5B9A",rendererSettings:xw,keyboardSettings:Lw,midiSettings:Fw,interfaceSettings:{title:"\u30A4\u30F3\u30BF\u30FC\u30D5\u30A7\u30FC\u30B9\u8A2D\u5B9A",toggleTheme:{title:"\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048",description:"\u30D7\u30ED\u30B0\u30E9\u30E0\u306E\u30C6\u30FC\u30DE\u3092\u5207\u308A\u66FF\u3048\u307E\u3059"},selectLanguage:{title:"\u8A00\u8A9E",description:"\u30D7\u30ED\u30B0\u30E9\u30E0\u306E\u8A00\u8A9E\u3092\u5909\u66F4\u3057\u307E\u3059"},layoutDirection:{title:"\u30EC\u30A4\u30A2\u30A6\u30C8\u306E\u65B9\u5411",description:"\u30EC\u30F3\u30C0\u30E9\u30FC\u3068\u30AD\u30FC\u30DC\u30FC\u30C9\u306E\u30EC\u30A4\u30A2\u30A6\u30C8\u65B9\u5411",values:{downwards:"\u4E0B\u5411\u304D",upwards:"\u4E0A\u5411\u304D",leftToRight:"\u5DE6\u304B\u3089\u53F3",rightToLeft:"\u53F3\u304B\u3089\u5DE6"}}}};var Tw={toggleButton:{title:"\u97F3\u697D\u30D7\u30EC\u30A4\u30E4\u30FC\u30E2\u30FC\u30C9\u306E\u5207\u308A\u66FF\u3048",description:"\u7C21\u7565\u5316\u3055\u308C\u305FUI\u30D0\u30FC\u30B8\u30E7\u30F3\u306B\u5207\u308A\u66FF\u3048\u3001\u30AD\u30FC\u30DC\u30FC\u30C9\u3068\u30CE\u30FC\u30C8\u306E\u8996\u899A\u5316\u3092\u96A0\u3057\u307E\u3059"},currentlyPlaying:"\u518D\u751F\u4E2D:",nothingPlaying:"\u518D\u751F\u3057\u3066\u3044\u308B\u3082\u306E\u306F\u3042\u308A\u307E\u305B\u3093",nothingPlayingCopyright:"MIDI\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3057\u3066\u304F\u3060\u3055\u3044\uFF01"};var Nw={voiceMeter:{title:"\u30DC\u30A4\u30B9: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3067\u518D\u751F\u4E2D\u306E\u30DC\u30A4\u30B9\u306E\u73FE\u5728\u306E\u6570"},pitchBendMeter:{title:"\u30D4\u30C3\u30C1: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30D4\u30C3\u30C1\u30D9\u30F3\u30C9"},panMeter:{title:"\u30D1\u30F3: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30B9\u30C6\u30EC\u30AA\u30D1\u30F3\u30CB\u30F3\u30B0\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},expressionMeter:{title:"\u30A8\u30AF\u30B9\u30D7\u30EC\u30C3\u30B7\u30E7\u30F3: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u8868\u73FE\uFF08\u97F3\u91CF\uFF09\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},volumeMeter:{title:"\u30DC\u30EA\u30E5\u30FC\u30E0: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u97F3\u91CF\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},modulationWheelMeter:{title:"\u30E2\u30B8\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\u30DB\u30A4\u30FC\u30EB: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u30E2\u30B8\u30E5\u30EC\u30FC\u30B7\u30E7\u30F3\uFF08\u901A\u5E38\u306F\u30D3\u30D6\u30E9\u30FC\u30C8\uFF09\u306E\u6DF1\u3055\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},chorusMeter:{title:"\u30B3\u30FC\u30E9\u30B9: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30B3\u30FC\u30E9\u30B9\u30A8\u30D5\u30A7\u30AF\u30C8\u306E\u30EC\u30D9\u30EB\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},reverbMeter:{title:"\u30EA\u30D0\u30FC\u30D6: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u73FE\u5728\u306E\u30EA\u30D0\u30FC\u30D6\u30A8\u30D5\u30A7\u30AF\u30C8\u306E\u30EC\u30D9\u30EB\uFF08\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF\uFF09"},filterMeter:{title:"\u30D5\u30A3\u30EB\u30BF\u30FC: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306B\u9069\u7528\u3055\u308C\u3066\u3044\u308B\u30ED\u30FC\u30D1\u30B9\u30D5\u30A3\u30EB\u30BF\u30FC\u306E\u30AB\u30C3\u30C8\u30AA\u30D5\u306E\u73FE\u5728\u306E\u30EC\u30D9\u30EB (\u53F3\u30AF\u30EA\u30C3\u30AF\u3067\u30ED\u30C3\u30AF)"},transposeMeter:{title:"\u30C8\u30E9\u30F3\u30B9\u30DD\u30FC\u30BA: ",description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u73FE\u5728\u306E\u79FB\u8ABF\uFF08\u30AD\u30FC\u30B7\u30D5\u30C8\uFF09"},presetSelector:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u304C\u4F7F\u7528\u3059\u308B\u30D1\u30C3\u30C1\uFF08\u697D\u5668\uFF09\u3092\u5909\u66F4",selectionPrompt:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u697D\u5668\u3092\u5909\u66F4\u3059\u308B",searchPrompt:"\u691C\u7D22..."},presetReset:{description:"\u30D7\u30ED\u30B0\u30E9\u30E0\u5909\u66F4\u3092\u8A31\u53EF\u3059\u308B\u305F\u3081\u306B\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u306E\u30ED\u30C3\u30AF\u3092\u89E3\u9664"},soloButton:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3092\u5358\u72EC\u518D\u751F"},muteButton:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3092\u30DF\u30E5\u30FC\u30C8/\u30DF\u30E5\u30FC\u30C8\u89E3\u9664"},drumToggleButton:{description:"\u30C1\u30E3\u30F3\u30CD\u30EB {0} \u3067\u30C9\u30E9\u30E0\u3092\u5207\u308A\u66FF\u3048"}};var Gw={toggleButton:{title:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC\u3092\u8868\u793A"},mainVoiceMeter:{title:"\u30DC\u30A4\u30B9: ",description:"\u73FE\u5728\u518D\u751F\u4E2D\u306E\u30DC\u30A4\u30B9\u306E\u7DCF\u6570"},mainVolumeMeter:{title:"\u30DC\u30EA\u30E5\u30FC\u30E0: ",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u306E\u73FE\u5728\u306E\u30DE\u30B9\u30BF\u30FC\u30DC\u30EA\u30E5\u30FC\u30E0"},mainPanMeter:{title:"\u30D1\u30F3: ",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u306E\u73FE\u5728\u306E\u30DE\u30B9\u30BF\u30FC\u30B9\u30C6\u30EC\u30AA\u30D1\u30F3\u30CB\u30F3\u30B0"},mainTransposeMeter:{title:"\u30C8\u30E9\u30F3\u30B9\u30DD\u30FC\u30BA: ",description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u3092\u79FB\u8ABF\u3057\u307E\u3059\uFF08\u30BB\u30DF\u30C8\u30FC\u30F3\u307E\u305F\u306F\u30AD\u30FC\uFF09"},midiPanic:{title:"MIDI\u30D1\u30CB\u30C3\u30AF",description:"\u3059\u3079\u3066\u306E\u30DC\u30A4\u30B9\u3092\u5373\u5EA7\u306B\u505C\u6B62"},systemReset:{title:"\u30B7\u30B9\u30C6\u30E0\u30EA\u30BB\u30C3\u30C8",description:"\u3059\u3079\u3066\u306E\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC\u3092\u30C7\u30D5\u30A9\u30EB\u30C8\u5024\u306B\u30EA\u30BB\u30C3\u30C8"},blackMidiMode:{title:"\u30D6\u30E9\u30C3\u30AFMIDI\u30E2\u30FC\u30C9",description:"\u9AD8\u6027\u80FD\u30E2\u30FC\u30C9\u3092\u5207\u308A\u66FF\u3048\u3001\u898B\u305F\u76EE\u3092\u7C21\u7D20\u5316\u3057\u3001\u30CE\u30FC\u30C8\u3092\u901F\u304F\u6D88\u53BB"},disableCustomVibrato:{title:"\u30AB\u30B9\u30BF\u30E0\u30D3\u30D6\u30E9\u30FC\u30C8\u3092\u7121\u52B9\u5316",description:"\u30AB\u30B9\u30BF\u30E0\uFF08NRPN\uFF09\u30D3\u30D6\u30E9\u30FC\u30C8\u3092\u6C38\u4E45\u306B\u7121\u52B9\u5316\u3002\u518D\u5EA6\u6709\u52B9\u5316\u3059\u308B\u306B\u306F\u30A6\u30A7\u30D6\u30B5\u30A4\u30C8\u3092\u30EA\u30ED\u30FC\u30C9"},helpButton:{title:"\u30D8\u30EB\u30D7",description:"\u4F7F\u7528\u30AC\u30A4\u30C9\u3092\u8868\u793A\u3057\u307E\u3059"},interpolation:{description:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u306E\u88DC\u9593\u65B9\u6CD5\u3092\u9078\u629E",linear:"\u30EA\u30CB\u30A2",nearestNeighbor:"\u306A\u3057"},channelController:Nw};var Uw={previousSong:"\u524D\u306E\u66F2",nextSong:"\u6B21\u306E\u66F2",loopThis:"\u3053\u306E\u66F2\u3092\u30EB\u30FC\u30D7",playPause:"\u518D\u751F/\u4E00\u6642\u505C\u6B62",lyrics:{show:"\u6B4C\u8A5E\u3092\u8868\u793A",title:"\u30C7\u30B3\u30FC\u30C9\u3055\u308C\u305F\u30C6\u30AD\u30B9\u30C8",noLyrics:"\u6B4C\u8A5E\u304C\u3042\u308A\u307E\u305B\u3093...",otherText:{title:"\u305D\u306E\u4ED6\u306E\u30C6\u30AD\u30B9\u30C8"}}};var Ow={button:{title:"\u97F3\u58F0\u3092\u4FDD\u5B58",description:"\u97F3\u58F0\u3092WAV\u3001MIDI\u3001SF2\u3001\u307E\u305F\u306FRMI\u30D5\u30A1\u30A4\u30EB\u3068\u3057\u3066\u4FDD\u5B58"},formats:{title:"\u30D5\u30A9\u30FC\u30DE\u30C3\u30C8\u3092\u9078\u629E",formats:{wav:{button:{title:"WAV\u97F3\u58F0 (.wav)",description:"\u5909\u66F4\u3092\u52A0\u3048\u305F\u66F2\u3092.wav\u30AA\u30FC\u30C7\u30A3\u30AA\u30D5\u30A1\u30A4\u30EB\u3068\u3057\u3066\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"},options:{title:"WAV\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u30AA\u30D7\u30B7\u30E7\u30F3",confirm:"\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8",normalizeVolume:{title:"\u97F3\u91CF\u306E\u6B63\u898F\u5316",description:"MIDI\u306E\u97F3\u91CF\u306B\u304B\u304B\u308F\u3089\u305A\u3001\u97F3\u91CF\u3092\u4E00\u5B9A\u306B\u4FDD\u3061\u307E\u3059\u3002\u63A8\u5968\u8A2D\u5B9A\u3067\u3059\u3002"},additionalTime:{title:"\u8FFD\u52A0\u6642\u9593\uFF08\u79D2\uFF09",description:"\u97F3\u304C\u30D5\u30A7\u30FC\u30C9\u30A2\u30A6\u30C8\u3059\u308B\u305F\u3081\u306B\u66F2\u306E\u6700\u5F8C\u306B\u8FFD\u52A0\u3059\u308B\u6642\u9593\u3067\u3059\u3002\uFF08\u79D2\uFF09"},separateChannels:{title:"\u30C1\u30E3\u30F3\u30CD\u30EB\u3092\u5206\u5272",description:"\u5404\u30C1\u30E3\u30F3\u30CD\u30EB\u3092\u5225\u3005\u306E\u30D5\u30A1\u30A4\u30EB\u3068\u3057\u3066\u4FDD\u5B58\u3057\u307E\u3059\u3002\u30AA\u30B7\u30ED\u30B9\u30B3\u30FC\u30D7\u30D3\u30E5\u30FC\u30A2\u306A\u3069\u306B\u4FBF\u5229\u3067\u3059\u3002\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u4F7F\u7528\u3059\u308B\u3068\u30EA\u30D0\u30FC\u30D6\u3084\u30B3\u30FC\u30E9\u30B9\u304C\u7121\u52B9\u306B\u306A\u308A\u307E\u3059\u3002",saving:{title:"\u30C1\u30E3\u30F3\u30CD\u30EB\u30D5\u30A1\u30A4\u30EB",save:"\u30C1\u30E3\u30F3\u30CD\u30EB{0}\u3092\u4FDD\u5B58"}},loopCount:{title:"\u30EB\u30FC\u30D7\u56DE\u6570",description:"\u66F2\u3092\u30EB\u30FC\u30D7\u3059\u308B\u56DE\u6570"}},exportMessage:{message:"WAV\u97F3\u58F0\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u3059...",estimated:"\u6B8B\u308A\u6642\u9593:",convertWav:"WAV\u306B\u5909\u63DB\u4E2D..."}},midi:{button:{title:"MIDI (.mid)",description:"\u30B3\u30F3\u30C8\u30ED\u30FC\u30E9\u30FC\u3068\u697D\u5668\u306E\u5909\u66F4\u304C\u9069\u7528\u3055\u308C\u305FMIDI\u30D5\u30A1\u30A4\u30EB\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"}},soundfont:{button:{title:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8 (.sf2)",description:"SoundFont2\u30D5\u30A1\u30A4\u30EB\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"},options:{title:"SF\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u30AA\u30D7\u30B7\u30E7\u30F3",confirm:"\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8",trim:{title:"\u30C8\u30EA\u30DF\u30F3\u30B0",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3067\u4F7F\u7528\u3055\u308C\u3066\u3044\u308B\u697D\u5668\u3068\u30B5\u30F3\u30D7\u30EB\u3060\u3051\u306B\u30C8\u30EA\u30DF\u30F3\u30B0\u3055\u308C\u305F\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059"},compress:{title:"\u5727\u7E2E",description:"\u672A\u5727\u7E2E\u306E\u5834\u5408\u306F\u3001Ogg Vorbis\u306E\u30ED\u30B9\u5727\u7E2E\u3067\u30B5\u30F3\u30D7\u30EB\u3092\u5727\u7E2E\u3057\u307E\u3059\u3002\u30D5\u30A1\u30A4\u30EB\u30B5\u30A4\u30BA\u304C\u5927\u5E45\u306B\u524A\u6E1B\u3055\u308C\u307E\u3059\u3002\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u304C\u3059\u3067\u306B\u5727\u7E2E\u3055\u308C\u3066\u3044\u308B\u5834\u5408\u3001\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u3092\u7121\u52B9\u306B\u3057\u3066\u3082\u518D\u5727\u7E2E\u3055\u308C\u308B\u3053\u3068\u306F\u3042\u308A\u307E\u305B\u3093"},quality:{title:"\u5727\u7E2E\u54C1\u8CEA",description:"\u5727\u7E2E\u306E\u54C1\u8CEA\u3067\u3059\u3002\u9AD8\u3044\u307B\u3069\u826F\u3044\u3067\u3059"}}},rmidi:{button:{title:"\u57CB\u3081\u8FBC\u307FMIDI (.rmi)",description:"\u5909\u66F4\u3055\u308C\u305FMIDI\u3068\u30C8\u30EA\u30DF\u30F3\u30B0\u3055\u308C\u305F\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u30921\u3064\u306E\u30D5\u30A1\u30A4\u30EB\u306B\u57CB\u3081\u8FBC\u3093\u3067\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u3057\u307E\u3059\u3002\u3053\u306E\u5F62\u5F0F\u306F\u5E83\u304F\u30B5\u30DD\u30FC\u30C8\u3055\u308C\u3066\u3044\u306A\u3044\u3053\u3068\u306B\u6CE8\u610F\u3057\u3066\u304F\u3060\u3055\u3044"},progress:{title:"\u57CB\u3081\u8FBC\u307E\u308C\u305FMIDI\u3092\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u4E2D...",loading:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3068MIDI\u3092\u8AAD\u307F\u8FBC\u307F\u4E2D...",modifyingMIDI:"MIDI\u3092\u4FEE\u6B63\u4E2D...",modifyingSoundfont:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u30C8\u30EA\u30DF\u30F3\u30B0\u4E2D...",saving:"RMIDI\u3092\u4FDD\u5B58\u4E2D...",done:"\u5B8C\u4E86\u3057\u307E\u3057\u305F\uFF01"},options:{title:"RMIDI\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8\u30AA\u30D7\u30B7\u30E7\u30F3",confirm:"\u30A8\u30AF\u30B9\u30DD\u30FC\u30C8",compress:{title:"\u5727\u7E2E",description:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092Ogg Vorbis\u306E\u30ED\u30B9\u5727\u7E2E\u3067\u5727\u7E2E\u3057\u307E\u3059\u3002\u30D5\u30A1\u30A4\u30EB\u30B5\u30A4\u30BA\u304C\u5927\u5E45\u306B\u524A\u6E1B\u3055\u308C\u307E\u3059\u3002\u63A8\u5968\u8A2D\u5B9A\u3067\u3059\u3002"},quality:{title:"\u5727\u7E2E\u54C1\u8CEA",description:"\u5727\u7E2E\u306E\u54C1\u8CEA\u3067\u3059\u3002\u9AD8\u3044\u307B\u3069\u826F\u3044\u3067\u3059\u3002"},bankOffset:{title:"\u30D0\u30F3\u30AF\u30AA\u30D5\u30BB\u30C3\u30C8",description:"\u30D5\u30A1\u30A4\u30EB\u306E\u30D0\u30F3\u30AF\u30AA\u30D5\u30BB\u30C3\u30C8\u3067\u3059\u30020\u306E\u5024\u304C\u63A8\u5968\u3055\u308C\u307E\u3059\u3002\u5909\u66F4\u306F\u614E\u91CD\u306B\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002"},adjust:{title:"MIDI\u3092\u8ABF\u6574",description:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u306B\u5408\u308F\u305B\u3066\u8ABF\u6574\u3057\u307E\u3059\u3002\u7279\u5225\u306A\u7406\u7531\u304C\u306A\u3044\u9650\u308A\u3001\u3053\u306E\u30AA\u30D7\u30B7\u30E7\u30F3\u306F\u30AA\u30F3\u306E\u307E\u307E\u306B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"}}}},metadata:{songTitle:{title:"\u30BF\u30A4\u30C8\u30EB:",description:"\u66F2\u306E\u30BF\u30A4\u30C8\u30EB"},album:{title:"\u30A2\u30EB\u30D0\u30E0:",description:"\u66F2\u306E\u30A2\u30EB\u30D0\u30E0"},artist:{title:"\u30A2\u30FC\u30C6\u30A3\u30B9\u30C8:",description:"\u66F2\u306E\u30A2\u30FC\u30C6\u30A3\u30B9\u30C8"},albumCover:{title:"\u30A2\u30EB\u30D0\u30E0\u30AB\u30D0\u30FC:",description:"\u66F2\u306E\u30A2\u30EB\u30D0\u30E0\u30AB\u30D0\u30FC"},creationDate:{title:"\u4F5C\u6210\u65E5:",description:"\u66F2\u306E\u4F5C\u6210\u65E5"},genre:{title:"\u30B8\u30E3\u30F3\u30EB:",description:"\u66F2\u306E\u30B8\u30E3\u30F3\u30EB"},comment:{title:"\u30B3\u30E1\u30F3\u30C8:",description:"\u66F2\u306E\u30B3\u30E1\u30F3\u30C8"},duration:{title:"\u9577\u3055:",description:"\u66F2\u306E\u9577\u3055"}}}};var Pw={localeName:"\u65E5\u672C\u8A9E",titleMessage:"SpessaSynth: SoundFont2 Javascript \u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC",demoTitleMessage:"SpessaSynth: SoundFont2 Javascript \u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC \u30AA\u30F3\u30E9\u30A4\u30F3\u30C7\u30E2",synthInit:{genericLoading:"\u8AAD\u307F\u8FBC\u307F\u4E2D...",loadingSoundfont:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...",loadingBundledSoundfont:"\u30D0\u30F3\u30C9\u30EB\u3055\u308C\u305F\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u8AAD\u307F\u8FBC\u3093\u3067\u3044\u307E\u3059...",startingSynthesizer:"\u30B7\u30F3\u30BB\u30B5\u30A4\u30B6\u30FC\u3092\u8D77\u52D5\u3057\u3066\u3044\u307E\u3059...",savingSoundfont:"\u518D\u5229\u7528\u306E\u305F\u3081\u306B\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u4FDD\u5B58\u3057\u3066\u3044\u307E\u3059...",noWebAudio:"\u304A\u4F7F\u3044\u306E\u30D6\u30E9\u30A6\u30B6\u306FWeb Audio\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u3066\u3044\u307E\u305B\u3093\u3002",done:"\u6E96\u5099\u5B8C\u4E86\uFF01"},midiUploadButton:"MIDI\u30D5\u30A1\u30A4\u30EB\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",exportAudio:Ow,yes:"\u306F\u3044",no:"\u3044\u3044\u3048",demoSoundfontUploadButton:"\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9",demoGithubPage:"\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u306E\u30DA\u30FC\u30B8",demoSongButton:"\u30C7\u30E2\u30BD\u30F3\u30B0",credits:"\u30AF\u30EA\u30A8\u30A4\u30BF\u30FC",dropPrompt:"\u3053\u3053\u306B\u30D5\u30A1\u30A4\u30EB\u3092\u30C9\u30ED\u30C3\u30D7...",warnings:{noMidiSupport:"\u3053\u306E\u30D6\u30E9\u30A6\u30B6\u306FMIDI\u5165\u529B\u3092\u30B5\u30DD\u30FC\u30C8\u3057\u3066\u3044\u306A\u3044\u305F\u3081\u3001\u3053\u306E\u6A5F\u80FD\u306F\u5229\u7528\u3067\u304D\u307E\u305B\u3093\u3002Chrome\u307E\u305F\u306FFirefox\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002",outOfMemory:`\u30D6\u30E9\u30A6\u30B6\u306E\u30E1\u30E2\u30EA\u304C\u4E0D\u8DB3\u3057\u307E\u3057\u305F\u3002Firefox\u3084SF3\u30B5\u30A6\u30F3\u30C9\u30D5\u30A9\u30F3\u30C8\u306E\u4F7F\u7528\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002 \uFF08\u30A8\u30E9\u30FC\u306B\u3064\u3044\u3066\u306F\u30B3\u30F3\u30BD\u30FC\u30EB\u3092\u53C2\u7167\u3057\u3066\u304F\u3060\u3055\u3044\uFF09\u3002`,chromeMobile:`SpessaSynth\u306FChrome Mobile\u3067\u306E\u52D5\u4F5C\u304C\u826F\u304F\u3042\u308A\u307E\u305B\u3093\u3002 -\u4EE3\u308F\u308A\u306BFirefox Android\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,warning:"\u6CE8\u610F"},hideTopBar:{title:"\u30C8\u30C3\u30D7\u30D0\u30FC\u3092\u96A0\u3059",description:"\u30C8\u30C3\u30D7\uFF08\u30BF\u30A4\u30C8\u30EB\uFF09\u30D0\u30FC\u3092\u96A0\u3057\u3066\u3001\u3088\u308A\u30B7\u30FC\u30E0\u30EC\u30B9\u306A\u4F53\u9A13\u3092\u63D0\u4F9B\u3057\u307E\u3059"},convertDls:{title:"DLS\u5909\u63DB",message:"DLS\u30D5\u30A1\u30A4\u30EB\u304C\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3055\u308C\u305F\u3088\u3046\u3067\u3059\u3002\u3053\u308C\u3092SF2\u306B\u5909\u63DB\u3057\u307E\u3059\u304B\uFF1F"},musicPlayerMode:Mw,settings:Fw,synthesizerController:Nw,sequencerController:Gw};var zB="en",k$={en:Bw,pl:_w,ja:Pw};var Zb=.2,Ci=class{constructor(n,l,g,u,S,r0,E0,m0){this.mode="dark",this.autoKeyRange=!1,this.renderer=u,this.midiKeyboard=S,this.midiDeviceHandler=r0,this.synthui=l,this.sequi=g,this.locale=m0,this.musicMode=E0,this.locales=k$,this.keyboardSizes={full:{min:0,max:127},piano:{min:21,max:108},"5 octaves":{min:36,max:96},"two octaves":{min:53,max:77}};let g0=document.createElement("div");g0.style.position="relative",g0.classList.add("seamless_button"),g0.classList.add("settings_button"),n.appendChild(g0);let u1=document.createElement("div");u1.classList.add("seamless_button"),this.locale.bindObjectProperty(u1,"innerText","locale.musicPlayerMode.toggleButton.title"),this.locale.bindObjectProperty(u1,"title","locale.musicPlayerMode.toggleButton.description"),n.appendChild(u1);let R=document.createElement("div");R.classList.add("seamless_button"),this.locale.bindObjectProperty(R,"innerText","locale.hideTopBar.title"),this.locale.bindObjectProperty(R,"title","locale.hideTopBar.description"),n.appendChild(R);let X0=document.getElementsByClassName("show_top_button")[0];X0.innerHTML=xy(20);let F0=document.createElement("span");this.locale.bindObjectProperty(F0,"innerText","locale.settings.toggleButton"),g0.appendChild(F0);let b1=document.createElement("div");b1.innerHTML=_y(24),b1.classList.add("gear"),g0.appendChild(b1),this.mainDiv=document.createElement("div"),this.mainDiv.classList.add("settings_menu"),this.visible=!1,this.animationId=-1,g0.onclick=()=>this.setVisibility(!this.visible),n.appendChild(this.mainDiv),u1.onclick=this.toggleMusicPlayerMode.bind(this),R.onclick=this.hideTopPart.bind(this),this.hideOnDocClick=!0,this.mainDiv.onclick=()=>{this.hideOnDocClick=!1},document.addEventListener("click",()=>{if(!this.hideOnDocClick){this.hideOnDocClick=!0;return}this.setVisibility(!1)}),this.mainDiv.innerHTML=Wy,jy(this.mainDiv);for(let y1 of this.mainDiv.querySelectorAll("*[translate-path]"))this.locale.bindObjectProperty(y1,"textContent",y1.getAttribute("translate-path"));for(let y1 of this.mainDiv.querySelectorAll("*[translate-path-title]")){let Y2=y1.getAttribute("translate-path-title");this.locale.bindObjectProperty(y1,"textContent",Y2+".title"),this.locale.bindObjectProperty(y1,"title",Y2+".description")}this.getHtmlControls(),document.addEventListener("keydown",y1=>{switch(y1.key.toLowerCase()){case e7.settingsShow:this.setVisibility(!this.visible);break;case e7.synthesizerUIShow:this.setVisibility(!1)}}),window.savedSettings?this._loadSettings().then(()=>{this.createHandlers(u,S,r0,g,l)}):this.createHandlers(u,S,r0,g,l),this.topPartVisible=!0;let l2=!1;window.addEventListener("resize",()=>{let y1=window.screen.height,Y2=window.screen.width,T2=window.outerHeight,K2=window.outerWidth,i3;i3=Y2===K2&&y1===T2,i3!==l2&&(l2=i3,i3?this.hideTopPart():this.showTopPart())}),document.addEventListener("fullscreenchange",()=>{document.fullscreenElement===null?this.showTopPart():this.hideTopPart()})}addSequencer;async toggleMusicPlayerMode(){this.musicMode.visible===!1&&this.hideTopPart(),this.musicMode.setVisibility(!this.musicMode.visible,document.getElementById("keyboard_canvas_wrapper")),this.renderer.renderBool=!this.musicMode.visible}showTopPart(){if(this.topPartVisible===!0)return;this.topPartVisible=!0;let n=document.getElementsByClassName("top_part")[0],l=document.getElementsByClassName("show_top_button")[0];n.style.display="",setTimeout(()=>{n.classList.remove("top_part_hidden")},75),l.classList.remove("shown"),l.style.display="none"}hideTopPart(){if(this.topPartVisible===!1)return;this.topPartVisible=!1;let n=document.getElementsByClassName("top_part")[0];n.classList.add("top_part_hidden"),setTimeout(()=>{n.style.display="none"},200);let l=document.getElementsByClassName("show_top_button")[0];l.style.display="flex",setTimeout(()=>{l.classList.add("shown")},75),l.onclick=this.showTopPart.bind(this)}setVisibility(n){this.animationId&&clearTimeout(this.animationId),n?(this.mainDiv.style.display="block",setTimeout(()=>{document.getElementsByClassName("top_part")[0].classList.add("settings_shown"),this.mainDiv.classList.add("settings_menu_show")},75),this.hideOnDocClick=!1):(document.getElementsByClassName("top_part")[0].classList.remove("settings_shown"),this.mainDiv.classList.remove("settings_menu_show"),this.animationId=setTimeout(()=>{this.mainDiv.style.display="none"},Zb*1e3)),this.visible=n}createHandlers(n,l,g,u,S){this._createRendererHandler(n),this._createMidiSettingsHandler(g,u,S),this._createKeyboardHandler(l,S,n),this._createInterfaceSettingsHandler()}getHtmlControls(){this.htmlControls={renderer:{noteTimeSlider:document.getElementById("note_time_slider"),analyserToggler:document.getElementById("analyser_toggler"),noteToggler:document.getElementById("note_toggler"),activeNoteToggler:document.getElementById("active_note_toggler"),visualPitchToggler:document.getElementById("visual_pitch_toggler"),stabilizeWaveformsToggler:document.getElementById("stabilize_waveforms_toggler"),analyserThicknessSlider:document.getElementById("analyser_thickness_slider"),analyserFftSlider:document.getElementById("analyser_fft_slider"),waveMultiplierSlizer:document.getElementById("wave_multiplier_slider")},keyboard:{channelSelector:document.getElementById("channel_selector"),modeSelector:document.getElementById("mode_selector"),sizeSelector:document.getElementById("keyboard_size_selector"),showSelector:document.getElementById("keyboard_show")},midi:{outputSelector:document.getElementById("midi_output_selector"),inputSelector:document.getElementById("midi_input_selector")},interface:{themeSelector:document.getElementById("toggle_mode_button"),languageSelector:document.getElementById("language_selector"),layoutSelector:document.getElementById("layout_selector")}}}};Ci.prototype._toggleDarkMode=ow;Ci.prototype._createInterfaceSettingsHandler=iw;Ci.prototype._changeLayout=nw;Ci.prototype._createRendererHandler=Aw;Ci.prototype._createMidiSettingsHandler=$w;Ci.prototype._createMidiInputHandler=lw;Ci.prototype._createMidiOutputHandler=cw;Ci.prototype._createKeyboardHandler=Zy;Ci.prototype._loadSettings=Xy;Ci.prototype._serializeSettings=tw;Ci.prototype._saveSettings=ew;var Ow=.5,OC=class{constructor(n,l){this.mainDiv=n,this.mainDiv.innerHTML=` +\u4EE3\u308F\u308A\u306BFirefox Android\u3092\u4F7F\u7528\u3059\u308B\u3053\u3068\u3092\u691C\u8A0E\u3057\u3066\u304F\u3060\u3055\u3044\u3002`,warning:"\u6CE8\u610F"},hideTopBar:{title:"\u30C8\u30C3\u30D7\u30D0\u30FC\u3092\u96A0\u3059",description:"\u30C8\u30C3\u30D7\uFF08\u30BF\u30A4\u30C8\u30EB\uFF09\u30D0\u30FC\u3092\u96A0\u3057\u3066\u3001\u3088\u308A\u30B7\u30FC\u30E0\u30EC\u30B9\u306A\u4F53\u9A13\u3092\u63D0\u4F9B\u3057\u307E\u3059"},convertDls:{title:"DLS\u5909\u63DB",message:"DLS\u30D5\u30A1\u30A4\u30EB\u304C\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3055\u308C\u305F\u3088\u3046\u3067\u3059\u3002\u3053\u308C\u3092SF2\u306B\u5909\u63DB\u3057\u307E\u3059\u304B\uFF1F"},musicPlayerMode:Tw,settings:Mw,synthesizerController:Gw,sequencerController:Uw};var KB="en",k$={en:pw,pl:Rw,ja:Pw};var Zb=.2,Ci=class{constructor(n,l,g,u,S,r0,E0,m0){this.mode="dark",this.autoKeyRange=!1,this.renderer=u,this.midiKeyboard=S,this.midiDeviceHandler=r0,this.synthui=l,this.sequi=g,this.locale=m0,this.musicMode=E0,this.locales=k$,this.keyboardSizes={full:{min:0,max:127},piano:{min:21,max:108},"5 octaves":{min:36,max:96},"two octaves":{min:53,max:77}};let g0=document.createElement("div");g0.style.position="relative",g0.classList.add("seamless_button"),g0.classList.add("settings_button"),n.appendChild(g0);let u1=document.createElement("div");u1.classList.add("seamless_button"),this.locale.bindObjectProperty(u1,"innerText","locale.musicPlayerMode.toggleButton.title"),this.locale.bindObjectProperty(u1,"title","locale.musicPlayerMode.toggleButton.description"),n.appendChild(u1);let R=document.createElement("div");R.classList.add("seamless_button"),this.locale.bindObjectProperty(R,"innerText","locale.hideTopBar.title"),this.locale.bindObjectProperty(R,"title","locale.hideTopBar.description"),n.appendChild(R);let X0=document.getElementsByClassName("show_top_button")[0];X0.innerHTML=Ly(20);let F0=document.createElement("span");this.locale.bindObjectProperty(F0,"innerText","locale.settings.toggleButton"),g0.appendChild(F0);let b1=document.createElement("div");b1.innerHTML=Ry(24),b1.classList.add("gear"),g0.appendChild(b1),this.mainDiv=document.createElement("div"),this.mainDiv.classList.add("settings_menu"),this.visible=!1,this.animationId=-1,g0.onclick=()=>this.setVisibility(!this.visible),n.appendChild(this.mainDiv),u1.onclick=this.toggleMusicPlayerMode.bind(this),R.onclick=this.hideTopPart.bind(this),this.hideOnDocClick=!0,this.mainDiv.onclick=()=>{this.hideOnDocClick=!1},document.addEventListener("click",()=>{if(!this.hideOnDocClick){this.hideOnDocClick=!0;return}this.setVisibility(!1)}),this.mainDiv.innerHTML=jy,Xy(this.mainDiv);for(let y1 of this.mainDiv.querySelectorAll("*[translate-path]"))this.locale.bindObjectProperty(y1,"textContent",y1.getAttribute("translate-path"));for(let y1 of this.mainDiv.querySelectorAll("*[translate-path-title]")){let Y2=y1.getAttribute("translate-path-title");this.locale.bindObjectProperty(y1,"textContent",Y2+".title"),this.locale.bindObjectProperty(y1,"title",Y2+".description")}this.getHtmlControls(),document.addEventListener("keydown",y1=>{switch(y1.key.toLowerCase()){case e7.settingsShow:this.setVisibility(!this.visible);break;case e7.synthesizerUIShow:this.setVisibility(!1)}}),window.savedSettings?this._loadSettings().then(()=>{this.createHandlers(u,S,r0,g,l)}):this.createHandlers(u,S,r0,g,l),this.topPartVisible=!0;let l2=!1;window.addEventListener("resize",()=>{let y1=window.screen.height,Y2=window.screen.width,T2=window.outerHeight,K2=window.outerWidth,i3;i3=Y2===K2&&y1===T2,i3!==l2&&(l2=i3,i3?this.hideTopPart():this.showTopPart())}),document.addEventListener("fullscreenchange",()=>{document.fullscreenElement===null?this.showTopPart():this.hideTopPart()})}addSequencer;async toggleMusicPlayerMode(){this.musicMode.visible===!1&&this.hideTopPart(),this.musicMode.setVisibility(!this.musicMode.visible,document.getElementById("keyboard_canvas_wrapper")),this.renderer.renderBool=!this.musicMode.visible}showTopPart(){if(this.topPartVisible===!0)return;this.topPartVisible=!0;let n=document.getElementsByClassName("top_part")[0],l=document.getElementsByClassName("show_top_button")[0];n.style.display="",setTimeout(()=>{n.classList.remove("top_part_hidden")},75),l.classList.remove("shown"),l.style.display="none"}hideTopPart(){if(this.topPartVisible===!1)return;this.topPartVisible=!1;let n=document.getElementsByClassName("top_part")[0];n.classList.add("top_part_hidden"),setTimeout(()=>{n.style.display="none"},200);let l=document.getElementsByClassName("show_top_button")[0];l.style.display="flex",setTimeout(()=>{l.classList.add("shown")},75),l.onclick=this.showTopPart.bind(this)}setVisibility(n){this.animationId&&clearTimeout(this.animationId),n?(this.mainDiv.style.display="block",setTimeout(()=>{document.getElementsByClassName("top_part")[0].classList.add("settings_shown"),this.mainDiv.classList.add("settings_menu_show")},75),this.hideOnDocClick=!1):(document.getElementsByClassName("top_part")[0].classList.remove("settings_shown"),this.mainDiv.classList.remove("settings_menu_show"),this.animationId=setTimeout(()=>{this.mainDiv.style.display="none"},Zb*1e3)),this.visible=n}createHandlers(n,l,g,u,S){this._createRendererHandler(n),this._createMidiSettingsHandler(g,u,S),this._createKeyboardHandler(l,S,n),this._createInterfaceSettingsHandler()}getHtmlControls(){this.htmlControls={renderer:{noteTimeSlider:document.getElementById("note_time_slider"),analyserToggler:document.getElementById("analyser_toggler"),noteToggler:document.getElementById("note_toggler"),activeNoteToggler:document.getElementById("active_note_toggler"),visualPitchToggler:document.getElementById("visual_pitch_toggler"),stabilizeWaveformsToggler:document.getElementById("stabilize_waveforms_toggler"),analyserThicknessSlider:document.getElementById("analyser_thickness_slider"),analyserFftSlider:document.getElementById("analyser_fft_slider"),waveMultiplierSlizer:document.getElementById("wave_multiplier_slider")},keyboard:{channelSelector:document.getElementById("channel_selector"),modeSelector:document.getElementById("mode_selector"),sizeSelector:document.getElementById("keyboard_size_selector"),showSelector:document.getElementById("keyboard_show")},midi:{outputSelector:document.getElementById("midi_output_selector"),inputSelector:document.getElementById("midi_input_selector")},interface:{themeSelector:document.getElementById("toggle_mode_button"),languageSelector:document.getElementById("language_selector"),layoutSelector:document.getElementById("layout_selector")}}}};Ci.prototype._toggleDarkMode=Aw;Ci.prototype._createInterfaceSettingsHandler=nw;Ci.prototype._changeLayout=rw;Ci.prototype._createRendererHandler=aw;Ci.prototype._createMidiSettingsHandler=lw;Ci.prototype._createMidiInputHandler=cw;Ci.prototype._createMidiOutputHandler=gw;Ci.prototype._createKeyboardHandler=Wy;Ci.prototype._loadSettings=ew;Ci.prototype._serializeSettings=iw;Ci.prototype._saveSettings=tw;var Hw=.5,OC=class{constructor(n,l){this.mainDiv=n,this.mainDiv.innerHTML=`${o}
\xD7 -`;for(let g of this.mainDiv.querySelectorAll("*[translate-path]"))l.bindObjectProperty(g,"textContent",g.getAttribute("translate-path"));for(let g of this.mainDiv.querySelectorAll("*[translate-path-title]"))l.bindObjectProperty(g,"textContent",g.getAttribute("translate-path-title")+".title"),l.bindObjectProperty(g,"title",g.getAttribute("translate-path-title")+".description");this.timeoutId=-1,this.visible=!1,this.locale=l}toggleDarkMode(){this.mainDiv.getElementsByClassName("player_info_wrapper")[0].classList.toggle("light_mode")}setTitle(n){document.getElementById("player_info_title").textContent=n}connectSequencer(n){this.seq=n,this.seq.addOnSongChangeEvent(l=>{let g=l.copyright.replaceAll(` `,""),u=(F0,b1,l2=!0)=>{let y1=document.getElementById(F0);if(b1.length>0)if(y1.parentElement.classList.remove("hidden"),y1.innerHTML="",b1.length>30&&l2){y1.classList.add("marquee");let Y2=document.createElement("span");Y2.textContent=b1,y1.appendChild(Y2)}else y1.textContent=b1;else y1.parentElement.classList.add("hidden")};u("player_info_detail",g),u("player_info_time",E$(this.seq.duration).time),u("player_info_file_name",l.fileName,!1);let S=(F0,b1,l2,y1="")=>this.seq.midiData.RMIDInfo?.[F0]===void 0?b1:y1+l2.decode(this.seq.midiData.RMIDInfo?.[F0]).replace(/\0$/,""),r0=S("IENC","ascii",new TextDecoder),E0=new TextDecoder(r0);u("player_info_album",S("IPRD","",E0)),u("player_info_artist",S("IART","",E0)),u("player_info_genre",S("IGNR","",E0)),u("player_info_creation",S("ICRD","",E0)+S("ICRT","",E0,` -`)),u("player_info_comment",S("ICMT","",E0));let m0=this.mainDiv.getElementsByTagName("svg")[0],g0=this.mainDiv.getElementsByTagName("img")[0],u1=document.getElementById("player_info_background_image");if(!l.isEmbedded){m0.style.display="",g0.style.display="none",u1.style.setProperty("--bg-image","undefined");return}if(l.RMIDInfo.IPIC===void 0){m0.style.display="",g0.style.display="none",u1.style.setProperty("--bg-image","undefined");return}m0.style.display="none",g0.style.display="";let R=new Blob([l.RMIDInfo.IPIC.buffer]),X0=URL.createObjectURL(R);g0.src=X0,u1.style.setProperty("--bg-image",`url('${X0}')`)},"player-js-song-change")}setVisibility(n,l){if(n===this.visible)return;this.visible=n,this.timeoutId&&clearTimeout(this.timeoutId);let g=this.mainDiv;if(n){l.classList.add("out_animation"),this.savedCKWrapperHeight=l.clientHeight;let u=l.clientHeight,S=l.getBoundingClientRect().top;g.style.position="absolute",g.style.top=`${S}px`,g.style.height=`${u}px`,g.style.display="flex",setTimeout(()=>{g.classList.add("player_info_show"),document.body.style.overflow="hidden"},75),this.timeoutId=setTimeout(async()=>{l.style.display="none",g.style.position="",g.style.top="",g.style.height="",document.body.style.overflow=""},Ow*1e3)}else{let u=g.getBoundingClientRect().top;l.style.display="",l.style.position="absolute",l.style.top=`${u}px`,l.style.height=`${this.savedCKWrapperHeight}px`,g.classList.remove("player_info_show"),setTimeout(()=>{l.classList.remove("out_animation"),document.body.style.overflow="hidden"},75),this.timeoutId=setTimeout(()=>{g.style.display="none",l.style.position="",l.style.top="",l.style.height="",document.body.style.overflow=""},Ow*1e3)}}};var HC=class{constructor(n){this.locale=k$[n]||k$[zB],this.fallbackLocale=k$[zB],this.localeCode=n,this._boundObjectProperties=[]}getLocaleString(n,l=[]){let g=this._resolveLocalePath(n);return l.length>0?this._formatLocale(g,l):g}_applyPropertyInternal(n){if(n.isEdited)return;let l=this._resolveLocalePath(n.localePath);n.formattingArguments.length>0&&(l=this._formatLocale(l,n.formattingArguments)),n.object[n.propertyName]=l}_validatePropertyIntegrity(n){let l=this._resolveLocalePath(n.localePath);n.formattingArguments.length>0&&(l=this._formatLocale(l,n.formattingArguments)),n.object[n.propertyName]!==l&&(n.isEdited=!0)}onLocaleChanged=[];_formatLocale(n,l){return n.replace(/{(\d+)}/g,(g,u)=>typeof l[u]<"u"?l[u]:g)}bindObjectProperty(n,l,g,u=[]){let S={object:n,propertyName:l,localePath:g,formattingArguments:u,isEdited:!1};this._applyPropertyInternal(S),this._boundObjectProperties.push(S)}_resolveLocalePath(n,l=!1){if(!n.startsWith("locale."))throw new Error(`Invalid locale path: ${n} (it should start with "locale.")`);let g=n.split("."),u=l?this.fallbackLocale:this.locale;for(let S=1;S- ${Ry("100%")} + ${xy("100%")}@@ -258,19 +258,19 @@ var EC=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(n,l)=>({this._validatePropertyIntegrity(u)}),this.locale=g,this._boundObjectProperties.forEach(u=>{this._applyPropertyInternal(u)}),this.onLocaleChanged.forEach(u=>u())}};function ZB(o,n=!0,l=0,g={},u=void 0){let S=o.getChannelData(l),r0=o.getChannelData(l+1),E0=S.length,m0=2,g0=new J3(0),u1=Object.keys(g).length>0;if(u1){let A0=new TextEncoder,y5=[xA("INFO"),Ze("ICMT",A0.encode("Created with SpessaSynth"),!0)];g.artist&&y5.push(Ze("IART",A0.encode(g.artist),!0)),g.album&&y5.push(Ze("IPRD",A0.encode(g.album),!0)),g.genre&&y5.push(Ze("IGNR",A0.encode(g.genre),!0)),g.title&&y5.push(Ze("INAM",A0.encode(g.title),!0)),g0=Ze("LIST",vr(y5))}let R=new J3(0),X0=u?.end!==void 0&&u?.start!==void 0;if(X0){let A0=Math.floor(u.start*o.sampleRate),y5=Math.floor(u.end*o.sampleRate),M3=new J3(24);l7(M3,0,4),l7(M3,0,4),g7(M3,"data"),l7(M3,0,4),l7(M3,0,4),l7(M3,A0,4);let $3=new J3(24);l7($3,1,4),l7($3,0,4),g7($3,"data"),l7($3,0,4),l7($3,0,4),l7($3,y5,4);let w6=vr([new J3([2,0,0,0]),M3,$3]);R=Ze("cue ",w6)}let F0=44,b1=E0*2*m0,l2=F0+b1+g0.length+R.length-8,y1=new Uint8Array(F0);y1.set([82,73,70,70],0),y1.set(new Uint8Array([l2&255,l2>>8&255,l2>>16&255,l2>>24&255]),4),y1.set([87,65,86,69],8),y1.set([102,109,116,32],12),y1.set([16,0,0,0],16),y1.set([1,0],20),y1.set([2,0],22);let Y2=o.sampleRate;y1.set(new Uint8Array([Y2&255,Y2>>8&255,Y2>>16&255,Y2>>24&255]),24);let T2=Y2*2*m0;y1.set(new Uint8Array([T2&255,T2>>8&255,T2>>16&255,T2>>24&255]),28),y1.set([4,0],32),y1.set([16,0],34),y1.set([100,97,116,97],36),y1.set(new Uint8Array([b1&255,b1>>8&255,b1>>16&255,b1>>24&255]),40);let K2=new Uint8Array(l2+8),i3=F0;K2.set(y1,0);let n3=32767;if(n){let A0=S.map((y5,M3)=>Math.max(Math.abs(y5),Math.abs(r0[M3]))).reduce((y5,M3)=>Math.max(y5,M3));n3=A0>0?32767/A0:1}for(let A0=0;A0 >8&255,K2[i3++]=M3&255,K2[i3++]=M3>>8&255}return u1&&(K2.set(g0,i3),i3+=g0.length),X0&&K2.set(R,i3),new Blob([K2.buffer],{type:"audio/wav"})}var qC="synthetizer/worklet_processor.min.js";var Hw=1e3;async function qw(o=!0,n=2,l=!1,g={},u=0){if(this.isExporting=!0,!this.seq)throw new Error("No sequencer active");let S=manager.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.message"),r0=manager.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.estimated"),E0=manager.localeManager.getLocaleString("locale.synthInit.genericLoading"),m0=mt(S,[{type:"text",textContent:E0},{type:"progress"}],9999999,!1),g0=await this.seq.getMIDI(),u1=vm(g0.loop.start,g0),R=vm(g0.loop.end,g0),X0=R-u1,F0=g0.duration+n+X0*u,b1=this.context.sampleRate,l2=b1*F0,y1=new OfflineAudioContext({numberOfChannels:l?32:2,sampleRate:b1,length:l2});await y1.audioWorklet.addModule(new URL("../../spessasynth_lib/"+qC,import.meta.url));let Y2=await this.synth.getSynthesizerSnapshot(),T2=this.soundFont,K2;try{K2=new ch(y1.destination,T2,!1,{parsedMIDI:g0,snapshot:Y2,oneOutput:l,loopCount:u},{reverbEnabled:!0,chorusEnabled:!0,chorusConfig:void 0,reverbImpulseResponse:this.impulseResponse})}catch(o9){throw mt(this.localeManager.getLocaleString("locale.warnings.warning"),[{type:"text",textContent:this.localeManager.getLocaleString("locale.warnings.outOfMemory")}]),o9}let i3=m0.div.getElementsByTagName("p")[0],n3=m0.div.getElementsByClassName("notification_progress")[0],A0=Hw/1e3,y5=K2.currentTime,M3=F0,$3=.1,w6=setInterval(()=>{let o9=K2.currentTime-y5;y5=K2.currentTime;let K4=K2.currentTime/F0;n3.style.width=`${K4*100}%`;let n4=o9/A0,K6=(1-K4)/n4*F0;K6!==1/0&&(M3=$3*K6+(1-$3)*M3,i3.innerText=`${r0} ${E$(M3).time}`)},Hw),s6=await y1.startRendering();if(n3.style.width="100%",clearInterval(w6),i3.innerText=this.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.convertWav"),await new Promise(o9=>setTimeout(o9,75)),l){let o9="locale.exportAudio.formats.formats.wav.options.separateChannels.saving.",K4=[],n4=new Set;for(let We of g0.usedChannelsOnTrack)We.forEach(On=>n4.add(On));for(let We=0;We<16;We++){let On=!0;for(let Ji=We;Ji {let Ms=OA.textContent;OA.textContent=this.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.convertWav"),await new Promise(XC=>setTimeout(XC,75));let Lm=ZB(s6,!1,We*2),_$=`${We+1} - ${Y2.channelSnapshots[We].patchName}.wav`;this.saveBlob(Lm,_$),OA.classList.add("green_button"),OA.textContent=Ms}})}let K6=mt(this.localeManager.getLocaleString(o9+"title"),K4,99999999,!0,void 0,{display:"flex",flexWrap:"wrap",flexDirection:"row"});K6.div.style.width="30rem"}else{let o9=vm(g0.firstNoteOn,g0),K4=u1-o9,n4=R-o9,K6;u===0&&(K6={start:K4,end:n4});let We=ZB(s6,o,0,g,K6);this.saveBlob(We,`${this.seqUI.currentSongTitle||"unnamed_song"}.wav`)}Ot(m0.id),this.isExporting=!1}async function Yw(){if(this.isExporting)return;let o="locale.exportAudio.formats.formats.wav.options.",n="locale.exportAudio.formats.metadata.",l=(g0,u1,R)=>this.seq.midiData.RMIDInfo?.[g0]===void 0?u1:R.decode(this.seq.midiData.RMIDInfo?.[g0]).replace(/\0$/,""),g=l("IENC","ascii",new TextDecoder),u=new TextDecoder(g),S=l("IPRD","",u),r0=l("IART","",u),E0=l("IGNR","",u),m0=[{type:"toggle",translatePathTitle:o+"normalizeVolume",attributes:{"normalize-volume-toggle":"1",checked:"true"}},{type:"input",translatePathTitle:o+"additionalTime",attributes:{value:"2",type:"number","additional-time":"1"}},{type:"input",translatePathTitle:o+"loopCount",attributes:{value:"0",type:"number","loop-count":"1"}},{type:"toggle",translatePathTitle:o+"separateChannels",attributes:{"separate-channels-toggle":"1"}},{type:"input",translatePathTitle:n+"songTitle",attributes:{name:"song_title",type:"text",value:this.seqUI.currentSongTitle}},{type:"input",translatePathTitle:n+"album",attributes:{value:S,name:"album",type:"text"}},{type:"input",translatePathTitle:n+"artist",attributes:{value:r0,name:"artist",type:"text"}},{type:"input",translatePathTitle:n+"genre",attributes:{value:E0,name:"genre",type:"text"}},{type:"button",textContent:this.localeManager.getLocaleString(o+"confirm"),onClick:g0=>{Ot(g0.id);let u1=g0.div.querySelector("input[normalize-volume-toggle]").checked,R=g0.div.querySelector("input[additional-time]").value,X0=g0.div.querySelector("input[loop-count]").value,F0=g0.div.querySelector("input[separate-channels-toggle]").checked,b1=g0.div.querySelector("input[name='artist']").value,l2=g0.div.querySelector("input[name='album']").value,y1=g0.div.querySelector("input[name='song_title']").value,Y2=g0.div.querySelector("input[name='genre']").value,T2={artist:b1.length>0?b1:void 0,album:l2.length>0?l2:void 0,title:y1.length>0?y1:void 0,genre:Y2.length>0?Y2:void 0};this._doExportAudioData(u1,parseInt(R),F0,T2,parseInt(X0))}}];mt(this.localeManager.getLocaleString(o+"title"),m0,9999999,!0,this.localeManager)}async function Jw(){let o=await this.seq.getMIDI();hh(o,await this.synth.getSynthesizerSnapshot());let n=bC(o),l=new Blob([n],{type:"audio/mid"});this.saveBlob(l,`${this.seqUI.currentSongTitle||"unnamed_song"}.mid`)}function Kw(o,n){ni("%cSearching for all used programs and keys...",_1.info);let l=16+o.midiPortChannelOffsets.reduce((R,X0)=>X0>R?X0:R),g=[];for(let R=0;R {r0[b1]>=F0.length||F0[r0[b1]].ticks 0;){let R=m0(),X0=o.tracks[R];if(r0[R]>=X0.length){E0--;continue}let F0=X0[r0[R]];if(r0[R]++,F0.messageStatusByte===K3.midiPort){g0[R]=F0.messageData[0];continue}let b1=F0.messageStatusByte&240;if(b1!==K3.noteOn&&b1!==K3.controllerChange&&b1!==K3.programChange&&b1!==K3.systemExclusive)continue;let l2=(F0.messageStatusByte&15)+o.midiPortChannelOffsets[g0[R]]||0,y1=g[l2];switch(b1){case K3.programChange:y1.program=F0.messageData[0],u(y1);break;case K3.controllerChange:if(F0.messageData[0]!==t6.bankSelect||u1==="gs"&&y1.drums)continue;let Y2=F0.messageData[1],T2=Math.max(0,Y2-o.bankOffset);if(u1==="xg"){let n3=Y2===120||Y2===126||Y2===127;n3!==y1.drums?(y1.drums=n3,y1.bank=y1.drums?128:T2,u(y1)):y1.bank=y1.drums?128:T2;continue}g[l2].bank=T2;break;case K3.noteOn:if(F0.messageData[1]===0)continue;u(y1),S[y1.string].add(`${F0.messageData[0]}-${F0.messageData[1]}`);break;case K3.systemExclusive:if(F0.messageData[0]!==65||F0.messageData[2]!==66||F0.messageData[3]!==18||F0.messageData[4]!==64||!(F0.messageData[5]&16)||F0.messageData[6]!==21){F0.messageData[0]===67&&F0.messageData[2]===76&&F0.messageData[5]===126&&F0.messageData[6]===0&&(u1="xg");continue}let K2=[9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15][F0.messageData[5]&15]+o.midiPortChannelOffsets[g0[R]],i3=!!(F0.messageData[7]>0&&F0.messageData[5]>>4);y1=g[K2],y1.drums=i3,y1.bank=i3?128:0,u(y1);break}}for(let R of Object.keys(S))S[R].size===0&&(Y5(`%cDetected change but no keys for %c${R}`,_1.info,_1.value),delete S[R]);return i4(),S}function YC(o,n){function l(u,S){let r0=0;for(let E0=0;E0 =g0.min&&X0.key<=g0.max&&X0.velocity>=u1.min&&X0.velocity<=u1.max){R=!0;break}R||(Y5(`%c${m0.sample.sampleName} %cremoved from %c${u.instrumentName}%c. Use count: %c${m0.useCount-1}`,_1.recognized,_1.info,_1.recognized,_1.info,_1.recognized),u.safeDeleteZone(E0)&&(r0++,E0--,Y5(`%c${m0.sample.sampleName} %cdeleted`,_1.recognized,_1.info)),m0.sample.useCount<1&&o.deleteSample(m0.sample))}return r0}gn("%cTrimming soundfont...",_1.info);let g=Kw(n,o);ni("%cModifying soundfont...",_1.info),Y5("Detected keys for midi:",g);for(let u=0;u {let R=u1.split("-");return{key:parseInt(R[0]),velocity:parseInt(R[1])}});ni(`%cTrimming %c${S.presetName}`,_1.info,_1.recognized),Y5(`Keys for ${S.presetName}:`,m0);let g0=0;for(let u1=0;u1 =X0.min&&l2.key<=X0.max&&l2.velocity>=F0.min&&l2.velocity<=F0.max){b1=!0;let y1=l(R.instrument,m0);Y5(`%cTrimmed off %c${y1}%c zones from %c${R.instrument.instrumentName}`,_1.info,_1.recognized,_1.info,_1.recognized);break}b1||(g0++,S.deleteZone(u1),R.instrument.useCount<1&&o.deleteInstrument(R.instrument),u1--)}Y5(`%cTrimmed off %c${g0}%c zones from %c${S.presetName}`,_1.info,_1.recognized,_1.info,_1.recognized),i4()}}o.removeUnusedElements(),o.soundFontInfo.ICMT=`NOTE: This soundfont was trimmed by SpessaSynth to only contain presets used in "${n.midiName}" +`)),u("player_info_comment",S("ICMT","",E0));let m0=this.mainDiv.getElementsByTagName("svg")[0],g0=this.mainDiv.getElementsByTagName("img")[0],u1=document.getElementById("player_info_background_image");if(!l.isEmbedded){m0.style.display="",g0.style.display="none",u1.style.setProperty("--bg-image","undefined");return}if(l.RMIDInfo.IPIC===void 0){m0.style.display="",g0.style.display="none",u1.style.setProperty("--bg-image","undefined");return}m0.style.display="none",g0.style.display="";let R=new Blob([l.RMIDInfo.IPIC.buffer]),X0=URL.createObjectURL(R);g0.src=X0,u1.style.setProperty("--bg-image",`url('${X0}')`)},"player-js-song-change")}setVisibility(n,l){if(n===this.visible)return;this.visible=n,this.timeoutId&&clearTimeout(this.timeoutId);let g=this.mainDiv;if(n){l.classList.add("out_animation"),this.savedCKWrapperHeight=l.clientHeight;let u=l.clientHeight,S=l.getBoundingClientRect().top;g.style.position="absolute",g.style.top=`${S}px`,g.style.height=`${u}px`,g.style.display="flex",setTimeout(()=>{g.classList.add("player_info_show"),document.body.style.overflow="hidden"},75),this.timeoutId=setTimeout(async()=>{l.style.display="none",g.style.position="",g.style.top="",g.style.height="",document.body.style.overflow=""},Hw*1e3)}else{let u=g.getBoundingClientRect().top;l.style.display="",l.style.position="absolute",l.style.top=`${u}px`,l.style.height=`${this.savedCKWrapperHeight}px`,g.classList.remove("player_info_show"),setTimeout(()=>{l.classList.remove("out_animation"),document.body.style.overflow="hidden"},75),this.timeoutId=setTimeout(()=>{g.style.display="none",l.style.position="",l.style.top="",l.style.height="",document.body.style.overflow=""},Hw*1e3)}}};var PC=class{constructor(n){this.locale=k$[n]||k$[KB],this.fallbackLocale=k$[KB],this.localeCode=n,this._boundObjectProperties=[]}getLocaleString(n,l=[]){let g=this._resolveLocalePath(n);return l.length>0?this._formatLocale(g,l):g}_applyPropertyInternal(n){if(n.isEdited)return;let l=this._resolveLocalePath(n.localePath);n.formattingArguments.length>0&&(l=this._formatLocale(l,n.formattingArguments)),n.object[n.propertyName]=l}_validatePropertyIntegrity(n){let l=this._resolveLocalePath(n.localePath);n.formattingArguments.length>0&&(l=this._formatLocale(l,n.formattingArguments)),n.object[n.propertyName]!==l&&(n.isEdited=!0)}onLocaleChanged=[];_formatLocale(n,l){return n.replace(/{(\d+)}/g,(g,u)=>typeof l[u]<"u"?l[u]:g)}bindObjectProperty(n,l,g,u=[]){let S={object:n,propertyName:l,localePath:g,formattingArguments:u,isEdited:!1};this._applyPropertyInternal(S),this._boundObjectProperties.push(S)}_resolveLocalePath(n,l=!1){if(!n.startsWith("locale."))throw new Error(`Invalid locale path: ${n} (it should start with "locale.")`);let g=n.split("."),u=l?this.fallbackLocale:this.locale;for(let S=1;S {this._validatePropertyIntegrity(u)}),this.locale=g,this._boundObjectProperties.forEach(u=>{this._applyPropertyInternal(u)}),this.onLocaleChanged.forEach(u=>u())}};function VB(o,n=!0,l=0,g={},u=void 0){let S=o.getChannelData(l),r0=o.getChannelData(l+1),E0=S.length,m0=2,g0=new J3(0),u1=Object.keys(g).length>0;if(u1){let A0=new TextEncoder,y5=[LA("INFO"),Ze("ICMT",A0.encode("Created with SpessaSynth"),!0)];g.artist&&y5.push(Ze("IART",A0.encode(g.artist),!0)),g.album&&y5.push(Ze("IPRD",A0.encode(g.album),!0)),g.genre&&y5.push(Ze("IGNR",A0.encode(g.genre),!0)),g.title&&y5.push(Ze("INAM",A0.encode(g.title),!0)),g0=Ze("LIST",vr(y5))}let R=new J3(0),X0=u?.end!==void 0&&u?.start!==void 0;if(X0){let A0=Math.floor(u.start*o.sampleRate),y5=Math.floor(u.end*o.sampleRate),M3=new J3(24);l7(M3,0,4),l7(M3,0,4),g7(M3,"data"),l7(M3,0,4),l7(M3,0,4),l7(M3,A0,4);let $3=new J3(24);l7($3,1,4),l7($3,0,4),g7($3,"data"),l7($3,0,4),l7($3,0,4),l7($3,y5,4);let w6=vr([new J3([2,0,0,0]),M3,$3]);R=Ze("cue ",w6)}let F0=44,b1=E0*2*m0,l2=F0+b1+g0.length+R.length-8,y1=new Uint8Array(F0);y1.set([82,73,70,70],0),y1.set(new Uint8Array([l2&255,l2>>8&255,l2>>16&255,l2>>24&255]),4),y1.set([87,65,86,69],8),y1.set([102,109,116,32],12),y1.set([16,0,0,0],16),y1.set([1,0],20),y1.set([2,0],22);let Y2=o.sampleRate;y1.set(new Uint8Array([Y2&255,Y2>>8&255,Y2>>16&255,Y2>>24&255]),24);let T2=Y2*2*m0;y1.set(new Uint8Array([T2&255,T2>>8&255,T2>>16&255,T2>>24&255]),28),y1.set([4,0],32),y1.set([16,0],34),y1.set([100,97,116,97],36),y1.set(new Uint8Array([b1&255,b1>>8&255,b1>>16&255,b1>>24&255]),40);let K2=new Uint8Array(l2+8),i3=F0;K2.set(y1,0);let n3=32767;if(n){let A0=S.map((y5,M3)=>Math.max(Math.abs(y5),Math.abs(r0[M3]))).reduce((y5,M3)=>Math.max(y5,M3));n3=A0>0?32767/A0:1}for(let A0=0;A0 >8&255,K2[i3++]=M3&255,K2[i3++]=M3>>8&255}return u1&&(K2.set(g0,i3),i3+=g0.length),X0&&K2.set(R,i3),new Blob([K2.buffer],{type:"audio/wav"})}var HC="synthetizer/worklet_processor.min.js";var qw=1e3;async function Yw(o=!0,n=2,l=!1,g={},u=0){if(this.isExporting=!0,!this.seq)throw new Error("No sequencer active");let S=manager.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.message"),r0=manager.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.estimated"),E0=manager.localeManager.getLocaleString("locale.synthInit.genericLoading"),m0=mt(S,[{type:"text",textContent:E0},{type:"progress"}],9999999,!1),g0=await this.seq.getMIDI(),u1=vm(g0.loop.start,g0),R=vm(g0.loop.end,g0),X0=R-u1,F0=g0.duration+n+X0*u,b1=this.context.sampleRate,l2=b1*F0,y1=new OfflineAudioContext({numberOfChannels:l?32:2,sampleRate:b1,length:l2});await y1.audioWorklet.addModule(new URL("../../spessasynth_lib/"+HC,import.meta.url));let Y2=await this.synth.getSynthesizerSnapshot(),T2=this.soundFont,K2;try{K2=new ch(y1.destination,T2,!1,{parsedMIDI:g0,snapshot:Y2,oneOutput:l,loopCount:u},{reverbEnabled:!0,chorusEnabled:!0,chorusConfig:void 0,reverbImpulseResponse:this.impulseResponse})}catch(o9){throw mt(this.localeManager.getLocaleString("locale.warnings.warning"),[{type:"text",textContent:this.localeManager.getLocaleString("locale.warnings.outOfMemory")}]),o9}let i3=m0.div.getElementsByTagName("p")[0],n3=m0.div.getElementsByClassName("notification_progress")[0],A0=qw/1e3,y5=K2.currentTime,M3=F0,$3=.1,w6=setInterval(()=>{let o9=K2.currentTime-y5;y5=K2.currentTime;let K4=K2.currentTime/F0;n3.style.width=`${K4*100}%`;let n4=o9/A0,K6=(1-K4)/n4*F0;K6!==1/0&&(M3=$3*K6+(1-$3)*M3,i3.innerText=`${r0} ${E$(M3).time}`)},qw),s6=await y1.startRendering();if(n3.style.width="100%",clearInterval(w6),i3.innerText=this.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.convertWav"),await new Promise(o9=>setTimeout(o9,75)),l){let o9="locale.exportAudio.formats.formats.wav.options.separateChannels.saving.",K4=[],n4=new Set;for(let We of g0.usedChannelsOnTrack)We.forEach(Pn=>n4.add(Pn));for(let We=0;We<16;We++){let Pn=!0;for(let Ji=We;Ji {let Ms=PA.textContent;PA.textContent=this.localeManager.getLocaleString("locale.exportAudio.formats.formats.wav.exportMessage.convertWav"),await new Promise(XC=>setTimeout(XC,75));let Lm=VB(s6,!1,We*2),_$=`${We+1} - ${Y2.channelSnapshots[We].patchName}.wav`;this.saveBlob(Lm,_$),PA.classList.add("green_button"),PA.textContent=Ms}})}let K6=mt(this.localeManager.getLocaleString(o9+"title"),K4,99999999,!0,void 0,{display:"flex",flexWrap:"wrap",flexDirection:"row"});K6.div.style.width="30rem"}else{let o9=vm(g0.firstNoteOn,g0),K4=u1-o9,n4=R-o9,K6;u===0&&(K6={start:K4,end:n4});let We=VB(s6,o,0,g,K6);this.saveBlob(We,`${this.seqUI.currentSongTitle||"unnamed_song"}.wav`)}Pt(m0.id),this.isExporting=!1}async function Jw(){if(this.isExporting)return;let o="locale.exportAudio.formats.formats.wav.options.",n="locale.exportAudio.formats.metadata.",l=(g0,u1,R)=>this.seq.midiData.RMIDInfo?.[g0]===void 0?u1:R.decode(this.seq.midiData.RMIDInfo?.[g0]).replace(/\0$/,""),g=l("IENC","ascii",new TextDecoder),u=new TextDecoder(g),S=l("IPRD","",u),r0=l("IART","",u),E0=l("IGNR","",u),m0=[{type:"toggle",translatePathTitle:o+"normalizeVolume",attributes:{"normalize-volume-toggle":"1",checked:"true"}},{type:"input",translatePathTitle:o+"additionalTime",attributes:{value:"2",type:"number","additional-time":"1"}},{type:"input",translatePathTitle:o+"loopCount",attributes:{value:"0",type:"number","loop-count":"1"}},{type:"toggle",translatePathTitle:o+"separateChannels",attributes:{"separate-channels-toggle":"1"}},{type:"input",translatePathTitle:n+"songTitle",attributes:{name:"song_title",type:"text",value:this.seqUI.currentSongTitle}},{type:"input",translatePathTitle:n+"album",attributes:{value:S,name:"album",type:"text"}},{type:"input",translatePathTitle:n+"artist",attributes:{value:r0,name:"artist",type:"text"}},{type:"input",translatePathTitle:n+"genre",attributes:{value:E0,name:"genre",type:"text"}},{type:"button",textContent:this.localeManager.getLocaleString(o+"confirm"),onClick:g0=>{Pt(g0.id);let u1=g0.div.querySelector("input[normalize-volume-toggle]").checked,R=g0.div.querySelector("input[additional-time]").value,X0=g0.div.querySelector("input[loop-count]").value,F0=g0.div.querySelector("input[separate-channels-toggle]").checked,b1=g0.div.querySelector("input[name='artist']").value,l2=g0.div.querySelector("input[name='album']").value,y1=g0.div.querySelector("input[name='song_title']").value,Y2=g0.div.querySelector("input[name='genre']").value,T2={artist:b1.length>0?b1:void 0,album:l2.length>0?l2:void 0,title:y1.length>0?y1:void 0,genre:Y2.length>0?Y2:void 0};this._doExportAudioData(u1,parseInt(R),F0,T2,parseInt(X0))}}];mt(this.localeManager.getLocaleString(o+"title"),m0,9999999,!0,this.localeManager)}async function Kw(){let o=await this.seq.getMIDI();hh(o,await this.synth.getSynthesizerSnapshot());let n=SC(o),l=new Blob([n],{type:"audio/mid"});this.saveBlob(l,`${this.seqUI.currentSongTitle||"unnamed_song"}.mid`)}function Vw(o,n){ni("%cSearching for all used programs and keys...",_1.info);let l=16+o.midiPortChannelOffsets.reduce((R,X0)=>X0>R?X0:R),g=[];for(let R=0;R {r0[b1]>=F0.length||F0[r0[b1]].ticks 0;){let R=m0(),X0=o.tracks[R];if(r0[R]>=X0.length){E0--;continue}let F0=X0[r0[R]];if(r0[R]++,F0.messageStatusByte===K3.midiPort){g0[R]=F0.messageData[0];continue}let b1=F0.messageStatusByte&240;if(b1!==K3.noteOn&&b1!==K3.controllerChange&&b1!==K3.programChange&&b1!==K3.systemExclusive)continue;let l2=(F0.messageStatusByte&15)+o.midiPortChannelOffsets[g0[R]]||0,y1=g[l2];switch(b1){case K3.programChange:y1.program=F0.messageData[0],u(y1);break;case K3.controllerChange:if(F0.messageData[0]!==t6.bankSelect||u1==="gs"&&y1.drums)continue;let Y2=F0.messageData[1],T2=Math.max(0,Y2-o.bankOffset);if(u1==="xg"){let n3=Y2===120||Y2===126||Y2===127;n3!==y1.drums?(y1.drums=n3,y1.bank=y1.drums?128:T2,u(y1)):y1.bank=y1.drums?128:T2;continue}g[l2].bank=T2;break;case K3.noteOn:if(F0.messageData[1]===0)continue;u(y1),S[y1.string].add(`${F0.messageData[0]}-${F0.messageData[1]}`);break;case K3.systemExclusive:if(F0.messageData[0]!==65||F0.messageData[2]!==66||F0.messageData[3]!==18||F0.messageData[4]!==64||!(F0.messageData[5]&16)||F0.messageData[6]!==21){F0.messageData[0]===67&&F0.messageData[2]===76&&F0.messageData[5]===126&&F0.messageData[6]===0&&(u1="xg");continue}let K2=[9,0,1,2,3,4,5,6,7,8,10,11,12,13,14,15][F0.messageData[5]&15]+o.midiPortChannelOffsets[g0[R]],i3=!!(F0.messageData[7]>0&&F0.messageData[5]>>4);y1=g[K2],y1.drums=i3,y1.bank=i3?128:0,u(y1);break}}for(let R of Object.keys(S))S[R].size===0&&(Y5(`%cDetected change but no keys for %c${R}`,_1.info,_1.value),delete S[R]);return i4(),S}function qC(o,n){function l(u,S){let r0=0;for(let E0=0;E0 =g0.min&&X0.key<=g0.max&&X0.velocity>=u1.min&&X0.velocity<=u1.max){R=!0;break}R||(Y5(`%c${m0.sample.sampleName} %cremoved from %c${u.instrumentName}%c. Use count: %c${m0.useCount-1}`,_1.recognized,_1.info,_1.recognized,_1.info,_1.recognized),u.safeDeleteZone(E0)&&(r0++,E0--,Y5(`%c${m0.sample.sampleName} %cdeleted`,_1.recognized,_1.info)),m0.sample.useCount<1&&o.deleteSample(m0.sample))}return r0}gn("%cTrimming soundfont...",_1.info);let g=Vw(n,o);ni("%cModifying soundfont...",_1.info),Y5("Detected keys for midi:",g);for(let u=0;u {let R=u1.split("-");return{key:parseInt(R[0]),velocity:parseInt(R[1])}});ni(`%cTrimming %c${S.presetName}`,_1.info,_1.recognized),Y5(`Keys for ${S.presetName}:`,m0);let g0=0;for(let u1=0;u1 =X0.min&&l2.key<=X0.max&&l2.velocity>=F0.min&&l2.velocity<=F0.max){b1=!0;let y1=l(R.instrument,m0);Y5(`%cTrimmed off %c${y1}%c zones from %c${R.instrument.instrumentName}`,_1.info,_1.recognized,_1.info,_1.recognized);break}b1||(g0++,S.deleteZone(u1),R.instrument.useCount<1&&o.deleteInstrument(R.instrument),u1--)}Y5(`%cTrimmed off %c${g0}%c zones from %c${S.presetName}`,_1.info,_1.recognized,_1.info,_1.recognized),i4()}}o.removeUnusedElements(),o.soundFontInfo.ICMT=`NOTE: This soundfont was trimmed by SpessaSynth to only contain presets used in "${n.midiName}" -`+o.soundFontInfo.ICMT,Y5("%cSoundfont modified!",_1.recognized),i4(),i4()}function Vw(){let o=4;for(let g of this.instruments)o+=g.instrumentZones.reduce((u,S)=>(S.generators=S.generators.filter(r0=>r0.generatorType!==v1.sampleID&&r0.generatorType!==v1.keyRange&&r0.generatorType!==v1.velRange),(S.velRange.max!==127||S.velRange.min!==0)&&S.generators.unshift({generatorType:v1.velRange,generatorValue:S.velRange.max<<8|S.velRange.min}),(S.keyRange.max!==127||S.keyRange.min!==0)&&S.generators.unshift({generatorType:v1.keyRange,generatorValue:S.keyRange.max<<8|S.keyRange.min}),S.isGlobal||S.generators.push({generatorType:v1.sampleID,generatorValue:this.samples.indexOf(S.sample)}),S.generators.length*4+u),0);let n=new J3(o),l=0;for(let g of this.instruments)for(let u of g.instrumentZones){u.generatorZoneStartIndex=l;for(let S of u.generators)Q9(n,S.generatorType),Q9(n,S.generatorValue),l++}return c7(n,0),ze(new Ee("igen",n.length,n))}function zw(o,n,l,g,u){let S=this.samples.map((g0,u1)=>{l&&g0.compressSample(g,u);let R=g0.getRawData();return Y5(`%cEncoded sample %c${u1}. ${g0.sampleName}%c of %c${this.samples.length}`,_1.info,_1.recognized,_1.info,_1.recognized),R}),r0=this.samples.reduce((g0,u1,R)=>g0+S[R].length+46,0),E0=new J3(r0);this.samples.forEach((g0,u1)=>{let R=S[u1],X0,F0,b1=R.length;g0.isCompressed?(X0=E0.currentIndex,F0=X0+R.length):(X0=E0.currentIndex/2,F0=X0+R.length/2,b1+=46),o.push(X0),E0.set(R,E0.currentIndex),E0.currentIndex+=b1,n.push(F0)});let m0=ze(new Ee("smpl",E0.length,E0),new J3([115,100,116,97]));return ze(new Ee("LIST",m0.length,m0))}function Zw(o,n){let g=new J3(46*(this.samples.length+1));return this.samples.forEach((u,S)=>{g7(g,u.sampleName,20);let r0=o[S];c7(g,r0);let E0=n[S];c7(g,E0);let m0=u.sampleLoopStartIndex+r0,g0=u.sampleLoopEndIndex+r0;u.isCompressed&&(m0-=r0,g0-=r0),c7(g,m0),c7(g,g0),c7(g,u.sampleRate),g[g.currentIndex++]=u.samplePitch,g[g.currentIndex++]=u.samplePitchCorrection,Q9(g,u.sampleLink),Q9(g,u.sampleType)}),g7(g,"EOS",46),ze(new Ee("shdr",g.length,g))}function Ww(){let o=10;for(let g of this.instruments)o+=g.instrumentZones.reduce((u,S)=>S.modulators.length*10+u,0);let n=new J3(o),l=0;for(let g of this.instruments)for(let u of g.instrumentZones){u.modulatorZoneStartIndex=l;for(let S of u.modulators)Q9(n,S.sourceEnum),Q9(n,S.modulatorDestination),Q9(n,S.transformAmount),Q9(n,S.secondarySourceEnum),Q9(n,S.transformType),l++}return l7(n,0,10),ze(new Ee("imod",n.length,n))}function jw(){let o=this.instruments.reduce((S,r0)=>r0.instrumentZones.length*4+S,4),n=new J3(o),l=0,g=0,u=0;for(let S of this.instruments){S.instrumentZoneIndex=l;for(let r0 of S.instrumentZones)r0.zoneID=l,Q9(n,g),Q9(n,u),g+=r0.generators.length,u+=r0.modulators.length,l++}return Q9(n,g),Q9(n,u),ze(new Ee("ibag",n.length,n))}function Xw(){let o=this.instruments.length*22+22,n=new J3(o),l=0,g=0;for(let u of this.instruments)g7(n,u.instrumentName,20),Q9(n,l),l+=u.instrumentZones.length,u.instrumentID=g,g++;return g7(n,"EOI",20),Q9(n,l),ze(new Ee("inst",n.length,n))}function ek(){let o=4;for(let g of this.presets)o+=g.presetZones.reduce((u,S)=>(S.generators=S.generators.filter(r0=>r0.generatorType!==v1.instrument&&r0.generatorType!==v1.keyRange&&r0.generatorType!==v1.velRange),(S.velRange.max!==127||S.velRange.min!==0)&&S.generators.unshift({generatorType:v1.velRange,generatorValue:S.velRange.max<<8|S.velRange.min}),(S.keyRange.max!==127||S.keyRange.min!==0)&&S.generators.unshift({generatorType:v1.keyRange,generatorValue:S.keyRange.max<<8|S.keyRange.min}),S.isGlobal||S.generators.push({generatorType:v1.instrument,generatorValue:this.instruments.indexOf(S.instrument)}),S.generators.length*4+u),0);let n=new J3(o),l=0;for(let g of this.presets)for(let u of g.presetZones){u.generatorZoneStartIndex=l;for(let S of u.generators)Q9(n,S.generatorType),Q9(n,S.generatorValue);l+=u.generators.length}return Q9(n,0),Q9(n,0),ze(new Ee("pgen",n.length,n))}function tk(){let o=10;for(let g of this.presets)o+=g.presetZones.reduce((u,S)=>S.modulators.length*10+u,0);let n=new J3(o),l=0;for(let g of this.presets)for(let u of g.presetZones){u.modulatorZoneStartIndex=l;for(let S of u.modulators)Q9(n,S.sourceEnum),Q9(n,S.modulatorDestination),Q9(n,S.transformAmount),Q9(n,S.secondarySourceEnum),Q9(n,S.transformType),l++}return l7(n,0,10),ze(new Ee("pmod",n.length,n))}function ik(){let o=this.presets.reduce((S,r0)=>r0.presetZones.length*4+S,4),n=new J3(o),l=0,g=0,u=0;for(let S of this.presets){S.presetZoneStartIndex=l;for(let r0 of S.presetZones)r0.zoneID=l,Q9(n,g),Q9(n,u),g+=r0.generators.length,u+=r0.modulators.length,l++}return Q9(n,g),Q9(n,u),ze(new Ee("pbag",n.length,n))}function nk(){let o=this.presets.length*38+38,n=new J3(o),l=0;for(let g of this.presets)g7(n,g.presetName,20),Q9(n,g.program),Q9(n,g.bank),Q9(n,l),c7(n,g.library),c7(n,g.genre),c7(n,g.morphology),l+=g.presetZones.length;return g7(n,"EOP",20),Q9(n,0),Q9(n,0),Q9(n,l),c7(n,0),c7(n,0),c7(n,0),ze(new Ee("phdr",n.length,n))}var Wb={compress:!1,compressionQuality:.5,compressionFunction:void 0};function rk(o=Wb){if(o.compress&&typeof o.compressionFunction!="function")throw new TypeError("No compression function supplied but compression enabled.");ni("%cSaving soundfont...",_1.info),Y5(`%cCompression: %c${o?.compress||"false"}%c quality: %c${o?.compressionQuality||"none"}`,_1.info,_1.recognized,_1.info,_1.recognized),Y5("%cWriting INFO...",_1.info);let n=[];this.soundFontInfo.ISFT="SpessaSynth",o?.compress&&(this.soundFontInfo.ifil="3.0");for(let[i3,n3]of Object.entries(this.soundFontInfo))if(i3==="ifil"||i3==="iver"){let A0=parseInt(n3.split(".")[0]),y5=parseInt(n3.split(".")[1]),M3=new J3(4);Q9(M3,A0),Q9(M3,y5),n.push(ze(new Ee(i3,4,M3)))}else if(i3==="DMOD")n.push(ze(new Ee(i3,n3.length,n3)));else{let A0=new J3(n3.length);g7(A0,n3),n.push(ze(new Ee(i3,n3.length,A0)))}let l=vr([new J3([73,78,70,79]),...n]),g=ze(new Ee("LIST",l.length,l));Y5("%cWriting SDTA...",_1.info);let u=[],S=[],r0=zw.call(this,u,S,o?.compress,o?.compressionQuality||.5,o.compressionFunction);Y5("%cWriting PDTA...",_1.info),Y5("%cWriting SHDR...",_1.info);let E0=Zw.call(this,u,S);Y5("%cWriting IGEN...",_1.info);let m0=Vw.call(this);Y5("%cWriting IMOD...",_1.info);let g0=Ww.call(this);Y5("%cWriting IBAG...",_1.info);let u1=jw.call(this);Y5("%cWriting INST...",_1.info);let R=Xw.call(this),X0=ek.call(this);Y5("%cWriting PMOD...",_1.info);let F0=tk.call(this);Y5("%cWriting PBAG...",_1.info);let b1=ik.call(this);Y5("%cWriting PHDR...",_1.info);let l2=nk.call(this),y1=vr([new J3([112,100,116,97]),l2,b1,F0,X0,R,u1,g0,m0,E0]),Y2=ze(new Ee("LIST",y1.length,y1));Y5("%cWriting the output file...",_1.info);let T2=vr([new J3([115,102,98,107]),g,r0,Y2]),K2=ze(new Ee("RIFF",T2.length,T2));return Y5(`%cSaved succesfully! Final file size: %c${K2.length}`,_1.info,_1.recognized),i4(),K2}var v$=class o{constructor(n=void 0){this.soundFontInfo={},this.presets=[],this.samples=[],this.instruments=[],this.defaultModulators=pC.map(l=>me.copy(l)),n?.presets&&(this.presets.push(...n.presets),this.soundFontInfo=n.info)}removeUnusedElements(){this.instruments.forEach(n=>{n.useCount<1&&n.instrumentZones.forEach(l=>{l.isGlobal||l.sample.useCount--})}),this.instruments=this.instruments.filter(n=>n.useCount>0),this.samples=this.samples.filter(n=>n.useCount>0)}deleteInstrument(n){if(n.useCount>0)throw new Error(`Cannot delete an instrument that has ${n.useCount} usages.`);this.instruments.splice(this.instruments.indexOf(n),1),n.deleteInstrument(),this.removeUnusedElements()}deleteSample(n){if(n.useCount>0)throw new Error(`Cannot delete sample that has ${n.useCount} usages.`);this.samples.splice(this.samples.indexOf(n),1),this.removeUnusedElements()}deletePreset(n){n.deletePreset(),this.presets.splice(this.presets.indexOf(n),1),this.removeUnusedElements()}getPresetNoFallback(n,l,g=!1){let u=this.presets.find(S=>S.bank===n&&S.program===l);if(u)return u;if(g!==!1)return n===128?this.presets.find(S=>S.bank===128):this.presets.find(S=>S.program===l)}setSampleIDOffset(n){this.presets.forEach(l=>l.sampleIDOffset=n)}getPreset(n,l){let g=this.presets.find(u=>u.bank===n&&u.program===l);return g||(n===128?(g=this.presets.find(u=>u.bank===128&&u.program===l),g||(g=this.presets.find(u=>u.bank===128))):g=this.presets.find(u=>u.program===l&&u.bank!==128),g&&R4(`%cPreset ${n}.${l} not found. Replaced with %c${g.presetName} (${g.bank}.${g.program})`,_1.warn,_1.recognized)),g||(R4(`Preset ${l} not found. Defaulting to`,this.presets[0].presetName),g=this.presets[0]),g}getPresetByName(n){let l=this.presets.find(g=>g.presetName===n);return l||(R4("Preset not found. Defaulting to:",this.presets[0].presetName),l=this.presets[0]),l}static mergeSoundfonts(...n){let l=n.shift(),g=l.presets;for(;n.length;)n.shift().presets.forEach(S=>{g.find(r0=>r0.bank===S.bank&&r0.program===S.program)===void 0&&g.push(S)});return new o({presets:g,info:l.soundFontInfo})}};v$.prototype.write=rk;function sk(o){ni("%cLoading instruments...",_1.info);for(let n=0;n n.deleteZone()),this.presetZones.length=0}deleteZone(n){this.presetZones[n].deleteZone(),this.presetZones.splice(n,1)}preload(n,l){for(let g=n;g {S.sample.isSampleLoaded||S.sample.getAudioData()})}preloadSpecific(n,l){this.getSamplesAndGenerators(n,l).forEach(g=>{g.sample.isSampleLoaded||g.sample.getAudioData()})}getSamplesAndGenerators(n,l){let g=this.foundSamplesAndGenerators[n][l];if(g)return g;if(this.presetZones.length<1)return[];function u(R,X0,F0){return F0>=R&&F0<=X0}function S(R,X0){R.push(...X0.filter(F0=>!R.find(b1=>b1.generatorType===F0.generatorType)))}function r0(R,X0){R.push(...X0.filter(F0=>!R.find(b1=>me.isIdentical(F0,b1))))}let E0=[],m0=this.presetZones[0].isGlobal?[...this.presetZones[0].generators]:[],g0=this.presetZones[0].isGlobal?[...this.presetZones[0].modulators]:[];return this.presetZones.filter(R=>u(R.keyRange.min,R.keyRange.max,n)&&u(R.velRange.min,R.velRange.max,l)&&!R.isGlobal).forEach(R=>{if(R.instrument.instrumentZones.length<1)return;let X0=R.generators,F0=R.modulators,b1=R.instrument.instrumentZones[0].isGlobal?[...R.instrument.instrumentZones[0].generators]:[],l2=R.instrument.instrumentZones[0].isGlobal?[...R.instrument.instrumentZones[0].modulators]:[];R.instrument.instrumentZones.filter(Y2=>u(Y2.keyRange.min,Y2.keyRange.max,n)&&u(Y2.velRange.min,Y2.velRange.max,l)&&!Y2.isGlobal).forEach(Y2=>{let T2=[...Y2.generators],K2=[...Y2.modulators];S(X0,m0),S(T2,b1),r0(F0,g0),r0(K2,l2),r0(K2,this.defaultModulators);let i3=[...K2];for(let n3=0;n3 me.isIdentical(A0,M3));y5!==-1?i3[y5]=i3[y5].sumTransform(A0):i3.push(A0)}E0.push({instrumentGenerators:T2,presetGenerators:X0,modulators:i3,sample:Y2.sample,sampleID:Y2.generators.find(n3=>n3.generatorType===v1.sampleID).generatorValue})})}),this.foundSamplesAndGenerators[n][l]=E0,E0}};var Rm=class{velRange={min:0,max:127};keyRange={min:0,max:127};isGlobal=!1;generators=[];modulators=[]};var GA=class extends Rm{sample=void 0;useCount=0;deleteZone(){this.useCount--,!this.isGlobal&&this.sample.useCount--}},Eh=class extends Rm{instrument=void 0;deleteZone(){this.isGlobal||this.instrument.removeUseCount()}};var mh=class{constructor(){this.instrumentName="",this.instrumentZones=[],this._useCount=0}addUseCount(){this._useCount++,this.instrumentZones.forEach(n=>n.useCount++)}removeUseCount(){this._useCount--;for(let n=0;n n.deleteZone()),this.instrumentZones.length=0}safeDeleteZone(n){return this.instrumentZones[n].useCount--,this.instrumentZones[n].useCount<1?(this.deleteZone(n),!0):!1}deleteZone(n){this.instrumentZones[n].deleteZone(),this.instrumentZones.splice(n,1)}};var JC=class extends Ih{constructor(n,l){super(pC),this.program=l&127,this.bank=n>>8&127,n>>31&&(this.bank=128),this.DLSInstrument=new mh,this.DLSInstrument.addUseCount();let u=new Eh;u.instrument=this.DLSInstrument,this.presetZones=[u]}};function ok(o){this.verifyHeader(o,"LIST"),this.verifyText(Ie(o.chunkData,4),"ins ");let n=[];for(;o.chunkData.length>o.chunkData.currentIndex;)n.push(d4(o.chunkData));let l=n.find(F0=>F0.header==="insh");if(!l)throw i4(),new Error("No instrument header!");let g=o3(l.chunkData,4),u=o3(l.chunkData,4),S=o3(l.chunkData,4),r0=new JC(u,S),E0="unnamedPreset",m0=bi(n,"INFO");if(m0){let F0=d4(m0.chunkData);for(;F0.header!=="INAM";)F0=d4(m0.chunkData);E0=Ie(F0.chunkData,F0.chunkData.length).trim()}r0.presetName=E0,r0.DLSInstrument.instrumentName=E0,gn(`%cParsing %c"${E0}"%c...`,_1.info,_1.recognized,_1.info);let g0=bi(n,"lrgn");if(!g0)throw i4(),new Error("No region list!");let u1=new GA;u1.isGlobal=!0;let R=bi(n,"lart"),X0=bi(n,"lar2");this.readLart(R,X0,u1),r0.DLSInstrument.instrumentZones.push(u1);for(let F0=0;F0 >10&15;Y2===Gn.linear&&y1!==Gn.linear&&(Y2=y1);let T2=g>>14&1,K2=g>>15&1;r0===v1.initialAttenuation&&(K2=!K2),R=Nn(Y2,T2,K2,E0.isCC,E0.enum)}let X0=g>>4&15,F0=g>>8&1,b1=g>>9&1,l2=Nn(X0,F0,b1,u1.isCC,u1.enum);if(m0){let y1=l2;l2=R,R=y1}return new me({srcEnum:R,secSrcEnum:l2,dest:r0,transform:0,amt:u})}function WB(o,n){let l=o.chunkData,g=[],u=[];o3(l,4);let S=o3(l,4);for(let r0=0;r0 >16;if(E0===0&&m0===0&&u1===0){let F0;switch(g0){case m6.pan:F0=new X6(v1.pan,X0);break;case m6.gain:F0=new X6(v1.initialAttenuation,-X0*10/.4);break;case m6.filterCutoff:F0=new X6(v1.initialFilterFc,X0);break;case m6.filterQ:F0=new X6(v1.initialFilterQ,X0);break;case m6.modLfoFreq:F0=new X6(v1.freqModLFO,X0);break;case m6.modLfoDelay:F0=new X6(v1.delayModLFO,X0);break;case m6.vibLfoFreq:F0=new X6(v1.freqVibLFO,X0);break;case m6.vibLfoDelay:F0=new X6(v1.delayVibLFO,X0);break;case m6.volEnvDelay:F0=new X6(v1.delayVolEnv,X0);break;case m6.volEnvAttack:F0=new X6(v1.attackVolEnv,X0);break;case m6.volEnvHold:F0=new X6(v1.holdVolEnv,X0);break;case m6.volEnvDecay:F0=new X6(v1.decayVolEnv,X0);break;case m6.volEnvRelease:F0=new X6(v1.releaseVolEnv,X0);break;case m6.volEnvSustain:let b1=(1e3-X0)/10;F0=new X6(v1.sustainVolEnv,b1*10);break;case m6.modEnvDelay:F0=new X6(v1.delayModEnv,X0);break;case m6.modEnvAttack:F0=new X6(v1.attackModEnv,X0);break;case m6.modEnvHold:F0=new X6(v1.holdModEnv,X0);break;case m6.modEnvDecay:F0=new X6(v1.decayModEnv,X0);break;case m6.modEnvRelease:F0=new X6(v1.releaseModEnv,X0);break;case m6.modEnvSustain:let l2=1e3-X0;F0=new X6(v1.sustainModEnv,l2);break;case m6.reverbSend:F0=new X6(v1.reverbEffectsSend,X0);break;case m6.chorusSend:F0=new X6(v1.chorusEffectsSend,X0);break;case m6.pitch:let y1=Math.floor(X0/100),Y2=Math.floor(X0-y1*100);F0=new X6(v1.fineTune,Y2),g.push(new X6(v1.coarseTune,y1));break}F0&&g.push(F0)}else{let F0=!0;if(m0===w4.none)if(E0===w4.modLfo&&g0===m6.pitch)g.push(new X6(v1.modLfoToPitch,X0));else if(E0===w4.modLfo&&g0===m6.gain)g.push(new X6(v1.modLfoToVolume,X0));else if(E0===w4.modLfo&&g0===m6.filterCutoff)g.push(new X6(v1.modLfoToFilterFc,X0));else if(E0===w4.vibratoLfo&&g0===m6.pitch)g.push(new X6(v1.vibLfoToPitch,X0));else if(E0===w4.modEnv&&g0===m6.pitch)g.push(new X6(v1.modEnvToPitch,X0));else if(E0===w4.modEnv&&g0===m6.filterCutoff)g.push(new X6(v1.modEnvToFilterFc,X0));else if(E0===w4.keyNum&&g0===m6.volEnvHold){g.push(new X6(v1.keyNumToVolEnvHold,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.holdVolEnv&&(l2.generatorValue+=b1)})}else if(E0===w4.keyNum&&g0===m6.volEnvDecay){g.push(new X6(v1.keyNumToVolEnvDecay,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.decayVolEnv&&(l2.generatorValue+=b1)})}else if(E0===w4.keyNum&&g0===m6.modEnvHold){g.push(new X6(v1.keyNumToModEnvHold,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.holdModEnv&&(l2.generatorValue+=b1)})}else if(E0===w4.keyNum&&g0===m6.modEnvDecay){g.push(new X6(v1.keyNumToModEnvDecay,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.decayModEnv&&(l2.generatorValue+=b1)})}else F0=!1;else F0=!1;if(F0===!1){let b1=ak(E0,m0,g0,u1,X0);b1?(u.push(b1),Y5("%cSucceeded converting to SF2 Modulator!",_1.recognized)):R4("Failed converting to SF2 Modulator!")}}}return u.find(r0=>r0.modulatorDestination===v1.reverbEffectsSend)===void 0&&u.push(new me({srcEnum:219,dest:v1.reverbEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),u.find(r0=>r0.modulatorDestination===v1.chorusEffectsSend)===void 0&&u.push(new me({srcEnum:221,dest:v1.chorusEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),n&&u.push(new me({srcEnum:129,dest:v1.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0}),new me({srcEnum:13,dest:v1.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0})),{modulators:u,generators:g}}function $k(o,n,l){if(o)for(;o.chunkData.currentIndexo.chunkData.currentIndex;)n.push(d4(o.chunkData));let l=n.find(M3=>M3.header==="rgnh"),g=o3(l.chunkData,2),u=o3(l.chunkData,2),S=o3(l.chunkData,2),r0=o3(l.chunkData,2),E0=new KC({min:g,max:u},{min:S,max:r0});o3(l.chunkData,2);let m0=o3(l.chunkData,2);m0!==0&&E0.generators.push(new X6(v1.exclusiveClass,m0));let g0=bi(n,"lart"),u1=bi(n,"lar2");this.readLart(g0,u1,E0),E0.isGlobal=!1;let R=n.find(M3=>M3.header==="wsmp");o3(R.chunkData,4);let X0=o3(R.chunkData,2),F0=RA(R.chunkData[R.chunkData.currentIndex++],R.chunkData[R.chunkData.currentIndex++]),l2=(o3(R.chunkData,4)|0)/-655360;o3(R.chunkData,4);let y1=o3(R.chunkData,4),Y2,T2={start:0,end:0};if(y1===0)Y2=0;else{o3(R.chunkData,4),o3(R.chunkData,4)===0?Y2=1:Y2=3,T2.start=o3(R.chunkData,4);let $3=o3(R.chunkData,4);T2.end=T2.start+$3}let K2=n.find(M3=>M3.header==="wlnk");if(K2===void 0)return;o3(K2.chunkData,2),o3(K2.chunkData,2),o3(K2.chunkData,4);let i3=o3(K2.chunkData,4),n3=this.samples[i3];if(n3===void 0)throw new Error("Invalid sample ID!");let y5=(l2||n3.sampleDbAttenuation)*10/.4;return E0.setWavesample(y5,Y2,T2,X0,n3,i3,F0),E0}var Ch=class{constructor(n,l,g,u,S,r0,E0,m0){this.sampleName=n,this.sampleRate=l,this.samplePitch=g,this.samplePitchCorrection=u,this.sampleLink=S,this.sampleType=r0,this.sampleLoopStartIndex=E0,this.sampleLoopEndIndex=m0,this.isCompressed=(r0&16)>0,this.compressedData=void 0,this.useCount=0}getRawData(){let n=new Error("Not implemented");throw n.name="NotImplementedError",n}compressSample(n,l){if(!this.isCompressed)try{this.compressedData=l([this.getAudioData()],1,this.sampleRate,n),this.sampleType|=16,this.isCompressed=!0}catch{R4(`Failed to compress ${this.sampleName}. Leaving as uncompressed!`),this.isCompressed=!1,this.compressedData=void 0,this.sampleType&=-17}}getAudioData(){let n=new Error("Not implemented");throw n.name="NotImplementedError",n}};var VC=class extends Ch{constructor(n,l,g,u,S,r0,E0,m0){super(n,l,g,u,0,1,S,r0-1),this.sampleData=E0,this.sampleDbAttenuation=m0}getAudioData(){return this.sampleData}sampleDbAttenuation;sampleData;getRawData(){if(this.isCompressed){if(!this.compressedData)throw new Error("Compressed but no data??");return this.compressedData}let n=new Uint8Array(this.sampleData.length*2);for(let l=0;l >8&255}return n}};function ck(o){ni("%cLoading Wave samples...",_1.recognized);let n=0;for(;o.chunkData.currentIndex $3.header==="fmt ");if(!u)throw new Error("No fmt chunk in the wave file!");if(o3(u.chunkData,2)!==1)throw new Error("Only PCM format in WAVE is supported.");if(o3(u.chunkData,2)!==1)throw new Error("Only mono samples are supported.");let E0=o3(u.chunkData,4);o3(u.chunkData,4),o3(u.chunkData,2);let m0=o3(u.chunkData,2),g0=m0/8,u1=Math.pow(2,g0*8-1),R=Math.pow(2,g0*8),X0,F0=!1;m0===8?(X0=255,F0=!0):X0=u1;let b1=g.find($3=>$3.header==="data");if(!b1)throw new Error("No data chunk in the wave chunk!");let l2=b1.size/g0,y1=new Float32Array(l2);for(let $3=0;$3 =u1&&(w6-=R),y1[$3]=w6/X0)}let Y2=60,T2=0,K2=0,i3=y1.length-1,n3=0,A0=g.find($3=>$3.header==="wsmp");if(A0){if(o3(A0.chunkData,4),Y2=o3(A0.chunkData,2),T2=RA(A0.chunkData[A0.chunkData.currentIndex++],A0.chunkData[A0.chunkData.currentIndex++]),n3=(o3(A0.chunkData,4)|0)/-655360,o3(A0.chunkData,4),o3(A0.chunkData,4)===1){o3(A0.chunkData,8),K2=o3(A0.chunkData,4);let s6=o3(A0.chunkData,4);i3=K2+s6}}else R4("No wsmp chunk in wave... using sane defaults.");let y5=bi(g,"INFO"),M3=`Unnamed ${n}`;if(y5){let $3=d4(y5.chunkData);for(;$3.header!=="INAM"&&y5.chunkData.currentIndex (S.generators=S.generators.filter(r0=>r0.generatorType!==v1.sampleID&&r0.generatorType!==v1.keyRange&&r0.generatorType!==v1.velRange),(S.velRange.max!==127||S.velRange.min!==0)&&S.generators.unshift({generatorType:v1.velRange,generatorValue:S.velRange.max<<8|S.velRange.min}),(S.keyRange.max!==127||S.keyRange.min!==0)&&S.generators.unshift({generatorType:v1.keyRange,generatorValue:S.keyRange.max<<8|S.keyRange.min}),S.isGlobal||S.generators.push({generatorType:v1.sampleID,generatorValue:this.samples.indexOf(S.sample)}),S.generators.length*4+u),0);let n=new J3(o),l=0;for(let g of this.instruments)for(let u of g.instrumentZones){u.generatorZoneStartIndex=l;for(let S of u.generators)Q9(n,S.generatorType),Q9(n,S.generatorValue),l++}return c7(n,0),ze(new me("igen",n.length,n))}function Zw(o,n,l,g,u){let S=this.samples.map((g0,u1)=>{l&&g0.compressSample(g,u);let R=g0.getRawData();return Y5(`%cEncoded sample %c${u1}. ${g0.sampleName}%c of %c${this.samples.length}`,_1.info,_1.recognized,_1.info,_1.recognized),R}),r0=this.samples.reduce((g0,u1,R)=>g0+S[R].length+46,0),E0=new J3(r0);this.samples.forEach((g0,u1)=>{let R=S[u1],X0,F0,b1=R.length;g0.isCompressed?(X0=E0.currentIndex,F0=X0+R.length):(X0=E0.currentIndex/2,F0=X0+R.length/2,b1+=46),o.push(X0),E0.set(R,E0.currentIndex),E0.currentIndex+=b1,n.push(F0)});let m0=ze(new me("smpl",E0.length,E0),new J3([115,100,116,97]));return ze(new me("LIST",m0.length,m0))}function Ww(o,n){let g=new J3(46*(this.samples.length+1));return this.samples.forEach((u,S)=>{g7(g,u.sampleName,20);let r0=o[S];c7(g,r0);let E0=n[S];c7(g,E0);let m0=u.sampleLoopStartIndex+r0,g0=u.sampleLoopEndIndex+r0;u.isCompressed&&(m0-=r0,g0-=r0),c7(g,m0),c7(g,g0),c7(g,u.sampleRate),g[g.currentIndex++]=u.samplePitch,g[g.currentIndex++]=u.samplePitchCorrection,Q9(g,u.sampleLink),Q9(g,u.sampleType)}),g7(g,"EOS",46),ze(new me("shdr",g.length,g))}function jw(){let o=10;for(let g of this.instruments)o+=g.instrumentZones.reduce((u,S)=>S.modulators.length*10+u,0);let n=new J3(o),l=0;for(let g of this.instruments)for(let u of g.instrumentZones){u.modulatorZoneStartIndex=l;for(let S of u.modulators)Q9(n,S.sourceEnum),Q9(n,S.modulatorDestination),Q9(n,S.transformAmount),Q9(n,S.secondarySourceEnum),Q9(n,S.transformType),l++}return l7(n,0,10),ze(new me("imod",n.length,n))}function Xw(){let o=this.instruments.reduce((S,r0)=>r0.instrumentZones.length*4+S,4),n=new J3(o),l=0,g=0,u=0;for(let S of this.instruments){S.instrumentZoneIndex=l;for(let r0 of S.instrumentZones)r0.zoneID=l,Q9(n,g),Q9(n,u),g+=r0.generators.length,u+=r0.modulators.length,l++}return Q9(n,g),Q9(n,u),ze(new me("ibag",n.length,n))}function ek(){let o=this.instruments.length*22+22,n=new J3(o),l=0,g=0;for(let u of this.instruments)g7(n,u.instrumentName,20),Q9(n,l),l+=u.instrumentZones.length,u.instrumentID=g,g++;return g7(n,"EOI",20),Q9(n,l),ze(new me("inst",n.length,n))}function tk(){let o=4;for(let g of this.presets)o+=g.presetZones.reduce((u,S)=>(S.generators=S.generators.filter(r0=>r0.generatorType!==v1.instrument&&r0.generatorType!==v1.keyRange&&r0.generatorType!==v1.velRange),(S.velRange.max!==127||S.velRange.min!==0)&&S.generators.unshift({generatorType:v1.velRange,generatorValue:S.velRange.max<<8|S.velRange.min}),(S.keyRange.max!==127||S.keyRange.min!==0)&&S.generators.unshift({generatorType:v1.keyRange,generatorValue:S.keyRange.max<<8|S.keyRange.min}),S.isGlobal||S.generators.push({generatorType:v1.instrument,generatorValue:this.instruments.indexOf(S.instrument)}),S.generators.length*4+u),0);let n=new J3(o),l=0;for(let g of this.presets)for(let u of g.presetZones){u.generatorZoneStartIndex=l;for(let S of u.generators)Q9(n,S.generatorType),Q9(n,S.generatorValue);l+=u.generators.length}return Q9(n,0),Q9(n,0),ze(new me("pgen",n.length,n))}function ik(){let o=10;for(let g of this.presets)o+=g.presetZones.reduce((u,S)=>S.modulators.length*10+u,0);let n=new J3(o),l=0;for(let g of this.presets)for(let u of g.presetZones){u.modulatorZoneStartIndex=l;for(let S of u.modulators)Q9(n,S.sourceEnum),Q9(n,S.modulatorDestination),Q9(n,S.transformAmount),Q9(n,S.secondarySourceEnum),Q9(n,S.transformType),l++}return l7(n,0,10),ze(new me("pmod",n.length,n))}function nk(){let o=this.presets.reduce((S,r0)=>r0.presetZones.length*4+S,4),n=new J3(o),l=0,g=0,u=0;for(let S of this.presets){S.presetZoneStartIndex=l;for(let r0 of S.presetZones)r0.zoneID=l,Q9(n,g),Q9(n,u),g+=r0.generators.length,u+=r0.modulators.length,l++}return Q9(n,g),Q9(n,u),ze(new me("pbag",n.length,n))}function rk(){let o=this.presets.length*38+38,n=new J3(o),l=0;for(let g of this.presets)g7(n,g.presetName,20),Q9(n,g.program),Q9(n,g.bank),Q9(n,l),c7(n,g.library),c7(n,g.genre),c7(n,g.morphology),l+=g.presetZones.length;return g7(n,"EOP",20),Q9(n,0),Q9(n,0),Q9(n,l),c7(n,0),c7(n,0),c7(n,0),ze(new me("phdr",n.length,n))}var Wb={compress:!1,compressionQuality:.5,compressionFunction:void 0};function sk(o=Wb){if(o.compress&&typeof o.compressionFunction!="function")throw new TypeError("No compression function supplied but compression enabled.");ni("%cSaving soundfont...",_1.info),Y5(`%cCompression: %c${o?.compress||"false"}%c quality: %c${o?.compressionQuality||"none"}`,_1.info,_1.recognized,_1.info,_1.recognized),Y5("%cWriting INFO...",_1.info);let n=[];this.soundFontInfo.ISFT="SpessaSynth",o?.compress&&(this.soundFontInfo.ifil="3.0");for(let[i3,n3]of Object.entries(this.soundFontInfo))if(i3==="ifil"||i3==="iver"){let A0=parseInt(n3.split(".")[0]),y5=parseInt(n3.split(".")[1]),M3=new J3(4);Q9(M3,A0),Q9(M3,y5),n.push(ze(new me(i3,4,M3)))}else if(i3==="DMOD")n.push(ze(new me(i3,n3.length,n3)));else{let A0=new J3(n3.length);g7(A0,n3),n.push(ze(new me(i3,n3.length,A0)))}let l=vr([new J3([73,78,70,79]),...n]),g=ze(new me("LIST",l.length,l));Y5("%cWriting SDTA...",_1.info);let u=[],S=[],r0=Zw.call(this,u,S,o?.compress,o?.compressionQuality||.5,o.compressionFunction);Y5("%cWriting PDTA...",_1.info),Y5("%cWriting SHDR...",_1.info);let E0=Ww.call(this,u,S);Y5("%cWriting IGEN...",_1.info);let m0=zw.call(this);Y5("%cWriting IMOD...",_1.info);let g0=jw.call(this);Y5("%cWriting IBAG...",_1.info);let u1=Xw.call(this);Y5("%cWriting INST...",_1.info);let R=ek.call(this),X0=tk.call(this);Y5("%cWriting PMOD...",_1.info);let F0=ik.call(this);Y5("%cWriting PBAG...",_1.info);let b1=nk.call(this);Y5("%cWriting PHDR...",_1.info);let l2=rk.call(this),y1=vr([new J3([112,100,116,97]),l2,b1,F0,X0,R,u1,g0,m0,E0]),Y2=ze(new me("LIST",y1.length,y1));Y5("%cWriting the output file...",_1.info);let T2=vr([new J3([115,102,98,107]),g,r0,Y2]),K2=ze(new me("RIFF",T2.length,T2));return Y5(`%cSaved succesfully! Final file size: %c${K2.length}`,_1.info,_1.recognized),i4(),K2}var v$=class o{constructor(n=void 0){this.soundFontInfo={},this.presets=[],this.samples=[],this.instruments=[],this.defaultModulators=pC.map(l=>oe.copy(l)),n?.presets&&(this.presets.push(...n.presets),this.soundFontInfo=n.info)}removeUnusedElements(){this.instruments.forEach(n=>{n.useCount<1&&n.instrumentZones.forEach(l=>{l.isGlobal||l.sample.useCount--})}),this.instruments=this.instruments.filter(n=>n.useCount>0),this.samples=this.samples.filter(n=>n.useCount>0)}deleteInstrument(n){if(n.useCount>0)throw new Error(`Cannot delete an instrument that has ${n.useCount} usages.`);this.instruments.splice(this.instruments.indexOf(n),1),n.deleteInstrument(),this.removeUnusedElements()}deleteSample(n){if(n.useCount>0)throw new Error(`Cannot delete sample that has ${n.useCount} usages.`);this.samples.splice(this.samples.indexOf(n),1),this.removeUnusedElements()}deletePreset(n){n.deletePreset(),this.presets.splice(this.presets.indexOf(n),1),this.removeUnusedElements()}getPresetNoFallback(n,l,g=!1){let u=this.presets.find(S=>S.bank===n&&S.program===l);if(u)return u;if(g!==!1)return n===128?this.presets.find(S=>S.bank===128):this.presets.find(S=>S.program===l)}setSampleIDOffset(n){this.presets.forEach(l=>l.sampleIDOffset=n)}getPreset(n,l){let g=this.presets.find(u=>u.bank===n&&u.program===l);return g||(n===128?(g=this.presets.find(u=>u.bank===128&&u.program===l),g||(g=this.presets.find(u=>u.bank===128))):g=this.presets.find(u=>u.program===l&&u.bank!==128),g&&R4(`%cPreset ${n}.${l} not found. Replaced with %c${g.presetName} (${g.bank}.${g.program})`,_1.warn,_1.recognized)),g||(R4(`Preset ${l} not found. Defaulting to`,this.presets[0].presetName),g=this.presets[0]),g}getPresetByName(n){let l=this.presets.find(g=>g.presetName===n);return l||(R4("Preset not found. Defaulting to:",this.presets[0].presetName),l=this.presets[0]),l}static mergeSoundfonts(...n){let l=n.shift(),g=l.presets;for(;n.length;)n.shift().presets.forEach(S=>{g.find(r0=>r0.bank===S.bank&&r0.program===S.program)===void 0&&g.push(S)});return new o({presets:g,info:l.soundFontInfo})}};v$.prototype.write=sk;function ok(o){ni("%cLoading instruments...",_1.info);for(let n=0;n n.deleteZone()),this.presetZones.length=0}deleteZone(n){this.presetZones[n].deleteZone(),this.presetZones.splice(n,1)}preload(n,l){for(let g=n;g {S.sample.isSampleLoaded||S.sample.getAudioData()})}preloadSpecific(n,l){this.getSamplesAndGenerators(n,l).forEach(g=>{g.sample.isSampleLoaded||g.sample.getAudioData()})}getSamplesAndGenerators(n,l){let g=this.foundSamplesAndGenerators[n][l];if(g)return g;if(this.presetZones.length<1)return[];function u(R,X0,F0){return F0>=R&&F0<=X0}function S(R,X0){R.push(...X0.filter(F0=>!R.find(b1=>b1.generatorType===F0.generatorType)))}function r0(R,X0){R.push(...X0.filter(F0=>!R.find(b1=>oe.isIdentical(F0,b1))))}let E0=[],m0=this.presetZones[0].isGlobal?[...this.presetZones[0].generators]:[],g0=this.presetZones[0].isGlobal?[...this.presetZones[0].modulators]:[];return this.presetZones.filter(R=>u(R.keyRange.min,R.keyRange.max,n)&&u(R.velRange.min,R.velRange.max,l)&&!R.isGlobal).forEach(R=>{if(R.instrument.instrumentZones.length<1)return;let X0=R.generators,F0=R.modulators,b1=R.instrument.instrumentZones[0].isGlobal?[...R.instrument.instrumentZones[0].generators]:[],l2=R.instrument.instrumentZones[0].isGlobal?[...R.instrument.instrumentZones[0].modulators]:[];R.instrument.instrumentZones.filter(Y2=>u(Y2.keyRange.min,Y2.keyRange.max,n)&&u(Y2.velRange.min,Y2.velRange.max,l)&&!Y2.isGlobal).forEach(Y2=>{let T2=[...Y2.generators],K2=[...Y2.modulators];S(X0,m0),S(T2,b1),r0(F0,g0),r0(K2,l2),r0(K2,this.defaultModulators);let i3=[...K2];for(let n3=0;n3 oe.isIdentical(A0,M3));y5!==-1?i3[y5]=i3[y5].sumTransform(A0):i3.push(A0)}E0.push({instrumentGenerators:T2,presetGenerators:X0,modulators:i3,sample:Y2.sample,sampleID:Y2.generators.find(n3=>n3.generatorType===v1.sampleID).generatorValue})})}),this.foundSamplesAndGenerators[n][l]=E0,E0}};var Rm=class{velRange={min:0,max:127};keyRange={min:0,max:127};isGlobal=!1;generators=[];modulators=[]};var GA=class extends Rm{sample=void 0;useCount=0;deleteZone(){this.useCount--,!this.isGlobal&&this.sample.useCount--}},Eh=class extends Rm{instrument=void 0;deleteZone(){this.isGlobal||this.instrument.removeUseCount()}};var mh=class{constructor(){this.instrumentName="",this.instrumentZones=[],this._useCount=0}addUseCount(){this._useCount++,this.instrumentZones.forEach(n=>n.useCount++)}removeUseCount(){this._useCount--;for(let n=0;n n.deleteZone()),this.instrumentZones.length=0}safeDeleteZone(n){return this.instrumentZones[n].useCount--,this.instrumentZones[n].useCount<1?(this.deleteZone(n),!0):!1}deleteZone(n){this.instrumentZones[n].deleteZone(),this.instrumentZones.splice(n,1)}};var YC=class extends Ih{constructor(n,l){super(pC),this.program=l&127,this.bank=n>>8&127,n>>31&&(this.bank=128),this.DLSInstrument=new mh,this.DLSInstrument.addUseCount();let u=new Eh;u.instrument=this.DLSInstrument,this.presetZones=[u]}};function Ak(o){this.verifyHeader(o,"LIST"),this.verifyText(Ee(o.chunkData,4),"ins ");let n=[];for(;o.chunkData.length>o.chunkData.currentIndex;)n.push(d4(o.chunkData));let l=n.find(F0=>F0.header==="insh");if(!l)throw i4(),new Error("No instrument header!");let g=o3(l.chunkData,4),u=o3(l.chunkData,4),S=o3(l.chunkData,4),r0=new YC(u,S),E0="unnamedPreset",m0=_i(n,"INFO");if(m0){let F0=d4(m0.chunkData);for(;F0.header!=="INAM";)F0=d4(m0.chunkData);E0=Ee(F0.chunkData,F0.chunkData.length).trim()}r0.presetName=E0,r0.DLSInstrument.instrumentName=E0,gn(`%cParsing %c"${E0}"%c...`,_1.info,_1.recognized,_1.info);let g0=_i(n,"lrgn");if(!g0)throw i4(),new Error("No region list!");let u1=new GA;u1.isGlobal=!0;let R=_i(n,"lart"),X0=_i(n,"lar2");this.readLart(R,X0,u1),r0.DLSInstrument.instrumentZones.push(u1);for(let F0=0;F0 >10&15;Y2===Gn.linear&&y1!==Gn.linear&&(Y2=y1);let T2=g>>14&1,K2=g>>15&1;r0===v1.initialAttenuation&&(K2=!K2),R=Nn(Y2,T2,K2,E0.isCC,E0.enum)}let X0=g>>4&15,F0=g>>8&1,b1=g>>9&1,l2=Nn(X0,F0,b1,u1.isCC,u1.enum);if(m0){let y1=l2;l2=R,R=y1}return new oe({srcEnum:R,secSrcEnum:l2,dest:r0,transform:0,amt:u})}function zB(o,n){let l=o.chunkData,g=[],u=[];o3(l,4);let S=o3(l,4);for(let r0=0;r0 >16;if(E0===0&&m0===0&&u1===0){let F0;switch(g0){case m6.pan:F0=new W6(v1.pan,X0);break;case m6.gain:F0=new W6(v1.initialAttenuation,-X0*10/.4);break;case m6.filterCutoff:F0=new W6(v1.initialFilterFc,X0);break;case m6.filterQ:F0=new W6(v1.initialFilterQ,X0);break;case m6.modLfoFreq:F0=new W6(v1.freqModLFO,X0);break;case m6.modLfoDelay:F0=new W6(v1.delayModLFO,X0);break;case m6.vibLfoFreq:F0=new W6(v1.freqVibLFO,X0);break;case m6.vibLfoDelay:F0=new W6(v1.delayVibLFO,X0);break;case m6.volEnvDelay:F0=new W6(v1.delayVolEnv,X0);break;case m6.volEnvAttack:F0=new W6(v1.attackVolEnv,X0);break;case m6.volEnvHold:F0=new W6(v1.holdVolEnv,X0);break;case m6.volEnvDecay:F0=new W6(v1.decayVolEnv,X0);break;case m6.volEnvRelease:F0=new W6(v1.releaseVolEnv,X0);break;case m6.volEnvSustain:let b1=(1e3-X0)/10;F0=new W6(v1.sustainVolEnv,b1*10);break;case m6.modEnvDelay:F0=new W6(v1.delayModEnv,X0);break;case m6.modEnvAttack:F0=new W6(v1.attackModEnv,X0);break;case m6.modEnvHold:F0=new W6(v1.holdModEnv,X0);break;case m6.modEnvDecay:F0=new W6(v1.decayModEnv,X0);break;case m6.modEnvRelease:F0=new W6(v1.releaseModEnv,X0);break;case m6.modEnvSustain:let l2=1e3-X0;F0=new W6(v1.sustainModEnv,l2);break;case m6.reverbSend:F0=new W6(v1.reverbEffectsSend,X0);break;case m6.chorusSend:F0=new W6(v1.chorusEffectsSend,X0);break;case m6.pitch:let y1=Math.floor(X0/100),Y2=Math.floor(X0-y1*100);F0=new W6(v1.fineTune,Y2),g.push(new W6(v1.coarseTune,y1));break}F0&&g.push(F0)}else{let F0=!0;if(m0===w4.none)if(E0===w4.modLfo&&g0===m6.pitch)g.push(new W6(v1.modLfoToPitch,X0));else if(E0===w4.modLfo&&g0===m6.gain)g.push(new W6(v1.modLfoToVolume,X0));else if(E0===w4.modLfo&&g0===m6.filterCutoff)g.push(new W6(v1.modLfoToFilterFc,X0));else if(E0===w4.vibratoLfo&&g0===m6.pitch)g.push(new W6(v1.vibLfoToPitch,X0));else if(E0===w4.modEnv&&g0===m6.pitch)g.push(new W6(v1.modEnvToPitch,X0));else if(E0===w4.modEnv&&g0===m6.filterCutoff)g.push(new W6(v1.modEnvToFilterFc,X0));else if(E0===w4.keyNum&&g0===m6.volEnvHold){g.push(new W6(v1.keyNumToVolEnvHold,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.holdVolEnv&&(l2.generatorValue+=b1)})}else if(E0===w4.keyNum&&g0===m6.volEnvDecay){g.push(new W6(v1.keyNumToVolEnvDecay,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.decayVolEnv&&(l2.generatorValue+=b1)})}else if(E0===w4.keyNum&&g0===m6.modEnvHold){g.push(new W6(v1.keyNumToModEnvHold,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.holdModEnv&&(l2.generatorValue+=b1)})}else if(E0===w4.keyNum&&g0===m6.modEnvDecay){g.push(new W6(v1.keyNumToModEnvDecay,X0/-128));let b1=Math.round(60/128*X0);g.forEach(l2=>{l2.generatorType===v1.decayModEnv&&(l2.generatorValue+=b1)})}else F0=!1;else F0=!1;if(F0===!1){let b1=$k(E0,m0,g0,u1,X0);b1?(u.push(b1),Y5("%cSucceeded converting to SF2 Modulator!",_1.recognized)):R4("Failed converting to SF2 Modulator!")}}}return u.find(r0=>r0.modulatorDestination===v1.reverbEffectsSend)===void 0&&u.push(new oe({srcEnum:219,dest:v1.reverbEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),u.find(r0=>r0.modulatorDestination===v1.chorusEffectsSend)===void 0&&u.push(new oe({srcEnum:221,dest:v1.chorusEffectsSend,amt:1e3,secSrcEnum:0,transform:0})),n&&u.push(new oe({srcEnum:129,dest:v1.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0}),new oe({srcEnum:13,dest:v1.vibLfoToPitch,amt:0,secSrcEnum:0,transform:0})),{modulators:u,generators:g}}function lk(o,n,l){if(o)for(;o.chunkData.currentIndexo.chunkData.currentIndex;)n.push(d4(o.chunkData));let l=n.find(M3=>M3.header==="rgnh"),g=o3(l.chunkData,2),u=o3(l.chunkData,2),S=o3(l.chunkData,2),r0=o3(l.chunkData,2),E0=new JC({min:g,max:u},{min:S,max:r0});o3(l.chunkData,2);let m0=o3(l.chunkData,2);m0!==0&&E0.generators.push(new W6(v1.exclusiveClass,m0));let g0=_i(n,"lart"),u1=_i(n,"lar2");this.readLart(g0,u1,E0),E0.isGlobal=!1;let R=n.find(M3=>M3.header==="wsmp");o3(R.chunkData,4);let X0=o3(R.chunkData,2),F0=xA(R.chunkData[R.chunkData.currentIndex++],R.chunkData[R.chunkData.currentIndex++]),l2=(o3(R.chunkData,4)|0)/-655360;o3(R.chunkData,4);let y1=o3(R.chunkData,4),Y2,T2={start:0,end:0};if(y1===0)Y2=0;else{o3(R.chunkData,4),o3(R.chunkData,4)===0?Y2=1:Y2=3,T2.start=o3(R.chunkData,4);let $3=o3(R.chunkData,4);T2.end=T2.start+$3}let K2=n.find(M3=>M3.header==="wlnk");if(K2===void 0)return;o3(K2.chunkData,2),o3(K2.chunkData,2),o3(K2.chunkData,4);let i3=o3(K2.chunkData,4),n3=this.samples[i3];if(n3===void 0)throw new Error("Invalid sample ID!");let y5=(l2||n3.sampleDbAttenuation)*10/.4;return E0.setWavesample(y5,Y2,T2,X0,n3,i3,F0),E0}var Ch=class{constructor(n,l,g,u,S,r0,E0,m0){this.sampleName=n,this.sampleRate=l,this.samplePitch=g,this.samplePitchCorrection=u,this.sampleLink=S,this.sampleType=r0,this.sampleLoopStartIndex=E0,this.sampleLoopEndIndex=m0,this.isCompressed=(r0&16)>0,this.compressedData=void 0,this.useCount=0}getRawData(){let n=new Error("Not implemented");throw n.name="NotImplementedError",n}compressSample(n,l){if(!this.isCompressed)try{this.compressedData=l([this.getAudioData()],1,this.sampleRate,n),this.sampleType|=16,this.isCompressed=!0}catch{R4(`Failed to compress ${this.sampleName}. Leaving as uncompressed!`),this.isCompressed=!1,this.compressedData=void 0,this.sampleType&=-17}}getAudioData(){let n=new Error("Not implemented");throw n.name="NotImplementedError",n}};var KC=class extends Ch{constructor(n,l,g,u,S,r0,E0,m0){super(n,l,g,u,0,1,S,r0-1),this.sampleData=E0,this.sampleDbAttenuation=m0}getAudioData(){return this.sampleData}sampleDbAttenuation;sampleData;getRawData(){if(this.isCompressed){if(!this.compressedData)throw new Error("Compressed but no data??");return this.compressedData}let n=new Uint8Array(this.sampleData.length*2);for(let l=0;l >8&255}return n}};function gk(o){ni("%cLoading Wave samples...",_1.recognized);let n=0;for(;o.chunkData.currentIndex $3.header==="fmt ");if(!u)throw new Error("No fmt chunk in the wave file!");if(o3(u.chunkData,2)!==1)throw new Error("Only PCM format in WAVE is supported.");if(o3(u.chunkData,2)!==1)throw new Error("Only mono samples are supported.");let E0=o3(u.chunkData,4);o3(u.chunkData,4),o3(u.chunkData,2);let m0=o3(u.chunkData,2),g0=m0/8,u1=Math.pow(2,g0*8-1),R=Math.pow(2,g0*8),X0,F0=!1;m0===8?(X0=255,F0=!0):X0=u1;let b1=g.find($3=>$3.header==="data");if(!b1)throw new Error("No data chunk in the wave chunk!");let l2=b1.size/g0,y1=new Float32Array(l2);for(let $3=0;$3 =u1&&(w6-=R),y1[$3]=w6/X0)}let Y2=60,T2=0,K2=0,i3=y1.length-1,n3=0,A0=g.find($3=>$3.header==="wsmp");if(A0){if(o3(A0.chunkData,4),Y2=o3(A0.chunkData,2),T2=xA(A0.chunkData[A0.chunkData.currentIndex++],A0.chunkData[A0.chunkData.currentIndex++]),n3=(o3(A0.chunkData,4)|0)/-655360,o3(A0.chunkData,4),o3(A0.chunkData,4)===1){o3(A0.chunkData,8),K2=o3(A0.chunkData,4);let s6=o3(A0.chunkData,4);i3=K2+s6}}else R4("No wsmp chunk in wave... using sane defaults.");let y5=_i(g,"INFO"),M3=`Unnamed ${n}`;if(y5){let $3=d4(y5.chunkData);for(;$3.header!=="INAM"&&y5.chunkData.currentIndex m0.header==="colh");if(!S)throw i4(),new Error("No colh chunk!");this.instrumentAmount=o3(S.chunkData,4),Y5(`%cInstruments amount: %c${this.instrumentAmount}`,_1.info,_1.recognized);let r0=bi(g,"wvpl");this.readDLSSamples(r0);let E0=bi(g,"lins");if(!E0)throw i4(),new Error("No lins chunk!");this.readDLSInstrumentList(E0),this.presets.sort((m0,g0)=>m0.program-g0.program+(m0.bank-g0.bank)),Y5(`%cParsing finished! %c"${this.soundFontInfo.INAM||"UNNAMED"}"%c has %c${this.presets.length} %cpresets, - %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,_1.info,_1.recognized,_1.info,_1.recognized,_1.info,_1.recognized,_1.info,_1.recognized,_1.info),i4()}verifyHeader(n,l){if(n.header.toLowerCase()!==l.toLowerCase())throw i4(),new SyntaxError(`Invalid DLS chunk header! Expected "${l.toLowerCase()}" got "${n.header.toLowerCase()}"`)}verifyText(n,l){if(n.toLowerCase()!==l.toLowerCase())throw i4(),new SyntaxError(`Invalid DLS soundfont! Expected "${l.toLowerCase()}" got "${n.toLowerCase()}"`)}};Fs.prototype.readDLSInstrumentList=sk;Fs.prototype.readDLSInstrument=ok;Fs.prototype.readRegion=lk;Fs.prototype.readLart=$k;Fs.prototype.readDLSSamples=ck;var UA=UA!==void 0?UA:{},gk=!1,hk;UA.isInitialized=new Promise(o=>hk=o);var eD=function(o){var n,l,g,u,S,r0,E0,m0="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",g0="",u1=0;o=o.replace(/[^A-Za-z0-9\+\/\=]/g,"");do u=m0.indexOf(o.charAt(u1++)),S=m0.indexOf(o.charAt(u1++)),r0=m0.indexOf(o.charAt(u1++)),E0=m0.indexOf(o.charAt(u1++)),n=u<<2|S>>4,l=(15&S)<<4|r0>>2,g=(3&r0)<<6|E0,g0+=String.fromCharCode(n),r0!==64&&(g0+=String.fromCharCode(l)),E0!==64&&(g0+=String.fromCharCode(g));while(u1 1&&(A0.thisProgram=process.argv[1].replace(/\\/g,"/")),A0.arguments=process.argv.slice(2),typeof module<"u",process.on("uncaughtException",function(R0){if(!(R0 instanceof Y$))throw R0}),process.on("unhandledRejection",function(R0,j0){process.exit(1)}),A0.quit=function(R0){process.exit(R0)},A0.inspect=function(){return"[Emscripten Module object]"}):s6?(typeof read<"u"&&(A0.read=function(j0){return read(j0)}),A0.readBinary=function(j0){var C1;return typeof readbuffer=="function"?new Uint8Array(readbuffer(j0)):(fn(typeof(C1=read(j0,"binary"))=="object"),C1)},typeof scriptArgs<"u"?A0.arguments=scriptArgs:typeof arguments<"u"&&(A0.arguments=arguments),typeof quit=="function"&&(A0.quit=function(R0){quit(R0)})):(M3||$3)&&(M3?document.currentScript&&(o9=document.currentScript.src):o9=self.location.href,o9=o9.indexOf("blob:")!==0?o9.split("/").slice(0,-1).join("/")+"/":"",A0.read=function(j0){var C1=new XMLHttpRequest;return C1.open("GET",j0,!1),C1.send(null),C1.responseText},$3&&(A0.readBinary=function(j0){var C1=new XMLHttpRequest;return C1.open("GET",j0,!1),C1.responseType="arraybuffer",C1.send(null),new Uint8Array(C1.response)}),A0.readAsync=function(j0,C1,S2){var Z3=new XMLHttpRequest;Z3.open("GET",j0,!0),Z3.responseType="arraybuffer",Z3.onload=function(){if(Z3.status==200||Z3.status==0&&Z3.response){C1(Z3.response);return}S2()},Z3.onerror=S2,Z3.send(null)},A0.setWindowTitle=function(R0){document.title=R0});var n4=A0.print||(typeof console<"u"?console.log.bind(console):typeof print<"u"?print:null),K6=A0.printErr||(typeof printErr<"u"?printErr:typeof console<"u"&&console.warn.bind(console)||n4);for(o in y5)y5.hasOwnProperty(o)&&(A0[o]=y5[o]);function We(R0){var j0=F0;return F0=F0+R0+15&-16,j0}function On(R0){var j0=m0[K2>>2],C1=j0+R0+15&-16;return m0[K2>>2]=C1,C1>=_9&&!Hn()?(m0[K2>>2]=j0,0):j0}function Ji(R0,j0){return j0||(j0=16),R0=Math.ceil(R0/j0)*j0}function OA(R0){switch(R0){case"i1":case"i8":return 1;case"i16":return 2;case"i32":case"float":return 4;case"i64":case"double":return 8;default:if(R0[R0.length-1]==="*")return 4;if(R0[0]!=="i")return 0;var j0=parseInt(R0.substr(1));return fn(j0%8==0),j0/8}}function Ms(R0){Ms.shown||(Ms.shown={}),Ms.shown[R0]||(Ms.shown[R0]=1,K6(R0))}y5=void 0;var Lm={"f64-rem":function(R0,j0){return R0%j0},debugger:function(){}},_$=[];function XC(R0,j0){for(var C1=0,S2=C1;S2 >>0)+4294967296*+(j0>>>0):+(R0>>>0)+4294967296*+(0|j0)}function R$(R0,j0,C1){return C1&&C1.length?A0["dynCall_"+R0].apply(null,[j0].concat(C1)):A0["dynCall_"+R0].call(null,j0)}var HA=0,ph=0;function fn(R0,j0){R0||Ki("Assertion failed: "+j0)}function qA(R0){var j0=A0["_"+R0];return fn(j0,"Cannot call unknown function "+R0+", make sure it is exported"),j0}var Fm={stackSave:function(){qm()},stackRestore:function(){q$()},arrayToC:function(R0){var j0,C1,S2=YA(R0.length);return j0=R0,C1=S2,u.set(j0,C1),S2},stringToC:function(R0){var j0=0;if(R0!=null&&R0!==0){var C1=(R0.length<<2)+1;j0=YA(C1),Tm(R0,j0,C1)}return j0}},Ts={string:Fm.stringToC,array:Fm.arrayToC};function Qh(R0,j0,C1,S2,Z3){var g9=qA(R0),J9=[],h6=0;if(S2)for(var Ct=0;Ct >0]=j0;break;case"i16":r0[R0>>1]=j0;break;case"i32":m0[R0>>2]=j0;break;case"i64":tempI64=[j0>>>0,+kh(tempDouble=j0)>=1?tempDouble>0?(0|Sh(+vh(tempDouble/4294967296),4294967295))>>>0:~~+O$((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0],m0[R0>>2]=tempI64[0],m0[R0+4>>2]=tempI64[1];break;case"float":u1[R0>>2]=j0;break;case"double":R[R0>>3]=j0;break;default:Ki("invalid type for setValue: "+C1)}}function E3(R0,j0,C1){switch((j0=j0||"i8").charAt(j0.length-1)==="*"&&(j0="i32"),j0){case"i1":case"i8":return u[R0>>0];case"i16":return r0[R0>>1];case"i32":case"i64":return m0[R0>>2];case"float":return u1[R0>>2];case"double":return R[R0>>3];default:Ki("invalid type for getValue: "+j0)}return null}function Ap(R0,j0,C1,S2){typeof R0=="number"?(g9=!0,J9=R0):(g9=!1,J9=R0.length);var Z3=typeof j0=="string"?j0:null;if(h6=C1==4?S2:[typeof Hs=="function"?Hs:We,YA,We,On][C1===void 0?2:C1](Math.max(J9,Z3?1:j0.length)),g9){for(S2=h6,fn((3&h6)==0),Ct=h6+(-4&J9);S2 >2]=0;for(Ct=h6+J9;S2 >0]=0;return h6}if(Z3==="i8")return R0.subarray||R0.slice?S.set(R0,h6):S.set(new Uint8Array(R0),h6),h6;for(var g9,J9,h6,Ct,Te,je,Se,h9=0;h9 >0],(S2!=0||j0)&&(J9++,!j0||J9!=j0););j0||(j0=J9);var h6="";if(g9<128){for(;j0>0;)Z3=String.fromCharCode.apply(String,S.subarray(R0,R0+Math.min(j0,1024))),h6=h6?h6+Z3:Z3,R0+=1024,j0-=1024;return h6}return C1=R0,function(Te,je){for(var Se=je;Te[Se];)++Se;if(Se-je>16&&Te.subarray&&Mm)return Mm.decode(Te.subarray(je,Se));for(var h9,M7,Mi,Bt,T7,Ti,Ni="";;){if(!(h9=Te[je++]))return Ni;if(!(128&h9)){Ni+=String.fromCharCode(h9);continue}if(M7=63&Te[je++],(224&h9)==192){Ni+=String.fromCharCode((31&h9)<<6|M7);continue}if(Mi=63&Te[je++],(240&h9)==224?h9=(15&h9)<<12|M7<<6|Mi:(Bt=63&Te[je++],(248&h9)==240?h9=(7&h9)<<18|M7<<12|Mi<<6|Bt:(T7=63&Te[je++],h9=(252&h9)==248?(3&h9)<<24|M7<<18|Mi<<12|Bt<<6|T7:(1&h9)<<30|M7<<24|Mi<<18|Bt<<12|T7<<6|(Ti=63&Te[je++]))),h9<65536)Ni+=String.fromCharCode(h9);else{var Fr=h9-65536;Ni+=String.fromCharCode(55296|Fr>>10,56320|1023&Fr)}}}(S,C1)}function ap(R0){for(var j0="";;){var C1=u[R0++>>0];if(!C1)return j0;j0+=String.fromCharCode(C1)}}function Ns(R0,j0){return function(S2,Z3,g9){for(var J9=0;J9 >0]=S2.charCodeAt(J9);g9||(u[Z3>>0]=0)}(R0,j0,!1)}var Mm=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function xr(R0,j0,C1,S2){if(!(S2>0))return 0;for(var Z3=C1,g9=C1+S2-1,J9=0;J9 =55296&&h6<=57343&&(h6=65536+((1023&h6)<<10)|1023&R0.charCodeAt(++J9)),h6<=127){if(C1>=g9)break;j0[C1++]=h6}else if(h6<=2047){if(C1+1>=g9)break;j0[C1++]=192|h6>>6,j0[C1++]=128|63&h6}else if(h6<=65535){if(C1+2>=g9)break;j0[C1++]=224|h6>>12,j0[C1++]=128|h6>>6&63,j0[C1++]=128|63&h6}else if(h6<=2097151){if(C1+3>=g9)break;j0[C1++]=240|h6>>18,j0[C1++]=128|h6>>12&63,j0[C1++]=128|h6>>6&63,j0[C1++]=128|63&h6}else if(h6<=67108863){if(C1+4>=g9)break;j0[C1++]=248|h6>>24,j0[C1++]=128|h6>>18&63,j0[C1++]=128|h6>>12&63,j0[C1++]=128|h6>>6&63,j0[C1++]=128|63&h6}else{if(C1+5>=g9)break;j0[C1++]=252|h6>>30,j0[C1++]=128|h6>>24&63,j0[C1++]=128|h6>>18&63,j0[C1++]=128|h6>>12&63,j0[C1++]=128|h6>>6&63,j0[C1++]=128|63&h6}}return j0[C1]=0,C1-Z3}function Tm(R0,j0,C1){return xr(R0,S,j0,C1)}function Gs(R0){for(var j0=0,C1=0;C1 =55296&&S2<=57343&&(S2=65536+((1023&S2)<<10)|1023&R0.charCodeAt(++C1)),S2<=127?++j0:S2<=2047?j0+=2:S2<=65535?j0+=3:S2<=2097151?j0+=4:S2<=67108863?j0+=5:j0+=6}return j0}var Nm=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0;function $p(R0){for(var j0=R0,C1=j0>>1;r0[C1];)++C1;if((j0=C1<<1)-R0>32&&Nm)return Nm.decode(S.subarray(R0,j0));for(var S2=0,Z3="";;){var g9=r0[R0+2*S2>>1];if(g9==0)return Z3;++S2,Z3+=String.fromCharCode(g9)}}function lp(R0,j0,C1){if(C1===void 0&&(C1=2147483647),C1<2)return 0;for(var S2=j0,Z3=(C1-=2)<2*R0.length?C1/2:R0.length,g9=0;g9 >1]=J9,j0+=2}return r0[j0>>1]=0,j0-S2}function cp(R0){return 2*R0.length}function gp(R0){for(var j0=0,C1="";;){var S2=m0[R0+4*j0>>2];if(S2==0)return C1;if(++j0,S2>=65536){var Z3=S2-65536;C1+=String.fromCharCode(55296|Z3>>10,56320|1023&Z3)}else C1+=String.fromCharCode(S2)}}function hp(R0,j0,C1){if(C1===void 0&&(C1=2147483647),C1<4)return 0;for(var S2=j0,Z3=S2+C1-4,g9=0;g9 =55296&&J9<=57343&&(J9=65536+((1023&J9)<<10)|1023&R0.charCodeAt(++g9)),m0[j0>>2]=J9,(j0+=4)+4>Z3)break}return m0[j0>>2]=0,j0-S2}function fp(R0){for(var j0=0,C1=0;C1 =55296&&S2<=57343&&++C1,j0+=4}return j0}function up(R0){var j0=Gs(R0)+1,C1=Hs(j0);return C1&&xr(R0,u,C1,j0),C1}function dp(R0){var j0=Gs(R0)+1,C1=YA(j0);return xr(R0,u,C1,j0),C1}function Gm(R0){return R0}function tB(){var R0,j0=function(){var S2=Error();if(!S2.stack){try{throw Error(0)}catch(Z3){S2=Z3}if(!S2.stack)return"(no stack trace available)"}return S2.stack.toString()}();return A0.extraStackTrace&&(j0+=` -`+A0.extraStackTrace()),(R0=j0).replace(/__Z[\w\d_]+/g,function(C1){var S2,Z3=S2=C1;return C1===Z3?C1:C1+" ["+Z3+"]"})}function yh(R0,j0){return R0%j0>0&&(R0+=j0-R0%j0),R0}function Um(R0){A0.buffer=g=R0}function Y9(){A0.HEAP8=u=new Int8Array(g),A0.HEAP16=r0=new Int16Array(g),A0.HEAP32=m0=new Int32Array(g),A0.HEAPU8=S=new Uint8Array(g),A0.HEAPU16=E0=new Uint16Array(g),A0.HEAPU32=g0=new Uint32Array(g),A0.HEAPF32=u1=new Float32Array(g),A0.HEAPF64=R=new Float64Array(g)}function Hn(){var R0=A0.usingWasm?65536:16777216,j0=2147483648-R0;if(m0[K2>>2]>j0)return!1;var C1=_9;for(_9=Math.max(_9,16777216);_9 >2];)_9=_9<=536870912?yh(2*_9,R0):Math.min(yh((3*_9+2147483648)/4,R0),j0);var S2=A0.reallocBuffer(_9);return S2&&S2.byteLength==_9?(Um(S2),Y9(),!0):(_9=C1,!1)}X0=F0=l2=y1=Y2=T2=K2=0,b1=!1,A0.reallocBuffer||(A0.reallocBuffer=function(R0){try{if(ArrayBuffer.transfer)j0=ArrayBuffer.transfer(g,R0);else{var j0,C1=u;j0=new ArrayBuffer(R0),new Int8Array(j0).set(C1)}}catch{return!1}return!!rB(j0)&&j0});try{(i3=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get))(new ArrayBuffer(4))}catch{i3=function(j0){return j0.byteLength}}var F$=A0.TOTAL_STACK||5242880,_9=A0.TOTAL_MEMORY||16777216;function M$(){return _9}function Us(R0){for(;R0.length>0;){var j0=R0.shift();if(typeof j0=="function"){j0();continue}var C1=j0.func;typeof C1=="number"?j0.arg===void 0?A0.dynCall_v(C1):A0.dynCall_vi(C1,j0.arg):C1(j0.arg===void 0?null:j0.arg)}}_9 =0?R0:j0<=32?2*Math.abs(1< =S2&&(j0<=32||R0>S2)&&(R0=-2*S2+R0),R0}var kh=Math.abs,O$=Math.ceil,vh=Math.floor,Sh=Math.min,Lr=0,bh=null,Os=null;function Ip(R0){return R0}A0.preloadedImages={},A0.preloadedAudios={};var Hm="data:application/octet-stream;base64,";function H$(R0){return String.prototype.startsWith?R0.startsWith(Hm):R0.indexOf(Hm)===0}(function(){var j0="main.wast",C1="main.wasm",S2="main.temp.asm.js";H$(j0)||(j0=K4(j0)),H$(C1)||(C1=K4(C1)),H$(S2)||(S2=K4(S2));var Z3={global:null,env:null,asm2wasm:Lm,parent:A0},g9=null;function J9(Se){return Se}function h6(){try{if(A0.wasmBinary)return new Uint8Array(A0.wasmBinary);if(A0.readBinary)return A0.readBinary(C1);throw"both async and sync fetching of the wasm failed"}catch(Se){Ki(Se)}}A0.asmPreload=A0.asm;var Ct=A0.reallocBuffer,Te=function(Se){Se=yh(Se,A0.usingWasm?65536:16777216);var h9=A0.buffer.byteLength;if(A0.usingWasm)try{var M7=A0.wasmMemory.grow((Se-h9)/65536);return M7!==-1?A0.buffer=A0.wasmMemory.buffer:null}catch{return null}};A0.reallocBuffer=function(Se){return je==="asmjs"?Ct(Se):Te(Se)};var je="";A0.asm=function(Se,h9,M7){var Mi;if(!(h9=Mi=h9).table){var Bt,T7=A0.wasmTableSize;T7===void 0&&(T7=1024);var Ti=A0.wasmMaxTableSize;typeof WebAssembly=="object"&&typeof WebAssembly.Table=="function"?Ti!==void 0?h9.table=new WebAssembly.Table({initial:T7,maximum:Ti,element:"anyfunc"}):h9.table=new WebAssembly.Table({initial:T7,element:"anyfunc"}):h9.table=Array(T7),A0.wasmTable=h9.table}return h9.memoryBase||(h9.memoryBase=A0.STATIC_BASE),h9.tableBase||(h9.tableBase=0),Bt=function(Fr,un,Ym){if(typeof WebAssembly!="object")return K6("no native wasm support detected"),!1;if(!(A0.wasmMemory instanceof WebAssembly.Memory))return K6("no native wasm Memory in use"),!1;function Dh(dn,Vi){if((g9=dn.exports).memory){var JA,qs,Ys;JA=g9.memory,qs=A0.buffer,JA.byteLength 0?C1:Gs(R0)+1,Z3=Array(S2),g9=xr(R0,Z3,0,Z3.length);return j0&&(Z3.length=g9),Z3}function nB(R0){for(var j0=[],C1=0;C1 255&&(S2&=255),j0.push(String.fromCharCode(S2))}return j0.join("")}F0+=16,K2=We(4),Y2=(l2=y1=Ji(F0))+F$,T2=Ji(Y2),m0[K2>>2]=T2,b1=!0,A0.wasmTableSize=4,A0.wasmMaxTableSize=4,A0.asmGlobalArg={},A0.asmLibraryArg={abort:Ki,assert:fn,enlargeMemory:Hn,getTotalMemory:M$,abortOnCannotGrowMemory:function(){Ki("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+_9+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which allows increasing the size at runtime, or (3) if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")},invoke_iii:function(j0,C1,S2){var Z3=qm();try{return A0.dynCall_iii(j0,C1,S2)}catch(g9){if(q$(Z3),typeof g9!="number"&&g9!=="longjmp")throw g9;A0.setThrew(1,0)}},___assert_fail:function(j0,C1,S2,Z3){Ki("Assertion failed: "+L$(j0)+", at: "+[C1?L$(C1):"unknown filename",S2,Z3?L$(Z3):"unknown function"])},___setErrNo:function(j0){return A0.___errno_location&&(m0[A0.___errno_location()>>2]=j0),j0},_abort:function(){A0.abort()},_emscripten_memcpy_big:function(j0,C1,S2){return S.set(S.subarray(C1,C1+S2),j0),j0},_llvm_floor_f64:vh,DYNAMICTOP_PTR:K2,tempDoublePtr:F7,ABORT:HA,STACKTOP:y1,STACK_MAX:Y2};var Jn=A0.asm(A0.asmGlobalArg,A0.asmLibraryArg,g);A0.asm=Jn,A0.___errno_location=function(){return A0.asm.___errno_location.apply(null,arguments)};var rB=A0._emscripten_replace_memory=function(){return A0.asm._emscripten_replace_memory.apply(null,arguments)};A0._free=function(){return A0.asm._free.apply(null,arguments)};var Hs=A0._malloc=function(){return A0.asm._malloc.apply(null,arguments)};A0._memcpy=function(){return A0.asm._memcpy.apply(null,arguments)},A0._memset=function(){return A0.asm._memset.apply(null,arguments)},A0._sbrk=function(){return A0.asm._sbrk.apply(null,arguments)},A0._stb_vorbis_js_channels=function(){return A0.asm._stb_vorbis_js_channels.apply(null,arguments)},A0._stb_vorbis_js_close=function(){return A0.asm._stb_vorbis_js_close.apply(null,arguments)},A0._stb_vorbis_js_decode=function(){return A0.asm._stb_vorbis_js_decode.apply(null,arguments)},A0._stb_vorbis_js_open=function(){return A0.asm._stb_vorbis_js_open.apply(null,arguments)},A0._stb_vorbis_js_sample_rate=function(){return A0.asm._stb_vorbis_js_sample_rate.apply(null,arguments)},A0.establishStackSpace=function(){return A0.asm.establishStackSpace.apply(null,arguments)},A0.getTempRet0=function(){return A0.asm.getTempRet0.apply(null,arguments)},A0.runPostSets=function(){return A0.asm.runPostSets.apply(null,arguments)},A0.setTempRet0=function(){return A0.asm.setTempRet0.apply(null,arguments)},A0.setThrew=function(){return A0.asm.setThrew.apply(null,arguments)};var YA=A0.stackAlloc=function(){return A0.asm.stackAlloc.apply(null,arguments)},q$=A0.stackRestore=function(){return A0.asm.stackRestore.apply(null,arguments)},qm=A0.stackSave=function(){return A0.asm.stackSave.apply(null,arguments)};function Y$(R0){this.name="ExitStatus",this.message="Program terminated with exit("+R0+")",this.status=R0}function J$(R0){R0=R0||A0.arguments,!(Lr>0)&&(function(){if(A0.preRun)for(typeof A0.preRun=="function"&&(A0.preRun=[A0.preRun]);A0.preRun.length;)iB(A0.preRun.shift());Us(qn)}(),!(Lr>0)&&(A0.calledRun||(A0.setStatus?(A0.setStatus("Running..."),setTimeout(function(){setTimeout(function(){A0.setStatus("")},1),j0()},1)):j0())));function j0(){!A0.calledRun&&(A0.calledRun=!0,HA||(G$||(G$=!0,Us(T$)),Us(wh),A0.onRuntimeInitialized&&A0.onRuntimeInitialized(),function(){if(A0.postRun)for(typeof A0.postRun=="function"&&(A0.postRun=[A0.postRun]);A0.postRun.length;)Fi(A0.postRun.shift());Us(N$)}()))}}function sB(R0,j0){(!j0||!A0.noExitRuntime||R0!==0)&&(A0.noExitRuntime||(HA=!0,ph=R0,y1=n3,Us(Bi),Li=!0,A0.onExit&&A0.onExit(R0)),A0.quit(R0,new Y$(R0)))}function Ki(R0){throw A0.onAbort&&A0.onAbort(R0),R0!==void 0?(n4(R0),K6(R0),R0=JSON.stringify(R0)):R0="",HA=!0,ph=1,"abort("+R0+"). Build with -s ASSERTIONS=1 for more info."}if(A0.dynCall_iii=function(){return A0.asm.dynCall_iii.apply(null,arguments)},A0.asm=Jn,A0.ccall=Qh,A0.cwrap=function(j0,C1,S2,Z3){var g9=(S2=S2||[]).every(function(J9){return J9==="number"});return C1!=="string"&&g9&&!Z3?qA(j0):function(){return Qh(j0,C1,S2,arguments,Z3)}},Y$.prototype=Error(),Y$.prototype.constructor=Y$,Os=function R0(){A0.calledRun||J$(),A0.calledRun||(Os=R0)},A0.run=J$,A0.abort=Ki,A0.preInit)for(typeof A0.preInit=="function"&&(A0.preInit=[A0.preInit]);A0.preInit.length>0;)A0.preInit.pop()();A0.noExitRuntime=!0,J$(),A0.onRuntimeInitialized=()=>{gk=!0,hk()},UA.decode=function(R0){return function(C1){if(!gk)throw Error("Not initialized");var S2={};function Z3(un){return new Int32Array(A0.HEAPU8.buffer,un,1)[0]}function g9(un,Ym){var Dh=new ArrayBuffer(Ym*Float32Array.BYTES_PER_ELEMENT),y8=new Float32Array(Dh);return y8.set(new Float32Array(A0.HEAPU8.buffer,un,Ym)),y8}S2.open=A0.cwrap("stb_vorbis_js_open","number",[]),S2.close=A0.cwrap("stb_vorbis_js_close","void",["number"]),S2.channels=A0.cwrap("stb_vorbis_js_channels","number",["number"]),S2.sampleRate=A0.cwrap("stb_vorbis_js_sample_rate","number",["number"]),S2.decode=A0.cwrap("stb_vorbis_js_decode","number",["number","number","number","number","number"]);var J9,h6,Ct,Te,je=S2.open(),Se=(J9=C1,h6=C1.byteLength,Ct=A0._malloc(h6),(Te=new Uint8Array(A0.HEAPU8.buffer,Ct,h6)).set(new Uint8Array(J9,0,h6)),Te),h9=A0._malloc(4),M7=A0._malloc(4),Mi=S2.decode(je,Se.byteOffset,Se.byteLength,h9,M7);if(A0._free(Se.byteOffset),Mi<0)throw S2.close(je),A0._free(h9),Error("stbvorbis decode failed: "+Mi);for(var Bt=S2.channels(je),T7=Array(Bt),Ti=new Int32Array(A0.HEAPU32.buffer,Z3(h9),Bt),Ni=0;Ni o.chunkData.currentIndex;){let S=tD(u,o.chunkData,n,l);g.push(S),u++}return g.length>1&&g.pop(),g}function tD(o,n,l,g){let u=Ie(n,20),S=o3(n,4)*2,r0=o3(n,4)*2,E0=o3(n,4),m0=o3(n,4),g0=o3(n,4),u1=n[n.currentIndex++];u1===255&&(u1=60);let R=iy(n[n.currentIndex++]),X0=o3(n,2),F0=o3(n,2);return new jB(u,S,r0,E0,m0,g0,u1,R,X0,F0,l,o,g)}var XB=class extends mh{constructor(n){super(),this.instrumentName=Ie(n.chunkData,20).trim(),this.instrumentZoneIndex=o3(n.chunkData,2),this.instrumentZonesAmount=0}getInstrumentZones(n,l){this.instrumentZonesAmount=n;for(let g=this.instrumentZoneIndex;g