spessasynth_lib 4.2.8 → 4.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,7 +14,7 @@ Output transform: ${this.transformName}
14
14
  Destination: ${this.destinationName}`}write(){let e=new $(12);te(e,this.source.source),te(e,this.control.source),te(e,this.destination);let t=this.transform|this.control.toTransformFlag()<<4|this.source.toTransformFlag()<<10;return te(e,t),de(e,this.scale),e}toSFGenerator(e){let t=this.destination,s=this.shortScale;switch(t){default:{k(`%cFailed converting DLS articulator into SF generator: %c${this.toString()}%c
15
15
  (invalid destination)`,l.warn,l.value,l.unrecognized);return}case L.pan:{e.setGenerator(g.pan,s);break}case L.gain:{e.addToGenerator(g.initialAttenuation,-s/.4);break}case L.filterCutoff:{e.setGenerator(g.initialFilterFc,s);break}case L.filterQ:{e.setGenerator(g.initialFilterQ,s);break}case L.modLfoFreq:{e.setGenerator(g.freqModLFO,s);break}case L.modLfoDelay:{e.setGenerator(g.delayModLFO,s);break}case L.vibLfoFreq:{e.setGenerator(g.freqVibLFO,s);break}case L.vibLfoDelay:{e.setGenerator(g.delayVibLFO,s);break}case L.volEnvDelay:{e.setGenerator(g.delayVolEnv,s);break}case L.volEnvAttack:{e.setGenerator(g.attackVolEnv,s);break}case L.volEnvHold:{e.setGenerator(g.holdVolEnv,s);break}case L.volEnvDecay:{e.setGenerator(g.decayVolEnv,s);break}case L.volEnvRelease:{e.setGenerator(g.releaseVolEnv,s);break}case L.volEnvSustain:{e.setGenerator(g.sustainVolEnv,1e3-s);break}case L.modEnvDelay:{e.setGenerator(g.delayModEnv,s);break}case L.modEnvAttack:{e.setGenerator(g.attackModEnv,s);break}case L.modEnvHold:{e.setGenerator(g.holdModEnv,s);break}case L.modEnvDecay:{e.setGenerator(g.decayModEnv,s);break}case L.modEnvRelease:{e.setGenerator(g.releaseModEnv,s);break}case L.modEnvSustain:{e.setGenerator(g.sustainModEnv,1e3-s);break}case L.reverbSend:{e.setGenerator(g.reverbEffectsSend,s);break}case L.chorusSend:{e.setGenerator(g.chorusEffectsSend,s);break}case L.pitch:{e.fineTuning+=s;break}}}toSFModulator(e){let t=this.shortScale,s,n,a=new IA,o=this.toCombinedSFDestination();if(o){s=o;let r=this.control.toSFSource();if(!r){this.failedConversion("Invalid control");return}n=r}else{let r=this.toSFDestination();if(!r){this.failedConversion("Invalid destination");return}typeof r=="object"?(t=r.newAmount,s=r.gen):s=r;let h=this.source.toSFSource();if(!h){this.failedConversion("Invalid source");return}n=h;let c=this.control.toSFSource();if(!c){this.failedConversion("Invalid control");return}a=c}this.transform!==me.linear&&n.curveType===me.linear&&(n.curveType=this.transform),s===g.initialAttenuation&&((this.source.source===Z.velocity||this.source.source===Z.volume||this.source.source===Z.expression)&&(n.isNegative=!0),t=Math.min(960,Math.max(0,t)));let i=new Fe(n,a,s,t,0);e.addModulators(i)}toCombinedSFDestination(){let e=this.source.source,t=this.destination;return e===Z.vibratoLfo&&t===L.pitch?g.vibLfoToPitch:e===Z.modLfo&&t===L.pitch?g.modLfoToPitch:e===Z.modLfo&&t===L.filterCutoff?g.modLfoToFilterFc:e===Z.modLfo&&t===L.gain?g.modLfoToVolume:e===Z.modEnv&&t===L.filterCutoff?g.modEnvToFilterFc:e===Z.modEnv&&t===L.pitch?g.modEnvToPitch:void 0}failedConversion(e){k(`%cFailed converting DLS articulator into SF2:
16
16
  %c${this.toString()}%c
17
- (${e})`,l.warn,l.value,l.unrecognized)}toSFDestination(){let e=this.shortScale;switch(this.destination){default:case L.none:return;case L.pan:return g.pan;case L.gain:return{gen:g.initialAttenuation,newAmount:-e};case L.pitch:return g.fineTune;case L.keyNum:return g.overridingRootKey;case L.volEnvDelay:return g.delayVolEnv;case L.volEnvAttack:return g.attackVolEnv;case L.volEnvHold:return g.holdVolEnv;case L.volEnvDecay:return g.decayVolEnv;case L.volEnvSustain:return{gen:g.sustainVolEnv,newAmount:1e3-e};case L.volEnvRelease:return g.releaseVolEnv;case L.modEnvDelay:return g.delayModEnv;case L.modEnvAttack:return g.attackModEnv;case L.modEnvHold:return g.holdModEnv;case L.modEnvDecay:return g.decayModEnv;case L.modEnvSustain:return{gen:g.sustainModEnv,newAmount:1e3-e};case L.modEnvRelease:return g.releaseModEnv;case L.filterCutoff:return g.initialFilterFc;case L.filterQ:return g.initialFilterQ;case L.chorusSend:return g.chorusEffectsSend;case L.reverbSend:return g.reverbEffectsSend;case L.modLfoFreq:return g.freqModLFO;case L.modLfoDelay:return g.delayModLFO;case L.vibLfoFreq:return g.freqVibLFO;case L.vibLfoDelay:return g.delayVibLFO}}},hi=class En extends ct{connectionBlocks=new Array;mode="dls2";get length(){return this.connectionBlocks.length}copyFrom(e){this.mode=e.mode;for(let t of e.connectionBlocks)this.connectionBlocks.push(pt.copyFrom(t))}fromSFZone(e){this.mode="dls2";let t=new Es;t.copyFrom(e);for(let s of t.generators){let n;switch(s.generatorType){default:continue;case g.keyNumToVolEnvDecay:{n=g.decayVolEnv;break}case g.keyNumToVolEnvHold:{n=g.holdVolEnv;break}case g.keyNumToModEnvDecay:{n=g.decayModEnv;break}case g.keyNumToModEnvHold:n=g.holdModEnv}let a=t.getGenerator(n,void 0),o=s.generatorValue*-128;if(a===void 0)continue;let i=60/128*o,r=a-i;t.setGenerator(s.generatorType,o,!1),t.setGenerator(n,r,!1)}for(let s of t.generators)pt.fromSFGenerator(s,this);for(let s of t.modulators)pt.fromSFModulator(s,this)}read(e){let t=LA(e,"lart"),s=LA(e,"lar2");if(t)for(this.mode="dls1";t.data.currentIndex<t.data.length;){let n=ge(t.data);En.verifyHeader(n,"art1","art2");let a=n.data,o=V(a,4);o!==8&&ne(`CbSize in articulation mismatch. Expected 8, got ${o}`);let i=V(a,4);for(let r=0;r<i;r++)this.connectionBlocks.push(pt.read(a))}else if(s)for(this.mode="dls2";s.data.currentIndex<s.data.length;){let n=ge(s.data);En.verifyHeader(n,"art2","art1");let a=n.data,o=V(a,4);o!==8&&ne(`CbSize in articulation mismatch. Expected 8, got ${o}`);let i=V(a,4);for(let r=0;r<i;r++)this.connectionBlocks.push(pt.read(a))}}write(){let e=new $(8);de(e,8),de(e,this.connectionBlocks.length);let t=this.connectionBlocks.map(n=>n.write()),s=Ze(this.mode==="dls2"?"art2":"art1",[e,...t]);return Qe(this.mode==="dls2"?"lar2":"lart",s,!1,!0)}toSFZone(e){let t=(s,n,a,o)=>{let i=s/-128;if(e.setGenerator(n,i),i<=120){let r=Math.round(.46875*s),h=this.connectionBlocks.find(c=>c.isStaticParameter&&c.destination===o);h&&e.setGenerator(a,r+h.shortScale)}};for(let s of this.connectionBlocks){let n=s.shortScale,a=s.source.source,o=s.control.source,i=s.destination;if(s.isStaticParameter){s.toSFGenerator(e);continue}if(o===Z.none)if(a===Z.keyNum){if(i===L.pitch){e.setGenerator(g.scaleTuning,n/128);continue}if(i===L.modEnvHold||i===L.modEnvDecay||i===L.volEnvHold||i==L.volEnvDecay)continue}else{let r=s.toCombinedSFDestination();if(r){e.setGenerator(r,n);continue}}s.toSFModulator(e)}for(let s of this.connectionBlocks){if(s.source.source!==Z.keyNum)continue;let n=s.shortScale;switch(s.destination){default:case L.volEnvHold:{t(n,g.keyNumToVolEnvHold,g.holdVolEnv,L.volEnvHold);break}case L.volEnvDecay:{t(n,g.keyNumToVolEnvDecay,g.decayVolEnv,L.volEnvDecay);break}case L.modEnvHold:{t(n,g.keyNumToModEnvHold,g.holdModEnv,L.modEnvHold);break}case L.modEnvDecay:{t(n,g.keyNumToModEnvDecay,g.decayModEnv,L.modEnvDecay);break}}}if(this.mode==="dls1"){e.setGenerator(g.delayVibLFO,e.getGenerator(g.delayModLFO,null)),e.setGenerator(g.freqVibLFO,e.getGenerator(g.freqModLFO,null)),e.setGenerator(g.vibLfoToPitch,e.getGenerator(g.modLfoToPitch,null));for(let s of e.modulators)s.destination===g.modLfoToPitch&&(s.destination=g.vibLfoToPitch)}}},Zs=class es{channel=1;tableIndex;fusOptions=0;phaseGroup=0;constructor(e){this.tableIndex=e}static copyFrom(e){let t=new es(e.tableIndex);return t.channel=e.channel,t.phaseGroup=e.phaseGroup,t.fusOptions=e.fusOptions,t}static read(e){let t=V(e.data,2),s=V(e.data,2),n=V(e.data,4),a=V(e.data,4),o=new es(a);return o.channel=n,o.fusOptions=t,o.phaseGroup=s,o}static fromSFZone(e,t){let s=e.indexOf(t.sample);if(s===-1)throw new Error(`Wave link error: Sample ${t.sample.name} does not exist in the sample list.`);let n=new es(s);switch(t.sample.sampleType){default:case xe.leftSample:case xe.monoSample:{n.channel=Math.trunc(1);break}case xe.rightSample:n.channel=2}return n}write(){let e=new $(12);return te(e,this.fusOptions),te(e,this.phaseGroup),de(e,this.channel),de(e,this.tableIndex),Qe("wlnk",e)}},As=class nt extends ct{articulation=new hi;keyRange={min:0,max:127};velRange={min:0,max:127};keyGroup=0;fusOptions=0;usLayer=0;waveSample;waveLink;constructor(e,t){super(),this.waveSample=t,this.waveLink=e}static copyFrom(e){let t=new nt(Zs.copyFrom(e.waveLink),rt.copyFrom(e.waveSample));return t.keyGroup=e.keyGroup,t.keyRange={...e.keyRange},t.velRange={...e.velRange},t.usLayer=e.usLayer,t.fusOptions=e.fusOptions,t.articulation.copyFrom(e.articulation),t}static read(e,t){let s=this.verifyAndReadList(t,"rgn ","rgn2"),n=s.find(y=>y.header==="wsmp"),a=n?rt.read(n):void 0,o=s.find(y=>y.header==="wlnk");if(!o){ne("Invalid DLS region: missing 'wlnk' chunk! Discarding...");return}let i=Zs.read(o),r=s.find(y=>y.header==="rgnh");if(!r){ne("Invalid DLS region: missing 'rgnh' chunk! Discarding...");return}let h=e[i.tableIndex];h||nt.parsingError(`Invalid sample index: ${i.tableIndex}. Samples available: ${e.length}`),a??=h.waveSample;let c=new nt(i,a),I=V(r.data,2),E=V(r.data,2),B=V(r.data,2),d=V(r.data,2);return B===0&&d===0&&(d=127,B=0),c.keyRange.max=E,c.keyRange.min=I,c.velRange.max=d,c.velRange.min=B,c.fusOptions=V(r.data,2),c.keyGroup=V(r.data,2),r.data.length-r.data.currentIndex>=2&&(c.usLayer=V(r.data,2)),c.articulation.read(s),c}static fromSFZone(e,t){let s=rt.fromSFZone(e),n=Zs.fromSFZone(t,e),a=new nt(n,s);return a.keyRange.min=Math.max(e.keyRange.min,0),a.keyRange.max=e.keyRange.max,a.velRange.min=Math.max(e.velRange.min,0),a.velRange.max=e.velRange.max,a.keyGroup=e.getGenerator(g.exclusiveClass,0),a.articulation.fromSFZone(e),a}write(){let e=[this.writeHeader(),this.waveSample.write(),this.waveLink.write(),this.articulation.write()];return Ze("rgn2",e,!0)}toSFZone(e,t){let s=t[this.waveLink.tableIndex];s||nt.parsingError(`Invalid sample index: ${this.waveLink.tableIndex}`);let n=e.createZone(s);return n.keyRange=this.keyRange,n.velRange=this.velRange,this.keyRange.max===127&&this.keyRange.min===0&&(n.keyRange.min=-1),this.velRange.max===127&&this.velRange.min===0&&(n.velRange.min=-1),this.keyGroup!==0&&n.setGenerator(g.exclusiveClass,this.keyGroup),this.waveSample.toSFZone(n,s),this.articulation.toSFZone(n),n.generators=n.generators.filter(a=>a.generatorValue!==hA[a.generatorType].def),n}writeHeader(){let e=new $(12);return te(e,Math.max(this.keyRange.min,0)),te(e,this.keyRange.max),te(e,Math.max(this.velRange.min,0)),te(e,this.velRange.max),te(e,this.fusOptions),te(e,this.keyGroup),te(e,this.usLayer),Qe("rgnh",e)}},Ws=class ts extends ct{articulation=new hi;regions=new Array;name="Unnamed";bankLSB=0;bankMSB=0;isGMGSDrum=!1;program=0;static copyFrom(e){let t=new ts;t.name=e.name,t.isGMGSDrum=e.isGMGSDrum,t.bankMSB=e.bankMSB,t.bankLSB=e.bankLSB,t.program=e.program,t.articulation.copyFrom(e.articulation);for(let s of e.regions)t.regions.push(As.copyFrom(s));return t}static read(e,t){let s=this.verifyAndReadList(t,"ins "),n=s.find(E=>E.header==="insh");if(!n)throw j(),new Error("No instrument header!");let a="",o=LA(s,"INFO");if(o){let E=ge(o.data);for(;E.header!=="INAM";)E=ge(o.data);a=pe(E.data,E.data.length).trim()}a.length===0&&(a="Unnamed Instrument");let i=new ts;i.name=a;let r=V(n.data,4),h=V(n.data,4),c=V(n.data,4);i.program=c&127,i.bankMSB=h>>>8&127,i.bankLSB=h&127,i.isGMGSDrum=h>>>31>0,Xe(`%cParsing %c"${a}"%c...`,l.info,l.recognized,l.info);let I=LA(s,"lrgn");if(!I)throw j(),new Error("No region list!");i.articulation.read(s);for(let E=0;E<r;E++){let B=ge(I.data);this.verifyHeader(B,"LIST");let d=pe(B.data,4);d!=="rgn "&&d!=="rgn2"&&(j(),this.parsingError(`Invalid DLS region! Expected "rgn " or "rgn2" got "${d}"`));let y=As.read(e,B);y&&i.regions.push(y)}return j(),i}static fromSFPreset(e,t){let s=new ts;s.name=e.name,s.bankLSB=e.bankLSB,s.bankMSB=e.bankMSB,s.program=e.program,s.isGMGSDrum=e.isGMGSDrum,tA(`%cConverting %c${e.toString()}%c to DLS...`,l.info,l.value,l.info);let n=e.toFlattenedInstrument();for(let a of n.zones)s.regions.push(As.fromSFZone(a,t));return j(),s}write(){Xe(`%cWriting %c${this.name}%c...`,l.info,l.recognized,l.info);let e=[this.writeHeader()],t=this.regions.map(n=>n.write());e.push(Ze("lrgn",t,!0)),this.articulation.length>0&&e.push(this.articulation.write());let s=Qe("INAM",fA(this.name,!0));return e.push(Qe("INFO",s,!1,!0)),j(),Ze("ins ",e,!0)}toSFPreset(e){let t=new Rt(e);t.name=this.name,t.bankMSB=this.bankMSB,t.bankLSB=this.bankLSB,t.isGMGSDrum=this.isGMGSDrum,t.program=this.program;let s=new vt;s.name=this.name,t.createZone(s),this.articulation.toSFZone(s.globalZone);for(let n of this.regions)n.toSFZone(s,e.samples);s.globalize(),s.globalZone.modulators.some(n=>n.destination===g.reverbEffectsSend)||s.globalZone.addModulators(Fe.copyFrom(ri)),s.globalZone.modulators.some(n=>n.destination===g.chorusEffectsSend)||s.globalZone.addModulators(Fe.copyFrom(oi)),s.globalZone.generators=s.globalZone.generators.filter(n=>n.generatorValue!==hA[n.generatorType].def),e.addPresets(t),e.addInstruments(s)}writeHeader(){let e=new $(12);de(e,this.regions.length);let t=(this.bankMSB&127)<<8|this.bankLSB&127;return this.isGMGSDrum&&(t|=1<<31),de(e,t),de(e,this.program&127),Qe("insh",e)}},gi={progressFunction:void 0},ci=class Bn extends ct{samples=new Array;instruments=new Array;soundBankInfo={name:"Unnamed",creationDate:new Date,software:"SpessaSynth",soundEngine:"DLS Level 2.2",version:{major:2,minor:4}};static read(e){if(!e)throw new Error("No data provided!");let t=new $(e);tA("%cParsing DLS file...",l.info);let s=ge(t,!1);this.verifyHeader(s,"RIFF"),this.verifyText(pe(t,4).toLowerCase(),"dls ");let n=[];for(;t.currentIndex<t.length;)n.push(ge(t));let a=new Bn;a.soundBankInfo.name="Unnamed DLS",a.soundBankInfo.product="SpessaSynth DLS",a.soundBankInfo.comment="(no description)";let o=LA(n,"INFO");if(o)for(;o.data.currentIndex<o.data.length;){let d=ge(o.data),y=d.header,D=pe(d.data,d.size);switch(y){case"INAM":{a.soundBankInfo.name=D;break}case"ICRD":{a.soundBankInfo.creationDate=wn(D);break}case"ICMT":{a.soundBankInfo.comment=D;break}case"ISBJ":{a.soundBankInfo.subject=D;break}case"ICOP":{a.soundBankInfo.copyright=D;break}case"IENG":{a.soundBankInfo.engineer=D;break}case"IPRD":{a.soundBankInfo.product=D;break}case"ISFT":a.soundBankInfo.software=D}}this.printInfo(a);let i=n.find(d=>d.header==="colh");if(!i)return this.parsingError("No colh chunk!"),5;let r=V(i.data,4);k(`%cInstruments amount: %c${r}`,l.info,l.recognized);let h=LA(n,"wvpl");if(!h)return this.parsingError("No wvpl chunk!"),5;let c=this.verifyAndReadList(h,"wvpl");for(let d of c)a.samples.push(Qa.read(d));let I=LA(n,"lins");if(!I)return this.parsingError("No lins chunk!"),5;let E=this.verifyAndReadList(I,"lins");Xe("%cLoading instruments...",l.info),E.length!==r&&ne(`Colh reported invalid amount of instruments. Detected ${E.length}, expected ${r}`);for(let d of E)a.instruments.push(Ws.read(a.samples,d));j();let B=n.find(d=>d.header==="pgal");if(B){k("%cFound the instrument aliasing chunk!",l.recognized);let d=B.data;(d[0]!==0||d[1]!==1||d[2]!==2||d[3]!==3)&&(d.currentIndex+=4);let y=a.instruments.find(M=>Re.isXGDrums(M.bankMSB)||M.isGMGSDrum);if(!y)return ne("MobileBAE aliasing chunk without a drum preset. Aborting!"),a;let D=d.slice(d.currentIndex,d.currentIndex+128);d.currentIndex+=128;for(let M=0;M<128;M++){let F=D[M];if(F===M)continue;let w=y.regions.find(P=>P.keyRange.max===F&&P.keyRange.min===F);if(!w){ne(`Invalid drum alias ${M} to ${F}: region does not exist.`);continue}let S=As.copyFrom(w);S.keyRange.max=M,S.keyRange.min=M,y.regions.push(S)}for(d.currentIndex+=4;d.currentIndex<d.length;){let M=V(d,2),F=M&127,w=M>>7&127,S=d[d.currentIndex++],P=d[d.currentIndex++];P!==0&&ne(`Invalid alias byte. Expected 0, got ${P}`);let C=V(d,2),x=C&127,J=C>>7&127,Y=d[d.currentIndex++];P=d[d.currentIndex++],P!==0&&ne(`Invalid alias header. Expected 0, got ${P}`);let T=a.instruments.find(q=>q.bankLSB===x&&q.bankMSB===J&&q.program===Y&&!q.isGMGSDrum);if(!T){ne(`Invalid alias. Missing instrument: ${x}:${J}:${Y}`);continue}let U=Ws.copyFrom(T);U.bankMSB=w,U.bankLSB=F,U.program=S,a.instruments.push(U)}}return k(`%cParsing finished! %c"${a.soundBankInfo.name||"UNNAMED"}"%c has %c${a.instruments.length}%c instruments and %c${a.samples.length}%c samples.`,l.info,l.recognized,l.info,l.recognized,l.info,l.recognized,l.info),j(),a}static fromSF(e){Xe("%cSaving SF2 to DLS level 2...",l.info);let t=new Bn;t.soundBankInfo={...e.soundBankInfo},t.soundBankInfo.comment=(t.soundBankInfo.comment??"(No description)")+`
17
+ (${e})`,l.warn,l.value,l.unrecognized)}toSFDestination(){let e=this.shortScale;switch(this.destination){default:case L.none:return;case L.pan:return g.pan;case L.gain:return{gen:g.initialAttenuation,newAmount:-e};case L.pitch:return g.fineTune;case L.keyNum:return g.overridingRootKey;case L.volEnvDelay:return g.delayVolEnv;case L.volEnvAttack:return g.attackVolEnv;case L.volEnvHold:return g.holdVolEnv;case L.volEnvDecay:return g.decayVolEnv;case L.volEnvSustain:return{gen:g.sustainVolEnv,newAmount:1e3-e};case L.volEnvRelease:return g.releaseVolEnv;case L.modEnvDelay:return g.delayModEnv;case L.modEnvAttack:return g.attackModEnv;case L.modEnvHold:return g.holdModEnv;case L.modEnvDecay:return g.decayModEnv;case L.modEnvSustain:return{gen:g.sustainModEnv,newAmount:1e3-e};case L.modEnvRelease:return g.releaseModEnv;case L.filterCutoff:return g.initialFilterFc;case L.filterQ:return g.initialFilterQ;case L.chorusSend:return g.chorusEffectsSend;case L.reverbSend:return g.reverbEffectsSend;case L.modLfoFreq:return g.freqModLFO;case L.modLfoDelay:return g.delayModLFO;case L.vibLfoFreq:return g.freqVibLFO;case L.vibLfoDelay:return g.delayVibLFO}}},hi=class En extends ct{connectionBlocks=new Array;mode="dls2";get length(){return this.connectionBlocks.length}copyFrom(e){this.mode=e.mode;for(let t of e.connectionBlocks)this.connectionBlocks.push(pt.copyFrom(t))}fromSFZone(e){this.mode="dls2";let t=new Es;t.copyFrom(e);for(let s of t.generators){let n;switch(s.generatorType){default:continue;case g.keyNumToVolEnvDecay:{n=g.decayVolEnv;break}case g.keyNumToVolEnvHold:{n=g.holdVolEnv;break}case g.keyNumToModEnvDecay:{n=g.decayModEnv;break}case g.keyNumToModEnvHold:n=g.holdModEnv}let a=t.getGenerator(n,void 0),o=s.generatorValue*-128;if(a===void 0)continue;let i=60/128*o,r=a-i;t.setGenerator(s.generatorType,o,!1),t.setGenerator(n,r,!1)}for(let s of t.generators)pt.fromSFGenerator(s,this);for(let s of t.modulators)pt.fromSFModulator(s,this)}read(e){let t=LA(e,"lart"),s=LA(e,"lar2");if(t)for(this.mode="dls1";t.data.currentIndex<t.data.length;){let n=ge(t.data);En.verifyHeader(n,"art1","art2");let a=n.data,o=V(a,4);o!==8&&ne(`CbSize in articulation mismatch. Expected 8, got ${o}`);let i=V(a,4);for(let r=0;r<i;r++)this.connectionBlocks.push(pt.read(a))}else if(s)for(this.mode="dls2";s.data.currentIndex<s.data.length;){let n=ge(s.data);En.verifyHeader(n,"art2","art1");let a=n.data,o=V(a,4);o!==8&&ne(`CbSize in articulation mismatch. Expected 8, got ${o}`);let i=V(a,4);for(let r=0;r<i;r++)this.connectionBlocks.push(pt.read(a))}}write(){let e=new $(8);de(e,8),de(e,this.connectionBlocks.length);let t=this.connectionBlocks.map(n=>n.write()),s=Ze(this.mode==="dls2"?"art2":"art1",[e,...t]);return Qe(this.mode==="dls2"?"lar2":"lart",s,!1,!0)}toSFZone(e){let t=(s,n,a,o)=>{let i=s/-128;if(e.setGenerator(n,i),i<=120){let r=Math.round(.46875*s),h=this.connectionBlocks.find(c=>c.isStaticParameter&&c.destination===o);h&&e.setGenerator(a,r+h.shortScale)}};for(let s of this.connectionBlocks){let n=s.shortScale,a=s.source.source,o=s.control.source,i=s.destination;if(s.isStaticParameter){s.toSFGenerator(e);continue}if(o===Z.none)if(a===Z.keyNum){if(i===L.pitch){e.setGenerator(g.scaleTuning,n/128);continue}if(i===L.modEnvHold||i===L.modEnvDecay||i===L.volEnvHold||i==L.volEnvDecay)continue}else{let r=s.toCombinedSFDestination();if(r){e.setGenerator(r,n);continue}}s.toSFModulator(e)}for(let s of this.connectionBlocks){if(s.source.source!==Z.keyNum)continue;let n=s.shortScale;switch(s.destination){default:case L.volEnvHold:{t(n,g.keyNumToVolEnvHold,g.holdVolEnv,L.volEnvHold);break}case L.volEnvDecay:{t(n,g.keyNumToVolEnvDecay,g.decayVolEnv,L.volEnvDecay);break}case L.modEnvHold:{t(n,g.keyNumToModEnvHold,g.holdModEnv,L.modEnvHold);break}case L.modEnvDecay:{t(n,g.keyNumToModEnvDecay,g.decayModEnv,L.modEnvDecay);break}}}if(this.mode==="dls1"){e.setGenerator(g.delayVibLFO,e.getGenerator(g.delayModLFO,null)),e.setGenerator(g.freqVibLFO,e.getGenerator(g.freqModLFO,null)),e.setGenerator(g.vibLfoToPitch,e.getGenerator(g.modLfoToPitch,null)),e.setGenerator(g.modLfoToPitch,null);for(let s of e.modulators)s.destination===g.modLfoToPitch&&(s.destination=g.vibLfoToPitch)}}},Zs=class es{channel=1;tableIndex;fusOptions=0;phaseGroup=0;constructor(e){this.tableIndex=e}static copyFrom(e){let t=new es(e.tableIndex);return t.channel=e.channel,t.phaseGroup=e.phaseGroup,t.fusOptions=e.fusOptions,t}static read(e){let t=V(e.data,2),s=V(e.data,2),n=V(e.data,4),a=V(e.data,4),o=new es(a);return o.channel=n,o.fusOptions=t,o.phaseGroup=s,o}static fromSFZone(e,t){let s=e.indexOf(t.sample);if(s===-1)throw new Error(`Wave link error: Sample ${t.sample.name} does not exist in the sample list.`);let n=new es(s);switch(t.sample.sampleType){default:case xe.leftSample:case xe.monoSample:{n.channel=Math.trunc(1);break}case xe.rightSample:n.channel=2}return n}write(){let e=new $(12);return te(e,this.fusOptions),te(e,this.phaseGroup),de(e,this.channel),de(e,this.tableIndex),Qe("wlnk",e)}},As=class nt extends ct{articulation=new hi;keyRange={min:0,max:127};velRange={min:0,max:127};keyGroup=0;fusOptions=0;usLayer=0;waveSample;waveLink;constructor(e,t){super(),this.waveSample=t,this.waveLink=e}static copyFrom(e){let t=new nt(Zs.copyFrom(e.waveLink),rt.copyFrom(e.waveSample));return t.keyGroup=e.keyGroup,t.keyRange={...e.keyRange},t.velRange={...e.velRange},t.usLayer=e.usLayer,t.fusOptions=e.fusOptions,t.articulation.copyFrom(e.articulation),t}static read(e,t){let s=this.verifyAndReadList(t,"rgn ","rgn2"),n=s.find(y=>y.header==="wsmp"),a=n?rt.read(n):void 0,o=s.find(y=>y.header==="wlnk");if(!o){ne("Invalid DLS region: missing 'wlnk' chunk! Discarding...");return}let i=Zs.read(o),r=s.find(y=>y.header==="rgnh");if(!r){ne("Invalid DLS region: missing 'rgnh' chunk! Discarding...");return}let h=e[i.tableIndex];h||nt.parsingError(`Invalid sample index: ${i.tableIndex}. Samples available: ${e.length}`),a??=h.waveSample;let c=new nt(i,a),I=V(r.data,2),E=V(r.data,2),B=V(r.data,2),d=V(r.data,2);return B===0&&d===0&&(d=127,B=0),c.keyRange.max=E,c.keyRange.min=I,c.velRange.max=d,c.velRange.min=B,c.fusOptions=V(r.data,2),c.keyGroup=V(r.data,2),r.data.length-r.data.currentIndex>=2&&(c.usLayer=V(r.data,2)),c.articulation.read(s),c}static fromSFZone(e,t){let s=rt.fromSFZone(e),n=Zs.fromSFZone(t,e),a=new nt(n,s);return a.keyRange.min=Math.max(e.keyRange.min,0),a.keyRange.max=e.keyRange.max,a.velRange.min=Math.max(e.velRange.min,0),a.velRange.max=e.velRange.max,a.keyGroup=e.getGenerator(g.exclusiveClass,0),a.articulation.fromSFZone(e),a}write(){let e=[this.writeHeader(),this.waveSample.write(),this.waveLink.write(),this.articulation.write()];return Ze("rgn2",e,!0)}toSFZone(e,t){let s=t[this.waveLink.tableIndex];s||nt.parsingError(`Invalid sample index: ${this.waveLink.tableIndex}`);let n=e.createZone(s);return n.keyRange=this.keyRange,n.velRange=this.velRange,this.keyRange.max===127&&this.keyRange.min===0&&(n.keyRange.min=-1),this.velRange.max===127&&this.velRange.min===0&&(n.velRange.min=-1),this.keyGroup!==0&&n.setGenerator(g.exclusiveClass,this.keyGroup),this.waveSample.toSFZone(n,s),this.articulation.toSFZone(n),n.generators=n.generators.filter(a=>a.generatorValue!==hA[a.generatorType].def),n}writeHeader(){let e=new $(12);return te(e,Math.max(this.keyRange.min,0)),te(e,this.keyRange.max),te(e,Math.max(this.velRange.min,0)),te(e,this.velRange.max),te(e,this.fusOptions),te(e,this.keyGroup),te(e,this.usLayer),Qe("rgnh",e)}},Ws=class ts extends ct{articulation=new hi;regions=new Array;name="Unnamed";bankLSB=0;bankMSB=0;isGMGSDrum=!1;program=0;static copyFrom(e){let t=new ts;t.name=e.name,t.isGMGSDrum=e.isGMGSDrum,t.bankMSB=e.bankMSB,t.bankLSB=e.bankLSB,t.program=e.program,t.articulation.copyFrom(e.articulation);for(let s of e.regions)t.regions.push(As.copyFrom(s));return t}static read(e,t){let s=this.verifyAndReadList(t,"ins "),n=s.find(E=>E.header==="insh");if(!n)throw j(),new Error("No instrument header!");let a="",o=LA(s,"INFO");if(o){let E=ge(o.data);for(;E.header!=="INAM";)E=ge(o.data);a=pe(E.data,E.data.length).trim()}a.length===0&&(a="Unnamed Instrument");let i=new ts;i.name=a;let r=V(n.data,4),h=V(n.data,4),c=V(n.data,4);i.program=c&127,i.bankMSB=h>>>8&127,i.bankLSB=h&127,i.isGMGSDrum=h>>>31>0,Xe(`%cParsing %c"${a}"%c...`,l.info,l.recognized,l.info);let I=LA(s,"lrgn");if(!I)throw j(),new Error("No region list!");i.articulation.read(s);for(let E=0;E<r;E++){let B=ge(I.data);this.verifyHeader(B,"LIST");let d=pe(B.data,4);d!=="rgn "&&d!=="rgn2"&&(j(),this.parsingError(`Invalid DLS region! Expected "rgn " or "rgn2" got "${d}"`));let y=As.read(e,B);y&&i.regions.push(y)}return j(),i}static fromSFPreset(e,t){let s=new ts;s.name=e.name,s.bankLSB=e.bankLSB,s.bankMSB=e.bankMSB,s.program=e.program,s.isGMGSDrum=e.isGMGSDrum,tA(`%cConverting %c${e.toString()}%c to DLS...`,l.info,l.value,l.info);let n=e.toFlattenedInstrument();for(let a of n.zones)s.regions.push(As.fromSFZone(a,t));return j(),s}write(){Xe(`%cWriting %c${this.name}%c...`,l.info,l.recognized,l.info);let e=[this.writeHeader()],t=this.regions.map(n=>n.write());e.push(Ze("lrgn",t,!0)),this.articulation.length>0&&e.push(this.articulation.write());let s=Qe("INAM",fA(this.name,!0));return e.push(Qe("INFO",s,!1,!0)),j(),Ze("ins ",e,!0)}toSFPreset(e){let t=new Rt(e);t.name=this.name,t.bankMSB=this.bankMSB,t.bankLSB=this.bankLSB,t.isGMGSDrum=this.isGMGSDrum,t.program=this.program;let s=new vt;s.name=this.name,t.createZone(s),this.articulation.toSFZone(s.globalZone);for(let n of this.regions)n.toSFZone(s,e.samples);s.globalize(),s.globalZone.modulators.some(n=>n.destination===g.reverbEffectsSend)||s.globalZone.addModulators(Fe.copyFrom(ri)),s.globalZone.modulators.some(n=>n.destination===g.chorusEffectsSend)||s.globalZone.addModulators(Fe.copyFrom(oi)),s.globalZone.generators=s.globalZone.generators.filter(n=>n.generatorValue!==hA[n.generatorType].def),e.addPresets(t),e.addInstruments(s)}writeHeader(){let e=new $(12);de(e,this.regions.length);let t=(this.bankMSB&127)<<8|this.bankLSB&127;return this.isGMGSDrum&&(t|=1<<31),de(e,t),de(e,this.program&127),Qe("insh",e)}},gi={progressFunction:void 0},ci=class Bn extends ct{samples=new Array;instruments=new Array;soundBankInfo={name:"Unnamed",creationDate:new Date,software:"SpessaSynth",soundEngine:"DLS Level 2.2",version:{major:2,minor:4}};static read(e){if(!e)throw new Error("No data provided!");let t=new $(e);tA("%cParsing DLS file...",l.info);let s=ge(t,!1);this.verifyHeader(s,"RIFF"),this.verifyText(pe(t,4).toLowerCase(),"dls ");let n=[];for(;t.currentIndex<t.length;)n.push(ge(t));let a=new Bn;a.soundBankInfo.name="Unnamed DLS",a.soundBankInfo.product="SpessaSynth DLS",a.soundBankInfo.comment="(no description)";let o=LA(n,"INFO");if(o)for(;o.data.currentIndex<o.data.length;){let d=ge(o.data),y=d.header,D=pe(d.data,d.size);switch(y){case"INAM":{a.soundBankInfo.name=D;break}case"ICRD":{a.soundBankInfo.creationDate=wn(D);break}case"ICMT":{a.soundBankInfo.comment=D;break}case"ISBJ":{a.soundBankInfo.subject=D;break}case"ICOP":{a.soundBankInfo.copyright=D;break}case"IENG":{a.soundBankInfo.engineer=D;break}case"IPRD":{a.soundBankInfo.product=D;break}case"ISFT":a.soundBankInfo.software=D}}this.printInfo(a);let i=n.find(d=>d.header==="colh");if(!i)return this.parsingError("No colh chunk!"),5;let r=V(i.data,4);k(`%cInstruments amount: %c${r}`,l.info,l.recognized);let h=LA(n,"wvpl");if(!h)return this.parsingError("No wvpl chunk!"),5;let c=this.verifyAndReadList(h,"wvpl");for(let d of c)a.samples.push(Qa.read(d));let I=LA(n,"lins");if(!I)return this.parsingError("No lins chunk!"),5;let E=this.verifyAndReadList(I,"lins");Xe("%cLoading instruments...",l.info),E.length!==r&&ne(`Colh reported invalid amount of instruments. Detected ${E.length}, expected ${r}`);for(let d of E)a.instruments.push(Ws.read(a.samples,d));j();let B=n.find(d=>d.header==="pgal");if(B){k("%cFound the instrument aliasing chunk!",l.recognized);let d=B.data;(d[0]!==0||d[1]!==1||d[2]!==2||d[3]!==3)&&(d.currentIndex+=4);let y=a.instruments.find(M=>Re.isXGDrums(M.bankMSB)||M.isGMGSDrum);if(!y)return ne("MobileBAE aliasing chunk without a drum preset. Aborting!"),a;let D=d.slice(d.currentIndex,d.currentIndex+128);d.currentIndex+=128;for(let M=0;M<128;M++){let F=D[M];if(F===M)continue;let w=y.regions.find(P=>P.keyRange.max===F&&P.keyRange.min===F);if(!w){ne(`Invalid drum alias ${M} to ${F}: region does not exist.`);continue}let S=As.copyFrom(w);S.keyRange.max=M,S.keyRange.min=M,y.regions.push(S)}for(d.currentIndex+=4;d.currentIndex<d.length;){let M=V(d,2),F=M&127,w=M>>7&127,S=d[d.currentIndex++],P=d[d.currentIndex++];P!==0&&ne(`Invalid alias byte. Expected 0, got ${P}`);let C=V(d,2),x=C&127,J=C>>7&127,Y=d[d.currentIndex++];P=d[d.currentIndex++],P!==0&&ne(`Invalid alias header. Expected 0, got ${P}`);let T=a.instruments.find(q=>q.bankLSB===x&&q.bankMSB===J&&q.program===Y&&!q.isGMGSDrum);if(!T){ne(`Invalid alias. Missing instrument: ${x}:${J}:${Y}`);continue}let U=Ws.copyFrom(T);U.bankMSB=w,U.bankLSB=F,U.program=S,a.instruments.push(U)}}return k(`%cParsing finished! %c"${a.soundBankInfo.name||"UNNAMED"}"%c has %c${a.instruments.length}%c instruments and %c${a.samples.length}%c samples.`,l.info,l.recognized,l.info,l.recognized,l.info,l.recognized,l.info),j(),a}static fromSF(e){Xe("%cSaving SF2 to DLS level 2...",l.info);let t=new Bn;t.soundBankInfo={...e.soundBankInfo},t.soundBankInfo.comment=(t.soundBankInfo.comment??"(No description)")+`
18
18
  Converted from SF2 to DLS with SpessaSynth`;for(let s of e.samples)t.samples.push(Qa.fromSFSample(s));for(let s of e.presets)t.instruments.push(Ws.fromSFPreset(s,e.samples));return k("%cConversion complete!",l.recognized),j(),t}static printInfo(e){for(let[t,s]of Object.entries(e.soundBankInfo)){if(typeof s=="object"&&"major"in s){let n=s;k(`%c${t}: %c"${n.major}.${n.minor}"`,l.info,l.recognized)}k(`%c${t}: %c${s.toLocaleString()}`,l.info,l.recognized)}}async write(e=gi){Xe("%cSaving DLS...",l.info);let t=new $(4);de(t,this.instruments.length);let s=Qe("colh",t);Xe("%cWriting instruments...",l.info);let n=Ze("lins",this.instruments.map(D=>D.write()),!0);k("%cSuccess!",l.recognized),j(),Xe("%cWriting WAVE samples...",l.info);let a=0,o=[],i=[],r=0;for(let D of this.samples){let M=D.write();await e?.progressFunction?.(D.name,r,this.samples.length),o.push(a),a+=M.length,i.push(M),r++}let h=Ze("wvpl",i,!0);k("%cSucceeded!",l.recognized);let c=new $(8+4*o.length);de(c,8),de(c,o.length);for(let D of o)de(c,D);let I=Qe("ptbl",c);this.soundBankInfo.software="SpessaSynth";let E=[],B=(D,M)=>{E.push(Qe(D,fA(M,!0)))};for(let[D,M]of Object.entries(this.soundBankInfo)){let F=D,w=M;if(w)switch(F){case"name":{B("INAM",w);break}case"comment":{B("ICMT",w);break}case"copyright":{B("ICOP",w);break}case"creationDate":{B("ICRD",Dn(w));break}case"engineer":{B("IENG",w);break}case"product":{B("IPRD",w);break}case"romVersion":case"version":case"soundEngine":case"romInfo":break;case"software":{B("ISFT",w);break}case"subject":B("ISBJ",w)}}let d=Ze("INFO",E,!0);k("%cCombining everything...");let y=Ze("RIFF",[fA("DLS "),s,n,I,h,d]);return k("%cSaved successfully!",l.recognized),j(),y.buffer}toSF(){tA("%cConverting DLS to SF2...",l.info);let e=new Ii;e.soundBankInfo.version.minor=4,e.soundBankInfo.version.major=2,e.soundBankInfo={...this.soundBankInfo},e.soundBankInfo.comment=(e.soundBankInfo.comment??"(No description)")+`
19
19
  Converted from DLS to SF2 with SpessaSynth`;for(let t of this.samples)t.toSFSample(e);for(let t of this.instruments)t.toSFPreset(e);return e.flush(),k("%cConversion complete!",l.recognized),j(),e}},Ii=class ss{static isSF3DecoderReady=Cs.isInitialized;soundBankInfo={name:"Unnamed",creationDate:new Date,software:"SpessaSynth",soundEngine:"E-mu 10K2",version:{major:2,minor:4}};presets=[];samples=[];instruments=[];defaultModulators=Xa.map(Fe.copyFrom.bind(Fe));customDefaultModulators=!1;_isXGBank=!1;get isXGBank(){return this._isXGBank}static mergeSoundBanks(...e){let t=e.shift();if(!t)throw new Error("No sound banks provided!");let s=t.presets;for(;e.length>0;){let a=e?.shift()?.presets;if(a)for(let o of a)s.some(i=>o.matches(i))||s.push(o)}let n=new ss;return n.addCompletePresets(s),n.soundBankInfo={...t.soundBankInfo},n}static async getSampleSoundBankFile(){let e=new ss,t=new Float32Array(128);for(let i=0;i<128;i++)t[i]=i/128*2-1;let s=new Ah;s.name="Saw",s.originalKey=65,s.pitchCorrection=20,s.loopEnd=127,s.setAudioData(t,44100),e.addSamples(s);let n=new vt;n.name="Saw Wave",n.globalZone.addGenerators(new Ye(g.initialAttenuation,375),new Ye(g.releaseVolEnv,-1e3),new Ye(g.sampleModes,1)),n.createZone(s),n.createZone(s).setGenerator(g.fineTune,-9),e.addInstruments(n);let o=new Rt(e);return o.name="Saw Wave",o.createZone(n),e.addPresets(o),e.soundBankInfo.name="Dummy",e.flush(),await e.writeSF2()}static copyFrom(e){let t=new ss;for(let s of e.presets)t.clonePreset(s);return t.soundBankInfo={...e.soundBankInfo},t}addCompletePresets(e){this.addPresets(...e);let t=[];for(let n of e)for(let a of n.zones)a.instrument&&!t.includes(a.instrument)&&t.push(a.instrument);this.addInstruments(...t);let s=[];for(let n of t)for(let a of n.zones)a.sample&&!s.includes(a.sample)&&s.push(a.sample);this.addSamples(...s)}async writeDLS(e=gi){return ci.fromSF(this).write(e)}async writeSF2(e=In){return ah(this,e)}addPresets(...e){this.presets.push(...e)}addInstruments(...e){this.instruments.push(...e)}addSamples(...e){this.samples.push(...e)}cloneSample(e){let t=this.samples.find(n=>n.name===e.name);if(t)return t;let s=new Bs(e.name,e.sampleRate,e.originalKey,e.pitchCorrection,e.sampleType,e.loopStart,e.loopEnd);if(e.isCompressed?s.setCompressedData(e.getRawData(!0)):s.setAudioData(e.getAudioData(),e.sampleRate),this.addSamples(s),e.linkedSample){let n=this.cloneSample(e.linkedSample);n.linkedSample||s.setLinkedSample(n,s.sampleType)}return s}cloneInstrument(e){let t=this.instruments.find(n=>n.name===e.name);if(t)return t;let s=new vt;s.name=e.name,s.globalZone.copyFrom(e.globalZone);for(let n of e.zones)s.createZone(this.cloneSample(n.sample)).copyFrom(n);return this.addInstruments(s),s}clonePreset(e){let t=this.presets.find(n=>n.name===e.name);if(t)return t;let s=new Rt(this);s.name=e.name,s.bankMSB=e.bankMSB,s.bankLSB=e.bankLSB,s.isGMGSDrum=e.isGMGSDrum,s.program=e.program,s.library=e.library,s.genre=e.genre,s.morphology=e.morphology,s.globalZone.copyFrom(e.globalZone);for(let n of e.zones)s.createZone(this.cloneInstrument(n.instrument)).copyFrom(n);return this.addPresets(s),s}flush(){this.presets.sort(CA.sorter.bind(CA)),this.parseInternal()}trimSoundBank(e){let t=(n,a)=>{let o=0;for(let i=0;i<n.zones.length;i++){let r=n.zones[i],h=r.keyRange,c=r.velRange,I=!1;for(let E of a)if(E.key>=h.min&&E.key<=h.max&&E.velocity>=c.min&&E.velocity<=c.max){I=!0;break}!I&&r.sample&&(k(`%c${r.sample.name}%c removed from %c${n.name}%c.`,l.recognized,l.info,l.recognized,l.info),n.deleteZone(i)&&(o++,i--,k(`%c${r.sample.name}%c deleted`,l.recognized,l.info)),r.sample.useCount<1&&this.deleteSample(r.sample))}return o};tA("%cTrimming sound bank...",l.info);let s=e.getUsedProgramsAndKeys(this);Xe("%cModifying sound bank...",l.info),k("Detected keys for midi:",s);for(let n=0;n<this.presets.length;n++){let a=this.presets[n],o=s.get(a);if(o===void 0)k(`%cDeleting preset %c${a.name}%c and its zones`,l.info,l.recognized,l.info),this.deletePreset(a),n--;else{let i=[...o].map(h=>{let c=h.split("-");return{key:Number.parseInt(c[0]),velocity:Number.parseInt(c[1])}});Xe(`%cTrimming %c${a.name}`,l.info,l.recognized),k(`Keys for ${a.name}:`,i);let r=0;for(let h=0;h<a.zones.length;h++){let c=a.zones[h],I=c.keyRange,E=c.velRange,B=!1;for(let d of i)if(d.key>=I.min&&d.key<=I.max&&d.velocity>=E.min&&d.velocity<=E.max&&c.instrument){B=!0;let y=t(c.instrument,i);k(`%cTrimmed off %c${y}%c zones from %c${c.instrument.name}`,l.info,l.recognized,l.info,l.recognized);break}!B&&c.instrument&&(r++,a.deleteZone(h),c.instrument.useCount<1&&this.deleteInstrument(c.instrument),h--)}k(`%cTrimmed off %c${r}%c zones from %c${a.name}`,l.info,l.recognized,l.info,l.recognized),j()}}this.removeUnusedElements(),k("%cSound bank modified!",l.recognized),j(),j()}removeUnusedElements(){this.instruments=this.instruments.filter(e=>{e.deleteUnusedZones();let t=e.useCount<1;return t&&e.delete(),!t}),this.samples=this.samples.filter(e=>{let t=e.useCount<1;return t&&e.unlinkSample(),!t})}deleteInstrument(e){e.delete(),this.instruments.splice(this.instruments.indexOf(e),1)}deletePreset(e){e.delete(),this.presets.splice(this.presets.indexOf(e),1)}deleteSample(e){e.unlinkSample(),this.samples.splice(this.samples.indexOf(e),1)}getPreset(e,t){return ei(this.presets,e,t)}destroySoundBank(){this.presets.length=0,this.instruments.length=0,this.samples.length=0}parsingError(e){throw new Error(`SF parsing error: ${e} The file may be corrupted.`)}parseInternal(){this._isXGBank=!1;let e=new Set([0,1,2,3,4,5,6,7,8,9,16,17,24,25,26,27,28,29,30,31,32,33,40,41,48,56,57,58,64,65,66,126,127]);for(let t of this.presets)if(Re.isXGDrums(t.bankMSB)&&(this._isXGBank=!0,!e.has(t.program))){this._isXGBank=!1,k(`%cThis bank is not valid XG. Preset %c${t.toString()}%c is not a valid XG drum. XG mode will use presets on bank 128.`,l.info,l.value,l.info);break}}printInfo(){for(let[e,t]of Object.entries(this.soundBankInfo)){if(typeof t=="object"&&"major"in t){let s=t;k(`%c${e}: %c"${s.major}.${s.minor}"`,l.info,l.recognized)}k(`%c${e}: %c${t.toLocaleString()}`,l.info,l.recognized)}}},gh=class extends Ye{constructor(A){let e=A.currentIndex,t=A[e+1]<<8|A[e],s=dn(A[e+2],A[e+3]);A.currentIndex+=4,super(t,s,!1)}};function fa(A){let e=[];for(;A.data.length>A.data.currentIndex;)e.push(new gh(A.data));return e.pop(),e}function ch(A,e,t,s,n){let a=A.gen,o=A.mod,i=0,r=0;for(let h of n)for(let c=0;c<h.zonesCount;c++){let I=a[r++],E=a[r],B=e.slice(I,E),d=o[i++],y=o[i],D=t.slice(d,y);B.some(M=>M.generatorType===g.instrument)?h.createSoundFontZone(D,B,s):(h.globalZone.addGenerators(...B),h.globalZone.addModulators(...D))}}var Ih=class extends Rt{zoneStartIndex;zonesCount=0;constructor(A,e){super(e),this.name=pe(A.data,20).replace(/\d{3}:\d{3}/,""),this.program=V(A.data,2);let t=V(A.data,2);this.bankMSB=t&127,this.isGMGSDrum=(t&128)>0,this.bankLSB=t>>8,this.zoneStartIndex=V(A.data,2),this.library=V(A.data,4),this.genre=V(A.data,4),this.morphology=V(A.data,4)}createSoundFontZone(A,e,t){let s=e.find(o=>o.generatorType===g.instrument),n;if(s)n=t[s.generatorValue];else throw new Error("No instrument ID found in preset zone.");if(!n)throw new Error(`Invalid instrument ID: ${s.generatorValue}, available instruments: ${t.length}`);let a=new $a(this,n);return a.addGenerators(...e),a.addModulators(...A),this.zones.push(a),a}};function ua(A,e){let t=[];for(;A.data.length>A.data.currentIndex;){let s=new Ih(A,e);if(t.length>0){let n=t[t.length-1];n.zonesCount=s.zoneStartIndex-n.zoneStartIndex}t.push(s)}return t.pop(),t}var lh=class extends vt{zoneStartIndex;zonesCount=0;constructor(A){super(),this.name=pe(A.data,20),this.zoneStartIndex=V(A.data,2)}createSoundFontZone(A,e,t){let s=e.find(o=>o.generatorType===g.sampleID),n;if(s)n=t[s.generatorValue];else throw new Error("No sample ID found in instrument zone.");if(!n)throw new Error(`Invalid sample ID: ${s.generatorValue}, available samples: ${t.length}`);let a=new ja(this,n);return a.addGenerators(...e),a.addModulators(...A),this.zones.push(a),a}};function ma(A){let e=[];for(;A.data.length>A.data.currentIndex;){let t=new lh(A);if(e.length>0){let s=e[e.length-1];s.zonesCount=t.zoneStartIndex-s.zoneStartIndex}e.push(t)}return e.pop(),e}function zs(A){let e=[];for(;A.data.length>A.data.currentIndex;){let t=A.data,s=V(t,2),n=V(t,2),a=dn(t[t.currentIndex++],t[t.currentIndex++]),o=V(t,2),i=V(t,2);e.push(new we(s,o,n,a,i))}return e.pop(),e}function Ch(A,e,t,s,n){let a=A.gen,o=A.mod,i=0,r=0;for(let h of n)for(let c=0;c<h.zonesCount;c++){let I=a[r++],E=a[r],B=e.slice(I,E),d=o[i++],y=o[i],D=t.slice(d,y);B.some(M=>M.generatorType===g.sampleID)?h.createSoundFontZone(D,B,s):(h.globalZone.addGenerators(...B),h.globalZone.addModulators(...D))}}function Wt(A){let e=[],t=[];for(;A.data.length>A.data.currentIndex;)t.push(V(A.data,2)),e.push(V(A.data,2));return{mod:e,gen:t}}var Eh=class extends Ii{sampleDataStartIndex=0;constructor(A,e=!0){if(super(),e)throw new Error("Using the constructor directly is deprecated. Use SoundBankLoader.fromArrayBuffer() instead.");let t=new $(A);tA("%cParsing a SoundFont2 file...",l.info),t||(j(),this.parsingError("No data provided!"));let s=ge(t,!1);this.verifyHeader(s,"riff");let n=pe(t,4).toLowerCase();if(n!=="sfbk"&&n!=="sfpk")throw j(),new SyntaxError(`Invalid soundFont! Expected "sfbk" or "sfpk" got "${n}"`);let a=n==="sfpk",o=ge(t);this.verifyHeader(o,"list");let i=pe(o.data,4);if(i!=="INFO")throw j(),new SyntaxError(`Invalid soundFont! Expected "INFO" or "${i}"`);let r;for(;o.data.length>o.data.currentIndex;){let O=ge(o.data),b=cA(O.data,O.data.length),G=O.header;switch(G){case"ifil":case"iver":{let K=V(O.data,2),ee=V(O.data,2);G==="ifil"?this.soundBankInfo.version={major:K,minor:ee}:this.soundBankInfo.romVersion={major:K,minor:ee};break}case"DMOD":{this.defaultModulators=zs(O),this.customDefaultModulators=!0;break}case"LIST":{pe(O.data,4)==="xdta"&&(k("%cExtended SF2 found!",l.recognized),r=O);break}case"ICRD":{this.soundBankInfo.creationDate=wn(pe(O.data,O.data.length));break}case"ISFT":{this.soundBankInfo.software=b;break}case"IPRD":{this.soundBankInfo.product=b;break}case"IENG":{this.soundBankInfo.engineer=b;break}case"ICOP":{this.soundBankInfo.copyright=b;break}case"INAM":{this.soundBankInfo.name=b;break}case"ICMT":{this.soundBankInfo.comment=b;break}case"irom":{this.soundBankInfo.romInfo=b;break}case"isng":this.soundBankInfo.soundEngine=b}}this.printInfo();let h={};r!==void 0&&(h.phdr=ge(r.data),h.pbag=ge(r.data),h.pmod=ge(r.data),h.pgen=ge(r.data),h.inst=ge(r.data),h.ibag=ge(r.data),h.imod=ge(r.data),h.igen=ge(r.data),h.shdr=ge(r.data));let c=ge(t,!1);this.verifyHeader(c,"list"),this.verifyText(pe(t,4),"sdta"),k("%cVerifying smpl chunk...",l.warn);let I=ge(t,!1);this.verifyHeader(I,"smpl");let E;if(a){k("%cSF2Pack detected, attempting to decode the smpl chunk...",l.info);try{E=Cs.decode(t.buffer.slice(t.currentIndex,t.currentIndex+c.size-12)).data[0]}catch(O){throw j(),new Error(`SF2Pack Ogg Vorbis decode error: ${O}`)}k(`%cDecoded the smpl chunk! Length: %c${E.length}`,l.info,l.value)}else E=t,this.sampleDataStartIndex=t.currentIndex;k(`%cSkipping sample chunk, length: %c${c.size-12}`,l.info,l.value),t.currentIndex+=c.size-12,k("%cLoading preset data chunk...",l.warn);let B=ge(t);this.verifyHeader(B,"list"),pe(B.data,4);let d=ge(B.data);this.verifyHeader(d,"phdr");let y=ge(B.data);this.verifyHeader(y,"pbag");let D=ge(B.data);this.verifyHeader(D,"pmod");let M=ge(B.data);this.verifyHeader(M,"pgen");let F=ge(B.data);this.verifyHeader(F,"inst");let w=ge(B.data);this.verifyHeader(w,"ibag");let S=ge(B.data);this.verifyHeader(S,"imod");let P=ge(B.data);this.verifyHeader(P,"igen");let C=ge(B.data);this.verifyHeader(C,"shdr"),k("%cParsing samples...",l.info),t.currentIndex=this.sampleDataStartIndex;let x=Ba(C,E,r===void 0);if(r&&h.shdr){let O=Ba(h.shdr,new Float32Array(1),!1);if(O.length===x.length)for(let[b,G]of x.entries())G.name+=O[b].name,G.linkedSampleIndex|=O[b].linkedSampleIndex<<16}for(let O of x)O.name=O.name.trim();this.samples.push(...x);let J=fa(P),Y=zs(S),T=ma(F);if(r&&h.inst){let O=ma(h.inst);if(O.length===T.length){for(let[b,G]of T.entries())G.name+=O[b].name,G.zoneStartIndex|=O[b].zoneStartIndex;for(let[b,G]of T.entries())b<T.length-1&&(G.zonesCount=T[b+1].zoneStartIndex-G.zoneStartIndex)}}for(let O of T)O.name=O.name.trim();this.instruments.push(...T);let U=Wt(w);if(r&&h.ibag){let O=Wt(h.ibag);for(let b=0;b<U.mod.length;b++)U.mod[b]|=O.mod[b]<<16;for(let b=0;b<U.gen.length;b++)U.gen[b]|=O.gen[b]<<16}Ch(U,J,Y,this.samples,T);let q=fa(M),m=zs(D),v=ua(d,this);if(r&&h.phdr){let O=ua(h.phdr,this);if(O.length===v.length){for(let[b,G]of v.entries())G.name+=O[b].name,G.zoneStartIndex|=O[b].zoneStartIndex;for(let[b,G]of v.entries())b<v.length-1&&(G.zonesCount=v[b+1].zoneStartIndex-G.zoneStartIndex)}}for(let O of v)O.name=O.name.trim();this.addPresets(...v);let H=Wt(y);if(r&&h.pbag){let O=Wt(h.pbag);for(let b=0;b<H.mod.length;b++)H.mod[b]|=O.mod[b]<<16;for(let b=0;b<H.gen.length;b++)H.gen[b]|=O.gen[b]<<16}ch(H,q,m,this.instruments,v),this.flush(),k(`%cParsing finished! %c"${this.soundBankInfo.name}"%c has %c${this.presets.length}%c presets,
20
20
  %c${this.instruments.length}%c instruments and %c${this.samples.length}%c samples.`,l.info,l.recognized,l.info,l.recognized,l.info,l.recognized,l.info,l.recognized,l.info),j()}verifyHeader(A,e){A.header.toLowerCase()!==e.toLowerCase()&&(j(),this.parsingError(`Invalid chunk header! Expected "${e.toLowerCase()}" got "${A.header.toLowerCase()}"`))}verifyText(A,e){A.toLowerCase()!==e.toLowerCase()&&(j(),this.parsingError(`Invalid FourCC: Expected "${e.toLowerCase()}" got "${A.toLowerCase()}"\``))}},Ft=class{static fromArrayBuffer(A){let e=A.slice(8,12),t=new $(e);return pe(t,4).toLowerCase()==="dls "?this.loadDLS(A):new Eh(A,!1)}static loadDLS(A){return ci.read(A).toSF()}},li=class{processorInitialized=Cs.isInitialized;sampleRate;onEventCall;process;processSplit;systemExclusive;controllerChange;noteOn;noteOff;polyPressure;channelPressure;pitchWheel;programChange;processMessage;synthCore;savedSnapshot;constructor(A,e={}){let t=Qn(e,kr);if(this.sampleRate=A,!Number.isFinite(t.initialTime)||!Number.isFinite(A))throw new TypeError(`Initial time or sample rate is invalid! initial time: ${t.initialTime}, sample rate: ${A}`);this.synthCore=new $o(this.callEvent.bind(this),this.missingPreset.bind(this),this.sampleRate,t);let s=this.synthCore;this.process=s.process.bind(s),this.processSplit=s.processSplit.bind(s),this.systemExclusive=s.systemExclusive.bind(s),this.controllerChange=s.controllerChange.bind(s),this.noteOn=s.noteOn.bind(s),this.noteOff=s.noteOff.bind(s),this.polyPressure=s.polyPressure.bind(s),this.channelPressure=s.channelPressure.bind(s),this.pitchWheel=s.pitchWheel.bind(s),this.programChange=s.programChange.bind(s),this.processMessage=s.processMessage.bind(s);for(let n=0;n<va;n++)this.synthCore.createMIDIChannel(!1);this.processorInitialized.then(()=>{k("%cSpessaSynth is ready!",l.recognized)})}get enableEffects(){return this.synthCore.enableEffects}set enableEffects(A){this.synthCore.enableEffects=A}get enableEventSystem(){return this.synthCore.enableEventSystem}set enableEventSystem(A){this.synthCore.enableEventSystem=A}get midiChannels(){return this.synthCore.midiChannels}get totalVoicesAmount(){return this.synthCore.voiceCount}get currentSynthTime(){return this.synthCore.currentTime}get reverbProcessor(){return this.synthCore.reverbProcessor}get chorusProcessor(){return this.synthCore.chorusProcessor}get delayProcessor(){return this.synthCore.delayProcessor}get soundBankManager(){return this.synthCore.soundBankManager}get keyModifierManager(){return this.synthCore.keyModifierManager}renderAudio(A,e,t,s=0,n=0){let a=this.synthCore.maxBufferSize;if(n>a){let o=0;for(;o<n;){let i=Math.min(a,n-o);this.synthCore.process(A[0],A[1],s+o,i),o+=i}}else this.synthCore.process(A[0],A[1],s,n)}renderAudioSplit(A,e,t,s=0,n=0){let a=this.synthCore.maxBufferSize;if(n>a){let o=0;for(;o<n;){let i=Math.min(a,n-o);this.synthCore.processSplit(t,A[0],A[1],s+o,i),o+=i}}else this.synthCore.processSplit(t,A[0],A[1],s,n)}onMissingPreset=(A,e)=>{ne(`No preset found for ${CA.toMIDIString(A)}! Did you forget to add a sound bank?`)};setMasterParameter(A,e){this.synthCore.setMasterParameter(A,e)}getMasterParameter(A){return this.synthCore.getMasterParameter(A)}getAllMasterParameters(){return this.synthCore.getAllMasterParameters()}resetAllControllers(A=un){this.synthCore.resetAllControllers(A)}applySynthesizerSnapshot(A){this.savedSnapshot=A,A.apply(this),k("%cFinished applying snapshot!",l.info),this.resetAllControllers()}getSnapshot(){return vn.create(this)}getInsertionSnapshot(){return this.synthCore.getInsertionSnapshot()}setEmbeddedSoundBank(A,e){let t=Ft.fromArrayBuffer(A);this.synthCore.soundBankManager.addSoundBank(t,Yt,e);let s=this.synthCore.soundBankManager.priorityOrder;s.pop(),s.unshift(Yt),this.synthCore.soundBankManager.priorityOrder=s,this.savedSnapshot!==void 0&&this.applySynthesizerSnapshot(this.savedSnapshot),k(`%cEmbedded sound bank set at offset %c${e}`,l.recognized,l.value)}clearEmbeddedBank(){this.synthCore.soundBankManager.soundBankList.some(A=>A.id===Yt)&&this.synthCore.soundBankManager.deleteSoundBank(Yt)}createMIDIChannel(){this.synthCore.createMIDIChannel(!0)}stopAllChannels(A=!1){this.synthCore.stopAllChannels(A)}destroySynthProcessor(){this.synthCore.destroySynthProcessor()}killVoices(A){ne(`killVoices is deprecated, don't use it! Amount requested: ${A}`)}clearCache(){this.synthCore.clearCache()}getVoicesForPreset(A,e,t){return this.synthCore.getVoicesForPreset(A,e,t)}callEvent(A,e){this.onEventCall?.({type:A,data:e})}missingPreset(A,e){return this.onMissingPreset(A,e)}};var ds=vA.consoleColors;var Ci="spessasynth-worklet-processor";function Ei(A,e){return{...e,...A}}var Bi={skipToFirstNoteOn:!0,initialPlaybackRate:1};var Nn=class extends Is{events=[];constructor(e){super(),super.copyFrom(e),this.events=[]}},Qs=class A extends ZA{tracks;embeddedSoundBank=void 0;embeddedSoundBankSize;constructor(e){super(),super.copyMetadataFrom(e),this.tracks=e.tracks.map(t=>new Nn(t)),this.embeddedSoundBankSize=e instanceof A?e.embeddedSoundBankSize:e?.embeddedSoundBank?.byteLength}};var fs={shuffleOn:1,shuffleOff:2,index:3};var di=1,us=class{synthesizer;sequencers=new Array;post;lastSequencerSync=0;alive=!1;enableEventSystem;constructor(e,t,s){this.synthesizer=new li(e,t),this.enableEventSystem=t.enableEventSystem??!1,this.post=s,this.synthesizer.onEventCall=n=>{this.post({type:"eventCall",data:n,currentTime:this.synthesizer.currentSynthTime})}}createNewSequencer(){let e=new xa(this.synthesizer),t=this.sequencers.length;this.sequencers.push(e),e.onEventCall=s=>{if(this.enableEventSystem){if(s.type==="songListChange"){let a=s.data.newSongList.map(o=>new Qs(o));this.post({type:"sequencerReturn",data:{type:s.type,data:{newSongList:a,shuffledSongIndexes:e.shuffledSongIndexes},id:t},currentTime:this.synthesizer.currentSynthTime});return}this.post({type:"sequencerReturn",data:{...s,id:t},currentTime:this.synthesizer.currentSynthTime})}}}postReady(e,t,s=[]){this.post({type:"isFullyInitialized",data:{type:e,data:t},currentTime:this.synthesizer.currentSynthTime},s)}postProgress(e,t){this.post({type:"renderingProgress",data:{type:e,data:t},currentTime:this.synthesizer.currentSynthTime})}destroy(){this.synthesizer.destroySynthProcessor(),delete this.synthesizer,delete this.sequencers}handleMessage(e){let t=e.channelNumber,s;if(t>=0&&(s=this.synthesizer.midiChannels[t],s===void 0)){vA.SpessaSynthWarn(`Trying to access channel ${t} which does not exist... ignoring!`);return}switch(e.type){case"midiMessage":{this.synthesizer.processMessage(e.data.messageData,e.data.channelOffset,e.data.options);break}case"customCcChange":{s?.setCustomController(e.data.ccNumber,e.data.ccValue);break}case"ccReset":{t===gt?this.synthesizer.resetAllControllers():s?.resetControllers();break}case"stopAll":{t===gt?this.synthesizer.stopAllChannels(e.data===1):s?.stopAllNotes(e.data===1);break}case"muteChannel":{s?.muteChannel(e.data);break}case"addNewChannel":{this.synthesizer.createMIDIChannel();break}case"setMasterParameter":{this.synthesizer.setMasterParameter(e.data.type,e.data.data);break}case"setDrums":{s?.setDrums(e.data);break}case"transposeChannel":{s?.transposeChannel(e.data.semitones,e.data.force);break}case"lockController":{if(e.data.controllerNumber===gt)s?.setPresetLock(e.data.isLocked);else{if(!s)return;s.lockedControllers[e.data.controllerNumber]=e.data.isLocked}break}case"sequencerSpecific":{let n=this.sequencers[e.data.id];if(!n)return;let a=e.data;switch(a.type){default:break;case"loadNewSongList":{try{let i=a.data.map(r=>"duration"in r?ZA.copyFrom(r):ZA.fromArrayBuffer(r.binary,r.fileName));n.loadNewSongList(i)}catch(o){console.error(o),this.post({type:"sequencerReturn",data:{type:"midiError",data:o,id:e.data.id},currentTime:this.synthesizer.currentSynthTime})}break}case"pause":{n.pause();break}case"play":{n.play();break}case"setTime":{n.currentTime=a.data;break}case"changeMIDIMessageSending":{n.externalMIDIPlayback=a.data;break}case"setPlaybackRate":{n.playbackRate=a.data;break}case"setLoopCount":{n.loopCount=a.data;break}case"changeSong":{switch(a.data.changeType){case fs.shuffleOff:{n.shuffleMode=!1;break}case fs.shuffleOn:{n.shuffleMode=!0;break}case fs.index:{a.data.data!==void 0&&(n.songIndex=a.data.data);break}}break}case"getMIDI":{if(!n.midiData)throw new Error("No MIDI is loaded!");this.post({type:"sequencerReturn",data:{type:"getMIDI",data:n.midiData,id:e.data.id},currentTime:this.synthesizer.currentSynthTime});break}case"setSkipToFirstNote":{n.skipToFirstNoteOn=a.data;break}}break}case"soundBankManager":{try{let n=this.synthesizer.soundBankManager,a=e.data,o;switch(a.type){case"addSoundBank":{o=Ft.fromArrayBuffer(a.data.soundBankBuffer),n.addSoundBank(o,a.data.id,a.data.bankOffset),this.postReady("soundBankManager",null);break}case"deleteSoundBank":{n.deleteSoundBank(a.data),this.postReady("soundBankManager",null);break}case"rearrangeSoundBanks":n.priorityOrder=a.data,this.postReady("soundBankManager",null)}}catch(n){this.post({type:"soundBankError",data:n,currentTime:this.synthesizer.currentSynthTime})}break}case"keyModifierManager":{let n=e.data,a=this.synthesizer.keyModifierManager;switch(n.type){default:return;case"addMapping":{a.addMapping(n.data.channel,n.data.midiNote,n.data.mapping);break}case"clearMappings":{a.clearMappings();break}case"deleteMapping":a.deleteMapping(n.data.channel,n.data.midiNote)}break}case"requestSynthesizerSnapshot":{let n=vn.create(this.synthesizer);this.postReady("synthesizerSnapshot",n);break}case"requestNewSequencer":{this.createNewSequencer();break}case"setLogLevel":{wa(e.data.enableInfo,e.data.enableWarning,e.data.enableGroup);break}case"destroyWorklet":{this.alive=!1,this.synthesizer.destroySynthProcessor(),this.destroy();break}default:{vA.SpessaSynthWarn("Unrecognized event!",e);break}}}};var ms=class extends us{alive=!0;oneOutputMode;port;constructor(e,t,s,n){super(e,{enableEffects:!n.oneOutput,enableEventSystem:n?.enableEventSystem,initialTime:t},(a,o)=>{s.postMessage(a,o)}),this.port=s,this.oneOutputMode=n.oneOutput,this.synthesizer.processorInitialized.then(()=>{this.port.onmessage=a=>this.handleMessage(a.data),this.postReady("sf3Decoder",null)})}process(e,t){if(!this.alive)return!1;for(let n of this.sequencers)n.processTick();if(this.oneOutputMode){let n=t[0],a=[];for(let o=0;o<32;o+=2)a.push([n[o],n[o+1]]);this.synthesizer.enableEffects=!1,this.synthesizer.processSplit(a,n[0],n[0])}else this.synthesizer.processSplit(t.slice(1),t[0][0],t[0][1]);let s=this.synthesizer.currentSynthTime;if(this.enableEventSystem&&s-this.lastSequencerSync>di){for(let n=0;n<this.sequencers.length;n++)this.post({type:"sequencerReturn",data:{type:"sync",data:this.sequencers[n].currentTime,id:n},currentTime:s});this.lastSequencerSync=s}return!0}handleMessage(e){if(e.type==="startOfflineRender"){this.startOfflineRender(e.data);return}super.handleMessage(e)}startOfflineRender(e){this.sequencers.length===0&&this.createNewSequencer();let t=this.sequencers[0];for(let[n,a]of e.soundBankList.entries())try{this.synthesizer.soundBankManager.addSoundBank(Ft.fromArrayBuffer(a.soundBankBuffer),`bank-${n}`,a.bankOffset)}catch(o){this.post({type:"soundBankError",data:o,currentTime:this.synthesizer.currentSynthTime})}e.snapshot!==void 0&&this.synthesizer.applySynthesizerSnapshot(e.snapshot),vA.SpessaSynthInfo("%cRendering enabled! Starting render.",ds.info),t.loopCount=e.loopCount,this.synthesizer.setMasterParameter("autoAllocateVoices",!0);let s=Ei(e.sequencerOptions,Bi);t.skipToFirstNoteOn=s.skipToFirstNoteOn,t.playbackRate=s.initialPlaybackRate;try{t.loadNewSongList([ZA.copyFrom(e.midiSequence)]),t.play()}catch(n){console.error(n),this.post({type:"sequencerReturn",data:{type:"midiError",data:n,id:0},currentTime:this.synthesizer.currentSynthTime})}this.postReady("startOfflineRender",null)}};var Tn=class extends AudioWorkletProcessor{process;core;constructor(e){super(),this.core=new ms(sampleRate,currentTime,this.port,e.processorOptions),this.process=this.core.process.bind(this.core)}};registerProcessor(Ci,Tn);vA.SpessaSynthInfo("%cProcessor successfully registered!",ds.recognized);