-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbeepbox_synth.min.js
More file actions
23 lines (20 loc) · 491 KB
/
beepbox_synth.min.js
File metadata and controls
23 lines (20 loc) · 491 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var beepbox=function(e){"use strict";
/*!
Copyright (c) 2012-2022 John Nesky and contributing authors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/var t=e&&e.t||function(e,t,s,i){return new(s||(s=Promise))((function(n,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function r(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,r)}l((i=i.apply(e,t||[])).next())}))};const s=["chip","FM","noise","spectrum","drumset","harmonics","pulse width","duty cycle","picked string","supersaw","chip (custom)","mod","FM (6-op)"];const i=new class{constructor(){this.statusTable={},this.urlTable={},this.totalSamples=0,this.samplesLoaded=0}};class n extends Event{constructor(e,t){super("sampleloaded"),this.totalSamples=e,this.samplesLoaded=t}}class a extends EventTarget{constructor(){super()}}const o=new a;function r(e,s,a,r,l){return t(this,void 0,void 0,(function*(){const t=new AudioContext({sampleRate:l});let h=!1;const u=p.chipWaves[s],m=p.rawChipWaves[s],d=p.rawRawChipWaves[s];fetch(e).then((e=>e.ok?e.arrayBuffer():(i.statusTable[s]=2,Promise.reject(new Error("Couldn't load sample"))))).then((e=>t.decodeAudioData(e))).then((e=>{const l=c(Array.from(e.getChannelData(0))),p=f(l);u.samples=p,m.samples=l,d.samples=l,r.isUsingAdvancedLoopControls&&(a.chipWaveLoopStart=null!=r.chipWaveLoopStart?r.chipWaveLoopStart:0,a.chipWaveLoopEnd=null!=r.chipWaveLoopEnd?r.chipWaveLoopEnd:l.length-1,a.chipWaveLoopMode=null!=r.chipWaveLoopMode?r.chipWaveLoopMode:0,a.chipWavePlayBackwards=r.chipWavePlayBackwards,a.chipWaveStartOffset=null!=r.chipWaveStartOffset?r.chipWaveStartOffset:0),i.samplesLoaded++,i.statusTable[s]=1,o.dispatchEvent(new n(i.totalSamples,i.samplesLoaded)),h||(h=!0,t.close())})).catch((n=>{i.statusTable[s]=2,alert("Failed to load "+e+":\n"+n),h||(h=!0,t.close())}))}))}function l(e){return new Promise(((t,s)=>{if(!p.willReloadForCustomSamples){const s=document.createElement("script");s.src=e,document.head.appendChild(s),s.addEventListener("load",(e=>{t()}))}}))}function h(e){const t=p.chipWaves[0].samples,s=p.rawRawChipWaves[0].samples;if(0==e){const e=[{name:"paandorasbox kick",expression:4,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"paandorasbox snare",expression:3,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"paandorasbox piano1",expression:3,isSampled:!0,isPercussion:!1,extraSampleDetune:2},{name:"paandorasbox WOW",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:0},{name:"paandorasbox overdrive",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-2},{name:"paandorasbox trumpet",expression:3,isSampled:!0,isPercussion:!1,extraSampleDetune:1.2},{name:"paandorasbox saxophone",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-5},{name:"paandorasbox orchestrahit",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:4.2},{name:"paandorasbox detatched violin",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:4.2},{name:"paandorasbox synth",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-.8},{name:"paandorasbox sonic3snare",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"paandorasbox come on",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:0},{name:"paandorasbox choir",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-3},{name:"paandorasbox overdriveguitar",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-6.2},{name:"paandorasbox flute",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-6},{name:"paandorasbox legato violin",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-28},{name:"paandorasbox tremolo violin",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-33},{name:"paandorasbox amen break",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-55},{name:"paandorasbox pizzicato violin",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-11},{name:"paandorasbox tim allen grunt",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-20},{name:"paandorasbox tuba",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:44},{name:"paandorasbox loopingcymbal",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-17},{name:"paandorasbox standardkick",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:-7},{name:"paandorasbox standardsnare",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"paandorasbox closedhihat",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:5},{name:"paandorasbox foothihat",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:4},{name:"paandorasbox openhihat",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:-31},{name:"paandorasbox crashcymbal",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:-43},{name:"paandorasbox pianoC4",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-42.5},{name:"paandorasbox liver pad",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-22.5},{name:"paandorasbox marimba",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-15.5},{name:"paandorasbox susdotwav",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-24.5},{name:"paandorasbox wackyboxtts",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-17.5},{name:"paandorasbox peppersteak_1",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-42.2},{name:"paandorasbox peppersteak_2",expression:2,isSampled:!0,isPercussion:!1,extraSampleDetune:-47},{name:"paandorasbox vinyl_noise",expression:2,isSampled:!0,isPercussion:!0,extraSampleDetune:-50},{name:"paandorasbeta slap bass",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-56},{name:"paandorasbeta HD EB overdrive guitar",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-60},{name:"paandorasbeta sunsoft bass",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-18.5},{name:"paandorasbeta masculine choir",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-50},{name:"paandorasbeta feminine choir",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-60.5},{name:"paandorasbeta tololoche",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-29.5},{name:"paandorasbeta harp",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-54},{name:"paandorasbeta pan flute",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-58},{name:"paandorasbeta krumhorn",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-46},{name:"paandorasbeta timpani",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-50},{name:"paandorasbeta crowd hey",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-29},{name:"paandorasbeta wario land 4 brass",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-68},{name:"paandorasbeta wario land 4 rock organ",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-63},{name:"paandorasbeta wario land 4 DAOW",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-35},{name:"paandorasbeta wario land 4 hour chime",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-47.5},{name:"paandorasbeta wario land 4 tick",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-12.5},{name:"paandorasbeta kirby kick",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-46.5},{name:"paandorasbeta kirby snare",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-46.5},{name:"paandorasbeta kirby bongo",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-46.5},{name:"paandorasbeta kirby click",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-46.5},{name:"paandorasbeta sonor kick",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-28.5},{name:"paandorasbeta sonor snare",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-28.5},{name:"paandorasbeta sonor snare (left hand)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-22.5},{name:"paandorasbeta sonor snare (right hand)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-22.5},{name:"paandorasbeta sonor high tom",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-41.5},{name:"paandorasbeta sonor low tom",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-41.5},{name:"paandorasbeta sonor hihat (closed)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-17},{name:"paandorasbeta sonor hihat (half opened)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-21},{name:"paandorasbeta sonor hihat (open)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-54.5},{name:"paandorasbeta sonor hihat (open tip)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-43.5},{name:"paandorasbeta sonor hihat (pedal)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-28},{name:"paandorasbeta sonor crash",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-51},{name:"paandorasbeta sonor crash (tip)",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-50.5},{name:"paandorasbeta sonor ride",expression:1,isSampled:!0,isPercussion:!0,extraSampleDetune:-46}];i.totalSamples+=e.length;const a=p.rawRawChipWaves.length;for(const n of e){const e=p.rawRawChipWaves.length,a={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:s},o={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:s},r={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:t};p.rawRawChipWaves[e]=o,p.rawRawChipWaves.dictionary[n.name]=o,p.rawChipWaves[e]=a,p.rawChipWaves.dictionary[n.name]=a,p.chipWaves[e]=r,p.chipWaves.dictionary[n.name]=a,i.statusTable[e]=0,i.urlTable[e]="legacySamples"}l("samples.js").then((()=>l("samples2.js"))).then((()=>l("samples3.js"))).then((()=>l("drumsamples.js"))).then((()=>l("wario_samples.js"))).then((()=>l("kirby_samples.js"))).then((()=>{const e=[c(kicksample),c(snaresample),c(pianosample),c(WOWsample),c(overdrivesample),c(trumpetsample),c(saxophonesample),c(orchhitsample),c(detatchedviolinsample),c(synthsample),c(sonic3snaresample),c(comeonsample),c(choirsample),c(overdrivensample),c(flutesample),c(legatoviolinsample),c(tremoloviolinsample),c(amenbreaksample),c(pizzicatoviolinsample),c(timallengruntsample),c(tubasample),c(loopingcymbalsample),c(kickdrumsample),c(snaredrumsample),c(closedhihatsample),c(foothihatsample),c(openhihatsample),c(crashsample),c(pianoC4sample),c(liverpadsample),c(marimbasample),c(susdotwavsample),c(wackyboxttssample),c(peppersteak1),c(peppersteak2),c(vinyl),c(slapbass),c(hdeboverdrive),c(sunsoftbass),c(masculinechoir),c(femininechoir),c(southtololoche),c(harp),c(panflute),c(krumhorn),c(timpani),c(crowdhey),c(warioland4brass),c(warioland4organ),c(warioland4daow),c(warioland4hourchime),c(warioland4tick),c(kirbykick),c(kirbysnare),c(kirbybongo),c(kirbyclick),c(funkkick),c(funksnare),c(funksnareleft),c(funksnareright),c(funktomhigh),c(funktomlow),c(funkhihatclosed),c(funkhihathalfopen),c(funkhihatopen),c(funkhihatopentip),c(funkhihatfoot),c(funkcrash),c(funkcrashtip),c(funkride)];let t=0;for(const s of e){const e=a+t;p.rawChipWaves[e].samples=s,p.rawRawChipWaves[e].samples=s,p.chipWaves[e].samples=f(s),i.statusTable[e]=1,i.samplesLoaded++,o.dispatchEvent(new n(i.totalSamples,i.samplesLoaded)),t++}}))}else if(1==e){const e=[{name:"chronoperc1final",expression:4,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"synthkickfm",expression:4,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"mcwoodclick1",expression:4,isSampled:!0,isPercussion:!0,extraSampleDetune:0},{name:"acoustic snare",expression:4,isSampled:!0,isPercussion:!0,extraSampleDetune:0}];i.totalSamples+=e.length;const a=p.rawRawChipWaves.length;for(const n of e){const e=p.rawRawChipWaves.length,a={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:s},o={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:s},r={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:t};p.rawRawChipWaves[e]=o,p.rawRawChipWaves.dictionary[n.name]=o,p.rawChipWaves[e]=a,p.rawChipWaves.dictionary[n.name]=a,p.chipWaves[e]=r,p.chipWaves.dictionary[n.name]=a,i.statusTable[e]=0,i.urlTable[e]="nintariboxSamples"}l("nintaribox_samples.js").then((()=>{const e=[c(chronoperc1finalsample),c(synthkickfmsample),c(woodclicksample),c(acousticsnaresample)];let t=0;for(const s of e){const e=a+t;p.rawChipWaves[e].samples=s,p.rawRawChipWaves[e].samples=s,p.chipWaves[e].samples=f(s),i.statusTable[e]=1,i.samplesLoaded++,o.dispatchEvent(new n(i.totalSamples,i.samplesLoaded)),t++}}))}else if(2==e){const e=[{name:"cat",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-3},{name:"gameboy",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:7},{name:"mario",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:0},{name:"drum",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:4},{name:"yoshi",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-16},{name:"star",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-16},{name:"fire flower",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-1},{name:"dog",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-1},{name:"oink",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:3},{name:"swan",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:1},{name:"face",expression:1,isSampled:!0,isPercussion:!1,extraSampleDetune:-12}];i.totalSamples+=e.length;const a=p.rawRawChipWaves.length;for(const n of e){const e=p.rawRawChipWaves.length,a={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:s},o={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:s},r={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:t};p.rawRawChipWaves[e]=o,p.rawRawChipWaves.dictionary[n.name]=o,p.rawChipWaves[e]=a,p.rawChipWaves.dictionary[n.name]=a,p.chipWaves[e]=r,p.chipWaves.dictionary[n.name]=a,i.statusTable[e]=0,i.urlTable[e]="marioPaintboxSamples"}l("mario_paintbox_samples.js").then((()=>{const e=[c(catpaintboxsample),c(gameboypaintboxsample),c(mariopaintboxsample),c(drumpaintboxsample),c(yoshipaintboxsample),c(starpaintboxsample),c(fireflowerpaintboxsample),c(dogpaintbox),c(oinkpaintbox),c(swanpaintboxsample),c(facepaintboxsample)];let t=0;for(const s of e){const e=a+t;p.rawChipWaves[e].samples=s,p.rawRawChipWaves[e].samples=s,p.chipWaves[e].samples=f(s),i.statusTable[e]=1,i.samplesLoaded++,o.dispatchEvent(new n(i.totalSamples,i.samplesLoaded)),t++}}))}else console.log("invalid set of built-in samples")}class p{}function c(e){let t=0;for(let s=0;s<e.length;s++)t+=e[s];const s=t/e.length;for(let t=0;t<e.length;t++)e[t]-=s;return f(e),e.push(0),new Float32Array(e)}function u(e){let t=0;c(e);for(let s=0;s<e.length-1;s++)t+=Math.abs(e[s]);const s=t/(e.length-1);for(let t=0;t<e.length-1;t++)e[t]=e[t]/s;return new Float32Array(e)}function f(e){let t=0,s=new Float32Array(e.length);for(let i=0;i<e.length;i++)s[i]=t,t+=e[i];return s}function m(e){return e/(2*p.pulseWidthRange)}function d(e,t,s){let i=p.chipNoises[e].samples;if(null==i){if(i=new Float32Array(p.chipNoiseLength+1),p.chipNoises[e].samples=i,0==e){let e=1;for(let t=0;t<p.chipNoiseLength;t++){i[t]=2*(1&e)-1;let s=e>>1;1==(e+s&1)&&(s+=16384),e=s}}else if(1==e)for(let e=0;e<p.chipNoiseLength;e++)i[e]=2*Math.random()-1;else if(2==e){let e=1;for(let t=0;t<p.chipNoiseLength;t++){i[t]=2*(1&e)-1;let s=e>>1;1==(e+s&1)&&(s+=32768),e=s}}else if(3==e){let e=1;for(let t=0;t<p.chipNoiseLength;t++){i[t]=2*(1&e)-1;let s=e>>1;1==(e+s&1)&&(s+=40),e=s}}else if(4==e)y(i,p.chipNoiseLength,10,11,1,1,0),y(i,p.chipNoiseLength,11,14,.6578,.6578,0),t(i,p.chipNoiseLength),s(i,1/Math.sqrt(p.chipNoiseLength));else if(5==e)for(var n=1,a=0;a<p.chipNoiseLength;a++){i[a]=2*(1&n)-1,1==(n+(o=n>>1)&1)&&(o+=40),n=o}else if(6==e)y(i,p.chipNoiseLength,1,10,1,1,0),y(i,p.chipNoiseLength,20,14,-2,-2,0),t(i,p.chipNoiseLength),s(i,1/Math.sqrt(p.chipNoiseLength));else if(7==e)for(n=1,a=0;a<p.chipNoiseLength;a++){i[a]=4*(1&n)*(14*Math.random()+1)-8,1==(n+(o=n>>1)&1)&&(o+=60),n=o}else if(8==e)for(n=1,a=0;a<p.chipNoiseLength;a++){i[a]=(1&n)/2-.5,1==(n+(o=n>>1)&1)&&(o-=40),n=o}else if(9==e){let e=1;for(let t=0;t<p.chipNoiseLength;t++){i[t]=2*(1&e)-1.1;let s=e>>1;1==(e+s&1)&&(s+=131080),e=s}}else if(10==e)for(let e=0;e<p.chipNoiseLength;e++)i[e]=Math.round(Math.random());else if(11==e)for(n=1,a=0;a<p.chipNoiseLength;a++){var o;i[a]=Math.round(1&n),1==(n+(o=n>>1)&1)&&(o-=40),n=o}else if(12==e)for(let e=0;e<p.chipNoiseLength;e++){var r=Math.random();i[e]=Math.pow(r,Math.clz32(r))}else if(13==e){var l,h,c,u,f=0,m=0,d=0;f=m=d=l=h=c=u=0;for(let e=0;e<p.chipNoiseLength;e++){f=.99886*f+.0555179*(g=2*Math.random()-1),m=.99332*m+.0750759*g,d=.969*d+.153852*g,l=.8665*l+.3104856*g,h=.55*h+.5329522*g,c=-.7616*c-.016898*g,i[e]=f+m+d+l+h+c+u+.5362*g,i[e]*=.44,u=.115926*g}}else{if(14!=e)throw new Error("Unrecognized drum index: "+e);var v=0;for(let e=0;e<p.chipNoiseLength;e++){var g=2*Math.random()-1;i[e]=(v+.02*g)/1.02,v=i[e],i[e]*=14}}i[p.chipNoiseLength]=i[0]}return i}function y(e,t,s,i,n,a,o){const r=0|Math.pow(2,s),l=Math.min(t>>1,0|Math.pow(2,i)),h=d(0,null,null);let p=0;for(let c=r;c<l;c++){let r=n+(a-n)*(Math.log2(c)-s)/(i-s),l=Math.pow(2,7*(r-1)+1)*r;l*=Math.pow(c/2048,o),p+=l,l*=h[c];const u=.61803398875*c*c*Math.PI*2;e[c]=Math.cos(u)*l,e[t-c]=Math.sin(u)*l}return p}function v(e=0){const t=new Float32Array(p.sineWaveLength+1),s=p.sineWaveLength/4;for(let i=0;i<p.sineWaveLength+1;i++)t[i]=2*+(Math.abs(i-s)<e*p.sineWaveLength/2||Math.abs(i-p.sineWaveLength-s)<e*p.sineWaveLength/2)-1;return t}function g(e=!1){const t=new Float32Array(p.sineWaveLength+1);for(let s=0;s<p.sineWaveLength+1;s++)t[s]=2*(s+p.sineWaveLength/4)/p.sineWaveLength%2-1,t[s]=e?-t[s]:t[s];return t}function b(e,t,s){let i=p.arpeggioPatterns[e-1];return null!=i?(2==e&&0==t&&(i=[0,0,1,1]),i[s%i.length]):s%e}function S(e){const t={};for(let s=0;s<e.length;s++){const i=e[s];i.index=s,t[i.name]=i}const s=e;return s.dictionary=t,s}function M(e){return 0!=(1024&e)}function w(e){return 0!=(2048&e)}function x(e){return 0!=(128&e)}function k(e){return 0!=(256&e)}function F(e){return 0!=(512&e)}function P(e){return 0!=(32&e)}function q(e){return 0!=(8&e)}function I(e){return 0!=(16&e)}function T(e){return 0!=(4&e)}function D(e){return 0!=(2&e)}function O(e){return 0!=(64&e)}function A(e){return 0!=(1&e)}p.thresholdVal=-10,p.kneeVal=40,p.ratioVal=12,p.attackVal=0,p.releaseVal=.25,p.willReloadForCustomSamples=!1,p.jsonFormat="Unbox",p.scales=S([{name:"Free",realName:"chromatic",flags:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},{name:"Major",realName:"ionian",flags:[!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!1,!0]},{name:"Minor",realName:"aeolian",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!0,!1,!0,!1]},{name:"Mixolydian",realName:"mixolydian",flags:[!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!0,!1]},{name:"Lydian",realName:"lydian",flags:[!0,!1,!0,!1,!0,!1,!0,!0,!1,!0,!1,!0]},{name:"Dorian",realName:"dorian",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!1,!0,!0,!1]},{name:"Phrygian",realName:"phrygian",flags:[!0,!0,!1,!0,!1,!0,!1,!0,!0,!1,!0,!1]},{name:"Locrian",realName:"locrian",flags:[!0,!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!1]},{name:"Lydian Dominant",realName:"lydian dominant",flags:[!0,!1,!0,!1,!0,!1,!0,!0,!1,!0,!0,!1]},{name:"Phrygian Dominant",realName:"phrygian dominant",flags:[!0,!0,!1,!1,!0,!0,!1,!0,!0,!1,!0,!1]},{name:"Harmonic Major",realName:"harmonic major",flags:[!0,!1,!0,!1,!0,!0,!1,!0,!0,!1,!1,!0]},{name:"Harmonic Minor",realName:"harmonic minor",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!0,!1,!1,!0]},{name:"Melodic Minor",realName:"melodic minor",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!1,!0,!1,!0]},{name:"Blues",realName:"blues",flags:[!0,!1,!1,!0,!1,!0,!0,!0,!1,!1,!0,!1]},{name:"Altered",realName:"altered",flags:[!0,!0,!1,!0,!0,!1,!0,!1,!0,!1,!0,!1]},{name:"Major Pentatonic",realName:"major pentatonic",flags:[!0,!1,!0,!1,!0,!1,!1,!0,!1,!0,!1,!1]},{name:"Minor Pentatonic",realName:"minor pentatonic",flags:[!0,!1,!1,!0,!1,!0,!1,!0,!1,!1,!0,!1]},{name:"Whole Tone",realName:"whole tone",flags:[!0,!1,!0,!1,!0,!1,!0,!1,!0,!1,!0,!1]},{name:"Octatonic",realName:"octatonic",flags:[!0,!1,!0,!0,!1,!0,!0,!1,!0,!0,!1,!0]},{name:"Hexatonic",realName:"hexatonic",flags:[!0,!1,!1,!0,!0,!1,!1,!0,!0,!1,!1,!0]},{name:"No Dabbing",realName:"no dabbing",flags:[!0,!0,!1,!0,!0,!0,!0,!0,!0,!1,!0,!1]},{name:"Jacked Toad",realName:"jacked toad",flags:[!0,!1,!0,!0,!1,!0,!0,!0,!0,!1,!0,!0]},{name:"Dumb",realName:"Originally named, currently named, and will always be named 'dumb.'",flags:[!0,!1,!1,!1,!1,!0,!0,!0,!0,!1,!1,!0]},{name:"Test Scale",realName:"**t",flags:[!0,!0,!1,!1,!1,!0,!0,!1,!1,!0,!0,!1]},{name:"die",realName:"death",flags:[!0,!1,!1,!1,!1,!1,!1,!1,!0,!1,!1,!1]},{name:"Custom",realName:"custom",flags:[!0,!1,!0,!0,!1,!1,!1,!0,!0,!1,!0,!0]}]),p.keys=S([{name:"C",isWhiteKey:!0,basePitch:12},{name:"C♯",isWhiteKey:!1,basePitch:13},{name:"D",isWhiteKey:!0,basePitch:14},{name:"D♯",isWhiteKey:!1,basePitch:15},{name:"E",isWhiteKey:!0,basePitch:16},{name:"F",isWhiteKey:!0,basePitch:17},{name:"F♯",isWhiteKey:!1,basePitch:18},{name:"G",isWhiteKey:!0,basePitch:19},{name:"G♯",isWhiteKey:!1,basePitch:20},{name:"A",isWhiteKey:!0,basePitch:21},{name:"A♯",isWhiteKey:!1,basePitch:22},{name:"B",isWhiteKey:!0,basePitch:23}]),p.blackKeyNameParents=[-1,1,-1,1,-1,1,-1,-1,1,-1,1,-1],p.tempoMin=1,p.tempoMax=1e3,p.octaveMin=-2,p.octaveMax=2,p.echoDelayRange=24,p.echoDelayStepTicks=4,p.echoSustainRange=8,p.echoShelfHz=4e3,p.echoShelfGain=Math.pow(2,-.5),p.reverbShelfHz=8e3,p.reverbShelfGain=Math.pow(2,-1.5),p.reverbRange=32,p.reverbDelayBufferSize=16384,p.reverbDelayBufferMask=p.reverbDelayBufferSize-1,p.beatsPerBarMin=1,p.beatsPerBarMax=64,p.barCountMin=1,p.barCountMax=1024,p.instrumentCountMin=1,p.layeredInstrumentCountMax=10,p.patternInstrumentCountMax=10,p.partsPerBeat=24,p.ticksPerPart=2,p.ticksPerArpeggio=3,p.arpeggioPatterns=[[0],[0,1],[0,1,2,1],[0,1,2,3],[0,1,2,3,4],[0,1,2,3,4,5],[0,1,2,3,4,5,6],[0,1,2,3,4,5,6,7]],p.rhythms=S([{name:"÷1 (whole notes)",stepsPerBeat:1,roundUpThresholds:[3]},{name:"÷2 (half notes)",stepsPerBeat:2,roundUpThresholds:[3,9]},{name:"÷3 (triplets)",stepsPerBeat:3,roundUpThresholds:[5,12,18]},{name:"÷4 (standard)",stepsPerBeat:4,roundUpThresholds:[3,9,17,21]},{name:"÷6 (sextuplets)",stepsPerBeat:6,roundUpThresholds:null},{name:"÷8 (eighth notes)",stepsPerBeat:8,roundUpThresholds:null},{name:"÷12 (twelfth notes)",stepsPerBeat:12,roundUpThresholds:null},{name:"÷24 (twenty-fourth notes)",stepsPerBeat:24,roundUpThresholds:null}]),p.instrumentTypeNames=["chip","FM","noise","spectrum","drumset","harmonics","PWM","duty cycle","Picked String","supersaw","custom chip","mod","FM6op"],p.instrumentTypeHasSpecialInterval=[!0,!0,!1,!1,!1,!0,!1,!1,!1,!1,!1],p.chipBaseExpression=.03375,p.fmBaseExpression=.03,p.noiseBaseExpression=.19,p.spectrumBaseExpression=.3,p.drumsetBaseExpression=.45,p.harmonicsBaseExpression=.025,p.pwmBaseExpression=.04725,p.supersawBaseExpression=.061425,p.pickedStringBaseExpression=.025,p.distortionBaseVolume=.011,p.bitcrusherBaseVolume=.01,p.rawChipWaves=S([{name:"rounded",expression:.94,samples:c([0,.2,.4,.5,.6,.7,.8,.85,.9,.95,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,.95,.9,.85,.8,.7,.6,.5,.4,.2,0,-.2,-.4,-.5,-.6,-.7,-.8,-.85,-.9,-.95,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-.95,-.9,-.85,-.8,-.7,-.6,-.5,-.4,-.2])},{name:"triangle",expression:1,samples:c([1/15,.2,5/15,7/15,.6,11/15,13/15,1,1,13/15,11/15,.6,7/15,5/15,.2,1/15,-1/15,-.2,-5/15,-7/15,-.6,-11/15,-13/15,-1,-1,-13/15,-11/15,-.6,-7/15,-5/15,-.2,-1/15])},{name:"square",expression:.5,samples:c([1,-1])},{name:"1/4 pulse",expression:.5,samples:c([1,-1,-1,-1])},{name:"1/8 pulse",expression:.5,samples:c([1,-1,-1,-1,-1,-1,-1,-1])},{name:"sawtooth",expression:.65,samples:c([1/31,3/31,5/31,7/31,9/31,11/31,13/31,15/31,17/31,19/31,21/31,23/31,25/31,27/31,29/31,1,-1,-29/31,-27/31,-25/31,-23/31,-21/31,-19/31,-17/31,-15/31,-13/31,-11/31,-9/31,-7/31,-5/31,-3/31,-1/31])},{name:"double saw",expression:.5,samples:c([0,-.2,-.4,-.6,-.8,-1,1,-.8,-.6,-.4,-.2,1,.8,.6,.4,.2])},{name:"double pulse",expression:.4,samples:c([1,1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1])},{name:"spiky",expression:.4,samples:c([1,-1,1,-1,1,0])},{name:"sine",expression:.88,samples:u([8,9,11,12,13,14,15,15,15,15,14,14,13,11,10,9,7,6,4,3,2,1,0,0,0,0,1,1,2,4,5,6])},{name:"flute",expression:.8,samples:u([3,4,6,8,10,11,13,14,15,15,14,13,11,8,5,3])},{name:"harp",expression:.8,samples:u([0,3,3,3,4,5,5,6,7,8,9,11,11,13,13,15,15,14,12,11,10,9,8,7,7,5,4,3,2,1,0,0])},{name:"sharp clarinet",expression:.38,samples:u([0,0,0,1,1,8,8,9,9,9,8,8,8,8,8,9,9,7,9,9,10,4,0,0,0,0,0,0,0,0,0,0])},{name:"soft clarinet",expression:.45,samples:u([0,1,5,8,9,9,9,9,9,9,9,11,11,12,13,12,10,9,7,6,4,3,3,3,1,1,1,1,1,1,1,1])},{name:"alto sax",expression:.3,samples:u([5,5,6,4,3,6,8,7,2,1,5,6,5,4,5,7,9,11,13,14,14,14,14,13,10,8,7,7,4,3,4,2])},{name:"bassoon",expression:.35,samples:u([9,9,7,6,5,4,4,4,4,5,7,8,9,10,11,13,13,11,10,9,7,6,4,2,1,1,1,2,2,5,11,14])},{name:"trumpet",expression:.22,samples:u([10,11,8,6,5,5,5,6,7,7,7,7,6,6,7,7,7,7,7,6,6,6,6,6,6,6,6,7,8,9,11,14])},{name:"electric guitar",expression:.2,samples:u([11,12,12,10,6,6,8,0,2,4,8,10,9,10,1,7,11,3,6,6,8,13,14,2,0,12,8,4,13,11,10,13])},{name:"organ",expression:.2,samples:u([11,10,12,11,14,7,5,5,12,10,10,9,12,6,4,5,13,12,12,10,12,5,2,2,8,6,6,5,8,3,2,1])},{name:"pan flute",expression:.35,samples:u([1,4,7,6,7,9,7,7,11,12,13,15,13,11,11,12,13,10,7,5,3,6,10,7,3,3,1,0,1,0,1,0])},{name:"glitch",expression:.5,samples:c([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1])},{name:"trapezoid",expression:1,samples:c([1/15,.4,10/15,14/15,1,1,1,1,1,1,1,1,14/15,10/15,.4,1/15,-1/15,-.4,-10/15,-14/15,-1,-1,-1,-1,-1,-1,-1,-1,-14/15,-10/15,-.4,-1/15])},{name:"AY3 Buzzer",expression:.5,samples:c([-24,-24,-24,-24,-23,-23,-22,-22,-21,-21,-20,-20,-19,-19,-18,-17,-16,-15,-14,-13,-12,-11,-9,-7,-5,-2,1,4,8,12,17,24,24,17,12,8,4,1,-2,-5,-7,-9,-11,-12,-13,-14,-15,-16,-17,-18,-19,-19,-20,-20,-21,-21,-22,-22,-23,-23,-24,-24,-24,-24])},{name:"AY3 Half Buzzer ↑",expression:.5,samples:c([-24,-24,-24,-24,-23,-23,-23,-23,-23,-23,-23,-23,-22,-22,-22,-22,-21,-21,-21,-21,-20,-20,-20,-20,-19,-19,-18,-18,-17,-17,-16,-16,-15,-15,-14,-14,-13,-13,-12,-12,-10,-10,-9,-9,-7,-7,-5,-5,-3,-3,-1,-1,1,1,4,4,8,8,12,12,17,17,24,24])},{name:"AY3 Half Buzzer ↓",expression:.5,samples:c([24,24,17,17,12,12,8,8,4,4,1,1,-1,-1,-3,-3,-5,-5,-7,-7,-9,-9,-10,-10,-12,-12,-13,-13,-14,-14,-15,-15,-16,-16,-17,-17,-18,-18,-19,-19,-20,-20,-20,-20,-21,-21,-21,-21,-22,-22,-22,-22,-23,-23,-23,-23,-23,-23,-23,-23,-24,-24,-24,-24])},{name:"AY3 Pseudo Sine",expression:.5,samples:c([-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-22,-22,-22,-22,-20,-20,-20,-20,-12,-12,-12,-12,8,8,8,8,15,15,15,15,24,24,24,24,15,15,15,15,8,8,8,8,-12,-12,-12,-12,-20,-20,-20,-20,-22,-22,-22,-22,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24])},{name:"Atari ST Kick",expression:.5,samples:c([-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-16,-0,9,17,19,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,23,19,17,9,-0,-16,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24])},{name:"C64 TriPulse",expression:.5,samples:u([-24,-24,-24,-24,-24,-24,-24,-24,-24,0,-24,-24,-24,-24,-24,-24,-17,-24,-5,4,14,-8,8,4,9,11,16,14,15,19,21,24,24,21,19,15,14,16,11,9,4,8,-8,14,4,-6,-24,-17,-24,-24,-24,-24,-24,0,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24])},{name:"C64 PulseSaw",expression:.5,samples:u([-1,1,-23,-24,-23,-24,-23,-24,-18,-24,-23,-24,-23,-21,-16,-13,-10,-24,-23,-24,-23,-24,-23,-24,-18,-24,-23,-7,4,17,19,20,21,22,23,24,-23,-24,-23,-24,-18,-24,-23,-24,-23,-21,-16,-13,-10,-24,-23,-24,-23,-24,-23,-24,-18,-24,-23,-24,-23,-24,-3,-2])},{name:"C64 SawTri",expression:.5,samples:u([0,-24,-24,-23,-23,-24,-24,-21,-20,-24,-24,-23,-23,-24,-24,-17,-16,-24,-24,-23,-23,-24,-24,-21,-20,-24,-24,-23,-23,-24,17,20,22,24,-24,-23,-23,-24,-24,-21,-20,-24,-24,-23,-23,-24,-24,-17,-16,-24,-24,-23,-23,-24,-24,-21,-20,-24,-24,-23,-23,-24,-24,-2])},{name:"C64 All",expression:.5,samples:u([-9,-24,-23,-24,-23,-24,-23,-24,-20,-24,-23,-24,-23,-24,-23,-20,-18,-24,-23,-24,-23,-24,-23,-24,-20,-24,-23,-24,-23,-24,18,20,22,24,-24,-23,-24,-23,-24,-21,-20,-23,-24,-23,-24,-23,-24,-20,-18,-23,-24,-23,-24,-23,-24,-21,-20,-23,-24,-23,-24,-23,-24,-11])},{name:"Alt sawtooth",expression:.65,samples:c([-1/31,-3/31,-5/31,-7/31,-9/31,-11/31,-13/31,-15/31,-17/31,-19/31,-21/31,-23/31,-25/31,-27/31,-29/31,-1,1,29/31,27/31,25/31,23/31,21/31,19/31,17/31,15/31,13/31,11/31,9/31,7/31,5/31,3/31,1/31])},{name:"Rising Saw",expression:.5,samples:u([-23,-22,-21,-21,-20,-19,-18,-18,-17,-16,-15,-15,-14,-13,-12,-12,-11,-10,-9,-9,-8,-7,-6,-6,-5,-4,-3,-3,-2,-1,0,0,1,2,3,3,4,5,6,6,7,8,9,9,10,11,12,12,13,14,15,15,16,17,18,18,19,20,21,21,22,23,24,24])},{name:"Falling Saw",expression:.5,samples:u([23,22,21,21,20,19,18,18,17,16,15,15,14,13,12,12,11,10,9,9,8,7,6,6,5,4,3,3,2,1,-0,-0,-1,-2,-3,-3,-4,-5,-6,-6,-7,-8,-9,-9,-10,-11,-12,-12,-13,-14,-15,-15,-16,-17,-18,-18,-19,-20,-21,-21,-22,-23,-24,-24])},{name:"Sync Buzzer Test",expression:.5,samples:u([24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,22,18,15,11,7,4,1,-2,-6,-9,-12,-15,-18,-20,-22,-24,-24,-22,-20,-18,-15,-12,-9,-6,-2,1,4,7,11,15,18,23])},{name:"Atari Pokey 1",expression:.5,samples:u([24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,24,24,24,24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,24,-24,-24,-24,-24])},{name:"Atari Pokey 2",expression:.5,samples:u([-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,24,24,24,24,24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,24,-24,-24,-24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24])},{name:"modbox 10% pulse",expression:.5,samples:u([1,-1,-1,-1,-1,-1,-1,-1,-1,-1])},{name:"modbox sunsoft bass",expression:1,samples:u([0,.1875,.3125,.5625,.5,.75,.875,1,1,.6875,.5,.625,.625,.5,.375,.5625,.4375,.5625,.4375,.4375,.3125,.1875,.1875,.375,.5625,.5625,.5625,.5625,.5625,.4375,.25,0])},{name:"modbox loud pulse",expression:.5,samples:u([1,.7,.1,.1,0,0,0,0,0,.1,.2,.15,.25,.125,.215,.345,4])},{name:"modbox sax",expression:.5,samples:u([1/15,.2,5/15,9,.06])},{name:"modbox guitar",expression:.5,samples:u([-.5,3.5,3,-.5,-.25,-1])},{name:"modbox sine",expression:.5,samples:u([0,.05,.125,.2,.25,.3,.425,.475,.525,.625,.675,.725,.775,.8,.825,.875,.9,.925,.95,.975,.98,.99,.995,1,.995,.99,.98,.975,.95,.925,.9,.875,.825,.8,.775,.725,.675,.625,.525,.475,.425,.3,.25,.2,.125,.05,0,-.05,-.125,-.2,-.25,-.3,-.425,-.475,-.525,-.625,-.675,-.725,-.775,-.8,-.825,-.875,-.9,-.925,-.95,-.975,-.98,-.99,-.995,-1,-.995,-.99,-.98,-.975,-.95,-.925,-.9,-.875,-.825,-.8,-.775,-.725,-.675,-.625,-.525,-.475,-.425,-.3,-.25,-.2,-.125,-.05])},{name:"modbox atari bass",expression:.5,samples:u([1,1,1,1,0,1,0,1,1,0,0,1,0,0,0])},{name:"modbox atari pulse",expression:.5,samples:u([1,0,1,1,1,1,1,1,1,1,1,1,1,1,1])},{name:"modbox 1% pulse",expression:.5,samples:u([1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])},{name:"modbox curved sawtooth",expression:.5,samples:u([1,.5,1/3,1/4])},{name:"modbox viola",expression:.45,samples:u([-.9,-1,-.85,-.775,-.7,-.6,-.5,-.4,-.325,-.225,-.2,-.125,-.1,-.11,-.125,-.15,-.175,-.18,-.2,-.21,-.22,-.21,-.2,-.175,-.15,-.1,-.5,.75,.11,.175,.2,.25,.26,.275,.26,.25,.225,.2,.19,.18,.19,.2,.21,.22,.23,.24,.25,.26,.275,.28,.29,.3,.29,.28,.27,.26,.25,.225,.2,.175,.15,.1,.075,0,-.01,-.025,.025,.075,.2,.3,.475,.6,.75,.85,.85,1,.99,.95,.8,.675,.475,.275,.01,-.15,-.3,-.475,-.5,-.6,-.71,-.81,-.9,-1,-.9])},{name:"modbox brass",expression:.45,samples:u([-1,-.95,-.975,-.9,-.85,-.8,-.775,-.65,-.6,-.5,-.475,-.35,-.275,-.2,-.125,-.05,0,.075,.125,.15,.2,.21,.225,.25,.225,.21,.2,.19,.175,.125,.1,.075,.06,.05,.04,.025,.04,.05,.1,.15,.225,.325,.425,.575,.7,.85,.95,1,.9,.675,.375,.2,.275,.4,.5,.55,.6,.625,.65,.65,.65,.65,.64,.6,.55,.5,.4,.325,.25,.15,.05,-.05,-.15,-.275,-.35,-.45,-.55,-.65,-.7,-.78,-.825,-.9,-.925,-.95,-.975])},{name:"modbox acoustic bass",expression:.5,samples:u([1,0,.1,-.1,-.2,-.4,-.3,-1])},{name:"modbox lyre",expression:.45,samples:u([1,-1,4,2.15,4.13,5.15,0,-.05,1])},{name:"modbox ramp pulse",expression:.5,samples:u([6.1,-2.9,1.4,-2.9])},{name:"modbox piccolo",expression:.5,samples:u([1,4,2,1,-.1,-1,-.12])},{name:"modbox squaretooth",expression:.5,samples:u([.2,1,2.6,1,0,-2.4])},{name:"modbox flatline",expression:1,samples:u([1,.9,.8,.7,.6,.5,.4,.3,.2,.1,0,.1,.2,.3,.4,.5,.6,.7,.8,.9])},{name:"modbox pnryshk a (u5)",expression:.4,samples:u([1,.9,.8,.7,.6,.5,.4,.3,.2,.1,0])},{name:"modbox pnryshk b (riff)",expression:.5,samples:u([1,-.9,.8,-.7,.6,-.5,.4,-.3,.2,-.1,0,-.1,.2,-.3,.4,-.5,.6,-.7,.8,-.9,1])},{name:"sandbox shrill lute",expression:.94,samples:u([1,1.5,1.25,1.2,1.3,1.5])},{name:"sandbox bassoon",expression:.5,samples:u([1,-1,1,1,1,1,1,1,1,1,1,1,0])},{name:"sandbox shrill bass",expression:.5,samples:u([0,1,0,0,1,0,1,0,0,0])},{name:"sandbox nes pulse",expression:.4,samples:u([2.1,-2.2,1.2,3])},{name:"sandbox saw bass",expression:.25,samples:u([1,1,1,1,0,2,1,2,3,1,-2,1,4,1,4,2,1,6,-3,4,2,1,5,1,4,1,5,6,7,1,6,1,4,1,9])},{name:"sandbox euphonium",expression:.3,samples:u([0,1,2,1,2,1,4,2,5,0,-2,1,5,1,2,1,2,4,5,1,5,-2,5,10,1])},{name:"sandbox shrill pulse",expression:.3,samples:u([2,0,4,1,4,6,7,3])},{name:"sandbox r-sawtooth",expression:.2,samples:u([6.1,-2.9,1.4,-2.9])},{name:"sandbox recorder",expression:.2,samples:u([5,-5.1,4,-4.1,3,-3.1,2,-2.1,1,-1.1,6])},{name:"sandbox narrow saw",expression:1.2,samples:u([.1,-1.3,.13/-.3,-.26,.13/-.7,.13/-.9,.13/-.11,.13/-.31,.13/-.51,.13/-.71,.13/-.91,.13/-.12,-.40625,-.25,.13/-.72,.13/-.92,-1,1,.13/.92,.13/.72,.25,.40625,.13/.12,.13/.91,.13/.71,.13/.51,.13/.31,.13/.11,.13/.9,.13/.7,.26,.13/.3,.13])},{name:"sandbox deep square",expression:1,samples:u([1,2.25,1,-1,-2.25,-1])},{name:"sandbox ring pulse",expression:1,samples:u([1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,-1,-1,-1,-1])},{name:"sandbox double sine",expression:1,samples:u([1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,1.8,1.7,1.6,1.5,1.4,1.3,1.2,1.1,1,0,-1,-1.1,-1.2,-1.3,-1.4,-1.5,-1.6,-1.7,-1.8,-1.9,-1.8,-1.7,-1.6,-1.5,-1.4,-1.3,-1.2,-1.1,-1])},{name:"sandbox contrabass",expression:.5,samples:u([4.2,6.9,1.337,6.66])},{name:"sandbox double bass",expression:.4,samples:u([0,.1875,.3125,.5625,.5,.75,.875,1,-1,-.6875,-.5,-.625,-.625,-.5,-.375,-.5625,-.4375,-.5625,-.4375,-.4375,-.3125,-.1875,.1875,.375,.5625,-.5625,.5625,.5625,.5625,.4375,.25,0])},{name:"haileybox test1",expression:.5,samples:u([1,.5,-1])},{name:"brucebox pokey 4bit lfsr",expression:.5,samples:u([1,-1,-1,-1,1,1,1,1,-1,1,-1,1,1,-1,-1])},{name:"brucebox pokey 5step bass",expression:.5,samples:u([1,-1,1,-1,1])},{name:"brucebox isolated spiky",expression:.5,samples:u([1,-1,1,-1,1,-1])},{name:"nerdbox unnamed 1",expression:.5,samples:u([.2,4,.7,-.4,-1,.5,-.5/.6])},{name:"nerdbox unnamed 2",expression:.5,samples:u([2,5/55,-9,1,-55,18.5/-26])},{name:"zefbox semi-square",expression:1,samples:u([1,1.5,2,2.5,2.5,2.5,2,1.5,1])},{name:"zefbox deep square",expression:1,samples:u([1,2.25,1,-1,-2.25,-1])},{name:"zefbox squaretal",expression:.7,samples:u([1.5,1,1.5,-1.5,-1,-1.5])},{name:"zefbox saw wide",expression:.65,samples:u([0,-.4,-.8,-1.2,-1.6,-2,0,-.4,-.8,-1.2,-1.6])},{name:"zefbox saw narrow",expression:.65,samples:u([1,.5,1,.5,1,.5,1,2,1,2,1])},{name:"zefbox deep sawtooth",expression:.5,samples:u([0,2,3,4,4.5,5,5.5,6,6.25,6.5,6.75,7,6.75,6.5,6.25,6,5.5,5,4.5,4,3,2,1])},{name:"zefbox sawtal",expression:.3,samples:u([1.5,1,1.25,-.5,1.5,-.5,0,-1.5,1.5,0,.5,-1.5,.5,1.25,-1,-1.5])},{name:"zefbox deep sawtal",expression:.7,samples:u([.75,.25,.5,-.5,.5,-.5,-.25,-.75])},{name:"zefbox pulse",expression:.5,samples:u([1,-2,-2,-1.5,-1.5,-1.25,-1.25,-1,-1])},{name:"zefbox triple pulse",expression:.4,samples:u([1,1,1,1,1,-1,-1,1.5,1,1,1,1,-1,-1,-1,1.5])},{name:"zefbox high pulse",expression:.2,samples:u([1,-2,2,-3,3,-4,5,-4,3,-3,2,-2,1])},{name:"zefbox deep pulse",expression:.2,samples:u([1,2,2,-2,-2,-3,-4,-4,-5,-5,-5,-5,0,-1,-2])},{name:"wackybox guitar string",expression:.6,samples:u([0,63,63,63,63,19,63,63,63,63,63,63,63,63,63,63,11,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,27,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,34,63,63,63,63])},{name:"wackybox intense",expression:.6,samples:u([36,25,33,35,18,51,22,40,27,37,31,33,25,29,41,23,31,31,45,20,37,23,29,26,42,29,33,26,31,27,40,25,40,26,37,24,41,32,0,32,33,29,32,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31])},{name:"wackybox buzz wave",expression:.6,samples:u([0,1,1,2,4,4,4,4,5,5,6,6,6,7,8,8,8,9,9,9,9,9,9,8,8,8,11,15,23,62,61,60,58,56,56,54,53,52,50,49,48,47,47,45,45,45,44,44,43,43,42,42,42,42,42,42,42,42,42,42,42,43,43,53])},{name:"todbox 1/3 pulse",expression:.5,samples:c([1,-1,-1])},{name:"todbox 1/5 pulse",expression:.5,samples:c([1,-1,-1,-1,-1])},{name:"todbox slap bass",expression:.5,samples:u([1,.5,0,.5,1.25,.5,-.25,.1,-.1,.1,1.1,2.1,3,3.5,2.9,3.3,2.7,2.9,2.3,2,1.9,1.8,1,.7,.9,.8,.4,.1,0,.2,.4,.6,.5,.8])},{name:"todbox harsh wave",expression:.45,samples:u([1,-1,-1,-1,.5,.5,.5,.7,.39,1.3,0,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])},{name:"todbox accordian",expression:.5,samples:u([0,1,1,2,2,1.5,1.5,.8,0,-2,-3.25,-4,-4.5,-5.5,-6,-5.75,-5.5,-5,-5,-5,-6,-6,-6,-5,-4,-3,-2,-1,.75,1,2,3,4,5,6,6.5,7.5,8,7.75,6,5.25,5,5,5,5,5,4.25,3.75,3.25,2.75,1.25,-.75,-2,-.75,1.25,1.25,2,2,2,2,1.5,-1,-2,-1,1.5,2,2.75,2.75,2.75,3,2.75,-1,-2,-2.5,-2,-1,-2.25,-2.75,-2,-3,-1.75,1,2,3.5,4,5.25,6,8,9.75,10,9.5,9,8.5,7.5,6.5,5.25,5,4.5,4,4,4,3.25,2.5,2,1,-.5,-2,-3.5,-4,-4,-4,-3.75,-3,-2,-1])},{name:"todbox beta banana wave",expression:.8,samples:u([0,.2,.4,.5,.6,.7,.8,.85,.9,.95,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,.95,.9,.85,.8,.7,.6,.5,.4,.2,0])},{name:"todbox beta test wave",expression:.5,samples:u([56,0,-52,16,3,3,2,-35,20,147,-53,0,0,5,-6])},{name:"todbox beta real snare",expression:1,samples:u([0,-.01208,-.02997,-.04382,-.06042,-.07529,-.09116,-.10654,-.12189,-.13751,-.15289,-.16849,-.18387,-.19974,-.21484,-.23071,-.24557,-.26144,-.27731,-.29141,-.3035,-.32416,-.34406,-.32947,-.31158,-.33725,-.37579,-.39746,-.40201,-.40906,-.4418,-.47229,-.47379,-.47733,-.45239,-.33954,-.22894,-.22443,-.32138,-.46371,-.57178,-.61081,-.59998,-.61459,-.62189,-.43979,-.19217,-.12643,-.17252,-.20956,-.20981,-.19217,-.22845,-.34332,-.50629,-.64307,-.72922,-.81384,-.87857,-.90149,-.88687,-.86169,-.87781,-.80478,-.52493,-.31308,-.33249,-.39395,-.39017,-.30301,-.19949,-.13071,-.02493,.14307,.34961,.52542,.63223,.68613,.7471,.87305,.98184,.98889,.97052,.99066,.99747,.99344,.99469,.99393,.9957,.99393,.99521,.99469,.9942,.99521,.9942,.99521,.99469,.99469,.99521,.9942,.99545,.99445,.99469,.99493,.9942,.99521,.99393,.99493,.99469,.99445,.9957,.99445,.99521,.99469,.99469,.99521,.9942,.99545,.99445,.99445,.99493,.9942,.99545,.9942,.99493,.99493,.9942,.99545,.99445,.99521,.99469,.99445,.99545,.99368,.99393,.99445,.99268,.97983,.97229,.95944,.88486,.76773,.64481,.53098,.39847,.19318,-.03827,-.20325,-.39319,-.68765,-.88461,-.93448,-.96069,-.97681,-.98715,-.99042,-.99142,-.99091,-.99142,-.99219,-.99091,-.99219,-.99066,-.99142,-.99142,-.99118,-.99191,-.99066,-.99191,-.99142,-.99142,-.99191,-.99091,-.99219,-.99118,-.99142,-.99167,-.99091,-.99219,-.99091,-.99167,-.99142,-.99091,-.99191,-.99091,-.99191,-.99142,-.99118,-.99191,-.99066,-.99191,-.99118,-.99142,-.99191,-.99066,-.99191,-.99091,-.99167,-.99191,-.99118,-.99219,-.99091,-.99191,-.99142,-.99142,-.99243,-.98865,-.98764,-.99219,-.98083,-.92517,-.9277,-.91486,-.59042,-.15189,.02945,.05667,.06195,.00629,-.18008,-.56497,-.8801,-.9277,-.92871,-.97705,-.99167,-.98663,-.99118,-.99042,-.99219,-.99142,-.99118,-.98941,-.99219,-1,-.9758,-.95993,-.99948,-.98236,-.84659,-.7486,-.70679,-.59747,-.48035,-.41687,-.36826,-.29745,-.18185,-.06219,.02164,.07907,.13123,.18033,.1962,.15692,.14053,.20251,.2753,.30905,.29092,.27252,.30402,.32416,.32214,.35239,.3967,.43198,.4942,.58487,.64154,.65967,.6705,.67026,.66522,.6554,.66119,.70627,.75842,.78738,.7894,.78763,.80402,.85944,.94559,.9899,.9816,.98007,.99368,.99393,.98538,.9758,.97101,.93802,.81812,.64633,.46649,.28613,.14685,.08966,.12543,.20325,.24557,.18866,.02795,-.20175,-.44205,-.58713,-.57629,-.41385,-.14255,.18033,.47882,.68311,.72314,.62064,.48309,.43073,.53577,.72794,.9025,.97354,.97,.98083,.99191,.99319,.99493,.99393,.99521,.99393,.99545,.9942,.99493,.99493,.99445,.99545,.9942,.99545,.99243,.98917,.98386,.97781,.95844,.89066,.81561,.78134,.77277,.75995,.73022,.67126,.57178,.47,.38361,.29419,.20703,.14734,.15866,.25162,.35818,.45062,.5675,.69748,.81232,.89697,.95062,.97656,.98615,.99191,.99219,.99243,.99368,.99368,.97028,.95566,.94559,.82617,.59973,.38361,.23901,.15338,.12921,.11206,.04382,-.12946,-.43552,-.72644,-.89847,-.95465,-.95541,-.97229,-.99268,-.99319,-.9884,-.99142,-.99167,-.99091,-.9884,-.98965,-.99368,-.97455,-.9501,-.94684,-.96219,-.98514,-.99243,-.98889,-.98917,-.99142,-.99219,-.99091,-.99191,-.99142,-.99142,-.99191,-.99066,-.99167,-.99091,-.99142,-.99191,-.99091,-.99191,-.99091,-.99167,-.99167,-.99091,-.99219,-.99091,-.99191,-.99142,-.99118,-.99191,-.99066,-.99191,-.99091,-.99118,-.99243,-.98941,-.98462,-.96976,-.9632,-.96194,-.87305,-.66196,-.44809,-.29495,-.18085,-.11813,-.11334,-.18564,-.34885,-.58237,-.8045,-.93726,-.97806,-.97354,-.97531,-.9899,-.99368,-.98941,-.99219,-.99091,-.99142,-.99167,-.99091,-.99191,-.99118,-.99219,-.98236,-.97781,-.97656,-.95135,-.87204,-.71335,-.52139,-.34232,-.17783,-.00906,.14886,.3045,.48889,.67404,.8403,.94128,.97681,.98462,.98337,.99142,.99521,.99493,.9942,.99445,.99521,.99393,.99545,.99445,.99521,.99521,.99445,.9957,.99445,.99521,.99469,.99445,.99521,.9942,.99521,.99445,.99445,.99521,.99445,.99545,.99445,.99469,.99493,.99393,.99493,.99445,.99393,.98285,.97781,.97479,.92844,.82114,.66095,.52417,.46826,.46722,.47934,.47379,.47076,.48209,.42014,.25439,.10074,-.00302,-.08966,-.16068,-.21436,-.2204,-.15137,-.00476,.18536,.37631,.52292,.62164,.70425,.74835,.72366,.63928,.52567,.40805,.35666,.42896,.60175,.802,.92743,.96548,.97632,.98337,.99066,.99521,.9942,.99368,.99292,.9884,.98083,.96774,.93323,.8544,.6947,.47202,.20425,-.0889,-.36423,-.60025,-.77481,-.90173,-.96017,-.97028,-.98108,-.9884,-.99219,-.9899,-.99219,-.99142,-.99142,-.99219,-.99091,-.99243,-.99066,-.99142,-.99142,-.99118,-.99191,-.99066,-.99167,-.99142,-.99142,-.99219,-.99091,-.99191,-.99118,-.99142,-.99191,-.99091,-.99191,-.99091,-.99167,-.99191,-.99118,-.99219,-.99091,-.99167,-.99142,-.99142,-.99219,-.99091,-.99191,-.99142,-.99118,-.98917,-.99042,-.99445,-.9733,-.9559,-.96219,-.8967,-.72241,-.55112,-.44809,-.39319,-.37833,-.35641,-.2627,-.1423,-.11282,-.13525,-.11536,-.09671,-.11511,-.1806,-.26874,-.33374,-.42215,-.51358,-.44785,-.3045,-.28613,-.30527,-.25037,-.1539,-.08286,-.11157,-.12592,-.00327,.13803,.19141,.1282,.01788,-.03952,-.12592,-.26773,-.34634,-.31384,-.1806,-.0108,.13574,.2612,.36975,.46573,.55087,.63626,.73022,.83072,.92014,.97177,.98587,.98413,.99167,.99445,.99292,.99219,.9874,.98007,.96472,.92239,.82166,.69067,.57959,.54962,.59695,.64255,.64633,.60629,.55942,.5491,.58966,.61887,.56952,.54181,.59518,.63248,.63876,.65463,.73398,.88312,.96927,.97101,.97958,.99344,.9942,.99268,.99493,.99469,.99445,.99521,.99445,.99545,.9942,.99493,.99493,.9942,.99545,.9942,.99493,.9942,.99393,.9942,.9884,.98309,.98309,.96069,.88461,.7937,.72064,.65765,.59998,.53247,.49268,.48615,.44205,.38034,.36447,.38715,.39294,.32645,.19595,.07782,-.05893,-.27832,-.48309,-.62619,-.72995,-.79999,-.84583,-.82166,-.73575,-.67227,-.65491,-.6496,-.66397,-.70175,-.72894,-.74658,-.76724,-.7952,-.82846,-.86523,-.90527,-.94382,-.89948,-.69849,-.47479,-.31662,-.15414,-.00729,.07077,.08237,.04431,-.02292,-.11761,-.24307,-.36926,-.45087,-.4617,-.4025,-.30679,-.17529,0,.14331,.24179,.36774,.49545,.56522,.57907,.56775,.53851,.51132,.48688,.41913,.26044,.00955,-.26297,-.46396,-.62341,-.82214,-.94684,-.96774,-.97531,-.98413,-.99017,-.9899,-.99219,-.99066,-.99142,-.99167,-.99118,-.99219,-.9899,-.99118,-.99368,-.99142,-.97757,-.97403,-.98007,-.9617,-.86826,-.67783,-.52719,-.48788,-.4549,-.43146,-.47681,-.54105,-.57983,-.60904,-.62317,-.59949,-.55566,-.52063,-.52115,-.55112,-.56244,-.58337,-.6554,-.73373,-.77228,-.74759,-.6889,-.64609,-.61887,-.5806,-.50351,-.40729,-.33929,-.3511,-.42944,-.47028,-.42267,-.32718,-.20224,-.0564,.04556,.10529,.1763,.26169,.33197,.32138,.23776,.20956,.23148,.20352,.23325,.39267,.52719,.58438,.62289,.66345,.70023,.66296,.5433,.42618,.33475,.24533,.14105,.03851,.01358,.09143,.22845,.34961,.41711,.4874,.58914,.69519,.78186,.84357,.89822,.95389,.98135,.98615,.99167,.99243,.99445,.9942,.99469,.99493,.99393,.99545,.99445,.99521,.99469,.99445,.99521,.9942,.99469,.98965,.98715,.98563,.96295,.91736,.86624,.82367,.77554,.68411,.53549,.38916,.2612,.11435,-.04053,-.18161,-.23172,-.19394,-.15237,-.1073,-.02997,.08588,.2262,.34305,.44104,.5574,.65765,.71259,.69217,.65363,.69748,.79572,.89368,.95514,.97733,.98413,.98816,.99243,.99445,.99243,.97302,.96674,.97983,.90378,.71005,.51056,.40451,.40982,.41559,.32996,.24356,.18866,.11411,.05365,.01157,-.03247,-.09216,-.16095,-.23248,-.31662,-.39771,-.48663,-.59647,-.71536,-.82013,-.85287,-.82947,-.84937,-.92215,-.97177,-.98663,-.98816,-.98438,-.99091,-.99219,-.99091,-.99191,-.99042,-.99191,-.99091,-.99142,-.99191,-.99091,-.99191,-.99091,-.99167,-.99142])},{name:"ultrabox shortened od guitar",expression:.5,samples:u([-.82785,-.67621,-.40268,-.43817,-.45468,-.22531,-.18329,.2475,.71246,.52155,.56082,.48395,.3399,.46957,.27744,.42313,.47104,.18796,.1293,-.13901,-.07431,-.16348,-.74857,-.73206,-.35181,-.26227,-.41882,-.27786,-.19806,-.19867,.18643,.24808,.08847,-.06964,.06912,.20474,-.05304,.29416,.31967,.14243,.27521,-.23932,-.14752,.1236,-.26123,-.26111,.06616,.2652,.0809,.1524,.16254,-.12061,.04562,.00131,.0405,.08182,-.21729,-.17041,-.16312,-.08563,.0639,.05099,.05627,.02728,.00726,-.13028,-.05673,-.14969,-.17645,.35492,.16766,-.00897,.24326,-.00461,-.04456,.01776,-.0495,-.01221,.02039,.07684,.13397,.3985,.35962,.13754,.4231,.27161,-.17609,.03659,.10635,-.21909,-.22046,-.20258,-.40973,-.4028,-.40521,-.66284])}]),p.chipWaves=function(e){const t=new Array(e.length),s={};for(let i=0;i<t.length;i++){t[i]=Object.assign([],e[i]);const n=t[i];n.index=i,s[n.name]=n}for(let e in s)s[e].samples=f(s[e].samples);const i=t;return i.dictionary=s,i}(p.rawChipWaves),p.rawRawChipWaves=p.rawChipWaves,p.firstIndexForSamplesInChipWaveList=p.chipWaves.length,p.chipNoises=S([{name:"retro",expression:.25,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"white",expression:1,basePitch:69,pitchFilterMult:8,isSoft:!0,samples:null},{name:"clang",expression:.4,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"buzz",expression:.3,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"hollow",expression:1.5,basePitch:96,pitchFilterMult:1,isSoft:!0,samples:null},{name:"shine",expression:1,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"deep",expression:1.5,basePitch:120,pitchFilterMult:1024,isSoft:!0,samples:null},{name:"cutter",expression:.005,basePitch:96,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"metallic",expression:1,basePitch:96,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"static",expression:1,basePitch:96,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"1-bit white",expression:.5,basePitch:74.41,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"1-bit metallic",expression:.5,basePitch:86.41,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"crackling",expression:.9,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"pink",expression:1,basePitch:69,pitchFilterMult:8,isSoft:!0,samples:null},{name:"brownian",expression:1,basePitch:69,pitchFilterMult:8,isSoft:!0,samples:null}]),p.filterFreqStep=1/4,p.filterFreqRange=34,p.filterFreqReferenceSetting=28,p.filterFreqReferenceHz=8e3,p.filterFreqMaxHz=p.filterFreqReferenceHz*Math.pow(2,p.filterFreqStep*(p.filterFreqRange-1-p.filterFreqReferenceSetting)),p.filterFreqMinHz=8,p.filterGainRange=15,p.filterGainCenter=7,p.filterGainStep=.5,p.filterMaxPoints=8,p.filterTypeNames=["low-pass","high-pass","peak"],p.filterMorphCount=10,p.filterSimpleCutRange=11,p.filterSimplePeakRange=8,p.fadeInRange=10,p.fadeOutTicks=[-24,-12,-6,-3,-1,6,12,24,48,72,96],p.fadeOutNeutral=4,p.drumsetFadeOutTicks=48,p.transitions=S([{name:"normal",isSeamless:!1,continues:!1,slides:!1,slideTicks:3,includeAdjacentPatterns:!1},{name:"interrupt",isSeamless:!0,continues:!1,slides:!1,slideTicks:3,includeAdjacentPatterns:!0},{name:"continue",isSeamless:!0,continues:!0,slides:!1,slideTicks:3,includeAdjacentPatterns:!0},{name:"slide",isSeamless:!0,continues:!1,slides:!0,slideTicks:3,includeAdjacentPatterns:!0},{name:"slide in pattern",isSeamless:!0,continues:!1,slides:!0,slideTicks:3,includeAdjacentPatterns:!1}]),p.vibratos=S([{name:"none",amplitude:0,type:0,delayTicks:0},{name:"light",amplitude:.15,type:0,delayTicks:0},{name:"delayed",amplitude:.3,type:0,delayTicks:37},{name:"heavy",amplitude:.45,type:0,delayTicks:0},{name:"shaky",amplitude:.1,type:1,delayTicks:0}]),p.vibratoTypes=S([{name:"normal",periodsSeconds:[.14],period:.14},{name:"shaky",periodsSeconds:[.11,.17798,.33],period:266.97}]),p.arpSpeedScale=[0,.0625,.125,.2,.25,1/3,.4,.5,2/3,.75,.8,.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.15,4.3,4.5,4.8,5,5.5,6,8],p.unisons=S([{name:"none",voices:1,spread:0,offset:0,expression:1.4,sign:1},{name:"shimmer",voices:2,spread:.018,offset:0,expression:.8,sign:1},{name:"hum",voices:2,spread:.045,offset:0,expression:1,sign:1},{name:"honky tonk",voices:2,spread:.09,offset:0,expression:1,sign:1},{name:"dissonant",voices:2,spread:.25,offset:0,expression:.9,sign:1},{name:"fifth",voices:2,spread:3.5,offset:3.5,expression:.9,sign:1},{name:"octave",voices:2,spread:6,offset:6,expression:.8,sign:1},{name:"bowed",voices:2,spread:.02,offset:0,expression:1,sign:-1},{name:"piano",voices:2,spread:.01,offset:0,expression:1,sign:.7},{name:"warbled",voices:2,spread:.25,offset:.05,expression:.9,sign:-.8},{name:"hecking gosh",voices:2,spread:6.25,offset:-6,expression:.8,sign:-.7},{name:"spinner",voices:2,spread:.02,offset:0,expression:1,sign:1},{name:"detune",voices:1,spread:0,offset:.25,expression:1,sign:1},{name:"rising",voices:2,spread:1,offset:.7,expression:.95,sign:1},{name:"vibrate",voices:2,spread:3.5,offset:7,expression:.975,sign:1},{name:"fourths",voices:2,spread:4,offset:4,expression:.95,sign:1},{name:"bass",voices:1,spread:0,offset:-7,expression:1,sign:1},{name:"dirty",voices:2,spread:0,offset:.1,expression:.975,sign:1},{name:"stationary",voices:2,spread:3.5,offset:0,expression:.9,sign:1},{name:"recurve",voices:2,spread:.005,offset:0,expression:1,sign:1},{name:"voiced",voices:2,spread:9.5,offset:0,expression:1,sign:1},{name:"fluctuate",voices:2,spread:12,offset:0,expression:1,sign:1},{name:"thin",voices:1,spread:0,offset:50,expression:1,sign:1},{name:"inject",voices:2,spread:6,offset:.4,expression:1,sign:1},{name:"askewed",voices:2,spread:0,offset:.42,expression:.7,sign:1},{name:"resonance",voices:2,spread:.0025,offset:.1,expression:.8,sign:-1.5},{name:"FART",voices:2,spread:13,offset:-5,expression:1,sign:-3},{name:"Shattered SYNC",voices:1,spread:2,offset:2,expression:1,sign:2}]),p.effectNames=["reverb","chorus","panning","distortion","bitcrusher","note filter","echo","pitch shift","detune","vibrato","transition type","chord type"],p.effectOrder=[2,10,11,7,8,9,5,3,4,1,6,0],p.noteSizeMax=6,p.volumeRange=50,p.volumeLogScale=.1428,p.panCenter=50,p.panMax=2*p.panCenter,p.panDelaySecondsMax=.001,p.chorusRange=8,p.chorusPeriodSeconds=2,p.chorusDelayRange=.0034,p.chorusDelayOffsets=[[1.51,2.1,3.35],[1.47,2.15,3.25]],p.chorusPhaseOffsets=[[0,2.1,4.2],[3.2,5.3,1]],p.chorusMaxDelay=p.chorusDelayRange*(1+p.chorusDelayOffsets[0].concat(p.chorusDelayOffsets[1]).reduce(((e,t)=>Math.max(e,t)))),p.chords=S([{name:"simultaneous",customInterval:!1,arpeggiates:!1,strumParts:0,singleTone:!1},{name:"strum",customInterval:!1,arpeggiates:!1,strumParts:1,singleTone:!1},{name:"arpeggio",customInterval:!1,arpeggiates:!0,strumParts:0,singleTone:!0},{name:"custom interval",customInterval:!0,arpeggiates:!1,strumParts:0,singleTone:!0}]),p.maxChordSize=9,p.operatorCount=4,p.maxPitchOrOperatorCount=Math.max(p.maxChordSize,p.operatorCount+2),p.algorithms=S([{name:"1←(2 3 4)",carrierCount:1,associatedCarrier:[1,1,1,1],modulatedBy:[[2,3,4],[],[],[]]},{name:"1←(2 3←4)",carrierCount:1,associatedCarrier:[1,1,1,1],modulatedBy:[[2,3],[],[4],[]]},{name:"1←2←(3 4)",carrierCount:1,associatedCarrier:[1,1,1,1],modulatedBy:[[2],[3,4],[],[]]},{name:"1←(2 3)←4",carrierCount:1,associatedCarrier:[1,1,1,1],modulatedBy:[[2,3],[4],[4],[]]},{name:"1←2←3←4",carrierCount:1,associatedCarrier:[1,1,1,1],modulatedBy:[[2],[3],[4],[]]},{name:"1←3 2←4",carrierCount:2,associatedCarrier:[1,2,1,2],modulatedBy:[[3],[4],[],[]]},{name:"1 2←(3 4)",carrierCount:2,associatedCarrier:[1,2,2,2],modulatedBy:[[],[3,4],[],[]]},{name:"1 2←3←4",carrierCount:2,associatedCarrier:[1,2,2,2],modulatedBy:[[],[3],[4],[]]},{name:"(1 2)←3←4",carrierCount:2,associatedCarrier:[1,2,2,2],modulatedBy:[[3],[3],[4],[]]},{name:"(1 2)←(3 4)",carrierCount:2,associatedCarrier:[1,2,2,2],modulatedBy:[[3,4],[3,4],[],[]]},{name:"1 2 3←4",carrierCount:3,associatedCarrier:[1,2,3,3],modulatedBy:[[],[],[4],[]]},{name:"(1 2 3)←4",carrierCount:3,associatedCarrier:[1,2,3,3],modulatedBy:[[4],[4],[4],[]]},{name:"1 2 3 4",carrierCount:4,associatedCarrier:[1,2,3,4],modulatedBy:[[],[],[],[]]},{name:"1←(2 3) 2←4",carrierCount:2,associatedCarrier:[1,2,1,2],modulatedBy:[[2,3],[4],[],[]]},{name:"1←(2 (3 (4",carrierCount:3,associatedCarrier:[1,2,3,3],modulatedBy:[[2,3,4],[3,4],[4],[]]}]),p.algorithms6Op=S([{name:"Custom",carrierCount:1,associatedCarrier:[1,1,1,1,1,1],modulatedBy:[[2,3,4,5,6],[],[],[],[],[]]},{name:"1←2←3←4←5←6",carrierCount:1,associatedCarrier:[1,1,1,1,1,1],modulatedBy:[[2],[3],[4],[5],[6],[]]},{name:"1←3 2←4←5←6",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3],[4],[],[5],[6],[]]},{name:"1←3←4 2←5←6",carrierCount:2,associatedCarrier:[1,1,1,2,2,2],modulatedBy:[[3],[5],[4],[],[6],[]]},{name:"1←4 2←5 3←6",carrierCount:3,associatedCarrier:[1,2,3,1,2,3],modulatedBy:[[4],[5],[6],[],[],[]]},{name:"1←3 2←(4 5←6)",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3],[4,5],[],[],[6],[]]},{name:"1←(3 4) 2←5←6",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3,4],[5],[],[],[6],[]]},{name:"1←3 2←(4 5 6)",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3],[4,5,6],[],[],[],[]]},{name:"1←3 2←(4 5)←6",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3],[4,5],[],[6],[6],[]]},{name:"1←3 2←4←(5 6)",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3],[4],[],[5,6],[],[]]},{name:"1←(2 3 4 5 6)",carrierCount:1,associatedCarrier:[1,1,1,1,1,1],modulatedBy:[[2,3,4,5,6],[],[],[],[],[]]},{name:"1←(2 3←5 4←6)",carrierCount:1,associatedCarrier:[1,1,1,1,1,1],modulatedBy:[[2,3,4],[],[5],[6],[],[]]},{name:"1←(2 3 4←5←6)",carrierCount:1,associatedCarrier:[1,1,1,1,1,1],modulatedBy:[[2,3,4],[],[],[5],[6],[]]},{name:"1←4←5 (2 3)←6",carrierCount:3,associatedCarrier:[1,2,3,1,2,3],modulatedBy:[[4],[6],[6],[5],[],[]]},{name:"1←(3 4)←5 2←6",carrierCount:2,associatedCarrier:[1,2,2,2,2,2],modulatedBy:[[3,4],[6],[5],[5],[],[]]},{name:"(1 2)←4 3←(5 6)",carrierCount:3,associatedCarrier:[1,2,3,1,2,3],modulatedBy:[[4],[4],[5,6],[],[],[]]},{name:"(1 2)←5 (3 4)←6",carrierCount:4,associatedCarrier:[1,2,3,4,4,4],modulatedBy:[[5],[5],[6],[6],[],[]]},{name:"(1 2 3)←(4 5 6)",carrierCount:3,associatedCarrier:[1,2,3,1,2,3],modulatedBy:[[4,5,6],[4,5,6],[4,5,6],[],[],[]]},{name:"1←5 (2 3 4)←6",carrierCount:4,associatedCarrier:[1,2,3,4,4,4],modulatedBy:[[5],[6],[6],[6],[],[]]},{name:"1 2←5 (3 4)←6",carrierCount:4,associatedCarrier:[1,2,3,4,4,4],modulatedBy:[[],[5],[6],[6],[],[]]},{name:"1 2 (3 4 5)←6",carrierCount:5,associatedCarrier:[1,2,3,4,5,5],modulatedBy:[[],[],[6],[6],[6],[]]},{name:"1 2 3 (4 5)←6",carrierCount:5,associatedCarrier:[1,2,3,4,5,5],modulatedBy:[[],[],[],[6],[6],[]]},{name:"1 2←4 3←(5 6)",carrierCount:3,associatedCarrier:[1,2,3,3,3,3],modulatedBy:[[],[4],[5,6],[],[],[]]},{name:"1←4 2←(5 6) 3",carrierCount:3,associatedCarrier:[1,2,3,3,3,3],modulatedBy:[[4],[5,6],[],[],[],[]]},{name:"1 2 3←5 4←6",carrierCount:4,associatedCarrier:[1,2,3,4,4,4],modulatedBy:[[],[],[5],[6],[],[]]},{name:"1 (2 3)←5←6 4",carrierCount:4,associatedCarrier:[1,2,3,4,4,4],modulatedBy:[[],[5],[5],[],[6],[]]},{name:"1 2 3←5←6 4",carrierCount:4,associatedCarrier:[1,2,3,4,4,4],modulatedBy:[[],[],[5,6],[],[],[]]},{name:"(1 2 3 4 5)←6",carrierCount:5,associatedCarrier:[1,2,3,4,5,5],modulatedBy:[[6],[6],[6],[6],[6],[]]},{name:"1 2 3 4 5←6",carrierCount:5,associatedCarrier:[1,2,3,4,5,5],modulatedBy:[[],[],[],[],[6],[]]},{name:"1 2 3 4 5 6",carrierCount:6,associatedCarrier:[1,2,3,4,5,6],modulatedBy:[[],[],[],[],[],[]]},{name:"1←(2 (3 (4 (5 (6",carrierCount:5,associatedCarrier:[1,2,3,4,5,5],modulatedBy:[[2,3,4,5,6],[3,4,5,6],[4,5,6],[5,6],[6],[]]},{name:"1←(2(3(4(5(6",carrierCount:1,associatedCarrier:[1,1,1,1,1,1],modulatedBy:[[2,3,4,5,6],[3,4,5,6],[4,5,6],[5,6],[6],[]]},{name:"1←4(2←5(3←6",carrierCount:3,associatedCarrier:[1,2,3,1,2,3],modulatedBy:[[2,3,4],[3,5],[6],[],[],[]]},{name:"1←4(2←5 3←6",carrierCount:3,associatedCarrier:[1,2,3,1,2,3],modulatedBy:[[2,3,4],[5],[6],[],[],[]]}]),p.operatorCarrierInterval=[0,.04,-.073,.091,.061,.024],p.operatorAmplitudeMax=15,p.operatorFrequencies=S([{name:"0.12×",mult:.125,hzOffset:0,amplitudeSign:1},{name:"0.25×",mult:.25,hzOffset:0,amplitudeSign:1},{name:"0.5×",mult:.5,hzOffset:0,amplitudeSign:1},{name:"0.75×",mult:.75,hzOffset:0,amplitudeSign:1},{name:"1×",mult:1,hzOffset:0,amplitudeSign:1},{name:"~1×",mult:1,hzOffset:1.5,amplitudeSign:-1},{name:"2×",mult:2,hzOffset:0,amplitudeSign:1},{name:"~2×",mult:2,hzOffset:-1.3,amplitudeSign:-1},{name:"3×",mult:3,hzOffset:0,amplitudeSign:1},{name:"3.5×",mult:3.5,hzOffset:-.05,amplitudeSign:1},{name:"4×",mult:4,hzOffset:0,amplitudeSign:1},{name:"~4×",mult:4,hzOffset:-2.4,amplitudeSign:-1},{name:"5×",mult:5,hzOffset:0,amplitudeSign:1},{name:"6×",mult:6,hzOffset:0,amplitudeSign:1},{name:"7×",mult:7,hzOffset:0,amplitudeSign:1},{name:"8×",mult:8,hzOffset:0,amplitudeSign:1},{name:"9×",mult:9,hzOffset:0,amplitudeSign:1},{name:"10×",mult:10,hzOffset:0,amplitudeSign:1},{name:"11×",mult:11,hzOffset:0,amplitudeSign:1},{name:"12×",mult:12,hzOffset:0,amplitudeSign:1},{name:"13×",mult:13,hzOffset:0,amplitudeSign:1},{name:"14×",mult:14,hzOffset:0,amplitudeSign:1},{name:"15×",mult:15,hzOffset:0,amplitudeSign:1},{name:"16×",mult:16,hzOffset:0,amplitudeSign:1},{name:"17×",mult:17,hzOffset:0,amplitudeSign:1},{name:"18×",mult:18,hzOffset:0,amplitudeSign:1},{name:"19×",mult:19,hzOffset:0,amplitudeSign:1},{name:"20×",mult:20,hzOffset:0,amplitudeSign:1},{name:"~20×",mult:20,hzOffset:-5,amplitudeSign:-1},{name:"25×",mult:25,hzOffset:0,amplitudeSign:1},{name:"50×",mult:50,hzOffset:0,amplitudeSign:1},{name:"75×",mult:75,hzOffset:0,amplitudeSign:1},{name:"100×",mult:100,hzOffset:0,amplitudeSign:1}]),p.envelopes=S([{name:"none",type:1,speed:0},{name:"note size",type:0,speed:0},{name:"punch",type:2,speed:0},{name:"flare -1",type:3,speed:128},{name:"flare 1",type:3,speed:32},{name:"flare 2",type:3,speed:8},{name:"flare 3",type:3,speed:2},{name:"twang -1",type:4,speed:128},{name:"twang 1",type:4,speed:32},{name:"twang 2",type:4,speed:8},{name:"twang 3",type:4,speed:2},{name:"swell -1",type:5,speed:128},{name:"swell 1",type:5,speed:32},{name:"swell 2",type:5,speed:8},{name:"swell 3",type:5,speed:2},{name:"tremolo0",type:6,speed:8},{name:"tremolo1",type:6,speed:4},{name:"tremolo2",type:6,speed:2},{name:"tremolo3",type:6,speed:1},{name:"tremolo4",type:7,speed:4},{name:"tremolo5",type:7,speed:2},{name:"tremolo6",type:7,speed:1},{name:"decay -1",type:8,speed:40},{name:"decay 1",type:8,speed:10},{name:"decay 2",type:8,speed:7},{name:"decay 3",type:8,speed:4},{name:"wibble-1",type:9,speed:96},{name:"wibble 1",type:9,speed:24},{name:"wibble 2",type:9,speed:12},{name:"wibble 3",type:9,speed:4},{name:"linear-2",type:11,speed:256},{name:"linear-1",type:11,speed:128},{name:"linear 1",type:11,speed:32},{name:"linear 2",type:11,speed:8},{name:"linear 3",type:11,speed:2},{name:"rise -2",type:12,speed:256},{name:"rise -1",type:12,speed:128},{name:"rise 1",type:12,speed:32},{name:"rise 2",type:12,speed:8},{name:"rise 3",type:12,speed:2},{name:"flute 1",type:9,speed:16},{name:"flute 2",type:9,speed:8},{name:"flute 3",type:9,speed:4},{name:"tripolo1",type:6,speed:9},{name:"tripolo2",type:6,speed:6},{name:"tripolo3",type:6,speed:3},{name:"tripolo4",type:7,speed:9},{name:"tripolo5",type:7,speed:6},{name:"tripolo6",type:7,speed:3},{name:"pentolo1",type:6,speed:10},{name:"pentolo2",type:6,speed:5},{name:"pentolo3",type:6,speed:2.5},{name:"pentolo4",type:7,speed:10},{name:"pentolo5",type:7,speed:5},{name:"pentolo6",type:7,speed:2.5},{name:"flutter 1",type:6,speed:14},{name:"flutter 2",type:7,speed:11},{name:"water-y flutter",type:6,speed:9},{name:"blip 1",type:13,speed:6},{name:"blip 2",type:13,speed:16},{name:"blip 3",type:13,speed:32}]),p.feedbacks=S([{name:"1⟲",indices:[[1],[],[],[]]},{name:"2⟲",indices:[[],[2],[],[]]},{name:"3⟲",indices:[[],[],[3],[]]},{name:"4⟲",indices:[[],[],[],[4]]},{name:"1⟲ 2⟲",indices:[[1],[2],[],[]]},{name:"3⟲ 4⟲",indices:[[],[],[3],[4]]},{name:"1⟲ 2⟲ 3⟲",indices:[[1],[2],[3],[]]},{name:"2⟲ 3⟲ 4⟲",indices:[[],[2],[3],[4]]},{name:"1⟲ 2⟲ 3⟲ 4⟲",indices:[[1],[2],[3],[4]]},{name:"1→2",indices:[[],[1],[],[]]},{name:"1→3",indices:[[],[],[1],[]]},{name:"1→4",indices:[[],[],[],[1]]},{name:"2→3",indices:[[],[],[2],[]]},{name:"2→4",indices:[[],[],[],[2]]},{name:"3→4",indices:[[],[],[],[3]]},{name:"1→3 2→4",indices:[[],[],[1],[2]]},{name:"1→4 2→3",indices:[[],[],[2],[1]]},{name:"1→2→3→4",indices:[[],[1],[2],[3]]},{name:"1↔2 3↔4",indices:[[2],[1],[4],[3]]},{name:"1↔4 2↔3",indices:[[4],[3],[2],[1]]},{name:"2→1→4→3→2",indices:[[2],[3],[4],[1]]},{name:"1→2→3→4→1",indices:[[4],[1],[2],[3]]},{name:"(1 2 3)→4",indices:[[],[],[],[1,2,3]]},{name:"ALL",indices:[[1,2,3,4],[1,2,3,4],[1,2,3,4],[1,2,3,4]]}]),p.feedbacks6Op=S([{name:"Custom",indices:[[2,3,4,5,6],[],[],[],[],[]]},{name:"1⟲",indices:[[1],[],[],[],[],[]]},{name:"2⟲",indices:[[],[2],[],[],[],[]]},{name:"3⟲",indices:[[],[],[3],[],[],[]]},{name:"4⟲",indices:[[],[],[],[4],[],[]]},{name:"5⟲",indices:[[],[],[],[],[5],[]]},{name:"6⟲",indices:[[],[],[],[],[],[6]]},{name:"1⟲ 2⟲",indices:[[1],[2],[],[],[],[]]},{name:"3⟲ 4⟲",indices:[[],[],[3],[4],[],[]]},{name:"1⟲ 2⟲ 3⟲",indices:[[1],[2],[3],[],[],[]]},{name:"2⟲ 3⟲ 4⟲",indices:[[],[2],[3],[4],[],[]]},{name:"1⟲ 2⟲ 3⟲ 4⟲",indices:[[1],[2],[3],[4],[],[]]},{name:"1⟲ 2⟲ 3⟲ 4⟲ 5⟲",indices:[[1],[2],[3],[4],[5],[]]},{name:"1⟲ 2⟲ 3⟲ 4⟲ 5⟲ 6⟲",indices:[[1],[2],[3],[4],[5],[6]]},{name:"1→2",indices:[[],[1],[],[],[],[]]},{name:"1→3",indices:[[],[],[1],[],[],[]]},{name:"1→4",indices:[[],[],[],[1],[],[]]},{name:"1→5",indices:[[],[],[],[],[1],[]]},{name:"1→6",indices:[[],[],[],[],[],[1]]},{name:"2→3",indices:[[],[],[2],[],[],[]]},{name:"2→4",indices:[[],[],[],[2],[],[]]},{name:"3→4",indices:[[],[],[],[3],[],[]]},{name:"4→5",indices:[[],[],[],[],[4],[]]},{name:"1→4 2→5 3→6",indices:[[],[],[],[1],[2],[3]]},{name:"1→5 2→6 3→4",indices:[[],[],[],[3],[1],[2]]},{name:"1→2→3→4→5→6",indices:[[],[1],[2],[3],[4],[5]]},{name:"2→1→6→5→4→3→2",indices:[[2],[3],[4],[5],[6],[1]]},{name:"1→2→3→4→5→6→1",indices:[[6],[1],[2],[3],[4],[5]]},{name:"1↔2 3↔4 5↔6",indices:[[2],[1],[4],[3],[6],[5]]},{name:"1↔4 2↔5 3↔6",indices:[[4],[5],[6],[1],[2],[3]]},{name:"(1,2,3,4,5)→6",indices:[[],[],[],[],[],[1,2,3,4,5]]},{name:"ALL",indices:[[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6]]}]),p.chipNoiseLength=32768,p.spectrumNoiseLength=32768,p.spectrumBasePitch=24,p.spectrumControlPoints=30,p.spectrumControlPointsPerOctave=7,p.spectrumControlPointBits=3,p.spectrumMax=(1<<p.spectrumControlPointBits)-1,p.harmonicsControlPoints=28,p.harmonicsRendered=64,p.harmonicsRenderedForPickedString=256,p.harmonicsControlPointBits=3,p.harmonicsMax=(1<<p.harmonicsControlPointBits)-1,p.harmonicsWavelength=2048,p.pulseWidthRange=50,p.pulseWidthStepPower=.5,p.dutyCycleSpeedScale=[0,.0625,.125,.2,.25,1/3,.4,.5,2/3,.75,.8,.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.15,4.3,4.5,4.8,5,5.5,6,1e6],p.supersawVoiceCount=7,p.supersawDynamismMax=6,p.supersawSpreadMax=12,p.supersawShapeMax=6,p.pitchChannelCountMin=1,p.pitchChannelCountMax=60,p.noiseChannelCountMin=0,p.noiseChannelCountMax=32,p.modChannelCountMin=0,p.modChannelCountMax=24,p.noiseInterval=6,p.pitchesPerOctave=12,p.drumCount=12,p.pitchOctaves=8,p.modCount=6,p.maxPitch=p.pitchOctaves*p.pitchesPerOctave,p.maximumTonesPerChannel=2*p.maxChordSize,p.pitchShiftRange=49,p.justIntonationSemitones=function(e,t){const s=[[1,1],[16,15],[9,8],[6,5],[5,4],[4,3],[45,32],[3,2],[8,5],[5,3],[16,9],[15,8],[2,1]],i=(e-1)/(2*t),n=[];for(let e=0;e<i;e++)for(let a=0;a<t;a++){const[o,r]=s[t-a];n.push(Math.log2(r/o)*t-t*(i-1-e))}for(let e=0;e<i;e++)for(let i=0;i<t;i++){const[a,o]=s[i];n.push(Math.log2(a/o)*t+t*e)}return n.push(t*i),n}(p.pitchShiftRange,p.pitchesPerOctave),p.pitchShiftCenter=p.pitchShiftRange>>1,p.detuneCenter=200,p.detuneMax=400,p.detuneMin=0,p.songDetuneMin=0,p.songDetuneMax=500,p.unisonVoicesMin=1,p.unisonVoicesMax=2,p.unisonSpreadMin=-96,p.unisonSpreadMax=96,p.unisonOffsetMin=-96,p.unisonOffsetMax=96,p.unisonExpressionMin=-2,p.unisonExpressionMax=2,p.unisonSignMin=-2,p.unisonSignMax=2,p.sineWaveLength=256,p.sineWaveMask=p.sineWaveLength-1,p.sineWave=function(){const e=new Float32Array(p.sineWaveLength+1);for(let t=0;t<p.sineWaveLength+1;t++)e[t]=Math.sin(t*Math.PI*2/p.sineWaveLength);return e}(),p.pickedStringDispersionCenterFreq=6e3,p.pickedStringDispersionFreqScale=.3,p.pickedStringDispersionFreqMult=4,p.pickedStringShelfHz=4e3,p.distortionRange=8,p.stringSustainRange=15,p.stringDecayRate=.12,p.enableAcousticSustain=!1,p.sustainTypeNames=["bright","acoustic"],p.bitcrusherFreqRange=14,p.bitcrusherOctaveStep=.5,p.bitcrusherQuantizationRange=8,p.maxEnvelopeCount=12,p.defaultAutomationRange=13,p.instrumentAutomationTargets=S([{name:"none",computeIndex:null,displayName:"none",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:null},{name:"noteVolume",computeIndex:0,displayName:"note volume",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:null},{name:"pulseWidth",computeIndex:2,displayName:"pulse width",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[6,7,9]},{name:"stringSustain",computeIndex:3,displayName:"sustain",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[8]},{name:"unison",computeIndex:4,displayName:"unison",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[0,5,8,10,6,7,2,3]},{name:"operatorFrequency",computeIndex:5,displayName:"fm# freq",interleave:!0,isFilter:!1,maxCount:p.operatorCount+2,effect:null,compatibleInstruments:[1,12]},{name:"operatorAmplitude",computeIndex:11,displayName:"fm# volume",interleave:!1,isFilter:!1,maxCount:p.operatorCount+2,effect:null,compatibleInstruments:[1,12]},{name:"feedbackAmplitude",computeIndex:17,displayName:"fm feedback",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[1,12]},{name:"pitchShift",computeIndex:18,displayName:"pitch shift",interleave:!1,isFilter:!1,maxCount:1,effect:7,compatibleInstruments:null},{name:"detune",computeIndex:19,displayName:"detune",interleave:!1,isFilter:!1,maxCount:1,effect:8,compatibleInstruments:null},{name:"vibratoDepth",computeIndex:20,displayName:"vibrato range",interleave:!1,isFilter:!1,maxCount:1,effect:9,compatibleInstruments:null},{name:"noteFilterAllFreqs",computeIndex:1,displayName:"n. filter freqs",interleave:!1,isFilter:!0,maxCount:1,effect:5,compatibleInstruments:null},{name:"noteFilterFreq",computeIndex:21,displayName:"n. filter # freq",interleave:!1,isFilter:!0,maxCount:p.filterMaxPoints,effect:5,compatibleInstruments:null},{name:"decimalOffset",computeIndex:37,displayName:"decimal offset",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[6,7,9]},{name:"supersawDynamism",computeIndex:38,displayName:"dynamism",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[9]},{name:"supersawSpread",computeIndex:39,displayName:"spread",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[9]},{name:"supersawShape",computeIndex:40,displayName:"saw↔pulse",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[9]}]),p.operatorWaves=S([{name:"sine",samples:p.sineWave},{name:"triangle",samples:function(){const e=new Float32Array(p.sineWaveLength+1);for(let t=0;t<p.sineWaveLength+1;t++)e[t]=Math.asin(Math.sin(t*Math.PI*2/p.sineWaveLength))/(Math.PI/2);return e}()},{name:"pulse width",samples:v()},{name:"sawtooth",samples:g()},{name:"ramp",samples:g(!0)},{name:"trapezoid",samples:function(e=2){const t=new Float32Array(p.sineWaveLength+1);for(let s=0;s<p.sineWaveLength+1;s++)t[s]=Math.max(-1,Math.min(1,Math.asin(Math.sin(s*Math.PI*2/p.sineWaveLength))*e));return t}(2)},{name:"rounded",samples:function(){const e=new Float32Array(p.sineWaveLength+1);for(let t=0;t<p.sineWaveLength+1;t++)e[t]=Math.round(Math.sin(t*Math.PI*2/p.sineWaveLength));return e}()}]),p.pwmOperatorWaves=S([{name:"1%",samples:v(.01)},{name:"5%",samples:v(.05)},{name:"12.5%",samples:v(.125)},{name:"25%",samples:v(.25)},{name:"33%",samples:v(1/3)},{name:"50%",samples:v(.5)},{name:"66%",samples:v(2/3)},{name:"75%",samples:v(.75)},{name:"87.5%",samples:v(.875)},{name:"95%",samples:v(.95)},{name:"99%",samples:v(.99)}]),p.barEditorHeight=10,p.modulators=S([{name:"none",pianoName:"None",maxRawVol:6,newNoteVol:6,forSong:!0,convertRealFactor:0,associatedEffect:12,promptName:"No Mod Setting",promptDesc:["No setting has been chosen yet, so this modulator will have no effect. Try choosing a setting with the dropdown, then click this '?' again for more info.","[$LO - $HI]"]},{name:"song volume",pianoName:"Volume",maxRawVol:100,newNoteVol:100,forSong:!0,convertRealFactor:0,associatedEffect:12,promptName:"Song Volume",promptDesc:["This setting affects the overall volume of the song, just like the main volume slider.","At $HI, the volume will be unchanged from default, and it will get gradually quieter down to $LO.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"tempo",pianoName:"Tempo",maxRawVol:p.tempoMax-p.tempoMin,newNoteVol:Math.ceil((p.tempoMax-p.tempoMin)/2),forSong:!0,convertRealFactor:p.tempoMin,associatedEffect:12,promptName:"Song Tempo",promptDesc:["This setting controls the speed your song plays at, just like the tempo slider.","When you first make a note for this setting, it will default to your current tempo. Raising it speeds up the song, up to $HI BPM, and lowering it slows it down, to a minimum of $LO BPM.","Note that you can make a 'swing' effect by rapidly changing between two tempo values.","[OVERWRITING] [$LO - $HI] [BPM]"]},{name:"song reverb",pianoName:"Reverb",maxRawVol:2*p.reverbRange,newNoteVol:p.reverbRange,forSong:!0,convertRealFactor:-p.reverbRange,associatedEffect:12,promptName:"Song Reverb",promptDesc:["This setting affects the overall reverb of your song. It works by multiplying existing reverb for instruments, so those with no reverb set will be unaffected.","At $MID, all instruments' reverb will be unchanged from default. This increases up to double the reverb value at $HI, or down to no reverb at $LO.","[MULTIPLICATIVE] [$LO - $HI]"]},{name:"next bar",pianoName:"Next Bar",maxRawVol:1,newNoteVol:1,forSong:!0,convertRealFactor:0,associatedEffect:12,promptName:"Go To Next Bar",promptDesc:["This setting functions a little different from most. Wherever a note is placed, the song will jump immediately to the next bar when it is encountered.","This jump happens at the very start of the note, so the length of a next-bar note is irrelevant. Also, the note can be value 0 or 1, but the value is also irrelevant - wherever you place a note, the song will jump.","You can make mixed-meter songs or intro sections by cutting off unneeded beats with a next-bar modulator.","[$LO - $HI]"]},{name:"note volume",pianoName:"Note Vol.",maxRawVol:p.volumeRange,newNoteVol:Math.ceil(p.volumeRange/2),forSong:!1,convertRealFactor:Math.ceil(-p.volumeRange/2),associatedEffect:12,promptName:"Note Volume",promptDesc:["This setting affects the volume of your instrument as if its note size had been scaled.","At $MID, an instrument's volume will be unchanged from default. This means you can still use the volume sliders to mix the base volume of instruments. The volume gradually increases up to $HI, or decreases down to mute at $LO.","This setting was the default for volume modulation in JummBox for a long time. Due to some new effects like distortion and bitcrush, note volume doesn't always allow fine volume control. Also, this modulator affects the value of FM modulator waves instead of just carriers. This can distort the sound which may be useful, but also may be undesirable. In those cases, use the 'mix volume' modulator instead, which will always just scale the volume with no added effects.","For display purposes, this mod will show up on the instrument volume slider, as long as there is not also an active 'mix volume' modulator anyhow. However, as mentioned, it works more like changing note volume.","[MULTIPLICATIVE] [$LO - $HI]"]},{name:"pan",pianoName:"Pan",maxRawVol:p.panMax,newNoteVol:Math.ceil(p.panMax/2),forSong:!1,convertRealFactor:0,associatedEffect:2,promptName:"Instrument Panning",promptDesc:["This setting controls the panning of your instrument, just like the panning slider.","At $LO, your instrument will sound like it is coming fully from the left-ear side. At $MID it will be right in the middle, and at $HI, it will sound like it's on the right.","[OVERWRITING] [$LO - $HI] [L-R]"]},{name:"reverb",pianoName:"Reverb",maxRawVol:p.reverbRange,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:0,promptName:"Instrument Reverb",promptDesc:["This setting controls the reverb of your insturment, just like the reverb slider.","At $LO, your instrument will have no reverb. At $HI, it will be at maximum.","[OVERWRITING] [$LO - $HI]"]},{name:"distortion",pianoName:"Distortion",maxRawVol:p.distortionRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:3,promptName:"Instrument Distortion",promptDesc:["This setting controls the amount of distortion for your instrument, just like the distortion slider.","At $LO, your instrument will have no distortion. At $HI, it will be at maximum.","[OVERWRITING] [$LO - $HI]"]},{name:"fm slider 1",pianoName:"FM 1",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 1",promptDesc:["This setting affects the strength of the first FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 2",pianoName:"FM 2",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 2",promptDesc:["This setting affects the strength of the second FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 3",pianoName:"FM 3",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 3",promptDesc:["This setting affects the strength of the third FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 4",pianoName:"FM 4",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 4",promptDesc:["This setting affects the strength of the fourth FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm feedback",pianoName:"FM Feedback",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Feedback",promptDesc:["This setting affects the strength of the FM feedback slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"pulse width",pianoName:"Pulse Width",maxRawVol:2*p.pulseWidthRange,newNoteVol:2*p.pulseWidthRange,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Pulse Width",promptDesc:["This setting controls the width of this instrument's pulse wave, just like the pulse width slider.","At $HI, your instrument will sound like a pure square wave (on 50% of the time). It will gradually sound narrower down to $LO, where it will be inaudible (as it is on 0% of the time).","Changing pulse width randomly between a few values is a common strategy in chiptune music to lend some personality to a lead instrument.","[OVERWRITING] [$LO - $HI] [%Duty]"]},{name:"detune",pianoName:"Detune",maxRawVol:p.detuneMax-p.detuneMin,newNoteVol:p.detuneCenter,forSong:!1,convertRealFactor:-p.detuneCenter,associatedEffect:8,promptName:"Instrument Detune",promptDesc:["This setting controls the detune for this instrument, just like the detune slider.","At $MID, your instrument will have no detune applied. Each tick corresponds to one cent, or one-hundredth of a pitch. Thus, each change of 100 ticks corresponds to one half-step of detune, up to two half-steps up at $HI, or two half-steps down at $LO.","[OVERWRITING] [$LO - $HI] [cents]"]},{name:"vibrato depth",pianoName:"Vibrato Depth",maxRawVol:50,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:9,promptName:"Vibrato Depth",promptDesc:["This setting controls the amount that your pitch moves up and down by during vibrato, just like the vibrato depth slider.","At $LO, your instrument will have no vibrato depth so its vibrato would be inaudible. This increases up to $HI, where an extreme pitch change will be noticeable.","[OVERWRITING] [$LO - $HI] [pitch ÷25]"]},{name:"song detune",pianoName:"Detune",maxRawVol:p.songDetuneMax-p.songDetuneMin,newNoteVol:Math.ceil((p.songDetuneMax-p.songDetuneMin)/2),forSong:!0,convertRealFactor:-250,associatedEffect:12,promptName:"Song Detune",promptDesc:["This setting controls the overall detune of the entire song. There is no associated slider.","At $MID, your song will have no extra detune applied and sound unchanged from default. Each tick corresponds to four cents, or four hundredths of a pitch. Thus, each change of 25 ticks corresponds to one half-step of detune, up to 10 half-steps up at $HI, or 10 half-steps down at $LO.","[MULTIPLICATIVE] [$LO - $HI] [cents x4]"]},{name:"vibrato speed",pianoName:"Vibrato Speed",maxRawVol:30,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:9,promptName:"Vibrato Speed",promptDesc:["This setting controls the speed your instrument will vibrato at, just like the slider.","A setting of $LO means there will be no oscillation, and vibrato will be disabled. Higher settings will increase the speed, up to a dramatic trill at the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"vibrato delay",pianoName:"Vibrato Delay",maxRawVol:50,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:9,promptName:"Vibrato Delay",promptDesc:["This setting controls the amount of time vibrato will be held off for before triggering for every new note, just like the slider.","A setting of $LO means there will be no delay. A setting of 24 corresponds to one full beat of delay. As a sole exception to this scale, setting delay to $HI will completely disable vibrato (as if it had infinite delay).","[OVERWRITING] [$LO - $HI] [beats ÷24]"]},{name:"arp speed",pianoName:"Arp Speed",maxRawVol:50,newNoteVol:12,forSong:!1,convertRealFactor:0,associatedEffect:11,promptName:"Arpeggio Speed",promptDesc:["This setting controls the speed at which your instrument's chords arpeggiate, just like the arpeggio speed slider.","Each setting corresponds to a different speed, from the slowest to the fastest. The speeds are listed below.","[0-4]: x0, x1/16, x⅛, x⅕, x¼,","[5-9]: x⅓, x⅖, x½, x⅔, x¾,","[10-14]: x⅘, x0.9, x1, x1.1, x1.2,","[15-19]: x1.3, x1.4, x1.5, x1.6, x1.7,","[20-24]: x1.8, x1.9, x2, x2.1, x2.2,","[25-29]: x2.3, x2.4, x2.5, x2.6, x2.7,","[30-34]: x2.8, x2.9, x3, x3.1, x3.2,","[35-39]: x3.3, x3.4, x3.5, x3.6, x3.7,","[40-44]: x3.8, x3.9, x4, x4.15, x4.3,","[45-50]: x4.5, x4.8, x5, x5.5, x6, x8","[OVERWRITING] [$LO - $HI]"]},{name:"pan delay",pianoName:"Pan Delay",maxRawVol:20,newNoteVol:10,forSong:!1,convertRealFactor:0,associatedEffect:2,promptName:"Panning Delay",promptDesc:["This setting controls the delay applied to panning for your instrument, just like the pan delay slider.","With more delay, the panning effect will generally be more pronounced. $MID is the default value, whereas $LO will remove any delay at all. No delay can be desirable for chiptune songs.","[OVERWRITING] [$LO - $HI]"]},{name:"reset arp",pianoName:"Reset Arp",maxRawVol:1,newNoteVol:1,forSong:!1,convertRealFactor:0,associatedEffect:11,promptName:"Reset Arpeggio",promptDesc:["This setting functions a little different from most. Wherever a note is placed, the arpeggio of this instrument will reset at the very start of that note. This is most noticeable with lower arpeggio speeds. The lengths and values of notes for this setting don't matter, just the note start times.","This mod can be used to sync up your apreggios so that they always sound the same, even if you are using an odd-ratio arpeggio speed or modulating arpeggio speed.","[$LO - $HI]"]},{name:"eq filter",pianoName:"EQFlt",maxRawVol:10,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"EQ Filter",promptDesc:["This setting controls a few separate things for your instrument's EQ filter.","When the option 'morph' is selected, your modulator values will indicate a sub-filter index of your EQ filter to 'morph' to over time. For example, a change from 0 to 1 means your main filter (default) will morph to sub-filter 1 over the specified duration. You can shape the main filter and sub-filters in the large filter editor ('+' button). If your two filters' number, type, and order of filter dots all match up, the morph will happen smoothly and you'll be able to hear them changing. If they do not match up, the filters will simply jump between each other.","Note that filters will morph based on endpoints in the pattern editor. So, if you specify a morph from sub-filter 1 to 4 but do not specifically drag in new endpoints for 2 and 3, it will morph directly between 1 and 4 without going through the others.","If you target Dot X or Dot Y, you can finely tune the coordinates of a single dot for your filter. The number of available dots to choose is dependent on your main filter's dot count.","[OVERWRITING] [$LO - $HI]"]},{name:"note filter",pianoName:"N.Flt",maxRawVol:10,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:5,promptName:"Note Filter",promptDesc:["This setting controls a few separate things for your instrument's note filter.","When the option 'morph' is selected, your modulator values will indicate a sub-filter index of your note filter to 'morph' to over time. For example, a change from 0 to 1 means your main filter (default) will morph to sub-filter 1 over the specified duration. You can shape the main filter and sub-filters in the large filter editor ('+' button). If your two filters' number, type, and order of filter dots all match up, the morph will happen smoothly and you'll be able to hear them changing. If they do not match up, the filters will simply jump between each other.","Note that filters will morph based on endpoints in the pattern editor. So, if you specify a morph from sub-filter 1 to 4 but do not specifically drag in new endpoints for 2 and 3, it will morph directly between 1 and 4 without going through the others.","If you target Dot X or Dot Y, you can finely tune the coordinates of a single dot for your filter. The number of available dots to choose is dependent on your main filter's dot count.","[OVERWRITING] [$LO - $HI]"]},{name:"bit crush",pianoName:"Bitcrush",maxRawVol:p.bitcrusherQuantizationRange-1,newNoteVol:Math.round(p.bitcrusherQuantizationRange/2),forSong:!1,convertRealFactor:0,associatedEffect:4,promptName:"Instrument Bit Crush",promptDesc:["This setting controls the bit crush of your instrument, just like the bit crush slider.","At a value of $LO, no bit crush will be applied. This increases and the bit crush effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"freq crush",pianoName:"Freq Crush",maxRawVol:p.bitcrusherFreqRange-1,newNoteVol:Math.round(p.bitcrusherFreqRange/2),forSong:!1,convertRealFactor:0,associatedEffect:4,promptName:"Instrument Frequency Crush",promptDesc:["This setting controls the frequency crush of your instrument, just like the freq crush slider.","At a value of $LO, no frequency crush will be applied. This increases and the frequency crush effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"echo",pianoName:"Echo",maxRawVol:p.echoSustainRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:6,promptName:"Instrument Echo Sustain",promptDesc:["This setting controls the echo sustain (echo loudness) of your instrument, just like the echo slider.","At $LO, your instrument will have no echo sustain and echo will not be audible. Echo sustain increases and the echo effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"echo delay",pianoName:"Echo Delay",maxRawVol:p.echoDelayRange,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Instrument Echo Delay",promptDesc:["This setting controls the echo delay of your instrument, just like the echo delay slider.","At $LO, your instrument will have very little echo delay, and this increases up to 2 beats of delay at $HI.","[OVERWRITING] [$LO - $HI] [~beats ÷12]"]},{name:"chorus",pianoName:"Chorus",maxRawVol:p.chorusRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:1,promptName:"Instrument Chorus",promptDesc:["This setting controls the chorus strength of your instrument, just like the chorus slider.","At $LO, the chorus effect will be disabled. The strength of the chorus effect increases up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"eq filt cut",pianoName:"EQFlt Cut",maxRawVol:p.filterSimpleCutRange-1,newNoteVol:p.filterSimpleCutRange-1,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"EQ Filter Cutoff Frequency",promptDesc:["This setting controls the filter cut position of your instrument, just like the filter cut slider.","This setting is roughly analagous to the horizontal position of a single low-pass dot on the advanced filter editor. At lower values, a wider range of frequencies is cut off.","[OVERWRITING] [$LO - $HI]"]},{name:"eq filt peak",pianoName:"EQFlt Peak",maxRawVol:p.filterSimplePeakRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"EQ Filter Peak Gain",promptDesc:["This setting controls the filter peak position of your instrument, just like the filter peak slider.","This setting is roughly analagous to the vertical position of a single low-pass dot on the advanced filter editor. At lower values, the cutoff frequency will not be emphasized, and at higher values you will hear emphasis on the cutoff frequency.","[OVERWRITING] [$LO - $HI]"]},{name:"note filt cut",pianoName:"N.Flt Cut",maxRawVol:p.filterSimpleCutRange-1,newNoteVol:p.filterSimpleCutRange-1,forSong:!1,convertRealFactor:0,associatedEffect:5,promptName:"Note Filter Cutoff Frequency",promptDesc:["This setting controls the filter cut position of your instrument, just like the filter cut slider.","This setting is roughly analagous to the horizontal position of a single low-pass dot on the advanced filter editor. At lower values, a wider range of frequencies is cut off.","[OVERWRITING] [$LO - $HI]"]},{name:"note filt peak",pianoName:"N.Flt Peak",maxRawVol:p.filterSimplePeakRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:5,promptName:"Note Filter Peak Gain",promptDesc:["This setting controls the filter peak position of your instrument, just like the filter peak slider.","This setting is roughly analagous to the vertical position of a single low-pass dot on the advanced filter editor. At lower values, the cutoff frequency will not be emphasized, and at higher values you will hear emphasis on the cutoff frequency.","[OVERWRITING] [$LO - $HI]"]},{name:"pitch shift",pianoName:"Pitch Shift",maxRawVol:p.pitchShiftRange-1,newNoteVol:p.pitchShiftCenter,forSong:!1,convertRealFactor:-p.pitchShiftCenter,associatedEffect:7,promptName:"Pitch Shift",promptDesc:["This setting controls the pitch offset of your instrument, just like the pitch shift slider.","At $MID your instrument will have no pitch shift. This increases as you decrease toward $LO pitches (half-steps) at the low end, or increases towards +$HI pitches at the high end.","[OVERWRITING] [$LO - $HI] [pitch]"]},{name:"sustain",pianoName:"Sustain",maxRawVol:p.stringSustainRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Picked String Sustain",promptDesc:["This setting controls the sustain of your picked string instrument, just like the sustain slider.","At $LO, your instrument will have minimum sustain and sound 'plucky'. This increases to a more held sound as your modulator approaches the maximum, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"mix volume",pianoName:"Mix Vol.",maxRawVol:p.volumeRange,newNoteVol:Math.ceil(p.volumeRange/2),forSong:!1,convertRealFactor:Math.ceil(-p.volumeRange/2),associatedEffect:12,promptName:"Mix Volume",promptDesc:["This setting affects the volume of your instrument as if its volume slider had been moved.","At $MID, an instrument's volume will be unchanged from default. This means you can still use the volume sliders to mix the base volume of instruments, since this setting and the default value work multiplicatively. The volume gradually increases up to $HI, or decreases down to mute at $LO.","Unlike the 'note volume' setting, mix volume is very straightforward and simply affects the resultant instrument volume after all effects are applied.","[MULTIPLICATIVE] [$LO - $HI]"]},{name:"fm slider 5",pianoName:"FM 5",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 5",promptDesc:["This setting affects the strength of the fifth FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 6",pianoName:"FM 6",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 6",promptDesc:["This setting affects the strength of the sixth FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"decimal offset",pianoName:"Decimal Offset",maxRawVol:100,newNoteVol:0,forSong:!1,convertRealFactor:0,invertSliderIndicator:!0,associatedEffect:12,promptName:"Decimal Offset",promptDesc:["This setting controls the decimal offset that is subtracted from the pulse width; use this for creating values like 12.5 or 6.25.","[$LO - $HI]"]},{name:"envelope speed",pianoName:"EnvelopeSpd",maxRawVol:50,newNoteVol:12,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Envelope Speed",promptDesc:["This setting controls how fast all of the envelopes for the instrument play.","At $LO, your instrument's envelopes will be frozen, and at values near there they will change very slowly. At 12, the envelopes will work as usual, performing at normal speed. This increases up to $HI, where the envelopes will change very quickly. The speeds are given below:","[0-4]: x0, x1/16, x⅛, x⅕, x¼,","[5-9]: x⅓, x⅖, x½, x⅔, x¾,","[10-14]: x⅘, x0.9, x1, x1.1, x1.2,","[15-19]: x1.3, x1.4, x1.5, x1.6, x1.7,","[20-24]: x1.8, x1.9, x2, x2.1, x2.2,","[25-29]: x2.3, x2.4, x2.5, x2.6, x2.7,","[30-34]: x2.8, x2.9, x3, x3.1, x3.2,","[35-39]: x3.3, x3.4, x3.5, x3.6, x3.7,","[40-44]: x3.8, x3.9, x4, x4.15, x4.3,","[45-50]: x4.5, x4.8, x5, x5.5, x6, x8","[OVERWRITING] [$LO - $HI]"]},{name:"dynamism",pianoName:"Dynamism",maxRawVol:p.supersawDynamismMax,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Supersaw Dynamism",promptDesc:["This setting controls the supersaw dynamism of your instrument, just like the dynamism slider.","At $LO, your instrument will have only a single pulse contributing. Increasing this will raise the contribution of other waves which is similar to a chorus effect. The effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"spread",pianoName:"Spread",maxRawVol:p.supersawSpreadMax,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Supersaw Spread",promptDesc:["This setting controls the supersaw spread of your instrument, just like the spread slider.","At $LO, all the pulses in your supersaw will be at the same frequency. Increasing this value raises the frequency spread of the contributing waves, up to a dissonant spread at the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"saw shape",pianoName:"Saw Shape",maxRawVol:p.supersawShapeMax,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Supersaw Shape",promptDesc:["This setting controls the supersaw shape of your instrument, just like the Saw↔Pulse slider.","As the slider's name implies, this effect will give you a sawtooth wave at $LO, and a full pulse width wave at $HI. Values in between will be a blend of the two.","[OVERWRITING] [$LO - $HI] [%]"]},{name:"dutyCycle Speed",pianoName:"Cycle Speed",maxRawVol:2*p.pulseWidthRange,newNoteVol:2*p.pulseWidthRange,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Duty Cycle Speed",promptDesc:["This setting controls the speed at which Duty Cycle cycles between pulse widths, just like the arpeggio speed slider.","Each setting corresponds to a different speed, from the slowest to the fastest. The speeds are listed below.","[0-4]: x0, x1/16, x⅛, x⅕, x¼,","[5-9]: x⅓, x⅖, x½, x⅔, x¾,","[10-14]: x⅘, x0.9, x1, x1.1, x1.2,","[15-19]: x1.3, x1.4, x1.5, x1.6, x1.7,","[20-24]: x1.8, x1.9, x2, x2.1, x2.2,","[25-29]: x2.3, x2.4, x2.5, x2.6, x2.7,","[30-34]: x2.8, x2.9, x3, x3.1, x3.2,","[35-39]: x3.3, x3.4, x3.5, x3.6, x3.7,","[40-44]: x3.8, x3.9, x4, x4.15, x4.3,","[45-50]: x4.5, x4.8, x5, x5.5, x6, x8","[OVERWRITING] [$LO - $HI]"]}]),/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|android|ipad|playbook|silk/i.test(navigator.userAgent);class z{static valueToPreset(e){var t;const s=e>>6,i=63&e;return null===(t=z.presetCategories[s])||void 0===t?void 0:t.presets[i]}static midiProgramToPresetValue(e){for(let t=0;t<z.presetCategories.length;t++){const s=z.presetCategories[t];for(let i=0;i<s.presets.length;i++){const n=s.presets[i];if(n.generalMidi&&n.midiProgram==e)return(t<<6)+i}}return null}static nameToPresetValue(e){for(let t=0;t<z.presetCategories.length;t++){const s=z.presetCategories[t];for(let i=0;i<s.presets.length;i++){if(s.presets[i].name==e)return(t<<6)+i}}return null}static instrumentToPreset(e){var t;return null===(t=z.presetCategories[0].presets.dictionary)||void 0===t?void 0:t[null==s?void 0:s[e]]}}function C(e,t){for(let s=0;s<e.length;s++)e[s]*=t}function R(e){if(!function(e){return!(!e||e&e-1)}(e))throw new Error("FFT array length must be a power of 2.");return Math.round(Math.log(e)/Math.log(2))}function E(e,t){const s=R(t);if(t<4)throw new Error("FFT array length must be at least 4.");for(let i=s-1;i>=2;i--){const s=1<<i,n=s>>1,a=s<<1,o=2*Math.PI/a,r=Math.cos(o),l=Math.sin(o),h=2*r;for(let i=0;i<t;i+=a){const t=i,a=t+n,o=t+s,p=o+n,c=o+s,u=e[t],f=e[o];e[t]=u+f,e[a]*=2,e[o]=u-f,e[p]*=2;let m=r,d=-l,y=1,v=0;for(let s=1;s<n;s++){const i=t+s,n=o-s,a=o+s,r=c-s,l=e[i],p=e[n],u=e[a],f=e[r],g=l-p,b=u+f;e[i]=l+p,e[n]=f-u,e[a]=g*m-b*d,e[r]=b*m+g*d;const S=h*m-y,M=h*d-v;y=m,v=d,m=S,d=M}}}for(let s=0;s<t;s+=4){const t=s+1,i=s+2,n=s+3,a=e[s],o=2*e[t],r=e[i],l=2*e[n],h=a+r,p=a-r;e[s]=h+o,e[t]=h-o,e[i]=p+l,e[n]=p-l}!function(e,t){const s=R(t);if(s>16)throw new Error("FFT array length must not be greater than 2^16.");const i=16-s;for(let s=0;s<t;s++){let t;if(t=(43690&s)>>1|(21845&s)<<1,t=(52428&t)>>2|(13107&t)<<2,t=(61680&t)>>4|(3855&t)<<4,t=(t>>8|(255&t)<<8)>>i,t>s){let i=e[s];e[s]=e[t],e[t]=i}}}(e,t)}z.version="0.0.9.0",z.versionDisplayName="Unbox "+z.version,z.releaseNotesURL="./patch_notes.html",z.informationURL="./information.html",z.isOnMac=/^Mac/i.test(navigator.platform)||/Mac OS X/i.test(navigator.userAgent)||/^(iPhone|iPad|iPod)/i.test(navigator.platform)||/(iPhone|iPad|iPod)/i.test(navigator.userAgent),z.ctrlSymbol=z.isOnMac?"⌘":"Ctrl+",z.ctrlName=z.isOnMac?"command":"control",z.presetCategories=S([{name:"Custom Instruments",presets:S([{name:s[0],customType:0},{name:s[1],customType:1},{name:s[2],customType:2},{name:s[3],customType:3},{name:s[4],customType:4},{name:s[5],customType:5},{name:s[6],customType:6},{name:s[7],customType:7},{name:s[8],customType:8},{name:s[9],customType:9},{name:s[10],customType:10},{name:s[12],customType:12}])},{name:"Common Waves",presets:S([{name:"square wave",midiProgram:80,settings:{type:"chip",eqFilter:[],effects:["aliasing"],transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1,chord:"arpeggio",wave:"square",unison:"none",envelopes:[]}},{name:"triangle wave",midiProgram:71,settings:{type:"chip",eqFilter:[],effects:["aliasing"],transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1,chord:"arpeggio",wave:"triangle",unison:"none",envelopes:[]}},{name:"sawtooth wave",midiProgram:81,settings:{type:"chip",eqFilter:[],effects:["aliasing"],transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1,chord:"arpeggio",wave:"sawtooth",unison:"none",envelopes:[]}},{name:"TEMP PWM",midiProgram:80,settings:{type:"PWM",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,pulseWidth:50,decimalOffset:0,unison:"none",envelopes:[]}}])},{name:"2A03/VRC6 (WIP)",presets:S([])},{name:"AY-3-8910/YM2149F/5B* (WIP)",presets:S([{name:"AY3 Buzzer",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"AY3 Buzzer",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"AY3 Half Buzzer Down",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"AY3 Half Buzzer Down",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"AY3 Half Buzzer Up",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"AY3 Half Buzzer Up",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"AY3 Pseudo Sine",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"AY3 Pseudo Sine",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"Atari ST Kick",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"Atari ST Kick",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"Sync Buzzer (WIP)",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"normal",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"Sync Buzzer Test",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}}])},{name:"SAA1099 (WIP)",presets:S([])},{name:"SN76489 (WIP)",presets:S([])},{name:"SID-6581/8580 (WIP)",presets:S([{name:"C64 TriPulse",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"C64 TriPulse",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"C64 PulseSaw",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"C64 PulseSaw",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"C64 SawTri",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"C64 SawTri",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"C64 All",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"C64 All",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}}])},{name:"TIA/POKEY/AMY/MIKEY (WIP)",presets:S([{name:"Atari Pokey 1",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"normal",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"Atari Pokey 1",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"Atari Pokey 2",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"normal",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"Atari Pokey 2",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}}])},{name:"HuC6280(WIP)",presets:S([])},{name:"Namco WSG/N163 (WIP)",presets:S([])},{name:"Unbox Presets(WIP)",presets:S([{name:"Soft Chimes",generalMidi:!1,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:.7071}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[{type:"low-pass",cutoffHz:6727.17,linearGain:.7071}],effects:["transition type","chord type","detune","vibrato","note filter","distortion","bitcrusher","chorus","echo"],transition:"interrupt",clicklessTransition:!1,chord:"strum",fastTwoNoteArp:!1,arpeggioSpeed:12,detuneCents:0,vibrato:"custom",vibratoDepth:.08,vibratoDelay:26,vibratoSpeed:1,vibratoType:0,noteFilterType:!0,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[],distortion:14,aliases:!1,bitcrusherOctave:5,bitcrusherQuantization:43,panDelay:10,chorus:29,echoSustain:71,echoDelayBeats:1,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"(1 2)←(3 4)",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,operators:[{frequency:"~1×",amplitude:13,waveform:"sine",pulseWidth:5},{frequency:"8×",amplitude:8,waveform:"sine",pulseWidth:5},{frequency:"20×",amplitude:3,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:1,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 2"},{target:"operatorAmplitude",envelope:"twang 3",index:2},{target:"operatorAmplitude",envelope:"twang 1",index:1}]}},{name:"Bass p1",generalMidi:!1,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.3536},{type:"high-pass",cutoffHz:148.65,linearGain:.5}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[{type:"low-pass",cutoffHz:4756.83,linearGain:.3536},{type:"high-pass",cutoffHz:148.65,linearGain:.5}],eqSubFilters1:[],effects:["detune","bitcrusher","reverb"],detuneCents:0,bitcrusherOctave:6.5,bitcrusherQuantization:0,panDelay:10,reverb:0,fadeInSeconds:0,fadeOutTicks:-3,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:4,operators:[{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"2×",amplitude:2,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:4,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:3,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorAmplitude",envelope:"punch",index:3},{target:"feedbackAmplitude",envelope:"decay 2"},{target:"operatorAmplitude",envelope:"twang 3",index:1}]}},{name:"Bass p2",generalMidi:!1,settings:{type:"FM",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],eqSubFilters1:[],effects:["transition type","detune","bitcrusher"],transition:"normal",clicklessTransition:!0,detuneCents:0,bitcrusherOctave:6.5,bitcrusherQuantization:0,panDelay:10,fadeInSeconds:0,fadeOutTicks:-3,algorithm:"1←(2 3 4)",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:4,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteVolume",envelope:"note size"}]}}])},{name:"Old Unbox Presets",presets:S([{name:"sawtooth wave rising",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"Falling Saw",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}},{name:"sawtooth wave falling",generalMidi:!1,settings:{type:"chip",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[],effects:["transition type"],transition:"interrupt",clicklessTransition:!1,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,wave:"Rising Saw",unison:"none",isUsingAdvancedLoopControls:!1,chipWaveLoopStart:0,chipWaveLoopEnd:64,chipWaveLoopMode:0,chipWavePlayBackwards:!1,chipWaveStartOffset:0,envelopes:[]}}])},{name:"Retro Presets(UB)",presets:S([{name:"square wave",midiProgram:80,settings:{type:"chip",eqFilter:[],effects:["aliasing"],transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1,chord:"arpeggio",wave:"square",unison:"none",envelopes:[]}},{name:"triangle wave",midiProgram:71,settings:{type:"chip",eqFilter:[],effects:["aliasing"],transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1,chord:"arpeggio",wave:"triangle",unison:"none",envelopes:[]}},{name:"square lead",midiProgram:80,generalMidi:!0,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.3536}],effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"simultaneous",wave:"square",unison:"hum",envelopes:[]}},{name:"sawtooth lead 1",midiProgram:81,generalMidi:!0,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.5}],effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"simultaneous",wave:"sawtooth",unison:"shimmer",envelopes:[]}},{name:"sawtooth lead 2",midiProgram:81,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:1}],effects:["vibrato","aliasing"],vibrato:"light",transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72,chord:"simultaneous",wave:"sawtooth",unison:"hum",envelopes:[]}},{name:"chip noise",midiProgram:116,isNoise:!0,settings:{type:"noise",transition:"hard",effects:["aliasing"],chord:"arpeggio",filterCutoffHz:4e3,filterResonance:0,filterEnvelope:"steady",wave:"retro"}},{name:"supersaw lead",midiProgram:81,settings:{type:"supersaw",eqFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:2}],effects:["reverb"],reverb:67,fadeInSeconds:0,fadeOutTicks:-6,pulseWidth:50,dynamism:100,spread:58,shape:0,envelopes:[]}},{name:"FM twang",midiProgram:32,settings:{type:"FM",eqFilter:[],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"simultaneous",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:15},{frequency:"1×",amplitude:15},{frequency:"1×",amplitude:0},{frequency:"1×",amplitude:0}],envelopes:[{target:"operatorAmplitude",envelope:"twang 2",index:1}]}},{name:"FM bass",midiProgram:36,settings:{type:"FM",eqFilter:[],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"custom interval",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"2×",amplitude:11},{frequency:"1×",amplitude:7},{frequency:"1×",amplitude:9},{frequency:"20×",amplitude:3}],envelopes:[{target:"operatorAmplitude",envelope:"twang 2",index:1},{target:"operatorAmplitude",envelope:"twang 3",index:2},{target:"operatorAmplitude",envelope:"twang 2",index:3}]}},{name:"FM flute",midiProgram:73,settings:{type:"FM",eqFilter:[],effects:[],transition:"normal",fadeInSeconds:.0263,fadeOutTicks:-3,chord:"simultaneous",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:15},{frequency:"1×",amplitude:6},{frequency:"1×",amplitude:0},{frequency:"1×",amplitude:0}],envelopes:[{target:"operatorAmplitude",envelope:"twang 2",index:1}]}},{name:"FM organ",midiProgram:16,settings:{type:"FM",eqFilter:[],effects:["vibrato"],vibrato:"delayed",transition:"normal",fadeInSeconds:.0263,fadeOutTicks:-3,chord:"custom interval",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:14},{frequency:"2×",amplitude:14},{frequency:"1×",amplitude:11},{frequency:"2×",amplitude:11}],envelopes:[]}},{name:"FM sine",midiProgram:55,settings:{type:"FM",transition:"seemless",effects:"none",chord:"harmony",filterCutoffHz:8e3,filterResonance:0,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:15,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"NES Pulse",midiProgram:80,settings:{type:"custom chip",effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"arpeggio",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.5}],unison:"none",vibrato:"none",envelopes:[],customChipWave:[-24,-24,-24,-24,-23,-23,-23,-23,-22,-22,-22,-22,-21,-21,-21,-21,-20,-20,-20,-20,-19,-19,-19,-19,-18,-18,-18,-18,-17,-17,-17,-17,24,24,24,24,23,23,23,23,22,22,22,22,21,21,21,21,20,20,20,20,19,19,19,19,18,18,18,18,17,17,17,17]}},{name:"Gameboy Pulse",midiProgram:80,settings:{type:"custom chip",effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"arpeggio",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.5}],unison:"none",envelopes:[],customChipWave:[-24,-20,-17,-15,-13,-13,-11,-11,-11,-9,-9,-9,-9,-7,-7,-7,-7,-7,-5,-5,-5,-5,-5,-5,-3,-3,-3,-3,-3,-3,-3,-3,24,20,17,15,13,13,11,11,11,9,9,9,9,7,7,7,7,7,5,5,5,5,5,5,3,3,3,3,3,3,3,3]}},{name:"VRC6 Sawtooth",midiProgram:81,settings:{type:"custom chip",effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"arpeggio",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.5}],unison:"none",envelopes:[],customChipWave:[-24,-20,-16,-13,-10,-8,-6,-5,-4,-4,0,0,0,0,4,4,4,4,4,4,8,8,8,8,8,8,8,8,12,12,12,12,12,12,12,12,16,16,16,16,16,16,16,16,20,20,20,20,20,20,20,20,24,24,24,24,24,24,24,24,24,24,24,24]}},{name:"Atari Square",midiProgram:80,settings:{type:"custom chip",effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"arpeggio",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.5}],unison:"none",envelopes:[],customChipWave:[-24,-24,-24,-23,-23,-23,-22,-22,-22,-21,-21,-21,-20,-20,-20,-19,-19,-19,-18,-18,-18,-17,-17,-17,-16,-16,-16,-15,-15,-15,-14,-14,-14,-13,-13,-13,24,24,24,23,23,23,22,22,22,21,21,21,20,20,20,19,19,19,18,18,18,17,17,17,16,16,15,15]}},{name:"Atari Bass",midiProgram:36,settings:{type:"custom chip",effects:["aliasing"],transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-3,chord:"arpeggio",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.5}],unison:"none",envelopes:[],customChipWave:[-24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,24,24,-24,-24,-24,24,24,24,-24,-24,-24,24,24,24,-24,-24,-24,24,24,-24,-24,-24,-24,-24,-24,-24,-24,-24,24,24,24,24,24,24,-24,-24,24,24,24,24,24,-24,-24,-24,-24,24,24,-24,-24,24,24]}},{name:"Sunsoft Bass",midiProgram:36,settings:{type:"custom chip",effects:["aliasing"],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"arpeggio",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.5}],unison:"none",envelopes:[],customChipWave:[24,24,15,15,9,9,-4,-4,0,0,-13,-13,-19,-19,-24,-24,-24,-24,-10,-10,0,0,-7,-7,-7,-7,0,0,6,6,-4,-4,3,3,-4,-4,3,3,3,3,9,9,15,15,15,15,6,6,-4,-4,-4,-4,-4,-4,-4,-4,-4,-4,3,3,12,12,24,24]}}])},{name:"Keyboard Presets",presets:S([{name:"grand piano 1",midiProgram:0,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"high-pass",cutoffHz:148.65,linearGain:.7071},{type:"peak",cutoffHz:2e3,linearGain:2.8284}],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.125}],reverb:67,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",harmonics:[100,100,86,86,86,71,71,71,0,86,71,71,71,57,57,71,57,14,57,57,57,57,57,57,57,57,29,57],unison:"piano",stringSustain:79,envelopes:[{target:"noteFilterAllFreqs",envelope:"note size"}]}},{name:"bright piano",midiProgram:1,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:1681.79,linearGain:.7071},{type:"high-pass",cutoffHz:148.65,linearGain:.5},{type:"peak",cutoffHz:3363.59,linearGain:1.4142}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:24,chord:"simultaneous",harmonics:[100,100,86,86,71,71,0,71,71,71,71,71,71,14,57,57,57,57,57,57,29,57,57,57,57,57,57,57],unison:"piano",stringSustain:86,envelopes:[]}},{name:"electric grand",midiProgram:2,generalMidi:!0,settings:{type:"chip",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:2378.41,linearGain:.5}],transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",wave:"1/8 pulse",unison:"shimmer",envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"}]}},{name:"honky-tonk piano",midiProgram:3,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:5656.85,linearGain:.3536}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",harmonics:[100,100,86,71,86,71,43,71,43,43,57,57,57,29,57,57,57,57,57,57,43,57,57,57,43,43,43,43],unison:"honky tonk",stringSustain:71,envelopes:[]}},{name:"electric piano 1",midiProgram:4,generalMidi:!0,settings:{type:"harmonics",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:3363.59,linearGain:.5}],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"simultaneous",harmonics:[86,100,100,71,71,57,57,43,43,43,29,29,29,14,14,14,0,0,0,0,0,57,0,0,0,0,0,0],unison:"none",envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 2"}]}},{name:"electric piano 2",midiProgram:5,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:13454.34,linearGain:.25}],transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:12},{frequency:"1×",amplitude:6},{frequency:"1×",amplitude:9},{frequency:"16×",amplitude:6}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"},{target:"operatorAmplitude",envelope:"twang 3",index:3}]}},{name:"harpsichord",midiProgram:6,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"high-pass",cutoffHz:250,linearGain:.3536},{type:"peak",cutoffHz:11313.71,linearGain:2.8284}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:24,chord:"simultaneous",harmonics:[100,100,100,86,57,86,86,86,86,57,57,71,71,86,86,71,71,86,86,71,71,71,71,71,71,71,71,71],unison:"none",stringSustain:79,envelopes:[]}},{name:"clavinet",midiProgram:7,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.3536}],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"simultaneous",algorithm:"1←(2 3 4)",feedbackType:"3⟲",feedbackAmplitude:6,operators:[{frequency:"3×",amplitude:15},{frequency:"~1×",amplitude:6},{frequency:"8×",amplitude:4},{frequency:"1×",amplitude:0}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 2"},{target:"feedbackAmplitude",envelope:"twang 2"}]}},{name:"dulcimer",midiProgram:15,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.3536}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"strum",harmonics:[100,100,100,86,100,86,57,100,100,86,100,86,100,86,100,71,57,71,71,100,86,71,86,86,100,86,86,86],unison:"piano",stringSustain:79,envelopes:[]}},{name:"grand piano 2",midiProgram:0,generalMidi:!0,settings:{type:"harmonics",eqFilter:[{type:"high-pass",cutoffHz:148.65,linearGain:.7071},{type:"peak",cutoffHz:2e3,linearGain:2.8284}],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.125}],reverb:67,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",harmonics:[100,86,86,86,86,71,71,57,0,57,29,43,57,57,57,43,43,0,29,43,43,43,43,43,43,29,0,29],unison:"piano",stringSustain:79,envelopes:[{target:"noteFilterAllFreqs",envelope:"note size"}]}},{name:"grand piano 3",midiProgram:0,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"high-pass",cutoffHz:148.65,linearGain:.7071},{type:"peak",cutoffHz:1681.79,linearGain:4},{type:"low-pass",cutoffHz:8e3,linearGain:.1768},{type:"peak",cutoffHz:3363.59,linearGain:4},{type:"peak",cutoffHz:2378.41,linearGain:.25}],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.3536},{type:"high-pass",cutoffHz:125,linearGain:.0884}],reverb:67,fadeInSeconds:0,fadeOutTicks:48,harmonics:[100,100,86,86,86,71,71,71,0,71,71,71,71,57,57,71,57,14,57,57,57,57,57,57,57,57,29,57],unison:"piano",stringSustain:86,stringSustainType:"acoustic",envelopes:[{target:"noteFilterFreq",envelope:"note size",index:0},{target:"noteFilterFreq",envelope:"twang 1",index:1},{target:"noteFilterFreq",envelope:"twang 1",index:1}]}}])},{name:"Idiophone Presets",presets:S([{name:"celesta",midiProgram:8,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:5657,filterResonance:14,filterEnvelope:"twang 2",vibrato:"none",algorithm:"(1 2)←(3 4)",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"~1×",amplitude:11,envelope:"custom"},{frequency:"8×",amplitude:6,envelope:"custom"},{frequency:"20×",amplitude:3,envelope:"twang 1"},{frequency:"3×",amplitude:1,envelope:"twang 2"}]}},{name:"glockenspiel",midiProgram:9,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:5657,filterResonance:14,filterEnvelope:"twang 2",vibrato:"none",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:2,feedbackEnvelope:"decay 1",operators:[{frequency:"1×",amplitude:7,envelope:"custom"},{frequency:"5×",amplitude:11,envelope:"custom"},{frequency:"8×",amplitude:7,envelope:"custom"},{frequency:"20×",amplitude:2,envelope:"twang 1"}]}},{name:"music box 1",midiProgram:10,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.5}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"strum",harmonics:[100,0,0,100,0,0,0,0,0,0,100,0,0,0,0,0,0,0,0,86,0,0,0,0,0,0,71,0],unison:"none",stringSustain:64,envelopes:[]}},{name:"music box 2",midiProgram:10,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:.7071}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"strum",harmonics:[100,57,57,0,0,0,0,0,0,57,0,0,0,0,0,0,0,0,0,43,0,0,0,0,0,0,0,0],unison:"none",stringSustain:29,envelopes:[]}},{name:"vibraphone",midiProgram:11,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 2",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1→2→3→4",feedbackAmplitude:3,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:9,envelope:"custom"},{frequency:"~1×",amplitude:9,envelope:"custom"},{frequency:"9×",amplitude:3,envelope:"custom"},{frequency:"4×",amplitude:9,envelope:"custom"}]}},{name:"marimba",midiProgram:12,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2e3,filterResonance:29,filterEnvelope:"decay 1",vibrato:"none",algorithm:"1 2←(3 4)",feedbackType:"1⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:10,envelope:"custom"},{frequency:"4×",amplitude:6,envelope:"custom"},{frequency:"13×",amplitude:6,envelope:"twang 1"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"kalimba",midiProgram:108,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"decay 1",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:11,envelope:"custom"},{frequency:"5×",amplitude:3,envelope:"twang 2"},{frequency:"20×",amplitude:3,envelope:"twang 1"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"xylophone",midiProgram:13,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"twang 1",vibrato:"none",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:9,envelope:"custom"},{frequency:"6×",amplitude:9,envelope:"custom"},{frequency:"11×",amplitude:9,envelope:"custom"},{frequency:"20×",amplitude:6,envelope:"twang 1"}]}},{name:"tubular bell",midiProgram:14,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.5},{type:"high-pass",cutoffHz:105.11,linearGain:.3536}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:96,chord:"strum",harmonics:[43,71,0,100,0,100,0,86,0,0,86,0,14,71,14,14,57,14,14,43,14,14,43,14,14,43,14,14],unison:"shimmer",stringSustain:86,envelopes:[]}},{name:"bell synth",midiProgram:14,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2e3,filterResonance:29,filterEnvelope:"twang 3",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"~2×",amplitude:10,envelope:"custom"},{frequency:"7×",amplitude:6,envelope:"twang 3"},{frequency:"20×",amplitude:1,envelope:"twang 1"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"rain drop",midiProgram:96,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"twang 1",vibrato:"none",algorithm:"(1 2)←(3 4)",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:12,envelope:"custom"},{frequency:"6×",amplitude:4,envelope:"custom"},{frequency:"20×",amplitude:3,envelope:"twang 1"},{frequency:"1×",amplitude:6,envelope:"tremolo1"}]}},{name:"crystal",midiProgram:98,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 2",vibrato:"delayed",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:4,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:10,envelope:"custom"},{frequency:"3×",amplitude:7,envelope:"custom"},{frequency:"6×",amplitude:4,envelope:"custom"},{frequency:"13×",amplitude:4,envelope:"custom"}]}},{name:"tinkle bell",midiProgram:112,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 2",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1→2→3→4",feedbackAmplitude:5,feedbackEnvelope:"twang 3",operators:[{frequency:"~2×",amplitude:7,envelope:"custom"},{frequency:"5×",amplitude:7,envelope:"custom"},{frequency:"7×",amplitude:7,envelope:"custom"},{frequency:"16×",amplitude:7,envelope:"custom"}]}},{name:"agogo",midiProgram:113,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"decay 1",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1→4",feedbackAmplitude:15,feedbackEnvelope:"decay 1",operators:[{frequency:"2×",amplitude:9,envelope:"custom"},{frequency:"5×",amplitude:6,envelope:"custom"},{frequency:"8×",amplitude:9,envelope:"custom"},{frequency:"13×",amplitude:11,envelope:"custom"}]}}])},{name:"Guitar Presets",presets:S([{name:"nylon guitar",midiProgram:24,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:5657,filterResonance:14,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←2←3←4",feedbackType:"3⟲",feedbackAmplitude:6,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:6,envelope:"steady"},{frequency:"5×",amplitude:2,envelope:"steady"},{frequency:"7×",amplitude:4,envelope:"steady"}]}},{name:"steel guitar",midiProgram:25,generalMidi:!0,settings:{type:"Picked String",eqFilter:[],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"strum",harmonics:[100,100,86,71,71,71,86,86,71,57,43,43,43,57,57,57,57,57,43,43,43,43,43,43,43,43,43,43],unison:"none",stringSustain:71,envelopes:[]}},{name:"jazz guitar",midiProgram:26,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"twang 2",interval:"union",vibrato:"none",harmonics:[100,100,86,71,57,71,71,43,57,71,57,43,29,29,29,29,29,29,29,29,14,14,14,14,14,14,14,0]}},{name:"clean guitar",midiProgram:27,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 2",interval:"union",vibrato:"none",harmonics:[86,100,100,100,86,57,86,100,100,100,71,57,43,71,86,71,57,57,71,71,71,71,57,57,57,57,57,43]}},{name:"muted guitar",midiProgram:28,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:7,feedbackEnvelope:"twang 2",operators:[{frequency:"1×",amplitude:13,envelope:"custom"},{frequency:"1×",amplitude:4,envelope:"twang 3"},{frequency:"4×",amplitude:4,envelope:"twang 2"},{frequency:"16×",amplitude:4,envelope:"twang 1"}]}}])},{name:"Picked Bass Presets",presets:S([{name:"acoustic bass",midiProgram:32,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"twang 1",interval:"union",vibrato:"none",harmonics:[100,86,71,71,71,71,57,57,57,57,43,43,43,43,43,29,29,29,29,29,29,14,14,14,14,14,14,14]}},{name:"fingered bass",midiProgram:33,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 1",interval:"union",vibrato:"none",harmonics:[100,86,71,57,71,43,57,29,29,29,29,29,29,14,14,14,14,14,14,14,14,14,14,14,14,14,14,0]}},{name:"picked bass",midiProgram:34,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:0,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"3⟲",feedbackAmplitude:4,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:5,envelope:"steady"},{frequency:"11×",amplitude:1,envelope:"twang 3"},{frequency:"1×",amplitude:9,envelope:"steady"}]}},{name:"fretless bass",midiProgram:35,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:1e3,filterResonance:14,filterEnvelope:"flare 2",interval:"union",vibrato:"none",harmonics:[100,100,86,71,71,57,57,71,71,71,57,57,57,57,57,57,57,43,43,43,43,43,43,43,43,29,29,14]}},{name:"slap bass 1",midiProgram:36,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:4e3,filterResonance:0,filterEnvelope:"twang 1",interval:"union",vibrato:"none",harmonics:[100,100,100,100,86,71,57,29,29,43,43,57,71,57,29,29,43,57,57,57,43,43,43,57,71,71,71,71]}},{name:"slap bass 2",midiProgram:37,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:5657,filterResonance:0,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←2←3←4",feedbackType:"3⟲",feedbackAmplitude:4,feedbackEnvelope:"steady",operators:[{frequency:"3×",amplitude:13,envelope:"custom"},{frequency:"1×",amplitude:7,envelope:"steady"},{frequency:"13×",amplitude:3,envelope:"steady"},{frequency:"1×",amplitude:11,envelope:"steady"}]}},{name:"bass synth 1",midiProgram:38,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard",chord:"strum",filterCutoffHz:4e3,filterResonance:43,filterEnvelope:"twang 2",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"3⟲ 4⟲",feedbackAmplitude:9,feedbackEnvelope:"twang 2",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"custom"},{frequency:"1×",amplitude:14,envelope:"twang 1"},{frequency:"~1×",amplitude:13,envelope:"twang 2"}]}},{name:"bass synth 2",midiProgram:39,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:1e3,filterResonance:57,filterEnvelope:"punch",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"1→2",feedbackAmplitude:4,feedbackEnvelope:"twang 3",operators:[{frequency:"1×",amplitude:9,envelope:"custom"},{frequency:"1×",amplitude:9,envelope:"steady"},{frequency:"3×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"bass & lead",midiProgram:87,generalMidi:!0,settings:{type:"chip",transition:"hard",effects:"reverb",chord:"harmony",filterCutoffHz:4e3,filterResonance:86,filterEnvelope:"twang 2",wave:"sawtooth",interval:"shimmer",vibrato:"none"}},{name:"dubstep yoi yoi",midiProgram:87,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:.7071}],effects:["note filter","bitcrusher"],noteFilter:[{type:"low-pass",cutoffHz:594.6,linearGain:11.3137}],bitcrusherOctave:1.5,bitcrusherQuantization:0,transition:"slide",fadeInSeconds:.0263,fadeOutTicks:-3,chord:"arpeggio",wave:"sawtooth",unison:"none",envelopes:[{target:"noteFilterFreq",envelope:"flare 2",index:0}]}}])},{name:"Picked String Presets",presets:S([{name:"pizzicato strings",midiProgram:45,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"medium fade",chord:"harmony",filterCutoffHz:1e3,filterResonance:14,filterEnvelope:"twang 1",vibrato:"none",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:7,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"3×",amplitude:11,envelope:"custom"},{frequency:"6×",amplitude:9,envelope:"custom"},{frequency:"~1×",amplitude:10,envelope:"steady"}]}},{name:"harp",midiProgram:46,generalMidi:!0,settings:{type:"FM",transition:"hard fade",effects:"reverb",chord:"strum",filterCutoffHz:2828,filterResonance:0,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"3⟲",feedbackAmplitude:6,feedbackEnvelope:"twang 2",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"4×",amplitude:6,envelope:"custom"},{frequency:"~2×",amplitude:3,envelope:"steady"},{frequency:"1×",amplitude:6,envelope:"steady"}]}},{name:"sitar",midiProgram:104,generalMidi:!0,settings:{type:"FM",transition:"hard fade",effects:"reverb",chord:"strum",filterCutoffHz:8e3,filterResonance:57,filterEnvelope:"twang 2",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:14,envelope:"twang 3"},{frequency:"9×",amplitude:3,envelope:"twang 3"},{frequency:"16×",amplitude:9,envelope:"swell 3"}]}},{name:"banjo",midiProgram:105,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 2",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"2⟲",feedbackAmplitude:4,feedbackEnvelope:"steady",operators:[{frequency:"4×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"steady"},{frequency:"11×",amplitude:3,envelope:"twang 3"},{frequency:"1×",amplitude:11,envelope:"steady"}]}},{name:"ukulele",midiProgram:105,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2e3,filterResonance:0,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"3⟲",feedbackAmplitude:5,feedbackEnvelope:"twang 1",operators:[{frequency:"2×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:6,envelope:"steady"},{frequency:"9×",amplitude:4,envelope:"twang 2"},{frequency:"1×",amplitude:11,envelope:"steady"}]}},{name:"shamisen",midiProgram:106,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:8e3,filterResonance:14,filterEnvelope:"twang 1",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"3⟲",feedbackAmplitude:9,feedbackEnvelope:"twang 3",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:12,envelope:"steady"},{frequency:"16×",amplitude:4,envelope:"twang 3"},{frequency:"1×",amplitude:7,envelope:"steady"}]}},{name:"koto",midiProgram:107,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"twang 2",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:5,feedbackEnvelope:"twang 2",operators:[{frequency:"~1×",amplitude:12,envelope:"custom"},{frequency:"6×",amplitude:10,envelope:"custom"},{frequency:"4×",amplitude:8,envelope:"twang 3"},{frequency:"~2×",amplitude:8,envelope:"twang 3"}]}}])},{name:"Distortion Presets",presets:S([{name:"overdrive guitar",midiProgram:29,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.7071},{type:"high-pass",cutoffHz:210.22,linearGain:1},{type:"low-pass",cutoffHz:5656.85,linearGain:1},{type:"peak",cutoffHz:840.9,linearGain:.5}],effects:["note filter","distortion"],noteFilter:[{type:"high-pass",cutoffHz:297.3,linearGain:2},{type:"low-pass",cutoffHz:2378.41,linearGain:.7071}],distortion:71,transition:"normal",fadeInSeconds:0,fadeOutTicks:12,chord:"strum",harmonics:[86,100,100,86,86,86,86,71,71,71,71,71,71,71,71,71,71,57,57,57,57,57,57,57,57,57,57,57],unison:"none",stringSustain:71,envelopes:[{target:"noteFilterFreq",envelope:"note size",index:1}]}},{name:"distortion guitar",midiProgram:30,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.7071},{type:"high-pass",cutoffHz:210.22,linearGain:1},{type:"low-pass",cutoffHz:5656.85,linearGain:1},{type:"peak",cutoffHz:594.6,linearGain:.3536},{type:"peak",cutoffHz:1e3,linearGain:.25}],effects:["note filter","distortion","reverb"],noteFilter:[{type:"high-pass",cutoffHz:353.55,linearGain:2},{type:"low-pass",cutoffHz:2e3,linearGain:1}],distortion:86,reverb:67,transition:"normal",fadeInSeconds:0,fadeOutTicks:12,chord:"strum",harmonics:[86,100,100,86,86,86,86,71,71,71,71,71,71,71,71,71,71,57,57,57,57,57,57,57,57,57,57,57],unison:"none",stringSustain:71,envelopes:[{target:"noteFilterFreq",envelope:"note size",index:1}]}},{name:"charango synth",midiProgram:84,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:11313.71,linearGain:1}],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"strum",algorithm:"1←(2 3←4)",feedbackType:"1→2→3→4",feedbackAmplitude:8,operators:[{frequency:"3×",amplitude:13},{frequency:"~1×",amplitude:5},{frequency:"4×",amplitude:6},{frequency:"3×",amplitude:7}],envelopes:[{target:"feedbackAmplitude",envelope:"twang 3"}]}},{name:"guitar harmonics",midiProgram:31,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:2}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"strum",algorithm:"1←(2 3)←4",feedbackType:"1⟲",feedbackAmplitude:2,operators:[{frequency:"4×",amplitude:12},{frequency:"16×",amplitude:5},{frequency:"1×",amplitude:2},{frequency:"~1×",amplitude:12}],envelopes:[{target:"operatorAmplitude",envelope:"swell 1",index:1},{target:"operatorAmplitude",envelope:"punch",index:2},{target:"operatorAmplitude",envelope:"twang 1",index:3}]}},{name:"PWM overdrive",midiProgram:29,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:5656.85,linearGain:1.4142}],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"strum",pulseWidth:17.67767,envelopes:[{target:"pulseWidth",envelope:"punch"}]}},{name:"PWM distortion",midiProgram:30,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:3363.59,linearGain:2}],effects:["vibrato"],vibrato:"delayed",transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"strum",pulseWidth:50,envelopes:[{target:"pulseWidth",envelope:"swell 1"}]}},{name:"FM overdrive",midiProgram:29,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:1}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"strum",algorithm:"1←(2 3←4)",feedbackType:"1→2",feedbackAmplitude:2,operators:[{frequency:"~1×",amplitude:15},{frequency:"1×",amplitude:12},{frequency:"~2×",amplitude:6},{frequency:"1×",amplitude:12}],envelopes:[{target:"operatorAmplitude",envelope:"twang 1",index:2},{target:"operatorAmplitude",envelope:"swell 3",index:3},{target:"feedbackAmplitude",envelope:"punch"}]}},{name:"FM distortion",midiProgram:30,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:2}],effects:["reverb"],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"strum",algorithm:"1←(2 3←4)",feedbackType:"1→2",feedbackAmplitude:4,operators:[{frequency:"~1×",amplitude:15},{frequency:"1×",amplitude:11},{frequency:"1×",amplitude:9},{frequency:"~2×",amplitude:4}],envelopes:[{target:"operatorAmplitude",envelope:"swell 1",index:2},{target:"operatorAmplitude",envelope:"swell 3",index:3}]}}])},{name:"Bellows Presets",presets:S([{name:"drawbar organ 1",midiProgram:16,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"harmonics",effects:"reverb",transition:"hard",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"steady",interval:"union",vibrato:"none",harmonics:[86,86,0,86,0,0,0,86,0,0,0,0,0,0,0,86,0,0,0,0,0,0,0,0,0,0,0,0]}},{name:"drawbar organ 2",midiProgram:16,midiSubharmonicOctaves:1,settings:{type:"harmonics",effects:"reverb",transition:"hard",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"steady",interval:"union",vibrato:"none",harmonics:[86,29,71,86,71,14,0,100,0,0,0,86,0,0,0,71,0,0,0,57,0,0,0,29,0,0,0,0]}},{name:"percussive organ",midiProgram:17,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"FM",transition:"hard",effects:"reverb",chord:"harmony",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"punch",vibrato:"light",algorithm:"1 2 3 4",feedbackType:"1→3 2→4",feedbackAmplitude:7,feedbackEnvelope:"decay 1",operators:[{frequency:"1×",amplitude:7,envelope:"custom"},{frequency:"2×",amplitude:7,envelope:"custom"},{frequency:"3×",amplitude:8,envelope:"custom"},{frequency:"4×",amplitude:8,envelope:"custom"}]}},{name:"rock organ",midiProgram:18,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"FM",effects:"chorus & reverb",transition:"hard",chord:"harmony",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"punch",vibrato:"delayed",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:2,feedbackEnvelope:"flare 1",operators:[{frequency:"1×",amplitude:9,envelope:"custom"},{frequency:"4×",amplitude:9,envelope:"custom"},{frequency:"6×",amplitude:9,envelope:"custom"},{frequency:"2×",amplitude:5,envelope:"steady"}]}},{name:"pipe organ",midiProgram:19,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"FM",transition:"cross fade",effects:"reverb",chord:"harmony",filterCutoffHz:5657,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:5,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:8,envelope:"custom"},{frequency:"2×",amplitude:9,envelope:"custom"},{frequency:"4×",amplitude:9,envelope:"custom"},{frequency:"8×",amplitude:8,envelope:"custom"}]}},{name:"reed organ",midiProgram:20,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2e3,filterResonance:29,filterEnvelope:"steady",interval:"union",vibrato:"none",harmonics:[71,86,100,86,71,100,57,71,71,71,43,43,43,71,43,71,57,57,57,57,57,57,57,29,43,29,29,14]}},{name:"accordion",midiProgram:21,generalMidi:!0,settings:{type:"chip",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:5657,filterResonance:0,filterEnvelope:"swell 1",wave:"double saw",interval:"honky tonk",vibrato:"none"}},{name:"bandoneon",midiProgram:23,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:29,filterEnvelope:"swell 1",interval:"hum",vibrato:"none",harmonics:[86,86,86,57,71,86,57,71,71,71,57,43,57,43,71,43,71,57,57,43,43,43,57,43,43,29,29,29]}},{name:"bagpipe",midiProgram:109,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:5657,filterResonance:43,filterEnvelope:"punch",interval:"hum",vibrato:"none",harmonics:[71,86,86,100,100,86,57,100,86,71,71,71,57,57,57,71,57,71,57,71,43,57,57,43,43,43,43,43]}}])},{name:"String Presets",presets:S([{name:"violin 1",midiProgram:40,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:1.4142},{type:"high-pass",cutoffHz:105.11,linearGain:.3536}],effects:["vibrato","reverb"],vibrato:"delayed",reverb:67,transition:"normal",fadeInSeconds:.0413,fadeOutTicks:6,chord:"simultaneous",algorithm:"(1 2)←(3 4)",feedbackType:"1→2",feedbackAmplitude:5,operators:[{frequency:"4×",amplitude:9},{frequency:"3×",amplitude:9},{frequency:"2×",amplitude:7},{frequency:"7×",amplitude:5}],envelopes:[{target:"operatorAmplitude",envelope:"swell 1",index:3},{target:"feedbackAmplitude",envelope:"twang 3"}]}},{name:"viola",midiProgram:41,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:29,filterEnvelope:"steady",vibrato:"delayed",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:8,feedbackEnvelope:"swell 1",operators:[{frequency:"2×",amplitude:11,envelope:"custom"},{frequency:"7×",amplitude:7,envelope:"custom"},{frequency:"13×",amplitude:4,envelope:"custom"},{frequency:"1×",amplitude:5,envelope:"steady"}]}},{name:"cello",midiProgram:42,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.1768},{type:"high-pass",cutoffHz:297.3,linearGain:.7071},{type:"peak",cutoffHz:4756.83,linearGain:5.6569}],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:16e3,linearGain:.0884}],reverb:67,transition:"normal",fadeInSeconds:.0125,fadeOutTicks:12,chord:"simultaneous",algorithm:"(1 2)←3←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:3,operators:[{frequency:"16×",amplitude:5},{frequency:"~1×",amplitude:10},{frequency:"1×",amplitude:9},{frequency:"6×",amplitude:3}],envelopes:[{target:"noteFilterAllFreqs",envelope:"swell 1"},{target:"operatorAmplitude",envelope:"swell 1",index:3}]}},{name:"contrabass",midiProgram:43,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:29,filterEnvelope:"steady",vibrato:"delayed",algorithm:"(1 2)←3←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"16×",amplitude:5,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"steady"},{frequency:"6×",amplitude:3,envelope:"swell 1"}]}},{name:"fiddle",midiProgram:110,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2828,filterResonance:29,filterEnvelope:"steady",vibrato:"delayed",algorithm:"(1 2)←(3 4)",feedbackType:"3⟲ 4⟲",feedbackAmplitude:5,feedbackEnvelope:"twang 1",operators:[{frequency:"2×",amplitude:10,envelope:"custom"},{frequency:"8×",amplitude:8,envelope:"custom"},{frequency:"1×",amplitude:8,envelope:"steady"},{frequency:"16×",amplitude:3,envelope:"steady"}]}},{name:"tremolo strings",midiProgram:44,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"medium fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:0,filterEnvelope:"tremolo4",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1→2→3→4",feedbackAmplitude:12,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:8,envelope:"custom"},{frequency:"~2×",amplitude:8,envelope:"custom"},{frequency:"4×",amplitude:8,envelope:"custom"},{frequency:"7×",amplitude:8,envelope:"custom"}]}},{name:"strings",midiProgram:48,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:2828,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"(1 2)←(3 4)",feedbackType:"4⟲",feedbackAmplitude:5,feedbackEnvelope:"twang 3",operators:[{frequency:"4×",amplitude:9,envelope:"custom"},{frequency:"3×",amplitude:9,envelope:"custom"},{frequency:"2×",amplitude:7,envelope:"steady"},{frequency:"7×",amplitude:3,envelope:"swell 1"}]}},{name:"slow strings",midiProgram:49,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"soft fade",chord:"harmony",filterCutoffHz:1414,filterResonance:0,filterEnvelope:"swell 2",vibrato:"none",algorithm:"(1 2)←(3 4)",feedbackType:"4⟲",feedbackAmplitude:6,feedbackEnvelope:"flare 3",operators:[{frequency:"4×",amplitude:10,envelope:"custom"},{frequency:"3×",amplitude:10,envelope:"custom"},{frequency:"2×",amplitude:7,envelope:"steady"},{frequency:"7×",amplitude:4,envelope:"swell 1"}]}},{name:"strings synth 1",midiProgram:50,generalMidi:!0,settings:{type:"chip",transition:"soft fade",effects:"chorus & reverb",chord:"harmony",filterCutoffHz:1414,filterResonance:43,filterEnvelope:"steady",wave:"sawtooth",interval:"hum",vibrato:"delayed"}},{name:"strings synth 2",midiProgram:51,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"soft fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:12,feedbackEnvelope:"swell 1",operators:[{frequency:"3×",amplitude:6,envelope:"custom"},{frequency:"2×",amplitude:7,envelope:"custom"},{frequency:"1×",amplitude:8,envelope:"custom"},{frequency:"1×",amplitude:9,envelope:"custom"}]}},{name:"orchestra hit 1",midiProgram:55,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"FM",effects:"chorus & reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:8e3,filterResonance:14,filterEnvelope:"custom",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:14,feedbackEnvelope:"twang 3",operators:[{frequency:"1×",amplitude:15,envelope:"twang 3"},{frequency:"2×",amplitude:15,envelope:"flare 3"},{frequency:"4×",amplitude:15,envelope:"flare 2"},{frequency:"8×",amplitude:15,envelope:"flare 1"}]}},{name:"violin 2",midiProgram:40,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:2828,linearGain:1.4142},{type:"high-pass",cutoffHz:105.11,linearGain:.3536}],effects:["vibrato","reverb"],vibrato:"light",reverb:67,transition:"normal",fadeInSeconds:.0413,fadeOutTicks:6,chord:"simultaneous",algorithm:"(1 2)←(3 4)",feedbackType:"4⟲",feedbackAmplitude:5,feedbackEnvelope:"twang 3",operators:[{frequency:"4×",amplitude:15,envelope:"custom"},{frequency:"3×",amplitude:13,envelope:"custom"},{frequency:"2×",amplitude:7,envelope:"steady"},{frequency:"7×",amplitude:8,envelope:"swell 1"}]}},{name:"orchestra hit 2",midiProgram:55,midiSubharmonicOctaves:1,settings:{type:"FM",effects:"chorus & reverb",transition:"medium fade",chord:"harmony",filterCutoffHz:8e3,filterResonance:0,filterEnvelope:"decay 1",vibrato:"delayed",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:14,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:12,envelope:"custom"},{frequency:"2×",amplitude:14,envelope:"custom"},{frequency:"3×",amplitude:12,envelope:"custom"},{frequency:"4×",amplitude:14,envelope:"custom"}]}},{name:"supersaw string",midiProgram:41,settings:{type:"supersaw",eqFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:1.4142},{type:"low-pass",cutoffHz:3363.59,linearGain:.1768}],effects:["note filter","reverb"],noteFilter:[{type:"high-pass",cutoffHz:500,linearGain:.1768}],reverb:33,fadeInSeconds:.0263,fadeOutTicks:6,pulseWidth:35.35534,dynamism:83,spread:8,shape:50,envelopes:[{target:"noteFilterFreq",envelope:"twang 1",index:0}]}},{name:"supersaw string 2",midiProgram:41,settings:{type:"supersaw",eqFilter:[{type:"low-pass",cutoffHz:2378.41,linearGain:.5},{type:"high-pass",cutoffHz:594.6,linearGain:.25},{type:"peak",cutoffHz:2e3,linearGain:2.8284},{type:"peak",cutoffHz:4756.83,linearGain:2}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters0:[{type:"low-pass",cutoffHz:2378.41,linearGain:.5},{type:"high-pass",cutoffHz:594.6,linearGain:.25},{type:"peak",cutoffHz:2e3,linearGain:2.8284},{type:"peak",cutoffHz:4756.83,linearGain:2}],effects:["note filter","chorus","reverb"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:1}],noteSubFilters0:[{type:"low-pass",cutoffHz:8e3,linearGain:1}],chorus:57,reverb:42,fadeInSeconds:.0575,fadeOutTicks:-6,pulseWidth:50,dynamism:67,spread:58,shape:0,envelopes:[{target:"noteFilterAllFreqs",envelope:"punch"},{target:"pulseWidth",envelope:"flare 2"}]}}])},{name:"Vocal Presets",presets:S([{name:"choir soprano",midiProgram:94,generalMidi:!0,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:2},{type:"peak",cutoffHz:1189.21,linearGain:5.6569},{type:"high-pass",cutoffHz:707.11,linearGain:2.8284},{type:"peak",cutoffHz:2e3,linearGain:.0884},{type:"peak",cutoffHz:840.9,linearGain:.25},{type:"low-pass",cutoffHz:6727.17,linearGain:11.3137}],effects:["vibrato","chorus","reverb"],vibrato:"shaky",chorus:100,reverb:33,fadeInSeconds:.0413,fadeOutTicks:24,harmonics:[100,100,86,57,29,29,57,71,57,29,14,14,14,29,43,57,43,29,14,14,14,14,14,14,0,0,0,0],unison:"none",envelopes:[]}},{name:"choir tenor",midiProgram:52,generalMidi:!0,settings:{type:"harmonics",eqFilter:[{type:"peak",cutoffHz:1e3,linearGain:11.3137},{type:"peak",cutoffHz:707.11,linearGain:5.6569},{type:"peak",cutoffHz:840.9,linearGain:.0884},{type:"peak",cutoffHz:1681.79,linearGain:.0884},{type:"high-pass",cutoffHz:297.3,linearGain:.7071},{type:"low-pass",cutoffHz:2828.43,linearGain:11.3137}],effects:["vibrato","chorus","reverb"],vibrato:"shaky",chorus:100,reverb:67,transition:"normal",fadeInSeconds:.0413,fadeOutTicks:48,chord:"simultaneous",harmonics:[86,100,100,86,71,57,43,29,29,29,29,43,43,43,29,29,29,29,29,29,29,29,29,14,14,14,14,14],unison:"none",envelopes:[]}},{name:"choir bass",midiProgram:52,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:2378.41,linearGain:11.3137},{type:"peak",cutoffHz:594.6,linearGain:5.6569},{type:"peak",cutoffHz:1681.79,linearGain:.0884},{type:"peak",cutoffHz:707.11,linearGain:.0884},{type:"peak",cutoffHz:840.9,linearGain:11.3137}],effects:["vibrato","chorus","reverb"],vibrato:"shaky",chorus:100,reverb:67,transition:"normal",fadeInSeconds:.0413,fadeOutTicks:48,chord:"simultaneous",harmonics:[71,86,100,100,86,86,57,43,29,29,29,29,29,29,43,43,43,43,43,29,29,29,29,14,14,14,14,14],unison:"none",envelopes:[]}},{name:"solo soprano",midiProgram:85,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:2},{type:"peak",cutoffHz:1189.21,linearGain:5.6569},{type:"high-pass",cutoffHz:707.11,linearGain:2.8284},{type:"peak",cutoffHz:2e3,linearGain:.0884},{type:"peak",cutoffHz:840.9,linearGain:.25}],effects:["vibrato","reverb"],vibrato:"shaky",reverb:33,fadeInSeconds:.0413,fadeOutTicks:12,harmonics:[86,100,86,43,14,14,57,71,57,14,14,14,14,14,43,57,43,14,14,14,14,14,14,14,0,0,0,0],unison:"none",envelopes:[]}},{name:"solo tenor",midiProgram:85,settings:{type:"harmonics",eqFilter:[{type:"peak",cutoffHz:1e3,linearGain:11.3137},{type:"peak",cutoffHz:707.11,linearGain:5.6569},{type:"peak",cutoffHz:840.9,linearGain:.0884},{type:"peak",cutoffHz:1681.79,linearGain:.0884},{type:"high-pass",cutoffHz:297.3,linearGain:.7071},{type:"low-pass",cutoffHz:2828.43,linearGain:11.3137}],effects:["vibrato","reverb"],vibrato:"shaky",reverb:33,fadeInSeconds:.0413,fadeOutTicks:12,harmonics:[86,100,100,86,71,57,43,29,29,29,29,43,43,43,29,29,29,29,29,29,29,29,29,14,14,14,14,14],unison:"none",envelopes:[]}},{name:"solo bass",midiProgram:85,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:2378.41,linearGain:5.6569},{type:"peak",cutoffHz:594.6,linearGain:8},{type:"peak",cutoffHz:1681.79,linearGain:.0884},{type:"peak",cutoffHz:707.11,linearGain:.0884},{type:"peak",cutoffHz:840.9,linearGain:8},{type:"high-pass",cutoffHz:210.22,linearGain:1.4142}],effects:["vibrato","reverb"],vibrato:"shaky",reverb:33,transition:"normal",fadeInSeconds:.0263,fadeOutTicks:12,chord:"simultaneous",harmonics:[71,86,100,100,86,86,57,43,29,29,29,29,29,29,43,43,43,43,43,29,29,29,29,14,14,14,14,14],unison:"none",envelopes:[]}},{name:"voice ooh",midiProgram:53,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:1414,filterResonance:57,filterEnvelope:"steady",interval:"union",vibrato:"shaky",harmonics:[100,57,43,43,14,14,0,0,0,14,29,29,14,0,14,29,29,14,0,0,0,0,0,0,0,0,0,0]}},{name:"voice synth",midiProgram:54,generalMidi:!0,settings:{type:"chip",transition:"medium fade",effects:"chorus & reverb",chord:"harmony",filterCutoffHz:4e3,filterResonance:57,filterEnvelope:"steady",wave:"rounded",interval:"union",vibrato:"light"}},{name:"vox synth lead",midiProgram:85,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"steady",vibrato:"light",algorithm:"(1 2 3)←4",feedbackType:"1→2→3→4",feedbackAmplitude:2,feedbackEnvelope:"punch",operators:[{frequency:"2×",amplitude:10,envelope:"custom"},{frequency:"9×",amplitude:5,envelope:"custom"},{frequency:"20×",amplitude:1,envelope:"custom"},{frequency:"~1×",amplitude:4,envelope:"steady"}]}},{name:"tiny robot",midiProgram:85,settings:{type:"FM",eqFilter:[],effects:["vibrato","reverb"],vibrato:"delayed",reverb:33,transition:"slide",fadeInSeconds:.0263,fadeOutTicks:-3,chord:"simultaneous",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:2,operators:[{frequency:"2×",amplitude:15},{frequency:"1×",amplitude:7},{frequency:"~1×",amplitude:7},{frequency:"1×",amplitude:0}],envelopes:[{target:"operatorAmplitude",envelope:"punch",index:1},{target:"feedbackAmplitude",envelope:"twang 3"}]}},{name:"yowie",midiProgram:85,settings:{type:"FM",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:86,filterEnvelope:"tremolo5",vibrato:"none",algorithm:"1←2←(3 4)",feedbackType:"1⟲",feedbackAmplitude:12,feedbackEnvelope:"tremolo3",operators:[{frequency:"2×",amplitude:12,envelope:"custom"},{frequency:"16×",amplitude:5,envelope:"steady"},{frequency:"1×",amplitude:5,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"mouse",midiProgram:85,settings:{type:"FM",eqFilter:[],effects:["vibrato","reverb"],vibrato:"light",reverb:33,transition:"slide in pattern",fadeInSeconds:.0263,fadeOutTicks:-3,chord:"simultaneous",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:5,operators:[{frequency:"2×",amplitude:13},{frequency:"5×",amplitude:12},{frequency:"1×",amplitude:0},{frequency:"1×",amplitude:0}],envelopes:[{target:"noteVolume",envelope:"note size"},{target:"feedbackAmplitude",envelope:"flare 2"}]}},{name:"gumdrop",midiProgram:85,settings:{type:"FM",effects:"reverb",transition:"hard",chord:"harmony",filterCutoffHz:8e3,filterResonance:0,filterEnvelope:"steady",vibrato:"none",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:0,feedbackEnvelope:"steady",operators:[{frequency:"2×",amplitude:15,envelope:"punch"},{frequency:"4×",amplitude:15,envelope:"punch"},{frequency:"7×",amplitude:15,envelope:"punch"},{frequency:"1×",amplitude:10,envelope:"twang 1"}]}},{name:"echo drop",midiProgram:102,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"hard",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"punch",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:2,feedbackEnvelope:"steady",operators:[{frequency:"~2×",amplitude:11,envelope:"custom"},{frequency:"~1×",amplitude:5,envelope:"steady"},{frequency:"11×",amplitude:2,envelope:"steady"},{frequency:"16×",amplitude:5,envelope:"swell 3"}]}},{name:"dark choir",midiProgram:85,settings:{type:"spectrum",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:29,filterEnvelope:"swell 1",spectrum:[43,14,14,14,14,14,14,100,14,14,14,57,14,14,100,14,43,14,43,14,14,43,14,29,14,29,14,14,29,0]}}])},{name:"Brass Presets",presets:S([{name:"trumpet",midiProgram:56,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2828,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:9,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:8,envelope:"steady"},{frequency:"1×",amplitude:5,envelope:"flare 2"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"trombone",midiProgram:57,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2e3,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"2⟲",feedbackAmplitude:7,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:8,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"tuba",midiProgram:58,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2e3,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"2⟲",feedbackAmplitude:8,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:6,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"muted trumpet",midiProgram:59,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:2.8284},{type:"peak",cutoffHz:4e3,linearGain:2.8284}],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:3363.59,linearGain:1}],reverb:33,fadeInSeconds:.0263,fadeOutTicks:-3,algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:5,operators:[{frequency:"1×",amplitude:13},{frequency:"1×",amplitude:5},{frequency:"9×",amplitude:5},{frequency:"13×",amplitude:7}],envelopes:[{target:"noteFilterAllFreqs",envelope:"swell 1"},{target:"operatorAmplitude",envelope:"swell 1",index:3},{target:"feedbackAmplitude",envelope:"flare 2"}]}},{name:"french horn",midiProgram:60,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:1},{type:"peak",cutoffHz:2378.41,linearGain:2.8284}],effects:["reverb"],reverb:33,fadeInSeconds:.0263,fadeOutTicks:-3,algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:3,operators:[{frequency:"1×",amplitude:15},{frequency:"1×",amplitude:12},{frequency:"1×",amplitude:10},{frequency:"~1×",amplitude:8}],envelopes:[{target:"operatorAmplitude",envelope:"swell 1",index:2},{target:"operatorAmplitude",envelope:"flare 2",index:3},{target:"feedbackAmplitude",envelope:"swell 1"}]}},{name:"brass section",midiProgram:61,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"punch",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:6,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:12,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"swell 1"},{frequency:"~1×",amplitude:10,envelope:"swell 1"}]}},{name:"brass synth 1",midiProgram:62,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:29,filterEnvelope:"steady",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:11,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:12,envelope:"flare 1"},{frequency:"~1×",amplitude:8,envelope:"flare 2"}]}},{name:"brass synth 2",midiProgram:63,generalMidi:!0,settings:{type:"FM",transition:"soft",effects:"reverb",chord:"harmony",filterCutoffHz:4e3,filterResonance:43,filterEnvelope:"twang 3",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:9,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"flare 1"},{frequency:"~1×",amplitude:7,envelope:"flare 1"}]}},{name:"pulse brass",midiProgram:62,settings:{type:"PWM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:29,filterEnvelope:"swell 1",pulseWidth:50,pulseEnvelope:"flare 3",vibrato:"none"}}])},{name:"Reed Presets",presets:S([{name:"soprano sax",midiProgram:64,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2e3,filterResonance:29,filterEnvelope:"steady",vibrato:"none",algorithm:"1←2←3←4",feedbackType:"4⟲",feedbackAmplitude:5,feedbackEnvelope:"swell 1",operators:[{frequency:"1×",amplitude:13,envelope:"custom"},{frequency:"4×",amplitude:4,envelope:"swell 1"},{frequency:"1×",amplitude:7,envelope:"steady"},{frequency:"5×",amplitude:4,envelope:"punch"}]}},{name:"alto sax",midiProgram:65,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2e3,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:4,feedbackEnvelope:"punch",operators:[{frequency:"1×",amplitude:13,envelope:"custom"},{frequency:"1×",amplitude:6,envelope:"steady"},{frequency:"4×",amplitude:6,envelope:"swell 1"},{frequency:"1×",amplitude:12,envelope:"steady"}]}},{name:"tenor sax",midiProgram:66,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2828,filterResonance:29,filterEnvelope:"steady",vibrato:"none",algorithm:"1←2←3←4",feedbackType:"1⟲",feedbackAmplitude:6,feedbackEnvelope:"swell 1",operators:[{frequency:"2×",amplitude:12,envelope:"custom"},{frequency:"3×",amplitude:7,envelope:"steady"},{frequency:"1×",amplitude:3,envelope:"steady"},{frequency:"8×",amplitude:3,envelope:"steady"}]}},{name:"baritone sax",midiProgram:67,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2828,filterResonance:0,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:2,feedbackEnvelope:"swell 2",operators:[{frequency:"1×",amplitude:12,envelope:"custom"},{frequency:"8×",amplitude:4,envelope:"steady"},{frequency:"4×",amplitude:5,envelope:"steady"},{frequency:"1×",amplitude:4,envelope:"punch"}]}},{name:"sax synth",midiProgram:64,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:8e3,filterResonance:0,filterEnvelope:"steady",vibrato:"light",algorithm:"1←(2 3 4)",feedbackType:"1⟲ 2⟲",feedbackAmplitude:4,feedbackEnvelope:"steady",operators:[{frequency:"4×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:15,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"shehnai",midiProgram:111,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:8e3,filterResonance:0,filterEnvelope:"steady",vibrato:"light",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:3,feedbackEnvelope:"steady",operators:[{frequency:"4×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:8,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"oboe",midiProgram:68,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"swell 1",vibrato:"none",algorithm:"1 2←(3 4)",feedbackType:"2⟲",feedbackAmplitude:2,feedbackEnvelope:"tremolo5",operators:[{frequency:"1×",amplitude:7,envelope:"custom"},{frequency:"4×",amplitude:12,envelope:"custom"},{frequency:"1×",amplitude:6,envelope:"steady"},{frequency:"6×",amplitude:2,envelope:"steady"}]}},{name:"english horn",midiProgram:69,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"steady",vibrato:"none",algorithm:"1 2←(3 4)",feedbackType:"2⟲",feedbackAmplitude:2,feedbackEnvelope:"steady",operators:[{frequency:"4×",amplitude:12,envelope:"custom"},{frequency:"2×",amplitude:10,envelope:"custom"},{frequency:"1×",amplitude:8,envelope:"punch"},{frequency:"8×",amplitude:4,envelope:"steady"}]}},{name:"bassoon",midiProgram:70,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:707,filterResonance:57,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:2,feedbackEnvelope:"steady",operators:[{frequency:"2×",amplitude:11,envelope:"custom"},{frequency:"1×",amplitude:6,envelope:"steady"},{frequency:"6×",amplitude:6,envelope:"swell 1"},{frequency:"1×",amplitude:0,envelope:"steady"}]}},{name:"clarinet",midiProgram:71,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:1414,filterResonance:14,filterEnvelope:"steady",interval:"union",vibrato:"none",harmonics:[100,43,86,57,86,71,86,71,71,71,71,71,71,43,71,71,57,57,57,57,57,57,43,43,43,29,14,0]}},{name:"harmonica",midiProgram:22,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:5657,filterResonance:29,filterEnvelope:"swell 1",vibrato:"none",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:9,feedbackEnvelope:"tremolo5",operators:[{frequency:"2×",amplitude:14,envelope:"custom"},{frequency:"1×",amplitude:15,envelope:"steady"},{frequency:"~2×",amplitude:2,envelope:"twang 3"},{frequency:"1×",amplitude:0,envelope:"steady"}]}}])},{name:"Flute Presets",presets:S([{name:"flute 1",midiProgram:73,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:5657,filterResonance:14,filterEnvelope:"steady",vibrato:"none",algorithm:"1←(2 3 4)",feedbackType:"4⟲",feedbackAmplitude:7,feedbackEnvelope:"decay 2",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"2×",amplitude:4,envelope:"steady"},{frequency:"1×",amplitude:3,envelope:"steady"},{frequency:"~1×",amplitude:1,envelope:"punch"}]}},{name:"recorder",midiProgram:74,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:29,filterEnvelope:"swell 2",interval:"union",vibrato:"none",harmonics:[100,43,57,43,57,43,43,43,43,43,43,43,43,29,29,29,29,29,29,29,14,14,14,14,14,14,14,0]}},{name:"whistle",midiProgram:78,generalMidi:!0,settings:{type:"harmonics",effects:"chorus & reverb",transition:"soft",chord:"harmony",filterCutoffHz:2e3,filterResonance:43,filterEnvelope:"steady",interval:"union",vibrato:"delayed",harmonics:[100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},{name:"ocarina",midiProgram:79,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:2828,filterResonance:43,filterEnvelope:"steady",interval:"union",vibrato:"none",harmonics:[100,14,57,14,29,14,14,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]}},{name:"piccolo",midiProgram:72,generalMidi:!0,settings:{type:"FM",effects:"reverb",transition:"soft",chord:"harmony",filterCutoffHz:5657,filterResonance:43,filterEnvelope:"steady",vibrato:"none",algorithm:"1←3 2←4",feedbackType:"4⟲",feedbackAmplitude:15,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"1×",amplitude:10,envelope:"custom"},{frequency:"~2×",amplitude:3,envelope:"punch"},{frequency:"~1×",amplitude:5,envelope:"punch"}]}},{name:"shakuhachi",midiProgram:77,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"steady",vibrato:"delayed",algorithm:"1←(2 3←4)",feedbackType:"3→4",feedbackAmplitude:15,feedbackEnvelope:"steady",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"2×",amplitude:3,envelope:"punch"},{frequency:"~1×",amplitude:4,envelope:"twang 1"},{frequency:"20×",amplitude:15,envelope:"steady"}]}},{name:"pan flute",midiProgram:75,generalMidi:!0,settings:{type:"spectrum",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:5.6569}],effects:["note filter","reverb"],noteFilter:[{type:"high-pass",cutoffHz:4756.83,linearGain:.7071}],reverb:33,fadeInSeconds:.0125,fadeOutTicks:-3,spectrum:[100,0,0,0,0,0,0,14,0,0,0,71,0,0,14,0,57,0,29,14,29,14,14,29,14,29,14,14,29,14],envelopes:[{target:"noteFilterFreq",envelope:"twang 1",index:0},{target:"noteVolume",envelope:"punch"}]}},{name:"blown bottle",midiProgram:76,generalMidi:!0,settings:{type:"FM",effects:"chorus & reverb",transition:"cross fade",chord:"harmony",filterCutoffHz:5657,filterResonance:57,filterEnvelope:"steady",vibrato:"none",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:7,feedbackEnvelope:"twang 1",operators:[{frequency:"1×",amplitude:15,envelope:"custom"},{frequency:"3×",amplitude:4,envelope:"custom"},{frequency:"6×",amplitude:2,envelope:"custom"},{frequency:"11×",amplitude:2,envelope:"custom"}]}},{name:"calliope",midiProgram:82,generalMidi:!0,settings:{type:"spectrum",transition:"cross fade",effects:"reverb",chord:"harmony",filterCutoffHz:5657,filterResonance:14,filterEnvelope:"steady",spectrum:[100,0,0,0,0,0,0,86,0,0,0,71,0,0,57,0,43,0,29,14,14,29,14,14,14,14,14,14,14,14]}},{name:"chiffer",midiProgram:83,generalMidi:!0,settings:{type:"spectrum",effects:"reverb",transition:"hard",chord:"harmony",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"punch",spectrum:[86,0,0,0,0,0,0,71,0,0,0,71,0,0,57,0,57,0,43,14,14,43,14,29,14,29,29,29,29,14]}},{name:"breath noise",midiProgram:121,generalMidi:!0,settings:{type:"spectrum",eqFilter:[],effects:["chord type","note filter","reverb"],chord:"strum",noteFilter:[{type:"high-pass",cutoffHz:840.9,linearGain:.3536},{type:"low-pass",cutoffHz:16e3,linearGain:.3536}],reverb:33,fadeInSeconds:.0413,fadeOutTicks:12,spectrum:[71,0,0,0,0,0,0,29,0,0,0,71,0,0,29,0,100,29,14,29,100,29,100,14,14,71,0,29,0,0],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 1"}]}},{name:"flute 2",midiProgram:73,generalMidi:!0,settings:{type:"harmonics",effects:"reverb",transition:"seamless",chord:"harmony",filterCutoffHz:1414,filterResonance:14,filterEnvelope:"steady",interval:"union",vibrato:"delayed",harmonics:[100,43,86,57,86,71,86,71,71,71,71,71,71,43,71,71,57,57,57,57,57,57,43,43,43,29,14,0]}}])},{name:"Pad Presets",presets:S([{name:"new age pad",midiProgram:88,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["chorus"],chorus:100,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",algorithm:"1←(2 3←4)",feedbackType:"1⟲ 2⟲",feedbackAmplitude:3,operators:[{frequency:"2×",amplitude:14},{frequency:"~1×",amplitude:4},{frequency:"6×",amplitude:3},{frequency:"13×",amplitude:3}],envelopes:[{target:"operatorAmplitude",envelope:"swell 2",index:1},{target:"operatorAmplitude",envelope:"twang 3",index:2},{target:"feedbackAmplitude",envelope:"swell 3"}]}},{name:"warm pad",midiProgram:89,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:3363.59,linearGain:1}],chorus:100,transition:"normal",fadeInSeconds:.0575,fadeOutTicks:96,chord:"simultaneous",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:7,operators:[{frequency:"1×",amplitude:14},{frequency:"1×",amplitude:6},{frequency:"1×",amplitude:0},{frequency:"1×",amplitude:0}],envelopes:[{target:"noteFilterAllFreqs",envelope:"swell 3"},{target:"operatorAmplitude",envelope:"swell 1",index:1}]}},{name:"polysynth pad",midiProgram:90,generalMidi:!0,settings:{type:"chip",eqFilter:[],effects:["vibrato","note filter","chorus"],vibrato:"delayed",noteFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:1}],chorus:100,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",wave:"sawtooth",unison:"honky tonk",envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"}]}},{name:"space voice pad",midiProgram:91,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:5.6569},{type:"peak",cutoffHz:2828.43,linearGain:5.6569},{type:"peak",cutoffHz:1414.21,linearGain:.1768}],effects:["chorus"],chorus:100,transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72,chord:"simultaneous",algorithm:"(1 2 3)←4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:5,operators:[{frequency:"1×",amplitude:10},{frequency:"2×",amplitude:8},{frequency:"3×",amplitude:7},{frequency:"11×",amplitude:2}],envelopes:[{target:"operatorAmplitude",envelope:"punch",index:3},{target:"feedbackAmplitude",envelope:"swell 2"}]}},{name:"bowed glass pad",midiProgram:92,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.5}],transition:"normal",fadeInSeconds:.0575,fadeOutTicks:96,chord:"simultaneous",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:10},{frequency:"2×",amplitude:12},{frequency:"3×",amplitude:7},{frequency:"7×",amplitude:4}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"},{target:"operatorAmplitude",envelope:"twang 3",index:2},{target:"operatorAmplitude",envelope:"flare 3",index:3}]}},{name:"metallic pad",midiProgram:93,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:.5}],transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72,chord:"simultaneous",algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲",feedbackAmplitude:13,operators:[{frequency:"1×",amplitude:15},{frequency:"~1×",amplitude:9},{frequency:"1×",amplitude:7},{frequency:"11×",amplitude:7}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"},{target:"operatorAmplitude",envelope:"swell 2",index:2},{target:"feedbackAmplitude",envelope:"twang 3"}]}},{name:"sweep pad",midiProgram:95,generalMidi:!0,settings:{type:"chip",eqFilter:[],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:4}],chorus:100,transition:"normal",fadeInSeconds:.0575,fadeOutTicks:96,chord:"simultaneous",wave:"sawtooth",unison:"hum",envelopes:[{target:"noteFilterAllFreqs",envelope:"flare 3"}]}},{name:"atmosphere",midiProgram:99,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:1}],effects:["chorus","reverb"],chorus:100,reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"strum",algorithm:"1←(2 3 4)",feedbackType:"3⟲ 4⟲",feedbackAmplitude:3,operators:[{frequency:"1×",amplitude:14},{frequency:"~1×",amplitude:10},{frequency:"3×",amplitude:7},{frequency:"1×",amplitude:7}],envelopes:[{target:"operatorAmplitude",envelope:"swell 3",index:1},{target:"operatorAmplitude",envelope:"twang 2",index:2},{target:"operatorAmplitude",envelope:"twang 3",index:3}]}},{name:"brightness",midiProgram:100,generalMidi:!0,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:2}],effects:["chorus"],chorus:100,transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72,chord:"simultaneous",harmonics:[100,86,86,86,43,57,43,71,43,43,43,57,43,43,57,71,57,43,29,43,57,57,43,29,29,29,29,14],unison:"octave",stringSustain:86,envelopes:[]}},{name:"goblins",midiProgram:101,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"peak",cutoffHz:2828.43,linearGain:11.3137}],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:1681.79,linearGain:.5}],chorus:100,transition:"normal",fadeInSeconds:.0575,fadeOutTicks:96,chord:"simultaneous",algorithm:"1←2←3←4",feedbackType:"1⟲",feedbackAmplitude:10,operators:[{frequency:"1×",amplitude:15},{frequency:"4×",amplitude:5},{frequency:"1×",amplitude:10},{frequency:"1×",amplitude:0}],envelopes:[{target:"noteFilterAllFreqs",envelope:"swell 2"},{target:"operatorAmplitude",envelope:"swell 3",index:1},{target:"operatorAmplitude",envelope:"tremolo1",index:2},{target:"feedbackAmplitude",envelope:"flare 3"}]}},{name:"sci-fi",midiProgram:103,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"peak",cutoffHz:9513.66,linearGain:2.8284}],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:.5}],chorus:100,transition:"normal",fadeInSeconds:.0125,fadeOutTicks:48,chord:"simultaneous",algorithm:"(1 2)←3←4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:8,operators:[{frequency:"~1×",amplitude:13},{frequency:"2×",amplitude:10},{frequency:"5×",amplitude:5},{frequency:"11×",amplitude:8}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"},{target:"operatorAmplitude",envelope:"twang 3",index:2},{target:"operatorAmplitude",envelope:"tremolo5",index:3},{target:"feedbackAmplitude",envelope:"twang 3"}]}},{name:"flutter pad",midiProgram:90,settings:{type:"FM",eqFilter:[],effects:["vibrato","note filter","chorus"],vibrato:"delayed",noteFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:4}],chorus:100,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",algorithm:"(1 2)←(3 4)",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:9,operators:[{frequency:"1×",amplitude:13},{frequency:"5×",amplitude:7},{frequency:"7×",amplitude:5},{frequency:"~1×",amplitude:6}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"},{target:"operatorAmplitude",envelope:"tremolo1",index:2},{target:"operatorAmplitude",envelope:"punch",index:3}]}},{name:"feedback pad",midiProgram:89,settings:{type:"FM",eqFilter:[{type:"peak",cutoffHz:2378.41,linearGain:8}],effects:[],transition:"normal",fadeInSeconds:.0575,fadeOutTicks:96,chord:"custom interval",algorithm:"1 2 3 4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:8,operators:[{frequency:"1×",amplitude:15},{frequency:"1×",amplitude:15},{frequency:"1×",amplitude:15},{frequency:"~1×",amplitude:15}],envelopes:[{target:"feedbackAmplitude",envelope:"swell 2"}]}},{name:"supersaw pad",midiProgram:93,settings:{type:"supersaw",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.1768}],effects:["reverb"],reverb:100,fadeInSeconds:.0263,fadeOutTicks:24,pulseWidth:50,dynamism:100,spread:58,shape:0,envelopes:[]}}])},{name:"Drum Presets",presets:S([{name:"standard drumset",midiProgram:116,isNoise:!0,settings:{type:"drumset",effects:"reverb",drums:[{filterEnvelope:"twang 1",spectrum:[57,71,71,86,86,86,71,71,71,71,57,57,57,57,43,43,43,43,29,29,29,29,29,29,29,29,29,29,29,29]},{filterEnvelope:"twang 1",spectrum:[0,0,0,100,71,71,57,86,57,57,57,71,43,43,57,43,43,43,43,43,43,43,43,43,43,43,43,43,43,43]},{filterEnvelope:"twang 1",spectrum:[0,0,0,0,100,57,43,43,29,57,43,29,71,43,43,43,43,57,43,43,43,43,43,43,43,43,29,43,43,43]},{filterEnvelope:"twang 1",spectrum:[0,0,0,0,0,71,57,43,43,43,57,57,43,29,57,43,43,43,29,43,57,43,43,43,43,43,43,29,43,43]},{filterEnvelope:"decay 2",spectrum:[0,14,29,43,86,71,29,43,43,43,43,29,71,29,71,29,43,43,43,43,57,43,43,57,43,43,43,57,57,57]},{filterEnvelope:"decay 1",spectrum:[0,0,14,14,14,14,29,29,29,43,43,43,57,57,57,71,71,71,71,71,71,71,71,57,57,57,57,43,43,43]},{filterEnvelope:"twang 3",spectrum:[43,43,43,71,29,29,43,43,43,29,43,43,43,29,29,43,43,29,29,29,57,14,57,43,43,57,43,43,57,57]},{filterEnvelope:"decay 3",spectrum:[29,43,43,43,43,29,29,43,29,29,43,29,14,29,43,29,43,29,57,29,43,57,43,71,43,71,57,57,71,71]},{filterEnvelope:"twang 3",spectrum:[43,29,29,43,29,29,29,57,29,29,29,57,43,43,29,29,57,43,43,43,71,43,43,71,57,71,71,71,71,71]},{filterEnvelope:"decay 3",spectrum:[57,57,57,43,57,57,43,43,57,43,43,43,71,57,43,57,86,71,57,86,71,57,86,100,71,86,86,86,86,86]},{filterEnvelope:"flare 1",spectrum:[0,0,14,14,14,14,29,29,29,43,43,43,57,57,71,71,86,86,100,100,100,100,100,100,100,100,86,57,29,0]},{filterEnvelope:"decay 2",spectrum:[14,14,14,14,29,14,14,29,14,43,14,43,57,86,57,57,100,57,43,43,57,100,57,43,29,14,0,0,0,0]}]}},{name:"steel pan",midiProgram:114,generalMidi:!0,settings:{type:"FM",eqFilter:[{type:"high-pass",cutoffHz:62.5,linearGain:.1768}],effects:["note filter","chorus","reverb"],noteFilter:[{type:"low-pass",cutoffHz:13454.34,linearGain:.25}],chorus:67,reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:24,chord:"simultaneous",algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"~1×",amplitude:14},{frequency:"7×",amplitude:3},{frequency:"3×",amplitude:5},{frequency:"4×",amplitude:4}],envelopes:[{target:"noteFilterAllFreqs",envelope:"decay 2"},{target:"operatorAmplitude",envelope:"flare 1",index:1},{target:"operatorAmplitude",envelope:"flare 2",index:2},{target:"operatorAmplitude",envelope:"swell 2",index:3}]}},{name:"steel pan synth",midiProgram:114,settings:{type:"FM",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:13454.34,linearGain:.25}],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"simultaneous",algorithm:"1 2 3←4",feedbackType:"1⟲",feedbackAmplitude:5,operators:[{frequency:"~1×",amplitude:12},{frequency:"2×",amplitude:15},{frequency:"4×",amplitude:14},{frequency:"~1×",amplitude:3}],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 1"},{target:"operatorAmplitude",envelope:"note size",index:0},{target:"operatorAmplitude",envelope:"note size",index:1},{target:"operatorAmplitude",envelope:"flare 1",index:2},{target:"operatorAmplitude",envelope:"flare 2",index:3},{target:"feedbackAmplitude",envelope:"flare 1"}]}},{name:"timpani",midiProgram:47,generalMidi:!0,settings:{type:"spectrum",eqFilter:[{type:"peak",cutoffHz:6727.17,linearGain:5.6569}],effects:["pitch shift","note filter","reverb"],pitchShiftSemitones:15,noteFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.5}],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",spectrum:[100,0,0,0,86,0,0,71,0,14,43,14,43,43,0,29,43,29,29,29,43,29,43,29,43,43,43,43,43,43],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"}]}},{name:"dark strike",midiProgram:47,settings:{type:"spectrum",eqFilter:[],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.7071}],reverb:33,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",spectrum:[0,0,14,14,14,29,29,43,43,86,43,43,43,29,86,29,29,29,86,29,14,14,14,14,0,0,0,0,0,0],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 2"}]}},{name:"woodblock",midiProgram:115,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-2.5,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:14,filterEnvelope:"twang 1",spectrum:[0,14,29,43,43,57,86,86,71,57,57,43,43,57,86,86,43,43,71,57,57,57,57,57,86,86,71,71,71,71]}},{name:"taiko drum",midiProgram:116,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-.5,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:29,filterEnvelope:"twang 1",spectrum:[71,100,100,43,43,71,71,43,43,43,43,43,43,57,29,57,43,57,43,43,57,43,43,43,43,43,43,43,43,43]}},{name:"melodic drum",midiProgram:117,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-1.5,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2828,filterResonance:43,filterEnvelope:"twang 1",spectrum:[100,71,71,57,57,43,43,71,43,43,43,57,43,43,57,43,43,43,43,29,29,29,29,29,29,29,29,29,29,29]}},{name:"drum synth",midiProgram:118,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-2,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:4e3,filterResonance:43,filterEnvelope:"decay 1",spectrum:[100,86,71,57,43,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29]}},{name:"tom-tom",midiProgram:116,isNoise:!0,midiSubharmonicOctaves:-1,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"twang 1",spectrum:[100,29,14,0,0,86,14,43,29,86,29,14,29,57,43,43,43,43,57,43,43,43,29,57,43,43,43,43,43,43]}},{name:"metal pipe",midiProgram:117,isNoise:!0,midiSubharmonicOctaves:-1.5,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:8e3,filterResonance:14,filterEnvelope:"twang 2",spectrum:[29,43,86,43,43,43,43,43,100,29,14,14,100,14,14,0,0,0,0,0,14,29,29,14,0,0,14,29,0,0]}},{name:"synth kick",midiProgram:47,settings:{type:"FM",eqFilter:[],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-6,chord:"simultaneous",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"8×",amplitude:15},{frequency:"1×",amplitude:0},{frequency:"1×",amplitude:0},{frequency:"1×",amplitude:0}],envelopes:[{target:"operatorFrequency",envelope:"twang 1",index:0},{target:"noteVolume",envelope:"twang 2"}]}}])},{name:"Novelty Presets",presets:S([{name:"guitar fret noise",midiProgram:120,generalMidi:!0,settings:{type:"spectrum",eqFilter:[{type:"high-pass",cutoffHz:1e3,linearGain:.1768}],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:5.6569}],transition:"normal",fadeInSeconds:.0125,fadeOutTicks:-3,chord:"simultaneous",spectrum:[0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,29,14,0,0,43,0,43,0,71,43,0,57,0],envelopes:[{target:"noteFilterAllFreqs",envelope:"flare 1"},{target:"noteVolume",envelope:"twang 2"}]}},{name:"fifth saw lead",midiProgram:86,generalMidi:!0,midiSubharmonicOctaves:1,settings:{type:"chip",eqFilter:[],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:1.4142}],chorus:67,transition:"normal",fadeInSeconds:0,fadeOutTicks:48,chord:"simultaneous",wave:"sawtooth",unison:"fifth",envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 3"}]}},{name:"fifth swell",midiProgram:86,midiSubharmonicOctaves:1,settings:{type:"chip",eqFilter:[],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:2e3,linearGain:2}],chorus:100,transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72,chord:"simultaneous",wave:"sawtooth",unison:"fifth",envelopes:[{target:"noteFilterAllFreqs",envelope:"swell 3"}]}},{name:"soundtrack",midiProgram:97,generalMidi:!0,settings:{type:"chip",eqFilter:[],effects:["note filter","chorus"],noteFilter:[{type:"low-pass",cutoffHz:2378.41,linearGain:.5}],chorus:67,transition:"normal",fadeInSeconds:.0413,fadeOutTicks:72,chord:"simultaneous",wave:"sawtooth",unison:"fifth",envelopes:[{target:"noteFilterAllFreqs",envelope:"flare 3"}]}},{name:"reverse cymbal",midiProgram:119,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-3,settings:{type:"spectrum",effects:"none",transition:"soft",chord:"harmony",filterCutoffHz:4e3,filterResonance:14,filterEnvelope:"swell 3",spectrum:[29,57,57,29,57,57,29,29,43,29,29,43,29,29,57,57,14,57,14,57,71,71,57,86,57,100,86,86,86,86]}},{name:"seashore",midiProgram:122,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-3,settings:{type:"spectrum",transition:"soft fade",effects:"reverb",chord:"harmony",filterCutoffHz:2828,filterResonance:0,filterEnvelope:"swell 3",spectrum:[14,14,29,29,43,43,43,57,57,57,57,57,57,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,71,57]}},{name:"bird tweet",midiProgram:123,generalMidi:!0,settings:{type:"harmonics",eqFilter:[],effects:["chord type","vibrato","reverb"],chord:"strum",vibrato:"heavy",reverb:67,fadeInSeconds:.0575,fadeOutTicks:-6,harmonics:[0,0,0,100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],unison:"hum",envelopes:[{target:"noteVolume",envelope:"decay 1"}]}},{name:"telephone ring",midiProgram:124,generalMidi:!0,settings:{type:"FM",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:5656.85,linearGain:1}],transition:"normal",fadeInSeconds:.0125,fadeOutTicks:-3,chord:"arpeggio",algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"2×",amplitude:12},{frequency:"1×",amplitude:4},{frequency:"20×",amplitude:1},{frequency:"1×",amplitude:0}],envelopes:[{target:"noteFilterAllFreqs",envelope:"tremolo4"},{target:"operatorAmplitude",envelope:"tremolo1",index:1}]}},{name:"helicopter",midiProgram:125,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-.5,settings:{type:"spectrum",effects:"reverb",transition:"seamless",chord:"arpeggio",filterCutoffHz:1414,filterResonance:14,filterEnvelope:"tremolo4",spectrum:[14,43,43,57,57,57,71,71,71,71,86,86,86,86,86,86,86,86,86,86,86,71,71,71,71,71,71,71,57,57]}},{name:"applause",midiProgram:126,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-3,settings:{type:"spectrum",effects:"reverb",transition:"soft fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"swell 3",spectrum:[14,14,29,29,29,43,43,57,71,71,86,86,86,71,71,57,57,57,71,86,86,86,86,86,71,71,57,57,57,57]}},{name:"gunshot",midiProgram:127,generalMidi:!0,isNoise:!0,midiSubharmonicOctaves:-2,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"strum",filterCutoffHz:1414,filterResonance:29,filterEnvelope:"twang 1",spectrum:[14,29,43,43,57,57,57,71,71,71,86,86,86,86,86,86,86,86,86,86,86,71,71,71,71,57,57,57,57,43]}},{name:"scoot",midiProgram:92,settings:{type:"chip",eqFilter:[],effects:["note filter"],noteFilter:[{type:"low-pass",cutoffHz:707.11,linearGain:4}],transition:"normal",fadeInSeconds:.0125,fadeOutTicks:-3,chord:"simultaneous",wave:"double saw",unison:"shimmer",envelopes:[{target:"noteFilterAllFreqs",envelope:"flare 1"}]}},{name:"buzz saw",midiProgram:30,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.5}],effects:[],transition:"normal",fadeInSeconds:.0263,fadeOutTicks:-3,chord:"custom interval",algorithm:"1←2←3←4",feedbackType:"1⟲",feedbackAmplitude:4,operators:[{frequency:"5×",amplitude:13},{frequency:"1×",amplitude:10},{frequency:"~1×",amplitude:6},{frequency:"11×",amplitude:12}],envelopes:[]}},{name:"mosquito",midiProgram:93,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:2}],effects:["vibrato"],vibrato:"shaky",transition:"normal",fadeInSeconds:.0575,fadeOutTicks:-6,chord:"simultaneous",pulseWidth:4.41942,envelopes:[{target:"pulseWidth",envelope:"tremolo6"}]}},{name:"breathing",midiProgram:126,isNoise:!0,midiSubharmonicOctaves:-1,settings:{type:"spectrum",effects:"reverb",transition:"hard fade",chord:"harmony",filterCutoffHz:2e3,filterResonance:14,filterEnvelope:"swell 2",spectrum:[14,14,14,29,29,29,29,29,43,29,29,43,43,43,29,29,71,43,86,86,57,100,86,86,86,86,71,86,71,57]}},{name:"klaxon synth",midiProgram:125,isNoise:!0,midiSubharmonicOctaves:-1,settings:{type:"noise",effects:"reverb",transition:"slide",chord:"harmony",filterCutoffHz:2e3,filterResonance:86,filterEnvelope:"steady",wave:"buzz"}},{name:"theremin",midiProgram:40,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:.7071}],effects:["vibrato","reverb"],vibrato:"heavy",reverb:33,transition:"slide in pattern",fadeInSeconds:.0263,fadeOutTicks:-6,chord:"simultaneous",harmonics:[100,71,57,43,29,29,14,14,14,14,14,14,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],unison:"none",envelopes:[]}},{name:"sonar ping",midiProgram:121,settings:{type:"spectrum",eqFilter:[],effects:["note filter","reverb"],noteFilter:[{type:"low-pass",cutoffHz:1681.79,linearGain:.5}],reverb:33,transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72,chord:"simultaneous",spectrum:[100,43,29,29,14,14,14,14,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],envelopes:[{target:"noteFilterAllFreqs",envelope:"twang 2"}]}}])},{name:"UltraBox Presets",presets:S([{name:"nes white",midiProgram:116,generalMidi:!0,isNoise:!0,settings:{type:"noise",eqFilter:[],eqFilterType:!1,eqSimpleCut:8,eqSimplePeak:0,eqSubFilters1:[],effects:["panning"],pan:0,panDelay:10,fadeInSeconds:0,fadeOutTicks:0,wave:"1-bit white",envelopes:[]}},{name:"nes ping",midiProgram:116,generalMidi:!0,isNoise:!0,settings:{type:"noise",eqFilter:[],eqFilterType:!1,eqSimpleCut:8,eqSimplePeak:0,eqSubFilters1:[],effects:["panning"],pan:0,panDelay:10,fadeInSeconds:0,fadeOutTicks:0,wave:"1-bit metallic",envelopes:[]}},{name:"distorted pulse vocal",generalMidi:!1,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.0884}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:19027.31,linearGain:.0884}],effects:["panning","transition type","pitch shift","vibrato","note filter","bitcrusher","echo","reverb"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:0,vibrato:"delayed",vibratoDepth:.3,vibratoDelay:18.5,vibratoSpeed:10,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"high-pass",cutoffHz:840.9,linearGain:11.3137},{type:"low-pass",cutoffHz:297.3,linearGain:8},{type:"peak",cutoffHz:500,linearGain:11.3137},{type:"high-pass",cutoffHz:62.5,linearGain:1.4142},{type:"peak",cutoffHz:176.78,linearGain:11.3137},{type:"high-pass",cutoffHz:250,linearGain:11.3137}],noteSubFilters0:[{type:"high-pass",cutoffHz:840.9,linearGain:11.3137},{type:"low-pass",cutoffHz:297.3,linearGain:8},{type:"peak",cutoffHz:500,linearGain:11.3137},{type:"high-pass",cutoffHz:62.5,linearGain:1.4142},{type:"peak",cutoffHz:176.78,linearGain:11.3137},{type:"high-pass",cutoffHz:250,linearGain:11.3137}],bitcrusherOctave:6.5,bitcrusherQuantization:71,pan:0,panDelay:10,echoSustain:14,echoDelayBeats:.167,reverb:0,fadeInSeconds:0,fadeOutTicks:-3,wave:"1/8 pulse",unison:"none",envelopes:[]}},{name:"dubsteb bwah",generalMidi:!1,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.7071}],eqFilterType:!0,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters1:[],effects:["panning","transition type","chord type"],transition:"interrupt",clicklessTransition:!1,chord:"custom interval",fastTwoNoteArp:!1,arpeggioSpeed:12,pan:0,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:10,operators:[{frequency:"2×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"4×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:11,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:13,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteVolume",envelope:"note size"},{target:"operatorAmplitude",envelope:"swell 2",index:1},{target:"operatorAmplitude",envelope:"punch",index:2},{target:"operatorAmplitude",envelope:"note size",index:3}]}},{name:"FM cool bass",generalMidi:!1,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:1},{type:"high-pass",cutoffHz:88.39,linearGain:1},{type:"peak",cutoffHz:1e3,linearGain:.7071}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:6727.17,linearGain:1},{type:"high-pass",cutoffHz:88.39,linearGain:1},{type:"peak",cutoffHz:1e3,linearGain:.7071}],effects:["panning","transition type","note filter","reverb"],transition:"interrupt",clicklessTransition:!1,noteFilterType:!0,noteSimpleCut:9,noteSimplePeak:2,noteFilter:[{type:"low-pass",cutoffHz:7231.23,linearGain:1}],noteSubFilters1:[{type:"low-pass",cutoffHz:7231.23,linearGain:1}],pan:0,panDelay:10,reverb:0,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←(2 3←4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"2×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:8,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:7,waveform:"sine",pulseWidth:5},{frequency:"13×",amplitude:11,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteFilterAllFreqs",envelope:"punch"},{target:"operatorAmplitude",envelope:"twang 2",index:1},{target:"operatorAmplitude",envelope:"twang 3",index:2},{target:"operatorAmplitude",envelope:"twang 2",index:3}]}},{name:"FM funky bass",generalMidi:!1,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.1768}],eqFilterType:!0,eqSimpleCut:5,eqSimplePeak:0,eqSubFilters1:[],effects:["panning","transition type","reverb"],transition:"normal",clicklessTransition:!1,pan:0,panDelay:10,reverb:0,fadeInSeconds:0,fadeOutTicks:-3,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"~1×",amplitude:8,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteVolume",envelope:"punch"},{target:"noteVolume",envelope:"note size"}]}},{name:"talking bass",generalMidi:!1,settings:{type:"FM",eqFilter:[],effects:["chord type"],chord:"custom interval",fadeInSeconds:0,fadeOutTicks:-3,algorithm:"1←(2 3)←4",feedbackType:"1⟲",feedbackAmplitude:15,operators:[{frequency:"1×",amplitude:15},{frequency:"2×",amplitude:8},{frequency:"2×",amplitude:5},{frequency:"1×",amplitude:12}],envelopes:[{target:"operatorAmplitude",envelope:"note size",index:2},{target:"operatorAmplitude",envelope:"note size",index:3},{target:"feedbackAmplitude",envelope:"note size"}]}},{name:"synth marimba",generalMidi:!1,settings:{type:"Picked String",eqFilter:[{type:"high-pass",cutoffHz:176.78,linearGain:1},{type:"peak",cutoffHz:4e3,linearGain:.5}],effects:["note filter","echo"],noteFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:1.4142}],echoSustain:71,echoDelayBeats:.5,fadeInSeconds:0,fadeOutTicks:-1,harmonics:[86,100,29,29,0,0,0,100,0,0,0,86,29,0,14,100,0,0,0,0,0,14,0,0,14,0,0,86],unison:"fifth",stringSustain:7,envelopes:[{target:"noteFilterAllFreqs",envelope:"punch"}]}},{name:"italian accordian",generalMidi:!1,settings:{type:"custom chip",eqFilter:[{type:"low-pass",cutoffHz:6e3,linearGain:.5}],eqFilterType:!0,eqSimpleCut:8,eqSimplePeak:1,eqSubFilters1:[],effects:["panning","chorus","reverb"],pan:0,panDelay:10,chorus:71,reverb:45,fadeInSeconds:.0263,fadeOutTicks:-3,wave:"square",unison:"honky tonk",customChipWave:{0:-24,1:-24,2:-24,3:-24,4:-24,5:-24,6:-24,7:-24,8:-24,9:-24,10:-24,11:-24,12:-24,13:-24,14:-24,15:-24,16:24,17:24,18:24,19:24,20:24,21:24,22:24,23:24,24:-24,25:-24,26:-24,27:-24,28:-24,29:-24,30:-24,31:-24,32:-24,33:-24,34:-24,35:-24,36:-24,37:-24,38:-24,39:-24,40:24,41:24,42:24,43:24,44:24,45:24,46:24,47:24,48:-24,49:-24,50:-24,51:-24,52:-24,53:-24,54:-24,55:-24,56:-24,57:-24,58:-24,59:-24,60:-24,61:-24,62:-24,63:-24},customChipWaveIntegral:{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,59:0,60:0,61:0,62:0,63:0,64:0},envelopes:[]}},{name:"chip supersaw",generalMidi:!1,settings:{type:"custom chip",eqFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.7071}],eqFilterType:!0,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters1:[],effects:["panning","transition type","vibrato","chorus","reverb"],transition:"interrupt",clicklessTransition:!1,vibrato:"delayed",vibratoDepth:.3,vibratoDelay:18.5,vibratoSpeed:10,vibratoType:0,pan:0,panDelay:10,chorus:29,reverb:29,fadeInSeconds:0,fadeOutTicks:-1,wave:"square",unison:"dissonant",customChipWave:{0:22,1:22,2:16,3:6,4:0,5:-3,6:-8,7:-10,8:-13,9:-16,10:-19,11:-19,12:-20,13:-22,14:-22,15:-24,16:-24,17:-24,18:-24,19:-24,20:-24,21:-24,22:-24,23:-24,24:-24,25:-24,26:-24,27:-24,28:-24,29:-24,30:-24,31:24,32:24,33:16,34:9,35:6,36:4,37:2,38:0,39:-1,40:-3,41:-4,42:-4,43:-6,44:-6,45:-6,46:-6,47:-5,48:-5,49:-4,50:-2,51:-2,52:1,53:4,54:6,55:8,56:10,57:12,58:14,59:16,60:18,61:19,62:22,63:24},customChipWaveIntegral:{0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0,11:0,12:0,13:0,14:0,15:0,16:0,17:0,18:0,19:0,20:0,21:0,22:0,23:0,24:0,25:0,26:0,27:0,28:0,29:0,30:0,31:0,32:0,33:0,34:0,35:0,36:0,37:0,38:0,39:0,40:0,41:0,42:0,43:0,44:0,45:0,46:0,47:0,48:0,49:0,50:0,51:0,52:0,53:0,54:0,55:0,56:0,57:0,58:0,59:0,60:0,61:0,62:0,63:0,64:0},envelopes:[]}},{name:"fm supersaw",generalMidi:!1,settings:{type:"FM6op",eqFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:1.4142},{type:"high-pass",cutoffHz:148.65,linearGain:.7071}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:19027.31,linearGain:1.4142},{type:"high-pass",cutoffHz:148.65,linearGain:.7071}],effects:["panning","transition type","pitch shift","note filter","chorus","reverb"],transition:"continue",clicklessTransition:!1,pitchShiftSemitones:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[],noteSubFilters0:[],noteSubFilters1:[{type:"low-pass",cutoffHz:4756.83,linearGain:1}],pan:0,panDelay:10,chorus:71,reverb:0,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1 2 3 4 5 6",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:13,waveform:"sawtooth",pulseWidth:5},{frequency:"~1×",amplitude:15,waveform:"sawtooth",pulseWidth:5},{frequency:"2×",amplitude:10,waveform:"sawtooth",pulseWidth:5},{frequency:"3×",amplitude:7,waveform:"sawtooth",pulseWidth:5},{frequency:"4×",amplitude:9,waveform:"sawtooth",pulseWidth:5},{frequency:"8×",amplitude:6,waveform:"sawtooth",pulseWidth:5}],envelopes:[]}},{name:"wind",generalMidi:!1,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:250.03,linearGain:11.3137}],eqFilterType:!0,eqSimpleCut:0,eqSimplePeak:7,envelopeSpeed:12,discreteEnvelope:!1,eqSubFilters1:[],effects:["transition type","reverb"],transition:"continue",clicklessTransition:!1,panDelay:10,reverb:0,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←(2 3 4)",feedbackType:"1→3 2→4",feedbackAmplitude:15,operators:[{frequency:"16×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"16×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"16×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"16×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[]}},{name:"mrow",generalMidi:!1,settings:{type:"FM",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[],effects:["panning","chord type","reverb"],chord:"custom interval",fastTwoNoteArp:!1,arpeggioSpeed:12,pan:0,panDelay:10,reverb:35,fadeInSeconds:.0263,fadeOutTicks:-3,algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲ 3⟲ 4⟲",feedbackAmplitude:5,operators:[{frequency:"4×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"~2×",amplitude:13,waveform:"sine",pulseWidth:5},{frequency:"~2×",amplitude:8,waveform:"sine",pulseWidth:5},{frequency:"~2×",amplitude:9,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorAmplitude",envelope:"flare 1",index:0},{target:"operatorAmplitude",envelope:"note size",index:1},{target:"operatorAmplitude",envelope:"note size",index:2},{target:"operatorAmplitude",envelope:"flare 3",index:3},{target:"feedbackAmplitude",envelope:"flare 1"}]}},{name:"vocal why",generalMidi:!1,settings:{type:"harmonics",eqFilter:[],effects:["note filter","panning","reverb"],noteFilter:[{type:"low-pass",cutoffHz:840.9,linearGain:11.3137}],pan:0,reverb:0,fadeInSeconds:.0263,fadeOutTicks:-3,harmonics:[100,86,29,29,14,14,0,14,14,43,71,100,100,86,71,71,57,57,43,43,43,43,43,0,0,0,0,0],unison:"octave",envelopes:[{target:"noteFilterAllFreqs",envelope:"note size"}]}}])}]);class H{constructor(){this.i=1,this.o=[void 0],this.l=0,this.h=0,this.p=0}pushFront(e){this.p>=this.i&&this.u(),this.h=this.h-1&this.l,this.o[this.h]=e,this.p++}pushBack(e){this.p>=this.i&&this.u(),this.o[this.h+this.p&this.l]=e,this.p++}popFront(){if(this.p<=0)throw new Error("No elements left to pop.");const e=this.o[this.h];return this.o[this.h]=void 0,this.h=this.h+1&this.l,this.p--,e}popBack(){if(this.p<=0)throw new Error("No elements left to pop.");this.p--;const e=this.h+this.p&this.l,t=this.o[e];return this.o[e]=void 0,t}peakFront(){if(this.p<=0)throw new Error("No elements left to pop.");return this.o[this.h]}peakBack(){if(this.p<=0)throw new Error("No elements left to pop.");return this.o[this.h+this.p-1&this.l]}count(){return this.p}set(e,t){if(e<0||e>=this.p)throw new Error("Invalid index");this.o[this.h+e&this.l]=t}get(e){if(e<0||e>=this.p)throw new Error("Invalid index");return this.o[this.h+e&this.l]}remove(e){if(e<0||e>=this.p)throw new Error("Invalid index");if(e<=this.p>>1){for(;e>0;)this.set(e,this.get(e-1)),e--;this.popFront()}else{for(e++;e<this.p;)this.set(e-1,this.get(e)),e++;this.popBack()}}u(){if(this.i>=1073741824)throw new Error("Capacity too big.");this.i=this.i<<1;const e=this.o,t=new Array(this.i),s=0|this.p,i=0|this.h;for(let n=0;n<s;n++)t[n]=e[i+n&this.l];for(let e=s;e<this.i;e++)t[e]=void 0;this.h=0,this.o=t,this.l=this.i-1}}const L=new class{constructor(){this.activeEvents=[],this.listeners={},this.activeEvents=[],this.listeners={}}raise(e,t,s){if(null!=this.listeners[e]){this.activeEvents.push(e);for(let i=0;i<this.listeners[e].length;i++)this.listeners[e][i](t,s);this.activeEvents.pop()}}listen(e,t){null==this.listeners[e]&&(this.listeners[e]=[]),this.listeners[e].push(t)}unlisten(e,t){if(null==this.listeners[e])return;const s=this.listeners[e].indexOf(t);-1!=s&&this.listeners[e].splice(s,1)}unlistenAll(e){null!=this.listeners[e]&&(this.listeners[e]=[])}};class N{constructor(){this.a=[1],this.b=[1],this.order=0}linearGain0thOrder(e){this.b[0]=e,this.order=0}lowPass1stOrderButterworth(e){const t=1/Math.tan(.5*e),s=1+t;this.a[1]=(1-t)/s,this.b[1]=this.b[0]=1/s,this.order=1}lowPass1stOrderSimplified(e){const t=2*Math.sin(.5*e);this.a[1]=t-1,this.b[0]=t,this.b[1]=0,this.order=1}highPass1stOrderButterworth(e){const t=1/Math.tan(.5*e),s=1+t;this.a[1]=(1-t)/s,this.b[0]=t/s,this.b[1]=-t/s,this.order=1}highShelf1stOrder(e,t){const s=Math.tan(.5*e),i=Math.sqrt(t),n=(s*i-1)/(s*i+1);this.a[1]=n/1,this.b[0]=(1+n+t*(1-n))/2,this.b[1]=(1+n-t*(1-n))/2,this.order=1}allPass1stOrderInvertPhaseAbove(e){const t=(Math.sin(e)-1)/Math.cos(e);this.a[1]=t,this.b[0]=t,this.b[1]=1,this.order=1}allPass1stOrderFractionalDelay(e){const t=(1-e)/(1+e);this.a[1]=t,this.b[0]=t,this.b[1]=1,this.order=1}lowPass2ndOrderButterworth(e,t){const s=Math.sin(e)/(2*t),i=Math.cos(e),n=1+s;this.a[1]=-2*i/n,this.a[2]=(1-s)/n,this.b[2]=this.b[0]=(1-i)/(2*n),this.b[1]=(1-i)/n,this.order=2}lowPass2ndOrderSimplified(e,t){const s=2*Math.sin(e/2),i=1-1/(2*t),n=i+i/(1-s);this.a[1]=2*s+(s-1)*s*n-2,this.a[2]=(s-1)*(s-s*n-1),this.b[0]=s*s,this.b[1]=0,this.b[2]=0,this.order=2}highPass2ndOrderButterworth(e,t){const s=Math.sin(e)/(2*t),i=Math.cos(e),n=1+s;this.a[1]=-2*i/n,this.a[2]=(1-s)/n,this.b[2]=this.b[0]=(1+i)/(2*n),this.b[1]=-(1+i)/n,this.order=2}highShelf2ndOrder(e,t,s){const i=Math.sqrt(t),n=Math.cos(e),a=i+1,o=i-1,r=.5*Math.sin(e)*Math.sqrt(a/i*(1/s-1)+2),l=2*Math.sqrt(i)*r,h=a-o*n+l;this.a[1]=2*(o-a*n)/h,this.a[2]=(a-o*n-l)/h,this.b[0]=i*(a+o*n+l)/h,this.b[1]=-2*i*(o+a*n)/h,this.b[2]=i*(a+o*n-l)/h,this.order=2}peak2ndOrder(e,t,s){const i=Math.sqrt(t),n=s*e/(i>=1?i:1/i),a=Math.tan(.5*n),o=1+a/i;this.b[0]=(1+a*i)/o,this.b[1]=this.a[1]=-2*Math.cos(e)/o,this.b[2]=(1-a*i)/o,this.a[2]=(1-a/i)/o,this.order=2}}class W{constructor(){this.real=0,this.imag=0,this.denom=1}analyze(e,t){this.analyzeComplex(e,Math.cos(t),Math.sin(t))}analyzeComplex(e,t,s){const i=e.a,n=e.b,a=t,o=-s;let r=n[0]+n[1]*a,l=n[1]*o,h=1+i[1]*a,p=i[1]*o,c=a,u=o;for(let t=2;t<=e.order;t++){const e=c*o+u*a;c=c*a-u*o,u=e,r+=n[t]*c,l+=n[t]*u,h+=i[t]*c,p+=i[t]*u}this.denom=h*h+p*p,this.real=r*h+l*p,this.imag=l*h-r*p}magnitude(){return Math.sqrt(this.real*this.real+this.imag*this.imag)/this.denom}angle(){return Math.atan2(this.imag,this.real)}}class G{constructor(){this.a1=0,this.a2=0,this.b0=1,this.b1=0,this.b2=0,this.a1Delta=0,this.a2Delta=0,this.b0Delta=0,this.b1Delta=0,this.b2Delta=0,this.output1=0,this.output2=0,this.useMultiplicativeInputCoefficients=!1}resetOutput(){this.output1=0,this.output2=0}loadCoefficientsWithGradient(e,t,s,i){if(2!=e.order||2!=t.order)throw new Error;this.a1=e.a[1],this.a2=e.a[2],this.b0=e.b[0],this.b1=e.b[1],this.b2=e.b[2],this.a1Delta=(t.a[1]-e.a[1])*s,this.a2Delta=(t.a[2]-e.a[2])*s,i?(this.b0Delta=Math.pow(t.b[0]/e.b[0],s),this.b1Delta=Math.pow(t.b[1]/e.b[1],s),this.b2Delta=Math.pow(t.b[2]/e.b[2],s)):(this.b0Delta=(t.b[0]-e.b[0])*s,this.b1Delta=(t.b[1]-e.b[1])*s,this.b2Delta=(t.b[2]-e.b[2])*s),this.useMultiplicativeInputCoefficients=i}}function B(e){return 2*Math.atan(.5*e)}const V=1e-24;function $(e,t,s){return s<=(t-=1)?s>=e?s:e:t}function U(e,t,s){if(e<=s&&s<=t)return s;throw new Error(`Value ${s} not in range [${e}, ${t}]`)}function j(e,t){let s=parseFloat(e);return Number.isNaN(s)&&(s=t),s}function _(e,t){let s=parseInt(e);return Number.isNaN(s)&&(s=t),s}function Y(e,t){e.push(X[t>>>30&3]),e.push(X[t>>>24&63]),e.push(X[t>>>18&63]),e.push(X[t>>>12&63]),e.push(X[t>>>6&63]),e.push(X[t>>>0&63])}function K(e,t){let s=0;return s|=Z[e.charCodeAt(t++)]<<30,s|=Z[e.charCodeAt(t++)]<<24,s|=Z[e.charCodeAt(t++)]<<18,s|=Z[e.charCodeAt(t++)]<<12,s|=Z[e.charCodeAt(t++)]<<6,s|=Z[e.charCodeAt(t++)]<<0,s}function J(e,t,s,i,n,a){e.push(X[t]),e.push(X[Number(s>0)]);let o=Math.round(1e3*Math.abs(s)),r=Math.floor(o/63);e.push(X[o%63],X[r%63],X[Math.floor(r/63)]),e.push(X[Number(i>0)]);let l=Math.round(1e3*Math.abs(i)),h=Math.floor(l/63);e.push(X[l%63],X[h%63],X[Math.floor(h/63)]),e.push(X[Number(n>0)]);let p=Math.round(1e3*Math.abs(n));e.push(X[p%63],X[Math.floor(p/63)]),e.push(X[Number(a>0)]);let c=Math.round(1e3*Math.abs(a));e.push(X[c%63],X[Math.floor(c/63)])}function Q(e){let t=$(0,p.keys.length,e),s=0;return 12===e?(t=0,s=1):13===e?(t=6,s=-1):14===e?(t=0,s=-1):15===e&&(t=5,s=-1),[t,s]}const X=[48,49,50,51,52,53,54,55,56,57,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,45,95],Z=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,62,62,0,0,1,2,3,4,5,6,7,8,9,0,0,0,0,0,0,0,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,0,0,0,0,63,0,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,0,0,0,0,0];class ee{constructor(e,t,s){this.m=[],this.v=0;for(let i=t;i<s;i++){const t=Z[e.charCodeAt(i)];this.m.push(t>>5&1),this.m.push(t>>4&1),this.m.push(t>>3&1),this.m.push(t>>2&1),this.m.push(t>>1&1),this.m.push(1&t)}}read(e){let t=0;for(;e>0;)t<<=1,t+=this.m[this.v++],e--;return t}readLongTail(e,t){let s=e,i=t;for(;this.m[this.v++];)s+=1<<i,i++;for(;i>0;)i--,this.m[this.v++]&&(s+=1<<i);return s}readPartDuration(){return this.readLongTail(1,3)}readLegacyPartDuration(){return this.readLongTail(1,2)}readPinCount(){return this.readLongTail(1,0)}readPitchInterval(){return this.read(1)?-this.readLongTail(1,3):this.readLongTail(1,3)}}class te{constructor(){this.g=0,this.m=[]}clear(){this.g=0}write(e,t){for(e--;e>=0;)this.m[this.g++]=t>>>e&1,e--}writeLongTail(e,t,s){if(s<e)throw new Error("value out of bounds");s-=e;let i=t;for(;s>=1<<i;)this.m[this.g++]=1,s-=1<<i,i++;for(this.m[this.g++]=0;i>0;)i--,this.m[this.g++]=s>>>i&1}writePartDuration(e){this.writeLongTail(1,3,e)}writePinCount(e){this.writeLongTail(1,0,e)}writePitchInterval(e){e<0?(this.write(1,1),this.writeLongTail(1,3,-e)):(this.write(1,0),this.writeLongTail(1,3,e))}concat(e){for(let t=0;t<e.g;t++)this.m[this.g++]=e.m[t]}encodeBase64(e){for(let t=0;t<this.g;t+=6){const s=this.m[t]<<5|this.m[t+1]<<4|this.m[t+2]<<3|this.m[t+3]<<2|this.m[t+4]<<1|this.m[t+5];e.push(X[s])}return e}lengthBase64(){return Math.ceil(this.g/6)}}function se(e,t,s){return{interval:e,time:t,size:s}}class ie{constructor(e,t,s,i,n=!1){this.pitches=[e],this.pins=[se(0,0,i),se(0,s-t,n?0:i)],this.start=t,this.end=s,this.continuesLastPattern=!1}pickMainInterval(){let e=0,t=0;for(let s=1;s<this.pins.length;s++){const i=this.pins[s-1],n=this.pins[s];if(i.interval==n.interval){const s=n.time-i.time;e<s&&(e=s,t=i.interval)}}if(0==e){let e=0;for(let s=0;s<this.pins.length;s++){const i=this.pins[s];e<i.size&&(e=i.size,t=i.interval)}}return t}clone(){const e=new ie(-1,this.start,this.end,3);e.pitches=this.pitches.concat(),e.pins=[];for(const t of this.pins)e.pins.push(se(t.interval,t.time,t.size));return e.continuesLastPattern=this.continuesLastPattern,e}getEndPinIndex(e){let t;for(t=1;t<this.pins.length-1&&!(this.pins[t].time+this.start>e);t++);return t}}class ne{constructor(){this.notes=[],this.instruments=[0]}cloneNotes(){const e=[];for(const t of this.notes)e.push(t.clone());return e}reset(){this.notes.length=0,this.instruments[0]=0,this.instruments.length=1}toJsonObject(e,t,s){const i=[];for(const n of this.notes){let a=t.instruments[this.instruments[0]],o=Math.max(0,p.modCount-n.pitches[0]-1),r=e.getVolumeCapForSetting(s,a.modulators[o],a.modFilterTypes[o]);const l=[];for(const t of n.pins){let i=s?Math.round(t.size):Math.round(100*t.size/r);l.push({tick:(t.time+n.start)*p.rhythms[e.rhythm].stepsPerBeat/p.partsPerBeat,pitchBend:t.interval,volume:i,forMod:s})}const h={pitches:n.pitches,points:l};0==n.start&&(h.continuesLastPattern=n.continuesLastPattern),i.push(h)}const n={notes:i};return e.patternInstruments&&(n.instruments=this.instruments.map((e=>e+1))),n}fromJsonObject(e,t,s,i,n,a){if(t.patternInstruments)if(Array.isArray(e.instruments)){const i=e.instruments,n=$(p.instrumentCountMin,t.getMaxInstrumentsPerPatternForChannel(s)+1,i.length);for(let e=0;e<n;e++)this.instruments[e]=$(0,s.instruments.length,(0|i[e])-1);this.instruments.length=n}else this.instruments[0]=$(0,s.instruments.length,(0|e.instrument)-1),this.instruments.length=1;if(e.notes&&e.notes.length>0){const o=Math.min(t.beatsPerBar*p.partsPerBeat*(a?p.modCount:1),e.notes.length>>>0);for(let r=0;r<e.notes.length&&!(r>=o);r++){const o=e.notes[r];if(!(o&&o.pitches&&o.pitches.length>=1&&o.points&&o.points.length>=2))continue;const l=new ie(0,0,0,0);l.pitches=[],l.pins=[];for(let e=0;e<o.pitches.length;e++){const t=0|o.pitches[e];if(-1==l.pitches.indexOf(t)&&(l.pitches.push(t),l.pitches.length>=p.maxChordSize))break}if(l.pitches.length<1)continue;let h=0;for(let e=0;e<o.points.length;e++){const n=o.points[e];if(null==n||null==n.tick)continue;const r=null==n.pitchBend?0:0|n.pitchBend,c=Math.round(+n.tick*p.partsPerBeat/i);let u,f=s.instruments[this.instruments[0]],m=Math.max(0,p.modCount-l.pitches[0]-1),d=t.getVolumeCapForSetting(a,f.modulators[m],f.modFilterTypes[m]);u=null==n.volume?d:null==n.forMod?Math.max(0,Math.min(d,Math.round((0|n.volume)*d/100))):(0|n.forMod)>0?Math.round(0|n.volume):Math.max(0,Math.min(d,Math.round((0|n.volume)*d/100))),c>t.beatsPerBar*p.partsPerBeat||(0==l.pins.length&&(l.start=c,h=r),l.pins.push(se(r-h,c-l.start,u)))}if(l.pins.length<2)continue;l.end=l.pins[l.pins.length-1].time+l.start;const c=n?p.drumCount-1:p.maxPitch;let u=c,f=0;for(let e=0;e<l.pitches.length;e++)l.pitches[e]+=h,(l.pitches[e]<0||l.pitches[e]>c)&&(l.pitches.splice(e,1),e--),l.pitches[e]<u&&(u=l.pitches[e]),l.pitches[e]>f&&(f=l.pitches[e]);if(!(l.pitches.length<1)){for(let e=0;e<l.pins.length;e++){const t=l.pins[e];t.interval+u<0&&(t.interval=-u),t.interval+f>c&&(t.interval=c-f),e>=2&&t.interval==l.pins[e-1].interval&&t.interval==l.pins[e-2].interval&&t.size==l.pins[e-1].size&&t.size==l.pins[e-2].size&&(l.pins.splice(e-1,1),e--)}0==l.start?l.continuesLastPattern=!0===o.continuesLastPattern:l.continuesLastPattern=!1,this.notes.push(l)}}}}}class ae{constructor(e){this.frequency=4,this.amplitude=0,this.waveform=0,this.pulseWidth=.5,this.reset(e)}reset(e){this.frequency=4,this.amplitude=e<=1?p.operatorAmplitudeMax:0,this.waveform=0,this.pulseWidth=5}copy(e){this.frequency=e.frequency,this.amplitude=e.amplitude,this.waveform=e.waveform,this.pulseWidth=e.pulseWidth}}class oe{constructor(){this.name="",this.carrierCount=0,this.modulatedBy=[[],[],[],[],[],[]],this.associatedCarrier=[],this.fromPreset(1)}set(e,t){this.reset(),this.carrierCount=e;for(let s=0;s<this.modulatedBy.length;s++){this.modulatedBy[s]=t[s],s<e&&(this.associatedCarrier[s]=s+1),this.name+=s+1;for(let i=0;i<t[s].length;i++)this.name+=t[s][i],t[s][i]>e-1&&(this.associatedCarrier[t[s][i]-1]=s+1),this.name+=",";this.name+=s<e?"|":"."}}reset(){this.name="",this.carrierCount=1,this.modulatedBy=[[2,3,4,5,6],[],[],[],[],[]],this.associatedCarrier=[1,1,1,1,1,1]}copy(e){this.name=e.name,this.carrierCount=e.carrierCount,this.modulatedBy=e.modulatedBy,this.associatedCarrier=e.associatedCarrier}fromPreset(e){this.reset();let t=p.algorithms6Op[e];this.name=t.name,this.carrierCount=t.carrierCount;for(var s=0;s<t.modulatedBy.length;s++)this.modulatedBy[s]=Array.from(t.modulatedBy[s]),this.associatedCarrier[s]=t.associatedCarrier[s]}}class re{constructor(){this.name="",this.indices=[[],[],[],[],[],[]],this.fromPreset(1)}set(e){this.reset();for(let t=0;t<this.indices.length;t++){this.indices[t]=e[t];for(let s=0;s<e[t].length;s++)this.name+=e[t][s],this.name+=",";this.name+="."}}reset(){this.reset,this.name="",this.indices=[[1],[],[],[],[],[]]}copy(e){this.name=e.name,this.indices=e.indices}fromPreset(e){this.reset();let t=p.feedbacks6Op[e];for(var s=0;s<t.indices.length;s++){this.indices[s]=Array.from(t.indices[s]);for(let e=0;e<t.indices[s].length;e++)this.name+=t.indices[s][e],this.name+=",";this.name+="."}}}class le{constructor(e){this.spectrum=[],this.hash=-1,this.reset(e)}reset(e){for(let t=0;t<p.spectrumControlPoints;t++)if(e)this.spectrum[t]=Math.round(p.spectrumMax*(1/Math.sqrt(1+t/3)));else{const e=0==t||7==t||11==t||14==t||16==t||18==t||21==t||23==t||t>=25;this.spectrum[t]=e?Math.max(0,Math.round(p.spectrumMax*(1-t/30))):0}this.markCustomWaveDirty()}markCustomWaveDirty(){const e=xe.fittingPowerOfTwo(p.spectrumMax+2)-1;let t=0;for(const s of this.spectrum)t=t*e+s>>>0;this.hash=t}}class he{constructor(){this.wave=null,this.S=-1}getCustomWave(e,t){if(this.S==e.hash)return this.wave;this.S=e.hash;const s=p.spectrumNoiseLength;null!=this.wave&&this.wave.length==s+1||(this.wave=new Float32Array(s+1));const i=this.wave;for(let e=0;e<s;e++)i[e]=0;const n=[0,1/7,Math.log2(5/4),3/7,Math.log2(1.5),5/7,6/7];function a(e){return t+Math.floor(e/p.spectrumControlPointsPerOctave)+n[(e+p.spectrumControlPointsPerOctave)%p.spectrumControlPointsPerOctave]}let o=1;for(let t=0;t<p.spectrumControlPoints+1;t++){const n=t<=0?0:e.spectrum[t-1],r=t>=p.spectrumControlPoints?e.spectrum[p.spectrumControlPoints-1]:e.spectrum[t],l=a(t-1);let h=a(t);t>=p.spectrumControlPoints&&(h=14+.25*(h-14)),0==n&&0==r||(o+=.02*y(i,s,l,h,n/p.spectrumMax,r/p.spectrumMax,-.5))}return e.spectrum[p.spectrumControlPoints-1]>0&&(o+=.02*y(i,s,14+.25*(a(p.spectrumControlPoints)-14),14,e.spectrum[p.spectrumControlPoints-1]/p.spectrumMax,0,-.5)),E(i,s),C(i,5/(Math.sqrt(s)*Math.pow(o,.75))),i[s]=i[0],i}}class pe{constructor(){this.harmonics=[],this.hash=-1,this.reset()}reset(){for(let e=0;e<p.harmonicsControlPoints;e++)this.harmonics[e]=0;this.harmonics[0]=p.harmonicsMax,this.harmonics[3]=p.harmonicsMax,this.harmonics[6]=p.harmonicsMax,this.markCustomWaveDirty()}markCustomWaveDirty(){const e=xe.fittingPowerOfTwo(p.harmonicsMax+2)-1;let t=0;for(const s of this.harmonics)t=t*e+s>>>0;this.hash=t}}class ce{constructor(){this.wave=null,this.S=-1}getCustomWave(e,t){if(this.S==e.hash&&this.M==t)return this.wave;this.S=e.hash,this.M=t;const s=8==t?p.harmonicsRenderedForPickedString:p.harmonicsRendered,i=p.harmonicsWavelength,n=d(0,null,null);null!=this.wave&&this.wave.length==i+1||(this.wave=new Float32Array(i+1));const a=this.wave;for(let e=0;e<i;e++)a[e]=0;let o=1;for(let t=0;t<s;t++){const r=t+1;let l=t<p.harmonicsControlPoints?e.harmonics[t]:e.harmonics[p.harmonicsControlPoints-1];t>=p.harmonicsControlPoints&&(l*=1-(t-p.harmonicsControlPoints)/(s-p.harmonicsControlPoints));const h=l/p.harmonicsMax;let c=Math.pow(2,l-p.harmonicsMax+1)*Math.sqrt(h);t<p.harmonicsControlPoints&&(o+=c),c*=Math.pow(r,-.25),c*=n[t+589],a[i-r]=c}E(a,i);const r=1/Math.pow(o,.7);for(let e=0;e<a.length;e++)a[e]*=r;return function(e){let t=0;for(let s=0;s<e.length;s++){const i=e[s];e[s]=t,t+=i}}(a),a[i]=a[0],a}}class ue{constructor(){this.freq=0,this.gain=p.filterGainCenter,this.type=2}set(e,t){this.freq=e,this.gain=t}getHz(){return ue.getHzFromSettingValue(this.freq)}static getHzFromSettingValue(e){return p.filterFreqReferenceHz*Math.pow(2,(e-p.filterFreqReferenceSetting)*p.filterFreqStep)}static getSettingValueFromHz(e){return Math.log2(e/p.filterFreqReferenceHz)/p.filterFreqStep+p.filterFreqReferenceSetting}static getRoundedSettingValueFromHz(e){return Math.max(0,Math.min(p.filterFreqRange-1,Math.round(ue.getSettingValueFromHz(e))))}getLinearGain(e=1){const t=(this.gain-p.filterGainCenter)*p.filterGainStep,s=2==this.type?0:-.5,i=s+(t-s)*e;return Math.pow(2,i)}static getRoundedSettingValueFromLinearGain(e){return Math.max(0,Math.min(p.filterGainRange-1,Math.round(Math.log2(e)/p.filterGainStep+p.filterGainCenter)))}toCoefficients(e,t,s=1,i=1){const n=2*Math.PI*Math.max(p.filterFreqMinHz,Math.min(p.filterFreqMaxHz,s*this.getHz()))/t,a=this.getLinearGain(i);switch(this.type){case 0:e.lowPass2ndOrderButterworth(n,a);break;case 1:e.highPass2ndOrderButterworth(n,a);break;case 2:e.peak2ndOrder(n,a,1);break;default:throw new Error}}getVolumeCompensationMult(){const e=(this.freq-p.filterFreqReferenceSetting)*p.filterFreqStep,t=(this.gain-p.filterGainCenter)*p.filterGainStep;switch(this.type){case 0:const s=Math.pow(2,e)*p.filterFreqReferenceHz/8e3,i=(Math.sqrt(1+4*s)-1)/2,n=Math.log2(i);return Math.pow(.5,.2*Math.max(0,t+1)+Math.min(0,Math.max(-3,.595*n+.35*Math.min(0,t+1))));case 1:return Math.pow(.5,.125*Math.max(0,t+1)+Math.min(0,.3*(-e-Math.log2(p.filterFreqReferenceHz/125))+.2*Math.min(0,t+1)));case 2:const a=e+Math.log2(p.filterFreqReferenceHz/2e3),o=Math.pow(1/(1+Math.pow(a/3,2)),2);return Math.pow(.5,.125*Math.max(0,t)+.1*o*Math.min(0,t));default:throw new Error}}}class fe{constructor(){this.controlPoints=[],this.controlPointCount=0,this.reset()}reset(){this.controlPointCount=0}addPoint(e,t,s){let i;this.controlPoints.length<=this.controlPointCount?(i=new ue,this.controlPoints[this.controlPointCount]=i):i=this.controlPoints[this.controlPointCount],this.controlPointCount++,i.type=e,i.set(t,s)}toJsonObject(){const e=[];for(let t=0;t<this.controlPointCount;t++){const s=this.controlPoints[t];e.push({type:p.filterTypeNames[s.type],cutoffHz:Math.round(100*s.getHz())/100,linearGain:Math.round(1e4*s.getLinearGain())/1e4})}return e}fromJsonObject(e){if(this.controlPoints.length=0,e)for(const t of e){const e=new ue;e.type=p.filterTypeNames.indexOf(t.type),-1==e.type&&(e.type=2),null!=t.cutoffHz?e.freq=ue.getRoundedSettingValueFromHz(t.cutoffHz):e.freq=0,null!=t.linearGain?e.gain=ue.getRoundedSettingValueFromLinearGain(t.linearGain):e.gain=p.filterGainCenter,this.controlPoints.push(e)}this.controlPointCount=this.controlPoints.length}static filtersCanMorph(e,t){if(e.controlPointCount!=t.controlPointCount)return!1;for(let s=0;s<e.controlPointCount;s++)if(e.controlPoints[s].type!=t.controlPoints[s].type)return!1;return!0}static lerpFilters(e,t,s){let i=new fe;if(null==e)return e;if(null==t)return t;if(s=Math.max(0,Math.min(1,s)),this.filtersCanMorph(e,t)){for(let n=0;n<e.controlPointCount;n++)i.controlPoints[n]=new ue,i.controlPoints[n].type=e.controlPoints[n].type,i.controlPoints[n].freq=e.controlPoints[n].freq+(t.controlPoints[n].freq-e.controlPoints[n].freq)*s,i.controlPoints[n].gain=e.controlPoints[n].gain+(t.controlPoints[n].gain-e.controlPoints[n].gain)*s;return i.controlPointCount=e.controlPointCount,i}return s>=1?t:e}convertLegacySettings(e,t,s){this.reset();const i=2*Math.asin(.475),n=t>1,a=0==t,o=10==e,r=3==s.type||4==s.type||8==s.type||0==s.type,l=48e3,h=8e3*Math.pow(2,.5*(e-10)),p=Math.min(i,2*Math.PI*h/l);if(1==s.type&&!n&&o);else if(a){const e=3.5,t=p*Math.pow(2,e),s=l*(t/(1+t/Math.PI))/(2*Math.PI),i=ue.getRoundedSettingValueFromHz(s),n=ue.getHzFromSettingValue(i),a=2*Math.PI*n/l,o=new N;o.lowPass1stOrderSimplified(p);const h=new W;h.analyze(o,a);const c=h.magnitude();let u=Math.log2(c);u=.82*(u+e)-e,r&&(u=Math.min(u,-1));const f=Math.pow(2,u),m=ue.getRoundedSettingValueFromLinearGain(f);this.addPoint(0,i,m)}else{const e=.5/(1-.95*Math.sqrt(Math.max(0,t-1)/6)),s=.5/e,i=p+(p*(p/(2*Math.PI*8e3/l)*Math.pow(s,.9)+1)-p)*s;let a;a=r?l*Math.min(i,p*Math.pow(2,.25))/(2*Math.PI):l*i/(2*Math.PI);const o=ue.getRoundedSettingValueFromHz(a);let h;if(r)h=e;else{const t=new N;t.lowPass2ndOrderSimplified(p,e);const s=new W;s.analyze(t,i),h=s.magnitude()}n||(h=Math.min(h,Math.sqrt(.5)));const c=ue.getRoundedSettingValueFromLinearGain(h);this.addPoint(0,o,c)}this.controlPoints.length=this.controlPointCount}convertLegacySettingsForSynth(e,t,s=!1){this.reset();const i=2*Math.asin(.475),n=0==t&&s,a=48e3,o=8e3*Math.pow(2,.5*(e-10)),r=Math.min(i,2*Math.PI*o/a);if(n){const e=3.5,t=r*Math.pow(2,e),s=a*(t/(1+t/Math.PI))/(2*Math.PI),i=ue.getRoundedSettingValueFromHz(s),n=ue.getHzFromSettingValue(i),o=2*Math.PI*n/a,l=new N;l.lowPass1stOrderSimplified(r);const h=new W;h.analyze(l,o);const p=h.magnitude();let c=Math.log2(p);c=.82*(c+e)-e;const u=Math.pow(2,c),f=ue.getRoundedSettingValueFromLinearGain(u);this.addPoint(0,i,f)}else{const e=.5/(1-.95*Math.sqrt(Math.max(0,t-1)/6)),s=.5/e,i=r+(r*(r/(2*Math.PI*8e3/a)*Math.pow(s,.9)+1)-r)*s;let n;n=a*i/(2*Math.PI);const o=ue.getSettingValueFromHz(n);let l;const h=new N;h.lowPass2ndOrderSimplified(r,e);const p=new W;p.analyze(h,i),l=p.magnitude();const c=ue.getRoundedSettingValueFromLinearGain(l);this.addPoint(0,o,c)}}}class me{constructor(){this.target=0,this.index=0,this.envelope=0,this.reset()}reset(){this.target=0,this.index=0,this.envelope=0}toJsonObject(){const e={target:p.instrumentAutomationTargets[this.target].name,envelope:p.envelopes[this.envelope].name};return p.instrumentAutomationTargets[this.target].maxCount>1&&(e.index=this.index),e}fromJsonObject(e){this.reset();let t=p.instrumentAutomationTargets.dictionary[e.target];null==t&&(t=p.instrumentAutomationTargets.dictionary.noteVolume),this.target=t.index;let s=p.envelopes.dictionary[e.envelope];null==s&&(s=p.envelopes.dictionary.none),this.envelope=s.index,null!=e.index?this.index=$(0,p.instrumentAutomationTargets[this.target].maxCount,0|e.index):this.index=0}}class de{constructor(e,t){if(this.type=0,this.preset=0,this.chipWave=2,this.isUsingAdvancedLoopControls=!1,this.chipWaveLoopStart=0,this.chipWaveLoopEnd=p.rawRawChipWaves[this.chipWave].samples.length-1,this.chipWaveLoopMode=0,this.chipWavePlayBackwards=!1,this.chipWaveStartOffset=0,this.chipNoise=1,this.eqFilter=new fe,this.eqFilterType=!1,this.eqFilterSimpleCut=p.filterSimpleCutRange-1,this.eqFilterSimplePeak=0,this.noteFilter=new fe,this.noteFilterType=!1,this.noteFilterSimpleCut=p.filterSimpleCutRange-1,this.noteFilterSimplePeak=0,this.eqSubFilters=[],this.noteSubFilters=[],this.envelopes=[],this.fadeIn=0,this.fadeOut=p.fadeOutNeutral,this.envelopeCount=0,this.transition=p.transitions.dictionary.normal.index,this.pitchShift=0,this.detune=0,this.vibrato=0,this.interval=0,this.vibratoDepth=0,this.vibratoSpeed=10,this.vibratoDelay=0,this.vibratoType=0,this.envelopeSpeed=12,this.discreteEnvelope=!1,this.unison=0,this.unisonVoices=1,this.unisonSpread=0,this.unisonOffset=0,this.unisonExpression=1.4,this.unisonSign=1,this.effects=0,this.chord=1,this.volume=0,this.pan=p.panCenter,this.panDelay=10,this.arpeggioSpeed=12,this.fastTwoNoteArp=!1,this.legacyTieOver=!1,this.clicklessTransition=!1,this.aliases=!1,this.pulseWidth=2*p.pulseWidthRange,this.decimalOffset=0,this.dutyCycleSequence=[0,1,6.25,12.25,18.75,25,31.25,37.5,43.75,50,56.25,62.5,68.75,75,81.25,87.5,93.75,99],this.dutyCycleSpeed=50,this.supersawDynamism=p.supersawDynamismMax,this.supersawSpread=Math.ceil(p.supersawSpreadMax/2),this.supersawShape=0,this.stringSustain=10,this.stringSustainType=1,this.distortion=0,this.bitcrusherFreq=0,this.bitcrusherQuantization=0,this.chorus=0,this.reverb=0,this.echoSustain=0,this.echoDelay=0,this.algorithm=0,this.feedbackType=0,this.algorithm6Op=1,this.feedbackType6Op=1,this.customAlgorithm=new oe,this.customFeedbackType=new re,this.feedbackAmplitude=0,this.customChipWave=new Float32Array(64),this.customChipWaveIntegral=new Float32Array(65),this.operators=[],this.harmonicsWave=new pe,this.drumsetEnvelopes=[],this.drumsetSpectrumWaves=[],this.modChannels=[],this.modInstruments=[],this.modulators=[],this.modFilterTypes=[],this.invalidModulators=[],t)for(let e=0;e<p.modCount;e++)this.modChannels.push(-2),this.modInstruments.push(0),this.modulators.push(p.modulators.dictionary.none.index);this.spectrumWave=new le(e);for(let e=0;e<p.operatorCount+2;e++)this.operators[e]=new ae(e);for(let e=0;e<p.drumCount;e++)this.drumsetEnvelopes[e]=p.envelopes.dictionary["twang 2"].index,this.drumsetSpectrumWaves[e]=new le(!0);for(let e=0;e<64;e++)this.customChipWave[e]=24-Math.floor(.75*e);let s=0;for(let e=0;e<this.customChipWave.length;e++)s+=this.customChipWave[e];const i=s/this.customChipWave.length;let n=0,a=0;for(let e=0;e<this.customChipWave.length;e++)n+=a,a=this.customChipWave[e]-i,this.customChipWaveIntegral[e]=n;this.customChipWaveIntegral[64]=0}setTypeAndReset(e,t,s){s&&(e=11),this.type=e,this.preset=e,this.volume=0,this.effects=4,this.chorus=p.chorusRange-1,this.reverb=0,this.echoSustain=Math.floor(.5*(p.echoSustainRange-1)),this.echoDelay=Math.floor(.5*(p.echoDelayRange-1)),this.eqFilter.reset(),this.eqFilterType=!1,this.eqFilterSimpleCut=p.filterSimpleCutRange-1,this.eqFilterSimplePeak=0;for(let e=0;e<p.filterMorphCount;e++)this.eqSubFilters[e]=null,this.noteSubFilters[e]=null;switch(this.noteFilter.reset(),this.noteFilterType=!1,this.noteFilterSimpleCut=p.filterSimpleCutRange-1,this.noteFilterSimplePeak=0,this.distortion=Math.floor(.75*(p.distortionRange-1)),this.bitcrusherFreq=Math.floor(.5*(p.bitcrusherFreqRange-1)),this.bitcrusherQuantization=Math.floor(.5*(p.bitcrusherQuantizationRange-1)),this.pan=p.panCenter,this.panDelay=10,this.pitchShift=p.pitchShiftCenter,this.detune=p.detuneCenter,this.vibrato=0,this.unison=0,this.stringSustain=10,this.stringSustainType=p.enableAcousticSustain?1:0,this.clicklessTransition=!1,this.arpeggioSpeed=12,this.envelopeSpeed=12,this.discreteEnvelope=!1,this.legacyTieOver=!1,this.aliases=!1,this.fadeIn=0,this.fadeOut=p.fadeOutNeutral,this.transition=p.transitions.dictionary.normal.index,this.envelopeCount=0,e){case 0:this.chipWave=2,this.chord=p.chords.dictionary.arpeggio.index,this.isUsingAdvancedLoopControls=!1,this.chipWaveLoopStart=0,this.chipWaveLoopEnd=p.rawRawChipWaves[this.chipWave].samples.length-1,this.chipWaveLoopMode=0,this.chipWavePlayBackwards=!1,this.chipWaveStartOffset=0;break;case 10:this.chipWave=2,this.chord=p.chords.dictionary.arpeggio.index;for(let e=0;e<64;e++)this.customChipWave[e]=24-Math.floor(.75*e);let s=0;for(let e=0;e<this.customChipWave.length;e++)s+=this.customChipWave[e];const i=s/this.customChipWave.length;let n=0,a=0;for(let e=0;e<this.customChipWave.length;e++)n+=a,a=this.customChipWave[e]-i,this.customChipWaveIntegral[e]=n;this.customChipWaveIntegral[64]=0;break;case 1:this.chord=p.chords.dictionary["custom interval"].index,this.algorithm=0,this.feedbackType=0,this.feedbackAmplitude=0;for(let e=0;e<this.operators.length;e++)this.operators[e].reset(e);break;case 12:this.transition=1,this.vibrato=0,this.effects=1,this.chord=3,this.algorithm=0,this.feedbackType=0,this.algorithm6Op=1,this.feedbackType6Op=1,this.customAlgorithm.fromPreset(1),this.feedbackAmplitude=0;for(let e=0;e<this.operators.length;e++)this.operators[e].reset(e);break;case 2:this.chipNoise=1,this.chord=p.chords.dictionary.arpeggio.index;break;case 3:this.chord=p.chords.dictionary.simultaneous.index,this.spectrumWave.reset(t);break;case 4:this.chord=p.chords.dictionary.simultaneous.index;for(let e=0;e<p.drumCount;e++)this.drumsetEnvelopes[e]=p.envelopes.dictionary["twang 2"].index,null==this.drumsetSpectrumWaves[e]&&(this.drumsetSpectrumWaves[e]=new le(!0)),this.drumsetSpectrumWaves[e].reset(t);break;case 5:this.chord=p.chords.dictionary.simultaneous.index,this.harmonicsWave.reset();break;case 6:case 7:this.chord=p.chords.dictionary.arpeggio.index,this.pulseWidth=p.pulseWidthRange,this.decimalOffset=0;break;case 8:this.chord=p.chords.dictionary.strum.index,this.harmonicsWave.reset();break;case 11:this.transition=0,this.vibrato=0,this.interval=0,this.effects=0,this.chord=0,this.modChannels=[],this.modInstruments=[],this.modulators=[];for(let e=0;e<p.modCount;e++)this.modChannels.push(-2),this.modInstruments.push(0),this.modulators.push(p.modulators.dictionary.none.index),this.invalidModulators[e]=!1,this.modFilterTypes[e]=0;break;case 9:this.chord=p.chords.dictionary.arpeggio.index,this.supersawDynamism=p.supersawDynamismMax,this.supersawSpread=Math.ceil(p.supersawSpreadMax/2),this.supersawShape=0,this.pulseWidth=p.pulseWidthRange-1,this.decimalOffset=0;break;default:throw new Error("Unrecognized instrument type: "+e)}this.chord!=p.chords.dictionary.simultaneous.index&&(this.effects=2048|this.effects)}convertLegacySettings(e,t){let s=e.filterCutoff,i=e.filterResonance,n=e.filterEnvelope,a=e.pulseEnvelope,o=e.operatorEnvelopes,r=e.feedbackEnvelope;null==s&&(s=0==this.type?6:10),null==i&&(i=0),null==n&&(n=p.envelopes.dictionary.none),null==a&&(a=p.envelopes.dictionary[6==this.type?"twang 2":"none"]),null==o&&(o=[p.envelopes.dictionary[1==this.type?"note size":"none"],p.envelopes.dictionary.none,p.envelopes.dictionary.none,p.envelopes.dictionary.none]),null==r&&(r=p.envelopes.dictionary.none);10==s&&2==n.type&&(n=p.envelopes.dictionary.none);const l=p.algorithms[this.algorithm].carrierCount;let h=!0,c=!0,u=0==n.type||0==a.type;if(1==this.type||12==this.type){u=u||0==r.type;for(let e=0;e<o.length;e++)e<l?0!=o[e].type?c=!1:h=!1:u=u||0==o[e].type}this.envelopeCount=0,1!=this.type&&12!=this.type||(c&&u?this.addEnvelope(p.instrumentAutomationTargets.dictionary.noteVolume.index,0,p.envelopes.dictionary["note size"].index):h&&!u&&this.addEnvelope(p.instrumentAutomationTargets.dictionary.none.index,0,p.envelopes.dictionary["note size"].index)),1==n.type?(this.noteFilter.reset(),this.noteFilterType=!1,this.eqFilter.convertLegacySettings(s,i,n),this.effects&=-33,(t||this.eqFilterType)&&(this.eqFilterType=!0,this.eqFilterSimpleCut=s,this.eqFilterSimplePeak=i)):(this.eqFilter.reset(),this.eqFilterType=!1,this.noteFilterType=!1,this.noteFilter.convertLegacySettings(s,i,n),this.effects|=32,this.addEnvelope(p.instrumentAutomationTargets.dictionary.noteFilterAllFreqs.index,0,n.index),(t||this.noteFilterType)&&(this.noteFilterType=!0,this.noteFilterSimpleCut=s,this.noteFilterSimplePeak=i)),1!=a.type&&this.addEnvelope(p.instrumentAutomationTargets.dictionary.pulseWidth.index,0,a.index);for(let e=0;e<o.length;e++)e<l&&c||1!=o[e].type&&this.addEnvelope(p.instrumentAutomationTargets.dictionary.operatorAmplitude.index,e,o[e].index);1!=r.type&&this.addEnvelope(p.instrumentAutomationTargets.dictionary.feedbackAmplitude.index,0,r.index)}toJsonObject(){const e={type:p.instrumentTypeNames[this.type],volume:this.volume,eqFilter:this.eqFilter.toJsonObject(),eqFilterType:this.eqFilterType,eqSimpleCut:this.eqFilterSimpleCut,eqSimplePeak:this.eqFilterSimplePeak,envelopeSpeed:this.envelopeSpeed,discreteEnvelope:this.discreteEnvelope};this.preset!=this.type&&(e.preset=this.preset);for(let t=0;t<p.filterMorphCount;t++)null!=this.eqSubFilters[t]&&(e["eqSubFilters"+t]=this.eqSubFilters[t].toJsonObject());const t=[];for(const e of p.effectOrder)this.effects&1<<e&&t.push(p.effectNames[e]);if(e.effects=t,M(this.effects)&&(e.transition=p.transitions[this.transition].name,e.clicklessTransition=this.clicklessTransition),w(this.effects)&&(e.chord=this.getChord().name,e.fastTwoNoteArp=this.fastTwoNoteArp,e.arpeggioSpeed=this.arpeggioSpeed),x(this.effects)&&(e.pitchShiftSemitones=this.pitchShift),k(this.effects)&&(e.detuneCents=xe.detuneToCents(this.detune)),F(this.effects)&&(-1==this.vibrato&&(this.vibrato=5),5!=this.vibrato?e.vibrato=p.vibratos[this.vibrato].name:e.vibrato="custom",e.vibratoDepth=this.vibratoDepth,e.vibratoDelay=this.vibratoDelay,e.vibratoSpeed=this.vibratoSpeed,e.vibratoType=this.vibratoType),P(this.effects)){e.noteFilterType=this.noteFilterType,e.noteSimpleCut=this.noteFilterSimpleCut,e.noteSimplePeak=this.noteFilterSimplePeak,e.noteFilter=this.noteFilter.toJsonObject();for(let t=0;t<p.filterMorphCount;t++)null!=this.noteSubFilters[t]&&(e["noteSubFilters"+t]=this.noteSubFilters[t].toJsonObject())}if(q(this.effects)&&(e.distortion=Math.round(100*this.distortion/(p.distortionRange-1)),e.aliases=this.aliases),I(this.effects)&&(e.bitcrusherOctave=(p.bitcrusherFreqRange-1-this.bitcrusherFreq)*p.bitcrusherOctaveStep,e.bitcrusherQuantization=Math.round(100*this.bitcrusherQuantization/(p.bitcrusherQuantizationRange-1))),T(this.effects)&&(e.pan=Math.round(100*(this.pan-p.panCenter)/p.panCenter),e.panDelay=this.panDelay),D(this.effects)&&(e.chorus=Math.round(100*this.chorus/(p.chorusRange-1))),O(this.effects)&&(e.echoSustain=Math.round(100*this.echoSustain/(p.echoSustainRange-1)),e.echoDelayBeats=Math.round(1e3*(this.echoDelay+1)*p.echoDelayStepTicks/(p.ticksPerPart*p.partsPerBeat))/1e3),A(this.effects)&&(e.reverb=Math.round(100*this.reverb/(p.reverbRange-1))),4!=this.type&&(e.fadeInSeconds=Math.round(1e4*xe.fadeInSettingToSeconds(this.fadeIn))/1e4,e.fadeOutTicks=xe.fadeOutSettingToTicks(this.fadeOut)),5==this.type||8==this.type){e.harmonics=[];for(let t=0;t<p.harmonicsControlPoints;t++)e.harmonics[t]=Math.round(100*this.harmonicsWave.harmonics[t]/p.harmonicsMax)}if(2==this.type)e.wave=p.chipNoises[this.chipNoise].name,e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign);else if(3==this.type){e.spectrum=[];for(let t=0;t<p.spectrumControlPoints;t++)e.spectrum[t]=Math.round(100*this.spectrumWave.spectrum[t]/p.spectrumMax);e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign)}else if(4==this.type){e.drums=[];for(let t=0;t<p.drumCount;t++){const s=[];for(let e=0;e<p.spectrumControlPoints;e++)s[e]=Math.round(100*this.drumsetSpectrumWaves[t].spectrum[e]/p.spectrumMax);e.drums[t]={filterEnvelope:this.getDrumsetEnvelope(t).name,spectrum:s}}}else if(0==this.type)e.wave=p.chipWaves[this.chipWave].name,e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign),e.isUsingAdvancedLoopControls=this.isUsingAdvancedLoopControls,e.chipWaveLoopStart=this.chipWaveLoopStart,e.chipWaveLoopEnd=this.chipWaveLoopEnd,e.chipWaveLoopMode=this.chipWaveLoopMode,e.chipWavePlayBackwards=this.chipWavePlayBackwards,e.chipWaveStartOffset=this.chipWaveStartOffset;else if(6==this.type)e.pulseWidth=this.pulseWidth,e.decimalOffset=this.decimalOffset,e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign);else if(7==this.type)e.pulseWidth=this.pulseWidth,e.decimalOffset=this.decimalOffset,e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign);else if(9==this.type)e.pulseWidth=this.pulseWidth,e.decimalOffset=this.decimalOffset,e.dynamism=Math.round(100*this.supersawDynamism/p.supersawDynamismMax),e.spread=Math.round(100*this.supersawSpread/p.supersawSpreadMax),e.shape=Math.round(100*this.supersawShape/p.supersawShapeMax);else if(8==this.type)e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign),e.stringSustain=Math.round(100*this.stringSustain/(p.stringSustainRange-1)),p.enableAcousticSustain&&(e.stringSustainType=p.sustainTypeNames[this.stringSustainType]);else if(5==this.type)e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign);else if(1==this.type||12==this.type){const t=[];for(const e of this.operators)t.push({frequency:p.operatorFrequencies[e.frequency].name,amplitude:e.amplitude,waveform:p.operatorWaves[e.waveform].name,pulseWidth:e.pulseWidth});if(1==this.type)e.algorithm=p.algorithms[this.algorithm].name,e.feedbackType=p.feedbacks[this.feedbackType].name,e.feedbackAmplitude=this.feedbackAmplitude,e.operators=t;else{if(e.algorithm=p.algorithms6Op[this.algorithm6Op].name,e.feedbackType=p.feedbacks6Op[this.feedbackType6Op].name,e.feedbackAmplitude=this.feedbackAmplitude,0==this.algorithm6Op){const t={};t.mods=this.customAlgorithm.modulatedBy,t.carrierCount=this.customAlgorithm.carrierCount,e.customAlgorithm=t}if(0==this.feedbackType6Op){const t={};t.mods=this.customFeedbackType.indices,e.customFeedback=t}e.operators=t}}else if(10==this.type){e.wave=p.chipWaves[this.chipWave].name,e.unison=this.unison==p.unisons.length?"custom":p.unisons[this.unison].name,this.unison==p.unisons.length&&(e.unisonVoices=this.unisonVoices,e.unisonSpread=this.unisonSpread,e.unisonOffset=this.unisonOffset,e.unisonExpression=this.unisonExpression,e.unisonSign=this.unisonSign),e.customChipWave=new Float64Array(64),e.customChipWaveIntegral=new Float64Array(65);for(let t=0;t<this.customChipWave.length;t++)e.customChipWave[t]=this.customChipWave[t]}else{if(11!=this.type)throw new Error("Unrecognized instrument type");e.modChannels=[],e.modInstruments=[],e.modSettings=[],e.modFilterTypes=[];for(let t=0;t<p.modCount;t++)e.modChannels[t]=this.modChannels[t],e.modInstruments[t]=this.modInstruments[t],e.modSettings[t]=this.modulators[t],e.modFilterTypes[t]=this.modFilterTypes[t]}const s=[];for(let e=0;e<this.envelopeCount;e++)s.push(this.envelopes[e].toJsonObject());return e.envelopes=s,e}fromJsonObject(e,t,s,i,n,a=0,o=p.jsonFormat){null==e&&(e={});let r=p.instrumentTypeNames.indexOf(e.type);if("SynthBox"==o&&"FM"==e.type&&(r=p.instrumentTypeNames.indexOf("FM6op")),-1==r&&(r=s?11:t?2:0),this.setTypeAndReset(r,t,s),this.effects&=-5,null!=e.preset&&(this.preset=e.preset>>>0),null!=e.volume?this.volume="JummBox"==o||"Midbox"==o||"SynthBox"==o||"UltraBox"==o||"Unbox"==o?$(-p.volumeRange/2,p.volumeRange/2+1,0|e.volume):Math.round(25*-$(0,8,Math.round(5-(0|e.volume)/20))/7):this.volume=0,null!=e.envelopeSpeed?this.envelopeSpeed=$(0,p.modulators.dictionary["envelope speed"].maxRawVol+1,0|e.envelopeSpeed):this.envelopeSpeed=12,null!=e.discreteEnvelope?this.discreteEnvelope=e.discreteEnvelope:this.discreteEnvelope=!1,Array.isArray(e.effects)){let t=0;for(let s=0;s<e.effects.length;s++)t|=1<<p.effectNames.indexOf(e.effects[s]);this.effects=4095&t}else{const t=["none","reverb","chorus","chorus & reverb"];this.effects=t.indexOf(e.effects),-1==this.effects&&(this.effects=2==this.type?0:1)}this.transition=p.transitions.dictionary.normal.index;const l=e.transition||e.envelope;if(null!=l){let t=p.transitions.dictionary[l];if(null==e.fadeInSeconds||null==e.fadeOutTicks){const e={binary:{transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1},seamless:{transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1},sudden:{transition:"normal",fadeInSeconds:0,fadeOutTicks:-3},hard:{transition:"normal",fadeInSeconds:0,fadeOutTicks:-3},smooth:{transition:"normal",fadeInSeconds:.025,fadeOutTicks:-3},soft:{transition:"normal",fadeInSeconds:.025,fadeOutTicks:-3},slide:{transition:"slide in pattern",fadeInSeconds:.025,fadeOutTicks:-3},"cross fade":{transition:"normal",fadeInSeconds:.04,fadeOutTicks:6},"hard fade":{transition:"normal",fadeInSeconds:0,fadeOutTicks:48},"medium fade":{transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72},"soft fade":{transition:"normal",fadeInSeconds:.06,fadeOutTicks:96}}[l];null!=e&&(t=p.transitions.dictionary[e.transition],this.fadeIn=xe.secondsToFadeInSetting(e.fadeInSeconds),this.fadeOut=xe.ticksToFadeOutSetting(e.fadeOutTicks))}null!=t&&(this.transition=t.index),this.transition!=p.transitions.dictionary.normal.index&&(this.effects=1024|this.effects)}null!=e.fadeInSeconds&&(this.fadeIn=xe.secondsToFadeInSetting(+e.fadeInSeconds)),null!=e.fadeOutTicks&&(this.fadeOut=xe.ticksToFadeOutSetting(+e.fadeOutTicks));{const t=e.chord,s={harmony:"simultaneous"},i=p.chords.dictionary[s[t]]||p.chords.dictionary[t];null!=i?this.chord=i.index:2==this.type?this.chord=p.chords.dictionary.arpeggio.index:8==this.type?this.chord=p.chords.dictionary.strum.index:0==this.type?this.chord=p.chords.dictionary.arpeggio.index:1==this.type||12==this.type?this.chord=p.chords.dictionary["custom interval"].index:this.chord=p.chords.dictionary.simultaneous.index}this.unison=p.unisons.dictionary.none.index;const h=e.unison||e.interval||e.chorus;if(null!=h){const e={union:"none",fifths:"fifth",octaves:"octave",error:"voiced"},t=p.unisons.dictionary[e[h]]||p.unisons.dictionary[h];null!=t&&(this.unison=t.index),"custom"==h&&(this.unison=p.unisons.length)}if(this.unisonVoices=null==e.unisonVoices?p.unisons[this.unison].voices:e.unisonVoices,this.unisonSpread=null==e.unisonSpread?p.unisons[this.unison].spread:e.unisonSpread,this.unisonOffset=null==e.unisonOffset?p.unisons[this.unison].offset:e.unisonOffset,this.unisonExpression=null==e.unisonExpression?p.unisons[this.unison].expression:e.unisonExpression,this.unisonSign=null==e.unisonSign?p.unisons[this.unison].sign:e.unisonSign,"custom harmony"==e.chorus&&(this.unison=p.unisons.dictionary.hum.index,this.chord=p.chords.dictionary["custom interval"].index),this.chord==p.chords.dictionary.simultaneous.index||Array.isArray(e.effects)||(this.effects=2048|this.effects),null!=e.pitchShiftSemitones&&(this.pitchShift=$(0,p.pitchShiftRange,"Unbox"==o?Math.round(+e.pitchShiftSemitones):Math.round(+e.pitchShiftSemitones+12))),null!=e.octoff){let t=e.octoff;this.effects=128|this.effects,this.pitchShift=$(0,p.pitchShiftRange,"+1 (octave)"==t?p.pitchShiftCenter+12:"+2 (2 octaves)"==t?p.pitchShiftCenter+24:"+1/2 (fifth)"==t?p.pitchShiftCenter+7:"+1 1/2 (octave and fifth)"==t?p.pitchShiftCenter+19:"-1 (octave)"==t?p.pitchShiftCenter-12:"-2 (2 octaves"==t||"-2 (2 octaves)"==t?p.pitchShiftCenter-24:"-1/2 (fifth)"==t?p.pitchShiftCenter-7:"-1 1/2 (octave and fifth)"==t?p.pitchShiftCenter-19:p.pitchShiftCenter)}null!=e.detuneCents&&(this.detune=$(p.detuneMin,p.detuneMax+1,Math.round(xe.centsToDetune(+e.detuneCents)))),this.vibrato=p.vibratos.dictionary.none.index;const c=e.vibrato||e.effect;if(null!=c){const t={"vibrato light":"light","vibrato delayed":"delayed","vibrato heavy":"heavy"},s=p.vibratos.dictionary[t[h]]||p.vibratos.dictionary[c];null!=s?this.vibrato=s.index:"custom"==c&&(this.vibrato=p.vibratos.length),this.vibrato==p.vibratos.length?(this.vibratoDepth=e.vibratoDepth,this.vibratoSpeed=e.vibratoSpeed,this.vibratoDelay=e.vibratoDelay,this.vibratoType=e.vibratoType):(this.vibratoDepth=p.vibratos[this.vibrato].amplitude,this.vibratoDelay=p.vibratos[this.vibrato].delayTicks/2,this.vibratoSpeed=10,this.vibratoType=p.vibratos[this.vibrato].type),s!=p.vibratos.dictionary.none&&(this.effects=512|this.effects)}if(null!=e.pan?(this.pan=$(0,p.panMax+1,Math.round(p.panCenter+(0|e.pan)*p.panCenter/100)),this.pan!=p.panCenter&&(this.effects=4|this.effects)):this.pan=p.panCenter,null!=e.panDelay?this.panDelay=0|e.panDelay:this.panDelay=10,null!=e.detune?this.detune=$(p.detuneMin,p.detuneMax+1,0|e.detune):null==e.detuneCents&&(this.detune=p.detuneCenter),null!=e.distortion&&(this.distortion=$(0,p.distortionRange,Math.round((p.distortionRange-1)*(0|e.distortion)/100))),null!=e.bitcrusherOctave&&(this.bitcrusherFreq=p.bitcrusherFreqRange-1-+e.bitcrusherOctave/p.bitcrusherOctaveStep),null!=e.bitcrusherQuantization&&(this.bitcrusherQuantization=$(0,p.bitcrusherQuantizationRange,Math.round((p.bitcrusherQuantizationRange-1)*(0|e.bitcrusherQuantization)/100))),null!=e.echoSustain&&(this.echoSustain=$(0,p.echoSustainRange,Math.round((p.echoSustainRange-1)*(0|e.echoSustain)/100))),null!=e.echoDelayBeats&&(this.echoDelay=$(0,p.echoDelayRange,Math.round(+e.echoDelayBeats*(p.ticksPerPart*p.partsPerBeat)/p.echoDelayStepTicks-1))),isNaN(e.chorus)||(this.chorus=$(0,p.chorusRange,Math.round((p.chorusRange-1)*(0|e.chorus)/100))),null!=e.reverb?this.reverb=$(0,p.reverbRange,Math.round((p.reverbRange-1)*(0|e.reverb)/100)):this.reverb=a,null!=e.pulseWidth?this.pulseWidth=$(1,2*p.pulseWidthRange+1,Math.round(e.pulseWidth)):this.pulseWidth=p.pulseWidthRange,null!=e.decimalOffset?this.decimalOffset=$(0,101,Math.round(e.decimalOffset)):this.decimalOffset=0,null!=e.dynamism?this.supersawDynamism=$(0,p.supersawDynamismMax+1,Math.round(p.supersawDynamismMax*(0|e.dynamism)/100)):this.supersawDynamism=p.supersawDynamismMax,null!=e.spread?this.supersawSpread=$(0,p.supersawSpreadMax+1,Math.round(p.supersawSpreadMax*(0|e.spread)/100)):this.supersawSpread=Math.ceil(p.supersawSpreadMax/2),null!=e.shape?this.supersawShape=$(0,p.supersawShapeMax+1,Math.round(p.supersawShapeMax*(0|e.shape)/100)):this.supersawShape=0,null!=e.harmonics){for(let t=0;t<p.harmonicsControlPoints;t++)this.harmonicsWave.harmonics[t]=Math.max(0,Math.min(p.harmonicsMax,Math.round(p.harmonicsMax*+e.harmonics[t]/100)));this.harmonicsWave.markCustomWaveDirty()}else this.harmonicsWave.reset();if(null!=e.spectrum)for(let t=0;t<p.spectrumControlPoints;t++)this.spectrumWave.spectrum[t]=Math.max(0,Math.min(p.spectrumMax,Math.round(p.spectrumMax*+e.spectrum[t]/100))),this.spectrumWave.markCustomWaveDirty();else this.spectrumWave.reset(t);null!=e.stringSustain?this.stringSustain=$(0,p.stringSustainRange,Math.round((p.stringSustainRange-1)*(0|e.stringSustain)/100)):this.stringSustain=10,this.stringSustainType=p.enableAcousticSustain?p.sustainTypeNames.indexOf(e.stringSustainType):0,-1==this.stringSustainType&&(this.stringSustainType=0),2==this.type&&(this.chipNoise=p.chipNoises.findIndex((t=>t.name==e.wave)),"pink noise"==e.wave&&(this.chipNoise=p.chipNoises.findIndex((e=>"pink"==e.name))),"brownian noise"==e.wave&&(this.chipNoise=p.chipNoises.findIndex((e=>"brownian"==e.name))),-1==this.chipNoise&&(this.chipNoise=1));const u={custom:"note size",steady:"none","pluck 1":"twang 1","pluck 2":"twang 2","pluck 3":"twang 3"},f=e=>null!=u[e]?p.envelopes.dictionary[u[e]]:p.envelopes.dictionary[e];if(4==this.type&&null!=e.drums)for(let t=0;t<p.drumCount;t++){const s=e.drums[t];if(null!=s){if(this.drumsetEnvelopes[t]=p.envelopes.dictionary["twang 2"].index,null!=s.filterEnvelope){const e=f(s.filterEnvelope);null!=e&&(this.drumsetEnvelopes[t]=e.index)}if(null!=s.spectrum)for(let e=0;e<p.spectrumControlPoints;e++)this.drumsetSpectrumWaves[t].spectrum[e]=Math.max(0,Math.min(p.spectrumMax,Math.round(p.spectrumMax*+s.spectrum[e]/100)));this.drumsetSpectrumWaves[t].markCustomWaveDirty()}}if(0==this.type){const t={triangle:1,square:2,"pulse wide":3,"pulse narrow":4,sawtooth:5,"double saw":6,"double pulse":7,spiky:8,plateau:0},s={"10% pulse":22,"sunsoft bass":23,"loud pulse":24,sax:25,guitar:26,"atari bass":28,"atari pulse":29,"1% pulse":30,"curved sawtooth":31,viola:32,brass:33,"acoustic bass":34,lyre:35,"ramp pulse":36,piccolo:37,squaretooth:38,flatline:39,"pnryshk a (u5)":40,"pnryshk b (riff)":41},i={"shrill lute":42,"shrill bass":44,"nes pulse":45,"saw bass":46,euphonium:47,"shrill pulse":48,"r-sawtooth":49,recorder:50,"narrow saw":51,"deep square":52,"ring pulse":53,"double sine":54,contrabass:55,"double bass":56},n={"semi-square":63,"deep square":64,squaretal:40,"saw wide":65,"saw narrow ":66,"deep sawtooth":67,sawtal:68,pulse:69,"triple pulse":70,"high pulse":71,"deep pulse":72},a={test1:56,"pokey 4bit lfsr":57,"pokey 5step bass":58,"isolated spiky":59,"unnamed 1":60,"unnamed 2":61,"guitar string":75,intense:76,"buzz wave":77,"pokey square":57,"pokey bass":58,"banana wave":83,"test 1":84,"test 2":84,"real snare":85,"earthbound o. guitar":86},o={kick:87,snare:88,piano1:89,WOW:90,overdrive:91,trumpet:92,saxophone:93,orchestrahit:94,"detached violin":95,synth:96,sonic3snare:97,"come on":98,choir:99,overdriveguitar:100,flute:101,"legato violin":102,"tremolo violin":103,"amen break":104,"pizzicato violin":105,"tim allen grunt":106,tuba:107,loopingcymbal:108,standardkick:109,standardsnare:110,closedhihat:111,foothihat:112,openhihat:113,crashcymbal:114,pianoC4:115,"liver pad":116,marimba:117,susdotwav:118,wackyboxtts:119};this.chipWave=-1;const r=e.wave;for(const e of[t,s,i,n,a,o])if(-1==this.chipWave&&null!=e[r]&&null!=p.chipWaves[e[r]]){this.chipWave=e[r];break}if(-1==this.chipWave){const e=p.chipWaves.findIndex((e=>e.name==r));-1!=e&&(this.chipWave=e)}-1==this.chipWave&&(this.chipWave=1)}if(1==this.type||12==this.type){if(1==this.type)this.algorithm=p.algorithms.findIndex((t=>t.name==e.algorithm)),-1==this.algorithm&&(this.algorithm=0),this.feedbackType=p.feedbacks.findIndex((t=>t.name==e.feedbackType)),-1==this.feedbackType&&(this.feedbackType=0);else if(this.algorithm6Op=p.algorithms6Op.findIndex((t=>t.name==e.algorithm)),-1==this.algorithm6Op&&(this.algorithm6Op=1),0==this.algorithm6Op?this.customAlgorithm.set(e.customAlgorithm.carrierCount,e.customAlgorithm.mods):this.customAlgorithm.fromPreset(this.algorithm6Op),this.feedbackType6Op=p.feedbacks6Op.findIndex((t=>t.name==e.feedbackType)),-1==this.feedbackType6Op&&"SynthBox"==o){this.feedbackType6Op=p.algorithms6Op.findIndex((e=>"Custom"==e.name));let t=S([{name:"2⟲ 3⟲",indices:[[],[2],[3],[],[],[]]},{name:"4⟲ 5⟲",indices:[[],[],[],[4],[5],[]]},{name:"5⟲ 6⟲",indices:[[],[],[],[],[5],[6]]},{name:"1⟲ 6⟲",indices:[[1],[],[],[],[],[6]]},{name:"1⟲ 3⟲",indices:[[1],[],[3],[],[],[]]},{name:"1⟲ 4⟲",indices:[[1],[],[],[4],[],[]]},{name:"1⟲ 5⟲",indices:[[1],[],[],[],[5],[]]},{name:"4⟲ 6⟲",indices:[[],[],[],[4],[],[6]]},{name:"2⟲ 6⟲",indices:[[],[2],[],[],[],[6]]},{name:"3⟲ 6⟲",indices:[[],[],[3],[],[],[6]]},{name:"4⟲ 5⟲ 6⟲",indices:[[],[],[],[4],[5],[6]]},{name:"1⟲ 3⟲ 6⟲",indices:[[1],[],[3],[],[],[6]]},{name:"2→5",indices:[[],[],[],[],[2],[]]},{name:"2→6",indices:[[],[],[],[],[],[2]]},{name:"3→5",indices:[[],[],[],[],[3],[]]},{name:"3→6",indices:[[],[],[],[],[],[3]]},{name:"4→6",indices:[[],[],[],[],[],[4]]},{name:"5→6",indices:[[],[],[],[],[],[5]]},{name:"1→3→4",indices:[[],[],[1],[],[3],[]]},{name:"2→5→6",indices:[[],[],[],[],[2],[5]]},{name:"2→4→6",indices:[[],[],[],[2],[],[4]]},{name:"4→5→6",indices:[[],[],[],[],[4],[5]]},{name:"3→4→5→6",indices:[[],[],[],[3],[4],[5]]},{name:"2→3→4→5→6",indices:[[],[1],[2],[3],[4],[5]]},{name:"1→2→3→4→5→6",indices:[[],[1],[2],[3],[4],[5]]}]),s=t[t.findIndex((t=>t.name==e.feedbackType))].indices;this.customFeedbackType.set(s)}else-1==this.feedbackType6Op&&(this.feedbackType6Op=1),0==this.feedbackType6Op?this.customFeedbackType.set(e.customFeedback.mods):this.customFeedbackType.fromPreset(this.feedbackType6Op);null!=e.feedbackAmplitude?this.feedbackAmplitude=$(0,p.operatorAmplitudeMax+1,0|e.feedbackAmplitude):this.feedbackAmplitude=0;for(let t=0;t<p.operatorCount+(12==this.type?2:0);t++){const s=this.operators[t];let i;null!=e.operators&&(i=e.operators[t]),null==i&&(i={}),s.frequency=p.operatorFrequencies.findIndex((e=>e.name==i.frequency)),-1==s.frequency&&(s.frequency=0),null!=i.amplitude?s.amplitude=$(0,p.operatorAmplitudeMax+1,0|i.amplitude):s.amplitude=0,null!=i.waveform?(s.waveform=p.operatorWaves.findIndex((e=>e.name==i.waveform)),-1==s.waveform&&("square"==i.waveform?(s.waveform=p.operatorWaves.dictionary["pulse width"].index,s.pulseWidth=5):s.waveform=0)):s.waveform=0,null!=i.pulseWidth?s.pulseWidth=0|i.pulseWidth:s.pulseWidth=5}}else if(10==this.type){if(e.customChipWave){for(let t=0;t<64;t++)this.customChipWave[t]=e.customChipWave[t];let t=0;for(let e=0;e<this.customChipWave.length;e++)t+=this.customChipWave[e];const s=t/this.customChipWave.length;let i=0,n=0;for(let e=0;e<this.customChipWave.length;e++)i+=n,n=this.customChipWave[e]-s,this.customChipWaveIntegral[e]=i;this.customChipWaveIntegral[64]=0}}else if(11==this.type&&null!=e.modChannels)for(let t=0;t<p.modCount;t++)this.modChannels[t]=e.modChannels[t],this.modInstruments[t]=e.modInstruments[t],this.modulators[t]=e.modSettings[t],null!=e.modFilterTypes&&(this.modFilterTypes[t]=e.modFilterTypes[t]);if(11!=this.type){this.chord==p.chords.dictionary.arpeggio.index&&null!=e.arpeggioSpeed?this.arpeggioSpeed=e.arpeggioSpeed:this.arpeggioSpeed=i?9:12,null!=e.fastTwoNoteArp?this.fastTwoNoteArp=e.fastTwoNoteArp:this.fastTwoNoteArp=n,null!=e.clicklessTransition?this.clicklessTransition=e.clicklessTransition:this.clicklessTransition=!1,null!=e.aliases?this.aliases=e.aliases:"ModBox"==o?(this.effects=8|this.effects,this.aliases=!0,this.distortion=0):this.aliases=!1,null!=e.noteFilterType&&(this.noteFilterType=e.noteFilterType),null!=e.noteSimpleCut&&(this.noteFilterSimpleCut=e.noteSimpleCut),null!=e.noteSimplePeak&&(this.noteFilterSimplePeak=e.noteSimplePeak),null!=e.noteFilter?this.noteFilter.fromJsonObject(e.noteFilter):this.noteFilter.reset();for(let t=0;t<p.filterMorphCount;t++)Array.isArray(e["noteSubFilters"+t])&&(this.noteSubFilters[t]=new fe,this.noteSubFilters[t].fromJsonObject(e["noteSubFilters"+t]));if(null!=e.eqFilterType&&(this.eqFilterType=e.eqFilterType),null!=e.eqSimpleCut&&(this.eqFilterSimpleCut=e.eqSimpleCut),null!=e.eqSimplePeak&&(this.eqFilterSimplePeak=e.eqSimplePeak),Array.isArray(e.eqFilter))this.eqFilter.fromJsonObject(e.eqFilter);else{this.eqFilter.reset();const t={},s=8e3,i=11,n=8;if(null!=e.filterCutoffHz?t.filterCutoff=$(0,i,Math.round(i-1+2*Math.log((0|e.filterCutoffHz)/s)/Math.LN2)):t.filterCutoff=0==this.type?6:10,null!=e.filterResonance?t.filterResonance=$(0,n,Math.round((n-1)*(0|e.filterResonance)/100)):t.filterResonance=0,t.filterEnvelope=f(e.filterEnvelope),t.pulseEnvelope=f(e.pulseEnvelope),t.feedbackEnvelope=f(e.feedbackEnvelope),Array.isArray(e.operators)){t.operatorEnvelopes=[];for(let s=0;s<p.operatorCount+(12==this.type?2:0);s++){let i;null!=e.operators[s]&&(i=f(e.operators[s].envelope)),t.operatorEnvelopes[s]=null!=i?i:p.envelopes.dictionary.none}}if(null!=e.filter){const s=[10,6,3,0,8,5,2],i=["none","none","none","none","decay 1","decay 2","decay 3"],n=["none","bright","medium","soft","decay bright","decay medium","decay soft"],a={"sustain sharp":1,"sustain medium":2,"sustain soft":3,"decay sharp":4};let o=null!=a[e.filter]?a[e.filter]:n.indexOf(e.filter);-1==o&&(o=0),t.filterCutoff=s[o],t.filterEnvelope=f(i[o]),t.filterResonance=0}this.convertLegacySettings(t,!0)}for(let t=0;t<p.filterMorphCount;t++)Array.isArray(e["eqSubFilters"+t])&&(this.eqSubFilters[t]=new fe,this.eqSubFilters[t].fromJsonObject(e["eqSubFilters"+t]));if(Array.isArray(e.envelopes)){const t=e.envelopes;for(let e=0;e<t.length&&!(this.envelopeCount>=p.maxEnvelopeCount);e++){const s=new me;s.fromJsonObject(t[e]),this.addEnvelope(s.target,s.index,s.envelope)}}}0===r&&(null!=e.isUsingAdvancedLoopControls?(this.isUsingAdvancedLoopControls=e.isUsingAdvancedLoopControls,this.chipWaveLoopStart=e.chipWaveLoopStart,this.chipWaveLoopEnd=e.chipWaveLoopEnd,this.chipWaveLoopMode=e.chipWaveLoopMode,this.chipWavePlayBackwards=e.chipWavePlayBackwards,this.chipWaveStartOffset=e.chipWaveStartOffset):(this.isUsingAdvancedLoopControls=!1,this.chipWaveLoopStart=0,this.chipWaveLoopEnd=p.rawRawChipWaves[this.chipWave].samples.length-1,this.chipWaveLoopMode=0,this.chipWavePlayBackwards=!1,this.chipWaveStartOffset=0))}getLargestControlPointCount(e){let t;if(e){t=this.noteFilter.controlPointCount;for(let e=0;e<p.filterMorphCount;e++)null!=this.noteSubFilters[e]&&this.noteSubFilters[e].controlPointCount>t&&(t=this.noteSubFilters[e].controlPointCount)}else{t=this.eqFilter.controlPointCount;for(let e=0;e<p.filterMorphCount;e++)null!=this.eqSubFilters[e]&&this.eqSubFilters[e].controlPointCount>t&&(t=this.eqSubFilters[e].controlPointCount)}return t}static frequencyFromPitch(e){return 440*Math.pow(2,(e-69)/12)}addEnvelope(e,t,s){let i=!1;if(this.supportsEnvelopeTarget(e,t)||(i=!0),this.envelopeCount>=p.maxEnvelopeCount)throw new Error;for(;this.envelopes.length<=this.envelopeCount;)this.envelopes[this.envelopes.length]=new me;const n=this.envelopes[this.envelopeCount];n.target=i?p.instrumentAutomationTargets.dictionary.none.index:e,n.index=i?0:t,n.envelope=s,this.envelopeCount++}supportsEnvelopeTarget(e,t){const s=p.instrumentAutomationTargets[e];if(null==s.computeIndex&&"none"!=s.name)return!1;if(t>=s.maxCount)return!1;if(null!=s.compatibleInstruments&&-1==s.compatibleInstruments.indexOf(this.type))return!1;if(null!=s.effect&&0==(this.effects&1<<s.effect))return!1;if(s.isFilter){let e=this.noteFilter.controlPointCount;if(this.noteFilterType&&(e=1),t>=e)return!1}return"operatorFrequency"!=s.name&&"operatorAmplitude"!=s.name||!(t>=4+(12==this.type?2:0))}clearInvalidEnvelopeTargets(){for(let e=0;e<this.envelopeCount;e++){const t=this.envelopes[e].target,s=this.envelopes[e].index;this.supportsEnvelopeTarget(t,s)||(this.envelopes[e].target=p.instrumentAutomationTargets.dictionary.none.index,this.envelopes[e].index=0)}}getTransition(){return M(this.effects)?p.transitions[this.transition]:11==this.type?p.transitions.dictionary.interrupt:p.transitions.dictionary.normal}getFadeInSeconds(){return 4==this.type?0:xe.fadeInSettingToSeconds(this.fadeIn)}getFadeOutTicks(){return 4==this.type?p.drumsetFadeOutTicks:xe.fadeOutSettingToTicks(this.fadeOut)}getChord(){return w(this.effects)?p.chords[this.chord]:p.chords.dictionary.simultaneous}getDrumsetEnvelope(e){if(4!=this.type)throw new Error("Can't getDrumsetEnvelope() for non-drumset.");return p.envelopes[this.drumsetEnvelopes[e]]}}class ye{constructor(){this.octave=0,this.instruments=[],this.patterns=[],this.bars=[],this.muted=!1,this.name=""}}class ve{constructor(e){this.scaleCustom=[],this.channels=[],this.limitDecay=4,this.limitRise=4e3,this.compressionThreshold=1,this.limitThreshold=1,this.compressionRatio=1,this.limitRatio=1,this.masterGain=1,this.inVolumeCap=0,this.outVolumeCap=0,this.getNewNoteVolume=(e,t,s,i)=>{if(e&&null!=t&&null!=s&&null!=i){i=p.modCount-i-1;let e=p.modulators[this.channels[t].instruments[s].modulators[i]].newNoteVol,n=p.modulators.dictionary.tempo.index;return this.channels[t].instruments[s].modulators[i]==n&&(e=this.tempo-p.modulators[n].convertRealFactor),null!=e?e:6}return 6},this.getVolumeCap=(e,t,s,i)=>{if(e&&null!=t&&null!=s&&null!=i){i=p.modCount-i-1;let e=this.channels[t].instruments[s],n=p.modulators[e.modulators[i]],a=n.maxRawVol;return null!=a?("eq filter"!=n.name&&"note filter"!=n.name||(a=p.filterMorphCount-1,e.modFilterTypes[i]>0&&e.modFilterTypes[i]%2?a=p.filterFreqRange:e.modFilterTypes[i]>0&&(a=p.filterGainRange)),a):6}return 6},this.getVolumeCapForSetting=(e,t,s)=>{if(e){let e=p.modulators[t].maxRawVol;return null!=e?(null==s||"eq filter"!=p.modulators[t].name&&"note filter"!=p.modulators[t].name||(e=p.filterMorphCount-1,s>0&&s%2?e=p.filterFreqRange:s>0&&(e=p.filterGainRange)),e):p.noteSizeMax}return p.noteSizeMax},null!=e?this.fromBase64String(e):this.initToDefault(!0)}getChannelCount(){return this.pitchChannelCount+this.noiseChannelCount+this.modChannelCount}getMaxInstrumentsPerChannel(){return Math.max(this.layeredInstruments?p.layeredInstrumentCountMax:p.instrumentCountMin,this.patternInstruments?p.patternInstrumentCountMax:p.instrumentCountMin)}getMaxInstrumentsPerPattern(e){return this.getMaxInstrumentsPerPatternForChannel(this.channels[e])}getMaxInstrumentsPerPatternForChannel(e){return this.layeredInstruments?Math.min(p.layeredInstrumentCountMax,e.instruments.length):1}getChannelIsNoise(e){return e>=this.pitchChannelCount&&e<this.pitchChannelCount+this.noiseChannelCount}getChannelIsMod(e){return e>=this.pitchChannelCount+this.noiseChannelCount}initToDefault(e=!0){if(this.scale=0,this.scaleCustom=[!0,!1,!0,!0,!1,!1,!1,!0,!0,!1,!0,!0],this.key=0,this.octave=0,this.loopStart=0,this.loopLength=4,this.tempo=120,this.reverb=0,this.beatsPerBar=8,this.barCount=16,this.patternsPerChannel=8,this.rhythm=3,this.layeredInstruments=!1,this.patternInstruments=!1,this.title="Unnamed",document.title=this.title+" - "+z.versionDisplayName,e){this.pitchChannelCount=3,this.noiseChannelCount=1,this.modChannelCount=0;for(let e=0;e<this.getChannelCount();e++){const t=e>=this.pitchChannelCount&&e<this.pitchChannelCount+this.noiseChannelCount,s=e>=this.pitchChannelCount+this.noiseChannelCount;this.channels.length<=e&&(this.channels[e]=new ye);const i=this.channels[e];i.octave=Math.max(3-e,0);for(let e=0;e<this.patternsPerChannel;e++)i.patterns.length<=e?i.patterns[e]=new ne:i.patterns[e].reset();i.patterns.length=this.patternsPerChannel;for(let e=0;e<p.instrumentCountMin;e++)i.instruments.length<=e&&(i.instruments[e]=new de(t,s)),i.instruments[e].setTypeAndReset(s?11:t?2:0,t,s);i.instruments.length=p.instrumentCountMin;for(let e=0;e<this.barCount;e++)i.bars[e]=e<4?1:0;i.bars.length=this.barCount}this.channels.length=this.getChannelCount()}}toBase64String(){let e,t=[];t.push(ve.k),t.push(X[ve.P]),t.push(78);var s=encodeURIComponent(this.title);t.push(X[s.length>>6],X[63&s.length]);for(let e=0;e<s.length;e++)t.push(s.charCodeAt(e));if(t.push(110,X[this.pitchChannelCount],X[this.noiseChannelCount],X[this.modChannelCount]),t.push(115,X[this.scale]),this.scale==p.scales.dictionary.Custom.index)for(var i=1;i<p.pitchesPerOctave;i++)t.push(X[this.scaleCustom[i]?1:0]);t.push(107,X[this.key],X[this.octave-p.octaveMin]),t.push(108,X[this.loopStart>>6],X[63&this.loopStart]),t.push(101,X[this.loopLength-1>>6],X[this.loopLength-1&63]),t.push(116,X[this.tempo>>6],X[63&this.tempo]),t.push(97,X[this.beatsPerBar-1]),t.push(103,X[this.barCount-1>>6],X[this.barCount-1&63]),t.push(106,X[this.patternsPerChannel-1>>6],X[this.patternsPerChannel-1&63]),t.push(114,X[this.rhythm]),t.push(79),1!=this.compressionRatio||1!=this.limitRatio||4e3!=this.limitRise||4!=this.limitDecay||1!=this.limitThreshold||1!=this.compressionThreshold||1!=this.masterGain?(t.push(X[Math.round(this.compressionRatio<1?10*this.compressionRatio:10+60*(this.compressionRatio-1))]),t.push(X[Math.round(this.limitRatio<1?10*this.limitRatio:9+this.limitRatio)]),t.push(X[this.limitDecay]),t.push(X[Math.round((this.limitRise-2e3)/250)]),t.push(X[Math.round(20*this.compressionThreshold)]),t.push(X[Math.round(20*this.limitThreshold)]),t.push(X[Math.round(50*this.masterGain)>>6],X[63&Math.round(50*this.masterGain)])):t.push(X[63]),t.push(85);for(let e=0;e<this.getChannelCount();e++){var n=encodeURIComponent(this.channels[e].name);t.push(X[n.length>>6],X[63&n.length]);for(let e=0;e<n.length;e++)t.push(n.charCodeAt(e))}if(t.push(105,X[this.layeredInstruments<<1|this.patternInstruments]),this.layeredInstruments||this.patternInstruments)for(let e=0;e<this.getChannelCount();e++)t.push(X[this.channels[e].instruments.length-p.instrumentCountMin]);t.push(111);for(let e=0;e<this.pitchChannelCount;e++)t.push(X[this.channels[e].octave]);for(let e=0;e<this.getChannelCount();e++)for(let s=0;s<this.channels[e].instruments.length;s++){const i=this.channels[e].instruments[s];if(t.push(84,X[i.type]),t.push(118,X[i.volume+p.volumeRange/2>>6],X[i.volume+p.volumeRange/2&63]),t.push(117,X[i.preset>>6],X[63&i.preset]),t.push(102),t.push(X[+i.eqFilterType]),i.eqFilterType)t.push(X[i.eqFilterSimpleCut]),t.push(X[i.eqFilterSimplePeak]);else{if(null==i.eqFilter)t.push(X[0]),console.log("Null EQ filter settings detected in toBase64String for channelIndex "+e+", instrumentIndex "+s);else{t.push(X[i.eqFilter.controlPointCount]);for(let e=0;e<i.eqFilter.controlPointCount;e++){const s=i.eqFilter.controlPoints[e];t.push(X[s.type],X[Math.round(s.freq)],X[Math.round(s.gain)])}}let n=0;for(let e=0;e<p.filterMorphCount-1;e++)n|=+(null!=i.eqSubFilters[e+1])<<e;t.push(X[n>>6],X[63&n]);for(let e=0;e<p.filterMorphCount-1;e++)if(n&1<<e){t.push(X[i.eqSubFilters[e+1].controlPointCount]);for(let s=0;s<i.eqSubFilters[e+1].controlPointCount;s++){const n=i.eqSubFilters[e+1].controlPoints[s];t.push(X[n.type],X[Math.round(n.freq)],X[Math.round(n.gain)])}}}if(t.push(113,X[i.effects>>6],X[63&i.effects]),P(i.effects))if(t.push(X[+i.noteFilterType]),i.noteFilterType)t.push(X[i.noteFilterSimpleCut]),t.push(X[i.noteFilterSimplePeak]);else{if(null==i.noteFilter)t.push(X[0]),console.log("Null note filter settings detected in toBase64String for channelIndex "+e+", instrumentIndex "+s);else{t.push(X[i.noteFilter.controlPointCount]);for(let e=0;e<i.noteFilter.controlPointCount;e++){const s=i.noteFilter.controlPoints[e];t.push(X[s.type],X[Math.round(s.freq)],X[Math.round(s.gain)])}}let n=0;for(let e=0;e<p.filterMorphCount-1;e++)n|=+(null!=i.noteSubFilters[e+1])<<e;t.push(X[n>>6],X[63&n]);for(let e=0;e<p.filterMorphCount-1;e++)if(n&1<<e){t.push(X[i.noteSubFilters[e+1].controlPointCount]);for(let s=0;s<i.noteSubFilters[e+1].controlPointCount;s++){const n=i.noteSubFilters[e+1].controlPoints[s];t.push(X[n.type],X[Math.round(n.freq)],X[Math.round(n.gain)])}}}if(M(i.effects)&&t.push(X[i.transition]),w(i.effects)&&(t.push(X[i.chord]),i.chord==p.chords.dictionary.arpeggio.index&&(t.push(X[i.arpeggioSpeed]),t.push(X[+i.fastTwoNoteArp]))),x(i.effects)&&t.push(X[i.pitchShift]),k(i.effects)&&t.push(X[i.detune-p.detuneMin>>6],X[i.detune-p.detuneMin&63]),F(i.effects)&&(t.push(X[i.vibrato]),i.vibrato==p.vibratos.length&&(t.push(X[Math.round(25*i.vibratoDepth)]),t.push(X[i.vibratoSpeed]),t.push(X[Math.round(i.vibratoDelay)]),t.push(X[i.vibratoType]))),q(i.effects)&&(t.push(X[i.distortion]),t.push(X[+i.aliases])),I(i.effects)&&t.push(X[i.bitcrusherFreq],X[i.bitcrusherQuantization]),T(i.effects)&&(t.push(X[i.pan>>6],X[63&i.pan]),t.push(X[i.panDelay])),D(i.effects)&&t.push(X[i.chorus]),O(i.effects)&&t.push(X[i.echoSustain],X[i.echoDelay]),A(i.effects)&&t.push(X[i.reverb]),4!=i.type&&(t.push(100,X[i.fadeIn],X[i.fadeOut]),t.push(X[+i.clicklessTransition])),5==i.type||8==i.type){t.push(72);const e=new te;for(let t=0;t<p.harmonicsControlPoints;t++)e.write(p.harmonicsControlPointBits,i.harmonicsWave.harmonics[t]);e.encodeBase64(t)}if(0==i.type){i.chipWave>186?(t.push(119,X[i.chipWave-186]),t.push(X[3])):i.chipWave>124?(t.push(119,X[i.chipWave-124]),t.push(X[2])):i.chipWave>62?(t.push(119,X[i.chipWave-62]),t.push(X[1])):(t.push(119,X[i.chipWave]),t.push(X[0])),t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign),t.push(121);const e=$(0,32,i.chipWaveLoopMode)<<1|(i.isUsingAdvancedLoopControls?1:0);t.push(X[e]);const s=$(0,32,0)<<1|(i.chipWavePlayBackwards?1:0);t.push(X[s]),Y(t,i.chipWaveLoopStart),Y(t,i.chipWaveLoopEnd),Y(t,i.chipWaveStartOffset)}else if(1==i.type||12==i.type){if(1==i.type)t.push(65,X[i.algorithm]),t.push(70,X[i.feedbackType]);else{if(t.push(65,X[i.algorithm6Op]),0==i.algorithm6Op){t.push(67,X[i.customAlgorithm.carrierCount]),t.push(113);for(let e=0;e<i.customAlgorithm.modulatedBy.length;e++){for(let s=0;s<i.customAlgorithm.modulatedBy[e].length;s++)t.push(X[i.customAlgorithm.modulatedBy[e][s]]);t.push(82)}t.push(113)}if(t.push(70,X[i.feedbackType6Op]),0==i.feedbackType6Op){t.push(113);for(let e=0;e<i.customFeedbackType.indices.length;e++){for(let s=0;s<i.customFeedbackType.indices[e].length;s++)t.push(X[i.customFeedbackType.indices[e][s]]);t.push(82)}t.push(113)}}t.push(66,X[i.feedbackAmplitude]),t.push(81);for(let e=0;e<(12==i.type?6:p.operatorCount);e++)t.push(X[i.operators[e].frequency]);t.push(80);for(let e=0;e<(12==i.type?6:p.operatorCount);e++)t.push(X[i.operators[e].amplitude]);t.push(82);for(let e=0;e<(12==i.type?6:p.operatorCount);e++)t.push(X[i.operators[e].waveform]),2==i.operators[e].waveform&&t.push(X[i.operators[e].pulseWidth])}else if(10==i.type){i.chipWave>186?(t.push(119,X[i.chipWave-186]),t.push(X[3])):i.chipWave>124?(t.push(119,X[i.chipWave-124]),t.push(X[2])):i.chipWave>62?(t.push(119,X[i.chipWave-62]),t.push(X[1])):(t.push(119,X[i.chipWave]),t.push(X[0])),t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign),t.push(77);for(let e=0;e<64;e++)t.push(X[i.customChipWave[e]+24])}else if(2==i.type)t.push(119,X[i.chipNoise]),t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign);else if(3==i.type){t.push(83);const e=new te;for(let t=0;t<p.spectrumControlPoints;t++)e.write(p.spectrumControlPointBits,i.spectrumWave.spectrum[t]);e.encodeBase64(t),t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign)}else if(4==i.type){t.push(122);for(let e=0;e<p.drumCount;e++)t.push(X[i.drumsetEnvelopes[e]]);t.push(83);const e=new te;for(let t=0;t<p.drumCount;t++)for(let s=0;s<p.spectrumControlPoints;s++)e.write(p.spectrumControlPointBits,i.drumsetSpectrumWaves[t].spectrum[s]);e.encodeBase64(t)}else if(5==i.type)t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign);else if(6==i.type)t.push(87,X[i.pulseWidth>>6],X[63&i.pulseWidth]),t.push(X[i.decimalOffset>>6],X[63&i.decimalOffset]),t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign);else if(7==i.type)t.push(87,X[i.pulseWidth>>6],X[63&i.pulseWidth]),t.push(X[i.decimalOffset>>6],X[63&i.decimalOffset]),t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign);else if(9==i.type)t.push(120,X[i.supersawDynamism],X[i.supersawSpread],X[i.supersawShape]),t.push(87,X[i.pulseWidth>>6],X[63&i.pulseWidth]),t.push(X[i.decimalOffset>>6],X[63&i.decimalOffset]);else if(8==i.type){if(p.stringSustainRange>32)throw new Error("Not enough bits to represent sustain value and type in same base64 character.");t.push(104,X[i.unison]),i.unison==p.unisons.length&&J(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign),t.push(73,X[i.stringSustain|i.stringSustainType<<5])}else if(11!=i.type)throw new Error("Unknown instrument type.");t.push(69,X[i.envelopeCount]),t.push(X[i.envelopeSpeed]),t.push(X[+i.discreteEnvelope]);for(let e=0;e<i.envelopeCount;e++)t.push(X[i.envelopes[e].target]),p.instrumentAutomationTargets[i.envelopes[e].target].maxCount>1&&t.push(X[i.envelopes[e].index]),t.push(X[i.envelopes[e].envelope])}t.push(98),e=new te;let a=0;for(;1<<a<this.patternsPerChannel+1;)a++;for(let t=0;t<this.getChannelCount();t++)for(let s=0;s<this.barCount;s++)e.write(a,this.channels[t].bars[s]);e.encodeBase64(t),t.push(112),e=new te;const o=new te,r=ve.getNeededBits(p.noteSizeMax);for(let t=0;t<this.getChannelCount();t++){const s=this.channels[t],i=this.getMaxInstrumentsPerPattern(t),n=this.getChannelIsNoise(t),a=this.getChannelIsMod(t),l=ve.getNeededBits(i-p.instrumentCountMin),h=ve.getNeededBits(s.instruments.length-1);if(a){const i=ve.getNeededBits(this.getMaxInstrumentsPerChannel()+2);for(let n=0;n<s.instruments.length;n++){let s=this.channels[t].instruments[n];for(let t=0;t<p.modCount;t++){const n=s.modChannels[t],a=s.modInstruments[t],o=s.modulators[t],r=s.modFilterTypes[t];let l=p.modulators[o].forSong?2:0;o==p.modulators.dictionary.none.index&&(l=3),e.write(2,l),0!=l&&1!=l||(e.write(8,n),e.write(i,a)),3!=l&&e.write(6,o),"eq filter"!=p.modulators[s.modulators[t]].name&&"note filter"!=p.modulators[s.modulators[t]].name||e.write(6,r)}}}const c=n||a?0:s.octave*p.pitchesPerOctave;let u=n?4:c;const f=a?[0,1,2,3,4,5]:n?[4,6,7,2,3,8,0,10]:[0,7,12,19,24,-5,-12],m=[];for(let e=0;e<f.length;e++)f[e]+=c;for(const t of s.patterns){if(this.patternInstruments){const s=U(p.instrumentCountMin,i,t.instruments.length);e.write(l,s-p.instrumentCountMin);for(let i=0;i<s;i++)e.write(h,t.instruments[i])}if(t.notes.length>0){e.write(1,1);let s=0;for(const i of t.notes){i.start<s&&a&&(e.write(2,0),e.write(1,1),e.writePartDuration(s-i.start)),i.start>s&&(e.write(2,0),a&&e.write(1,0),e.writePartDuration(i.start-s)),o.clear(),1==i.pitches.length?o.write(1,0):(o.write(1,1),o.write(3,i.pitches.length-2)),o.writePinCount(i.pins.length-1),a?o.write(10,i.pins[0].size):o.write(r,i.pins[0].size);let t=0,n=i.pitches[0],l=n;const h=[];for(let e=1;e<i.pins.length;e++){const s=i.pins[e],p=n+s.interval;l!=p?(o.write(1,1),h.push(p),l=p):o.write(1,0),o.writePartDuration(s.time-t),t=s.time,a?o.write(10,s.size):o.write(r,s.size)}const p=String.fromCharCode.apply(null,o.encodeBase64([])),c=m.indexOf(p);-1==c?(e.write(2,1),e.concat(o)):(e.write(1,1),e.writeLongTail(0,0,c),m.splice(c,1)),m.unshift(p),m.length>10&&m.pop();const d=i.pitches.concat(h);for(let t=0;t<d.length;t++){const s=d[t],n=f.indexOf(s);if(-1==n){let t=0,i=u;if(i<s)for(;i!=s;)i++,-1==f.indexOf(i)&&t++;else for(;i!=s;)i--,-1==f.indexOf(i)&&t--;e.write(1,0),e.writePitchInterval(t)}else e.write(1,1),e.write(4,n),f.splice(n,1);f.unshift(s),f.length>16&&f.pop(),u=t==i.pitches.length-1?i.pitches[0]:s}0==i.start&&e.write(1,i.continuesLastPattern?1:0),s=i.end}s<this.beatsPerBar*p.partsPerBeat+ +a&&(e.write(2,0),a&&e.write(1,0),e.writePartDuration(this.beatsPerBar*p.partsPerBeat+ +a-s))}else e.write(1,0)}}let l=e.lengthBase64(),h=[];for(;l>0;)h.unshift(X[63&l]),l>>=6;t.push(X[h.length]),Array.prototype.push.apply(t,h),e.encodeBase64(t);const c=64e3;let u="";if(null!=z.customSamples&&z.customSamples.length>0&&(u="|"+z.customSamples.join("|")),t.length<c)return String.fromCharCode.apply(null,t)+u;{let e="";for(let s=0;s<t.length;s+=c)e+=String.fromCharCode.apply(null,t.slice(s,s+c));return e+u}}static q(e){return 0==e?e=1:1==e&&(e=0),p.envelopes[$(0,p.envelopes.length,e)]}fromBase64String(e,t="auto"){if(null==e||""==e)return ve.I(),void this.initToDefault(!0);let s=0;for(;e.charCodeAt(s)<=32;)s++;if(35==e.charCodeAt(s)&&s++,123==e.charCodeAt(s))return void this.fromJsonObject(JSON.parse(0==s?e:e.substring(s)),t);const a=e.charCodeAt(s);let r,l,c,u,f;106==a?(r=!1,l=!0,c=!1,u=!1,f=!1,s++):103==a?(r=!1,l=!1,c=!0,u=!1,f=!1,s++):117==a?(r=!1,l=!1,c=!1,u=!0,f=!1,s++):85==a?(r=!1,l=!1,c=!1,u=!1,f=!0,s++):100==a?(r=!1,l=!0,c=!1,u=!1,f=!1,s++):(r=!0,l=!1,c=!1,u=!1,f=!1);const m=Z[e.charCodeAt(s++)];if(r&&(-1==m||m>ve.T||m<ve.O))return;if(l&&(-1==m||m>ve.R||m<ve.H))return;if(c&&(-1==m||m>ve.L||m<ve.N))return;if(u&&(-1==m||m>ve.W||m<ve.V))return;if(f&&(-1==m||m>ve.P||m<ve.$))return;const d=m<2,y=m<3,v=m<4,g=m<5,b=m<6,C=m<7,R=m<8,E=m<9;this.initToDefault(r&&E||l&&g||v&&c);const H=r&&E||l&&g;let L=!1;if(u||c||f){var N=(e=e.replaceAll("%7C","|")).split("|");if(e=N.shift(),null==z.customSamples||z.customSamples.join(", ")!=N.join(", ")){ve.U();let e=!1,t=!1,s=!1;const a=[],r=[];i.statusTable={},i.urlTable={},i.totalSamples=0,i.samplesLoaded=0,o.dispatchEvent(new n(i.totalSamples,i.samplesLoaded));for(const n of N)if("legacysamples"===n.toLowerCase())e||(e=!0,a.push(n),h(0));else if("nintariboxsamples"===n.toLowerCase())t||(t=!0,a.push(n),h(1));else if("mariopaintboxsamples"===n.toLowerCase())s||(s=!0,a.push(n),h(2));else{const e=y;if(!ve.j(n,a,r,i,e))continue}if(a.length>0&&(z.customSamples=a),r.length>0){const e=S(r);z.presetCategories[z.presetCategories.length]={name:"Custom Sample Presets",presets:e,index:z.presetCategories.length}}}}if(y&&r){for(const e of this.channels)e.instruments[0].transition=p.transitions.dictionary.interrupt.index,e.instruments[0].effects|=1024;this.channels[3].instruments[0].chipNoise=0}let W=null;if(r&&E||l&&g||v&&c){W=[];for(let e=W.length;e<this.getChannelCount();e++){W[e]=[];for(let t=0;t<p.instrumentCountMin;t++)W[e][t]={}}}let G,B=0,V=0,j=-1,_=!1,Y=!1;for(;s<e.length;)switch(G=e.charCodeAt(s++)){case 78:var J=(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)];this.title=decodeURIComponent(e.substring(s,s+J)),document.title=this.title+" - "+z.versionDisplayName,s+=J;break;case 110:this.pitchChannelCount=Z[e.charCodeAt(s++)],this.noiseChannelCount=Z[e.charCodeAt(s++)],this.modChannelCount=r||l&&d?0:Z[e.charCodeAt(s++)],this.pitchChannelCount=U(p.pitchChannelCountMin,p.pitchChannelCountMax,this.pitchChannelCount),this.noiseChannelCount=U(p.noiseChannelCountMin,p.noiseChannelCountMax,this.noiseChannelCount),this.modChannelCount=U(p.modChannelCountMin,p.modChannelCountMax,this.modChannelCount);for(let e=this.channels.length;e<this.getChannelCount();e++)this.channels[e]=new ye;if(this.channels.length=this.getChannelCount(),r&&E||l&&g||v&&c)for(let e=W.length;e<this.getChannelCount();e++){W[e]=[];for(let t=0;t<p.instrumentCountMin;t++)W[e][t]={}}break;case 115:if(this.scale=Z[e.charCodeAt(s++)],this.scale==p.scales.dictionary.Custom.index)for(var X=1;X<p.pitchesPerOctave;X++)this.scaleCustom[X]=1==Z[e.charCodeAt(s++)];r&&(this.scale=0);break;case 107:if(C&&r)this.key=$(0,p.keys.length,11-Z[e.charCodeAt(s++)]),this.octave=0;else if(r||l)this.key=$(0,p.keys.length,Z[e.charCodeAt(s++)]),this.octave=0;else if(c||y&&u){const t=Z[e.charCodeAt(s++)],[i,n]=Q(t);this.key=i,this.octave=n}else this.key=$(0,p.keys.length,Z[e.charCodeAt(s++)]),this.octave=$(p.octaveMin,p.octaveMax+1,Z[e.charCodeAt(s++)]+p.octaveMin);break;case 108:this.loopStart=g&&r?Z[e.charCodeAt(s++)]:(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)];break;case 101:this.loopLength=g&&r?Z[e.charCodeAt(s++)]:(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]+1;break;case 116:this.tempo=v&&r?[95,120,151,190][Z[e.charCodeAt(s++)]]:C&&r?[88,95,103,111,120,130,140,151,163,176,190,206,222,240,259][Z[e.charCodeAt(s++)]]:Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)],this.tempo=$(p.tempoMin,p.tempoMax+1,this.tempo);break;case 109:E&&r?(B=12*Z[e.charCodeAt(s++)],B=$(0,p.reverbRange,B)):(l&&g||v&&c)&&(B=Z[e.charCodeAt(s++)],B=$(0,p.reverbRange,B));break;case 97:this.beatsPerBar=y&&r?[6,7,8,9,10][Z[e.charCodeAt(s++)]]:Z[e.charCodeAt(s++)]+1,this.beatsPerBar=Math.max(p.beatsPerBarMin,Math.min(p.beatsPerBarMax,this.beatsPerBar));break;case 103:{const t=(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]+1;this.barCount=U(p.barCountMin,p.barCountMax,t);for(let e=0;e<this.getChannelCount();e++){for(let t=this.channels[e].bars.length;t<this.barCount;t++)this.channels[e].bars[t]=t<4?1:0;this.channels[e].bars.length=this.barCount}}break;case 106:{let t;t=R&&r?Z[e.charCodeAt(s++)]+1:(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]+1,this.patternsPerChannel=U(1,p.barCountMax,t);const i=this.getChannelCount();for(let e=0;e<i;e++){const t=this.channels[e].patterns;for(let e=t.length;e<this.patternsPerChannel;e++)t[e]=new ne;t.length=this.patternsPerChannel}}break;case 105:if(E&&r||l&&g||v&&c){const t=U(p.instrumentCountMin,p.patternInstrumentCountMax,Z[e.charCodeAt(s++)]+p.instrumentCountMin);this.layeredInstruments=!1,this.patternInstruments=t>1;for(let e=0;e<this.getChannelCount();e++){const s=e>=this.pitchChannelCount&&e<this.pitchChannelCount+this.noiseChannelCount,i=e>=this.pitchChannelCount+this.noiseChannelCount;for(let n=this.channels[e].instruments.length;n<t;n++)this.channels[e].instruments[n]=new de(s,i);if(this.channels[e].instruments.length=t,b&&r)for(let n=0;n<t;n++)this.channels[e].instruments[n].setTypeAndReset(s?2:0,s,i);for(let s=W[e].length;s<t;s++)W[e][s]={}}}else{const t=Z[e.charCodeAt(s++)];this.layeredInstruments=0!=(2&t),this.patternInstruments=0!=(1&t);for(let t=0;t<this.getChannelCount();t++){let i=1;(this.layeredInstruments||this.patternInstruments)&&(i=U(p.instrumentCountMin,this.getMaxInstrumentsPerChannel(),Z[e.charCodeAt(s++)]+p.instrumentCountMin));const n=this.channels[t],a=this.getChannelIsNoise(t),o=this.getChannelIsMod(t);for(let e=n.instruments.length;e<i;e++)n.instruments[e]=new de(a,o);n.instruments.length=i}}break;case 114:if(u||f)this.rhythm=Z[e.charCodeAt(s++)];else{let t=Z[e.charCodeAt(s++)];this.rhythm=$(0,p.rhythms.length,t+2),(l&&y||r)&&(this.rhythm!=p.rhythms.dictionary["÷3 (triplets)"].index&&this.rhythm!=p.rhythms.dictionary["÷6 (sextuplets)"].index||(_=!0),this.rhythm>=p.rhythms.dictionary["÷6 (sextuplets)"].index&&(Y=!0))}break;case 111:if(y&&r){const t=Z[e.charCodeAt(s++)];this.channels[t].octave=$(0,p.pitchOctaves,Z[e.charCodeAt(s++)]+1),t>=this.pitchChannelCount&&(this.channels[t].octave=0)}else if(E&&r||l&&g||v&&c)for(let t=0;t<this.getChannelCount();t++)this.channels[t].octave=$(0,p.pitchOctaves,Z[e.charCodeAt(s++)]+1),t>=this.pitchChannelCount&&(this.channels[t].octave=0);else{for(let t=0;t<this.pitchChannelCount;t++)this.channels[t].octave=$(0,p.pitchOctaves,Z[e.charCodeAt(s++)]);for(let e=this.pitchChannelCount;e<this.getChannelCount();e++)this.channels[e].octave=0}break;case 84:{j++,j>=this.channels[V].instruments.length&&(V++,j=0),U(0,this.channels.length-1,V);const t=this.channels[V].instruments[j];let i=U(0,12,Z[e.charCodeAt(s++)]);if(l&&g||v&&c)switch(i){case 7:i=10;break;case 8:i=11;break;case 9:i=12}else if(l&&b||c&&!v||u&&g)switch(i){case 7:i=8;break;case 8:i=10;break;case 9:i=11;break;case 10:i=12}else if(l&&!b||u&&!g)switch(i){case 7:i=8;break;case 8:i=9;break;case 9:i=10;break;case 10:i=11;break;case 11:i=12}t.setTypeAndReset(i,V>=this.pitchChannelCount&&V<this.pitchChannelCount+this.noiseChannelCount,V>=this.pitchChannelCount+this.noiseChannelCount),!(C&&r||d&&l)||0!=i&&10!=i&&6!=i||(t.aliases=!0,t.distortion=0,t.effects|=8),_&&(t.arpeggioSpeed=9),Y&&(t.fastTwoNoteArp=!0),C&&r&&t.chord!=p.chords.dictionary.simultaneous.index&&(t.effects|=2048)}break;case 117:{const t=Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)];if(this.channels[V].instruments[j].preset=t,l&&g||v&&c)switch(this.channels[V].instruments[j].preset){case 7:this.channels[V].instruments[j].preset=10,this.channels[V].instruments[j].type=10;break;case 9:this.channels[V].instruments[j].preset=12,this.channels[V].instruments[j].type=12}else if(l&&b||c&&!v||u&&g)switch(this.channels[V].instruments[j].preset){case 7:this.channels[V].instruments[j].preset=8,this.channels[V].instruments[j].type=8;break;case 8:this.channels[V].instruments[j].preset=10,this.channels[V].instruments[j].type=10;break;case 10:this.channels[V].instruments[j].preset=12,this.channels[V].instruments[j].type=12}else if(l&&!b||u&&!g){switch(this.channels[V].instruments[j].preset){case 7:this.channels[V].instruments[j].preset=8,this.channels[V].instruments[j].type=8;break;case 8:this.channels[V].instruments[j].preset=9,this.channels[V].instruments[j].type=9;break;case 9:this.channels[V].instruments[j].preset=10,this.channels[V].instruments[j].type=10;break;case 11:this.channels[V].instruments[j].preset=12,this.channels[V].instruments[j].type=12}11==this.channels[V].instruments[j].preset&&(this.channels[V].instruments[j].preset=12,this.channels[V].instruments[j].type=12)}r&&t==z.nameToPresetValue("grand piano 1")&&(this.channels[V].instruments[j].preset=z.nameToPresetValue("grand piano 3"))}break;case 119:if(y&&r){const t=[1,2,3,4,5,6,7,8,0],i=Z[e.charCodeAt(s++)],n=this.channels[i].instruments[0];n.chipWave=$(0,p.chipWaves.length,0|t[Z[e.charCodeAt(s++)]]),n.convertLegacySettings(W[i][0],H)}else if(b&&r){const t=[1,2,3,4,5,6,7,8,0];for(let i=0;i<this.getChannelCount();i++)for(const n of this.channels[i].instruments)i>=this.pitchChannelCount?n.chipNoise=$(0,p.chipNoises.length,Z[e.charCodeAt(s++)]):n.chipWave=$(0,p.chipWaves.length,0|t[Z[e.charCodeAt(s++)]])}else if(C&&r){const t=[1,2,3,4,5,6,7,8,0];V>=this.pitchChannelCount?this.channels[V].instruments[j].chipNoise=$(0,p.chipNoises.length,Z[e.charCodeAt(s++)]):this.channels[V].instruments[j].chipWave=$(0,p.chipWaves.length,0|t[Z[e.charCodeAt(s++)]])}else if(2==this.channels[V].instruments[j].type)this.channels[V].instruments[j].chipNoise=$(0,p.chipNoises.length,Z[e.charCodeAt(s++)]);else if(u||f){const t=Z[e.charCodeAt(s++)],i=Z[e.charCodeAt(s++)];this.channels[V].instruments[j].chipWave=$(0,p.chipWaves.length,3==i?t+186:2==i?t+124:1==i?t+62:t)}else this.channels[V].instruments[j].chipWave=$(0,p.chipWaves.length,Z[e.charCodeAt(s++)]);break;case 102:if(E&&r||g&&l||v&&c)if(C&&r){const t=[10,6,3,0,8,5,2],i=["none","none","none","none","decay 1","decay 2","decay 3"];if(y&&r){const n=Z[e.charCodeAt(s++)],a=this.channels[n].instruments[0],o=W[n][0],r=[1,3,4,5][$(0,t.length,Z[e.charCodeAt(s++)])];o.filterCutoff=t[r],o.filterResonance=0,o.filterEnvelope=p.envelopes.dictionary[i[r]],a.convertLegacySettings(o,H)}else if(b&&r)for(let n=0;n<this.getChannelCount();n++)for(let a=0;a<this.channels[n].instruments.length;a++){const o=this.channels[n].instruments[a],r=W[n][a],l=$(0,t.length,Z[e.charCodeAt(s++)]+1);n<this.pitchChannelCount?(r.filterCutoff=t[l],r.filterResonance=0,r.filterEnvelope=p.envelopes.dictionary[i[l]]):(r.filterCutoff=10,r.filterResonance=0,r.filterEnvelope=p.envelopes.dictionary.none),o.convertLegacySettings(r,H)}else{const n=$(0,t.length,Z[e.charCodeAt(s++)]),a=this.channels[V].instruments[j],o=W[V][j];o.filterCutoff=t[n],o.filterResonance=0,o.filterEnvelope=p.envelopes.dictionary[i[n]],a.convertLegacySettings(o,H)}}else{const t=11,i=this.channels[V].instruments[j],n=W[V][j];n.filterCutoff=$(0,t,Z[e.charCodeAt(s++)]),i.convertLegacySettings(n,H)}else{const t=this.channels[V].instruments[j];let i=Z[e.charCodeAt(s++)];if(r||0==i){t.eqFilterType=!1,(l||c||u||f)&&(i=Z[e.charCodeAt(s++)]);const n=i;t.eqFilter.controlPointCount=$(0,p.filterMaxPoints+1,n);for(let e=t.eqFilter.controlPoints.length;e<t.eqFilter.controlPointCount;e++)t.eqFilter.controlPoints[e]=new ue;for(let i=0;i<t.eqFilter.controlPointCount;i++){const n=t.eqFilter.controlPoints[i];n.type=$(0,3,Z[e.charCodeAt(s++)]),n.freq=$(0,p.filterFreqRange,Z[e.charCodeAt(s++)]),n.gain=$(0,p.filterGainRange,Z[e.charCodeAt(s++)])}for(let e=t.eqFilter.controlPointCount;e<n;e++)s+=3;if(t.eqSubFilters[0]=t.eqFilter,l&&!g||c&&!v||u||f){let i=Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)];for(let n=0;n<p.filterMorphCount-1;n++)if(i&1<<n){const i=Z[e.charCodeAt(s++)];null==t.eqSubFilters[n+1]&&(t.eqSubFilters[n+1]=new fe),t.eqSubFilters[n+1].controlPointCount=$(0,p.filterMaxPoints+1,i);for(let e=t.eqSubFilters[n+1].controlPoints.length;e<t.eqSubFilters[n+1].controlPointCount;e++)t.eqSubFilters[n+1].controlPoints[e]=new ue;for(let i=0;i<t.eqSubFilters[n+1].controlPointCount;i++){const a=t.eqSubFilters[n+1].controlPoints[i];a.type=$(0,3,Z[e.charCodeAt(s++)]),a.freq=$(0,p.filterFreqRange,Z[e.charCodeAt(s++)]),a.gain=$(0,p.filterGainRange,Z[e.charCodeAt(s++)])}for(let e=t.eqSubFilters[n+1].controlPointCount;e<i;e++)s+=3}}}else t.eqFilterType=!0,t.eqFilterSimpleCut=$(0,p.filterSimpleCutRange,Z[e.charCodeAt(s++)]),t.eqFilterSimplePeak=$(0,p.filterSimplePeakRange,Z[e.charCodeAt(s++)])}break;case 121:if(u||f)if(u&&y){const t=K(e,s);s+=6;const i=e.slice(s,s+t);s+=t;const n=JSON.parse(atob(i));for(const e of n){const t=e.channel,s=e.instrument,i=e.info,n=this.channels[t].instruments[s];n.isUsingAdvancedLoopControls=i.isUsingAdvancedLoopControls,n.chipWaveLoopStart=i.chipWaveLoopStart,n.chipWaveLoopEnd=i.chipWaveLoopEnd,n.chipWaveLoopMode=i.chipWaveLoopMode,n.chipWavePlayBackwards=i.chipWavePlayBackwards,n.chipWaveStartOffset=i.chipWaveStartOffset}}else{const t=Z[e.charCodeAt(s++)],i=Boolean(1&t),n=t>>1,a=Z[e.charCodeAt(s++)],o=Boolean(1&a),r=K(e,s);s+=6;const l=K(e,s);s+=6;const h=K(e,s);s+=6;const p=this.channels[V].instruments[j];p.isUsingAdvancedLoopControls=i,p.chipWaveLoopStart=r,p.chipWaveLoopEnd=l,p.chipWaveLoopMode=n,p.chipWavePlayBackwards=o,p.chipWaveStartOffset=h}else if(c&&!v&&b)"legacysamples"!=document.URL.substring(document.URL.length-13).toLowerCase()&&(L||(L=!0,p.willReloadForCustomSamples=!0,z.customSamples=["legacySamples"],h(0))),this.channels[V].instruments[j].chipWave=$(0,p.chipWaves.length,Z[e.charCodeAt(s++)]+125);else if(E&&r||l&&g||v&&c){const t=8,i=this.channels[V].instruments[j],n=W[V][j];n.filterResonance=$(0,t,Z[e.charCodeAt(s++)]),i.convertLegacySettings(n,H)}break;case 122:{const t=this.channels[V].instruments[j],i=[0,1,2,4,5,6,8,9,10,12,13,14,16,17,18,19,20,21,23,24,25,27,28,29,32,33,34,31,11];if(E&&r||g&&l||v&&c)if(4==t.type)for(let n=0;n<p.drumCount;n++){let a=Z[e.charCodeAt(s++)];(d&&c||!c&&!u&&!f)&&(a=i[a]),t.drumsetEnvelopes[n]=ve.q(a).index}else{const n=W[V][j];let a=Z[e.charCodeAt(s++)];(d&&c||!c&&!u&&!f)&&(a=i[a]),n.filterEnvelope=ve.q(a),t.convertLegacySettings(n,H)}else for(let n=0;n<p.drumCount;n++){let a=Z[e.charCodeAt(s++)];(d&&c||!c&&!u&&!f)&&(a=i[a]),t.drumsetEnvelopes[n]=$(0,p.envelopes.length,a)}}break;case 87:{const t=this.channels[V].instruments[j];t.pulseWidth=$(0,2*p.pulseWidthRange+1,(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]),(u&&!v||f)&&(t.decimalOffset=$(0,101,(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]))}break;case 73:{const t=this.channels[V].instruments[j],i=Z[e.charCodeAt(s++)];t.stringSustain=$(0,p.stringSustainRange,31&i),t.stringSustainType=p.enableAcousticSustain?$(0,2,i>>5):0}break;case 100:if(E&&r||l&&g||v&&c){const t=[{transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1},{transition:"normal",fadeInSeconds:0,fadeOutTicks:-3},{transition:"normal",fadeInSeconds:.025,fadeOutTicks:-3},{transition:"slide in pattern",fadeInSeconds:.025,fadeOutTicks:-3},{transition:"normal",fadeInSeconds:.04,fadeOutTicks:6},{transition:"normal",fadeInSeconds:0,fadeOutTicks:48},{transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72},{transition:"normal",fadeInSeconds:.06,fadeOutTicks:96},{transition:"slide in pattern",fadeInSeconds:.025,fadeOutTicks:-3}];if(y&&r){const i=Z[e.charCodeAt(s++)],n=t[$(0,t.length,Z[e.charCodeAt(s++)])],a=this.channels[i].instruments[0];a.fadeIn=xe.secondsToFadeInSetting(n.fadeInSeconds),a.fadeOut=xe.ticksToFadeOutSetting(n.fadeOutTicks),a.transition=p.transitions.dictionary[n.transition].index,a.transition!=p.transitions.dictionary.normal.index&&(a.effects|=1024)}else if(b&&r)for(let i=0;i<this.getChannelCount();i++)for(const n of this.channels[i].instruments){const i=t[$(0,t.length,Z[e.charCodeAt(s++)])];n.fadeIn=xe.secondsToFadeInSetting(i.fadeInSeconds),n.fadeOut=xe.ticksToFadeOutSetting(i.fadeOutTicks),n.transition=p.transitions.dictionary[i.transition].index,n.transition!=p.transitions.dictionary.normal.index&&(n.effects|=1024)}else if(v&&!c&&!u&&!f||r){const i=t[$(0,t.length,Z[e.charCodeAt(s++)])],n=this.channels[V].instruments[j];n.fadeIn=xe.secondsToFadeInSetting(i.fadeInSeconds),n.fadeOut=xe.ticksToFadeOutSetting(i.fadeOutTicks),n.transition=p.transitions.dictionary[i.transition].index,n.transition!=p.transitions.dictionary.normal.index&&(n.effects|=1024)}else{const i=t[$(0,t.length,Z[e.charCodeAt(s++)])],n=this.channels[V].instruments[j];n.fadeIn=xe.secondsToFadeInSetting(i.fadeInSeconds),n.fadeOut=xe.ticksToFadeOutSetting(i.fadeOutTicks),n.transition=p.transitions.dictionary[i.transition].index,Z[e.charCodeAt(s++)]>0&&(n.legacyTieOver=!0),n.clicklessTransition=!!Z[e.charCodeAt(s++)],(n.transition!=p.transitions.dictionary.normal.index||n.clicklessTransition)&&(n.effects|=1024)}}else{const t=this.channels[V].instruments[j];t.fadeIn=$(0,p.fadeInRange,Z[e.charCodeAt(s++)]),t.fadeOut=$(0,p.fadeOutTicks.length,Z[e.charCodeAt(s++)]),(l||c||u||f)&&(t.clicklessTransition=!!Z[e.charCodeAt(s++)])}break;case 99:if(E&&r||l&&g||v&&c)if(C&&r)if(y&&r){const t=[0,3,2,0],i=["none","none","none","tremolo2"],n=Z[e.charCodeAt(s++)],a=$(0,t.length,Z[e.charCodeAt(s++)]),o=this.channels[n].instruments[0],r=W[n][0];o.vibrato=t[a],null!=r.filterEnvelope&&1!=r.filterEnvelope.type||(r.filterEnvelope=p.envelopes.dictionary[i[a]],o.convertLegacySettings(r,H)),o.vibrato!=p.vibratos.dictionary.none.index&&(o.effects|=512)}else if(b&&r){const t=[0,1,2,3,0,0],i=["none","none","none","none","tremolo5","tremolo2"];for(let n=0;n<this.getChannelCount();n++)for(let a=0;a<this.channels[n].instruments.length;a++){const o=$(0,t.length,Z[e.charCodeAt(s++)]),r=this.channels[n].instruments[a],h=W[n][a];r.vibrato=t[o],null!=h.filterEnvelope&&1!=h.filterEnvelope.type||(h.filterEnvelope=p.envelopes.dictionary[i[o]],r.convertLegacySettings(h,H)),r.vibrato!=p.vibratos.dictionary.none.index&&(r.effects|=512),(0!=B||l&&g||v&&c)&&!this.getChannelIsNoise(n)&&(r.effects|=1,r.reverb=B)}}else{const t=[0,1,2,3,0,0],i=["none","none","none","none","tremolo5","tremolo2"],n=$(0,t.length,Z[e.charCodeAt(s++)]),a=this.channels[V].instruments[j],o=W[V][j];a.vibrato=t[n],null!=o.filterEnvelope&&1!=o.filterEnvelope.type||(o.filterEnvelope=p.envelopes.dictionary[i[n]],a.convertLegacySettings(o,H)),a.vibrato!=p.vibratos.dictionary.none.index&&(a.effects|=512),(0!=B||l&&g||v&&c)&&(a.effects|=1,a.reverb=B)}else{const t=this.channels[V].instruments[j],i=$(0,p.vibratos.length+1,Z[e.charCodeAt(s++)]);t.vibrato=i,t.vibrato!=p.vibratos.dictionary.none.index&&(t.effects|=512),i==p.vibratos.length?(t.vibratoDepth=$(0,p.modulators.dictionary["vibrato depth"].maxRawVol+1,Z[e.charCodeAt(s++)])/50,t.vibratoSpeed=$(0,p.modulators.dictionary["vibrato speed"].maxRawVol+1,Z[e.charCodeAt(s++)]),t.vibratoDelay=$(0,p.modulators.dictionary["vibrato delay"].maxRawVol+1,Z[e.charCodeAt(s++)])/2,t.vibratoType=$(0,p.vibratoTypes.length,Z[e.charCodeAt(s++)]),t.effects|=512):(t.vibratoDepth=p.vibratos[t.vibrato].amplitude,t.vibratoSpeed=10,t.vibratoDelay=p.vibratos[t.vibrato].delayTicks/2,t.vibratoType=p.vibratos[t.vibrato].type)}break;case 71:if(l&&g||v&&c){const t=this.channels[V].instruments[j];t.arpeggioSpeed=$(0,p.modulators.dictionary["arp speed"].maxRawVol+1,Z[e.charCodeAt(s++)]),t.fastTwoNoteArp=!!Z[e.charCodeAt(s++)]}break;case 104:if(y&&r){const t=Z[e.charCodeAt(s++)];this.channels[t].instruments[0].unison=$(0,p.unisons.length,Z[e.charCodeAt(s++)]);const i=this.channels[t].instruments[0];i.unisonVoices=p.unisons[i.unison].voices,i.unisonSpread=p.unisons[i.unison].spread,i.unisonOffset=p.unisons[i.unison].offset,i.unisonExpression=p.unisons[i.unison].expression,i.unisonSign=p.unisons[i.unison].sign}else if(b&&r)for(let t=0;t<this.getChannelCount();t++)for(const i of this.channels[t].instruments){const t=Z[e.charCodeAt(s++)];let n=$(0,p.unisons.length,t);8==t&&(n=2,i.chord=3),i.unison=n,i.unisonVoices=p.unisons[i.unison].voices,i.unisonSpread=p.unisons[i.unison].spread,i.unisonOffset=p.unisons[i.unison].offset,i.unisonExpression=p.unisons[i.unison].expression,i.unisonSign=p.unisons[i.unison].sign}else if(C&&r){const t=Z[e.charCodeAt(s++)];let i=$(0,p.unisons.length,t);8==t&&(i=2,this.channels[V].instruments[j].chord=3),this.channels[V].instruments[j].unison=i;const n=this.channels[V].instruments[j];n.unisonVoices=p.unisons[n.unison].voices,n.unisonSpread=p.unisons[n.unison].spread,n.unisonOffset=p.unisons[n.unison].offset,n.unisonExpression=p.unisons[n.unison].expression,n.unisonSign=p.unisons[n.unison].sign}else{this.channels[V].instruments[j].unison=$(0,p.unisons.length+1,Z[e.charCodeAt(s++)]);const t=this.channels[V].instruments[j];if((u&&!g||f)&&t.unison==p.unisons.length){t.unisonVoices=Z[e.charCodeAt(s++)];const i=Z[e.charCodeAt(s++)],n=Z[e.charCodeAt(s++)]+63*(Z[e.charCodeAt(s++)]+63*Z[e.charCodeAt(s++)]),a=Z[e.charCodeAt(s++)],o=Z[e.charCodeAt(s++)]+63*(Z[e.charCodeAt(s++)]+63*Z[e.charCodeAt(s++)]),r=Z[e.charCodeAt(s++)],l=Z[e.charCodeAt(s++)]+63*Z[e.charCodeAt(s++)],h=Z[e.charCodeAt(s++)],p=Z[e.charCodeAt(s++)]+63*Z[e.charCodeAt(s++)];t.unisonSpread=n/1e3,0==i&&(t.unisonSpread*=-1),t.unisonOffset=o/1e3,0==a&&(t.unisonOffset*=-1),t.unisonExpression=l/1e3,0==r&&(t.unisonExpression*=-1),t.unisonSign=p/1e3,0==h&&(t.unisonSign*=-1)}else t.unisonVoices=p.unisons[t.unison].voices,t.unisonSpread=p.unisons[t.unison].spread,t.unisonOffset=p.unisons[t.unison].offset,t.unisonExpression=p.unisons[t.unison].expression,t.unisonSign=p.unisons[t.unison].sign}break;case 67:if(E&&r||l&&g||v&&c){const t=this.channels[V].instruments[j];t.chord=$(0,p.chords.length,Z[e.charCodeAt(s++)]),t.chord!=p.chords.dictionary.simultaneous.index&&(t.effects|=2048)}break;case 113:{const t=this.channels[V].instruments[j];if(E&&r||l&&g||v&&c){t.effects=4095&Z[e.charCodeAt(s++)],0!=B||l&&g||v&&c?A(t.effects)&&(t.reverb=B):t.effects&=-2,t.effects|=4,t.vibrato!=p.vibratos.dictionary.none.index&&(t.effects|=512),t.detune!=p.detuneCenter&&(t.effects|=256),t.aliases?t.effects|=8:t.effects&=-9;const i=W[V][j];t.convertLegacySettings(i,H)}else{if(t.effects=Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)],P(t.effects)){let i=Z[e.charCodeAt(s++)];if(r||0==i){t.noteFilterType=!1,(l||c||u||f)&&(i=Z[e.charCodeAt(s++)]),t.noteFilter.controlPointCount=$(0,p.filterMaxPoints+1,i);for(let e=t.noteFilter.controlPoints.length;e<t.noteFilter.controlPointCount;e++)t.noteFilter.controlPoints[e]=new ue;for(let i=0;i<t.noteFilter.controlPointCount;i++){const n=t.noteFilter.controlPoints[i];n.type=$(0,3,Z[e.charCodeAt(s++)]),n.freq=$(0,p.filterFreqRange,Z[e.charCodeAt(s++)]),n.gain=$(0,p.filterGainRange,Z[e.charCodeAt(s++)])}for(let e=t.noteFilter.controlPointCount;e<i;e++)s+=3;if(t.noteSubFilters[0]=t.noteFilter,l&&!g||c||u||f){let i=Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)];for(let n=0;n<p.filterMorphCount-1;n++)if(i&1<<n){const i=Z[e.charCodeAt(s++)];null==t.noteSubFilters[n+1]&&(t.noteSubFilters[n+1]=new fe),t.noteSubFilters[n+1].controlPointCount=$(0,p.filterMaxPoints+1,i);for(let e=t.noteSubFilters[n+1].controlPoints.length;e<t.noteSubFilters[n+1].controlPointCount;e++)t.noteSubFilters[n+1].controlPoints[e]=new ue;for(let i=0;i<t.noteSubFilters[n+1].controlPointCount;i++){const a=t.noteSubFilters[n+1].controlPoints[i];a.type=$(0,3,Z[e.charCodeAt(s++)]),a.freq=$(0,p.filterFreqRange,Z[e.charCodeAt(s++)]),a.gain=$(0,p.filterGainRange,Z[e.charCodeAt(s++)])}for(let e=t.noteSubFilters[n+1].controlPointCount;e<i;e++)s+=3}}}else t.noteFilterType=!0,t.noteFilter.reset(),t.noteFilterSimpleCut=$(0,p.filterSimpleCutRange,Z[e.charCodeAt(s++)]),t.noteFilterSimplePeak=$(0,p.filterSimplePeakRange,Z[e.charCodeAt(s++)])}M(t.effects)&&(t.transition=$(0,p.transitions.length,Z[e.charCodeAt(s++)])),w(t.effects)&&(t.chord=$(0,p.chords.length,Z[e.charCodeAt(s++)]),t.chord==p.chords.dictionary.arpeggio.index&&(l||c||u||f)&&(t.arpeggioSpeed=Z[e.charCodeAt(s++)],t.fastTwoNoteArp=!!Z[e.charCodeAt(s++)])),x(t.effects)&&(t.pitchShift=$(0,p.pitchShiftRange,f?Z[e.charCodeAt(s++)]:Z[e.charCodeAt(s++)]+12)),k(t.effects)&&(r?(t.detune=$(p.detuneMin,p.detuneMax+1,Z[e.charCodeAt(s++)]),t.detune=Math.round((t.detune-9)*(Math.abs(t.detune-9)+1)/2+p.detuneCenter)):t.detune=$(p.detuneMin,p.detuneMax+1,(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)])),F(t.effects)&&(t.vibrato=$(0,p.vibratos.length+1,Z[e.charCodeAt(s++)]),t.vibrato==p.vibratos.length&&(l||c||u||f)?(t.vibratoDepth=$(0,p.modulators.dictionary["vibrato depth"].maxRawVol+1,Z[e.charCodeAt(s++)])/25,t.vibratoSpeed=$(0,p.modulators.dictionary["vibrato speed"].maxRawVol+1,Z[e.charCodeAt(s++)]),t.vibratoDelay=$(0,p.modulators.dictionary["vibrato delay"].maxRawVol+1,Z[e.charCodeAt(s++)]),t.vibratoType=$(0,p.vibratoTypes.length,Z[e.charCodeAt(s++)])):(t.vibratoDepth=p.vibratos[t.vibrato].amplitude,t.vibratoSpeed=10,t.vibratoDelay=p.vibratos[t.vibrato].delayTicks/2,t.vibratoType=p.vibratos[t.vibrato].type)),q(t.effects)&&(t.distortion=$(0,p.distortionRange,Z[e.charCodeAt(s++)]),(l&&!g||c||u||f)&&(t.aliases=!!Z[e.charCodeAt(s++)])),I(t.effects)&&(t.bitcrusherFreq=$(0,p.bitcrusherFreqRange,Z[e.charCodeAt(s++)]),t.bitcrusherQuantization=$(0,p.bitcrusherQuantizationRange,Z[e.charCodeAt(s++)])),T(t.effects)&&(t.pan=$(0,p.panMax+1,r?Math.round(Z[e.charCodeAt(s++)]*(p.panMax/8)):(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]),(l&&!d||c||u||f)&&(t.panDelay=Z[e.charCodeAt(s++)])),D(t.effects)&&(t.chorus=r?2*$(0,p.chorusRange/2+1,Z[e.charCodeAt(s++)]):$(0,p.chorusRange,Z[e.charCodeAt(s++)])),O(t.effects)&&(t.echoSustain=$(0,p.echoSustainRange,Z[e.charCodeAt(s++)]),t.echoDelay=$(0,p.echoDelayRange,Z[e.charCodeAt(s++)])),A(t.effects)&&(t.reverb=$(0,p.reverbRange,r?Math.round(Z[e.charCodeAt(s++)]*p.reverbRange/3):Z[e.charCodeAt(s++)]))}t.effects&=4095}break;case 118:if(y&&r){const t=Z[e.charCodeAt(s++)];this.channels[t].instruments[0].volume=Math.round($(-p.volumeRange/2,1,5*-Z[e.charCodeAt(s++)]))}else if(b&&r)for(let t=0;t<this.getChannelCount();t++)for(const i of this.channels[t].instruments)i.volume=Math.round($(-p.volumeRange/2,1,5*-Z[e.charCodeAt(s++)]));else if(C&&r){this.channels[V].instruments[j].volume=Math.round($(-p.volumeRange/2,1,5*-Z[e.charCodeAt(s++)]))}else if(r){this.channels[V].instruments[j].volume=Math.round($(-p.volumeRange/2,1,25*-Z[e.charCodeAt(s++)]/7))}else{this.channels[V].instruments[j].volume=Math.round($(-p.volumeRange/2,p.volumeRange/2+1,(Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)])-p.volumeRange/2))}break;case 76:if(E&&r){this.channels[V].instruments[j].pan=$(0,p.panMax+1,Z[e.charCodeAt(s++)]*(p.panMax/8))}else if(l&&g||v&&c){const t=this.channels[V].instruments[j];t.pan=$(0,p.panMax+1,(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]),(l&&!y||c||u||f)&&(t.panDelay=Z[e.charCodeAt(s++)])}break;case 68:{const t=this.channels[V].instruments[j];(l&&g||v&&c)&&(t.detune=$(p.detuneMin,p.detuneMax+1,4*((Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)])),t.effects|=256)}break;case 77:{let t=this.channels[V].instruments[j];for(let i=0;i<64;i++)t.customChipWave[i]=$(-24,25,Z[e.charCodeAt(s++)]-24);let i=0;for(let e=0;e<t.customChipWave.length;e++)i+=t.customChipWave[e];const n=i/t.customChipWave.length;let a=0,o=0;for(let e=0;e<t.customChipWave.length;e++)a+=o,o=t.customChipWave[e]-n,t.customChipWaveIntegral[e]=a;t.customChipWaveIntegral[64]=0}break;case 79:{let t=Z[e.charCodeAt(s++)];63==t?this.restoreLimiterDefaults():(this.compressionRatio=t<10?t/10:1+(t-10)/60,t=Z[e.charCodeAt(s++)],this.limitRatio=t<10?t/10:t-9,this.limitDecay=Z[e.charCodeAt(s++)],this.limitRise=250*Z[e.charCodeAt(s++)]+2e3,this.compressionThreshold=Z[e.charCodeAt(s++)]/20,this.limitThreshold=Z[e.charCodeAt(s++)]/20,this.masterGain=((Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)])/50)}break;case 85:for(let t=0;t<this.getChannelCount();t++){var te;te=!v||c||u||f?(Z[e.charCodeAt(s++)]<<6)+Z[e.charCodeAt(s++)]:Z[e.charCodeAt(s++)],this.channels[t].name=decodeURIComponent(e.substring(s,s+te)),s+=te}break;case 65:{const t=this.channels[V].instruments[j];if(1==t.type)t.algorithm=$(0,p.algorithms.length,Z[e.charCodeAt(s++)]);else if(t.algorithm6Op=$(0,p.algorithms6Op.length,Z[e.charCodeAt(s++)]),t.customAlgorithm.fromPreset(t.algorithm6Op),67==e.charCodeAt(s)){let i=$(1,p.operatorCount+2+1,Z[e.charCodeAt(s+1)]);s++;let n=[];if(113==e.charCodeAt(s+1)){s++;let a=0;for(s++;113!=e.charCodeAt(s);){n[a]=[];let t=0;for(;82!=e.charCodeAt(s);)n[a][t]=$(1,p.operatorCount+3,Z[e.charCodeAt(s)]),t++,s++;a++,s++}t.customAlgorithm.set(i,n),s++}}if(E&&r||g&&l||v&&c){const e=W[V][j];t.convertLegacySettings(e,H)}}break;case 120:if(c&&!v&&b){const t=Z[e.charCodeAt(s++)];t+62>85&&"legacysamples"!=document.URL.substring(document.URL.length-13).toLowerCase()&&(L||(L=!0,p.willReloadForCustomSamples=!0,z.customSamples=["legacySamples"],h(0))),this.channels[V].instruments[j].chipWave=t+62>78?$(0,p.chipWaves.length,t+63):t+62>67?$(0,p.chipWaves.length,t+61):t+62==67?40:$(0,p.chipWaves.length,t+62)}else{const t=this.channels[V].instruments[j];t.supersawDynamism=$(0,p.supersawDynamismMax+1,Z[e.charCodeAt(s++)]),t.supersawSpread=$(0,p.supersawSpreadMax+1,Z[e.charCodeAt(s++)]),t.supersawShape=$(0,p.supersawShapeMax+1,Z[e.charCodeAt(s++)])}break;case 70:{const t=this.channels[V].instruments[j];if(1==t.type)t.feedbackType=$(0,p.feedbacks.length,Z[e.charCodeAt(s++)]);else{t.feedbackType6Op=$(0,p.feedbacks6Op.length,Z[e.charCodeAt(s++)]),t.customFeedbackType.fromPreset(t.feedbackType6Op);let i=[];if(113==e.charCodeAt(s)){let n=0;for(s++;113!=e.charCodeAt(s);){i[n]=[];let t=0;for(;82!=e.charCodeAt(s);)i[n][t]=$(1,p.operatorCount+2,Z[e.charCodeAt(s)]),t++,s++;n++,s++}t.customFeedbackType.set(i),s++}}}break;case 66:this.channels[V].instruments[j].feedbackAmplitude=$(0,p.operatorAmplitudeMax+1,Z[e.charCodeAt(s++)]);break;case 86:if(E&&r||g&&l||v&&c){const t=[0,1,2,4,5,6,8,9,10,12,13,14,16,17,18,19,20,21,23,24,25,27,28,29,32,33,34,31,11],i=this.channels[V].instruments[j],n=W[V][j];let a=Z[e.charCodeAt(s++)];(d&&c||!c&&!u&&!f)&&(a=t[a]),n.feedbackEnvelope=ve.q(Z[a]),i.convertLegacySettings(n,H)}break;case 81:{const t=this.channels[V].instruments[j];if(y&&c){const i=[4,5,6,7,8,10,12,13,14,15,16,18,20,22,24,2,1,9,17,19,21,23,0,3];for(let n=0;n<(12==t.type?6:p.operatorCount);n++)t.operators[n].frequency=i[$(0,i.length,Z[e.charCodeAt(s++)])]}else if(c||u||f)for(let i=0;i<(12==t.type?6:p.operatorCount);i++)t.operators[i].frequency=$(0,p.operatorFrequencies.length,Z[e.charCodeAt(s++)]);else{const i=[4,5,6,7,8,10,12,13,14,15,16,18,20,23,27,2,1,9,17,19,21,23,0,3];for(let n=0;n<(12==t.type?6:p.operatorCount);n++)t.operators[n].frequency=i[$(0,i.length,Z[e.charCodeAt(s++)])]}}break;case 80:{const t=this.channels[V].instruments[j];for(let i=0;i<(12==t.type?6:p.operatorCount);i++)t.operators[i].amplitude=$(0,p.operatorAmplitudeMax+1,Z[e.charCodeAt(s++)])}break;case 69:{const t=[0,1,2,4,5,6,8,9,10,12,13,14,16,17,18,19,20,21,23,24,25,27,28,29,32,33,34,31,11],i=[0,1,2,4,5,6,8,9,10,12,13,14,16,17,18,19,20,21,23,24,25,58,59,60],n=this.channels[V].instruments[j];if(E&&r||g&&l||v&&c){const a=W[V][j];a.operatorEnvelopes=[];for(let o=0;o<(12==n.type?6:p.operatorCount);o++){let n=Z[e.charCodeAt(s++)];(d&&c||r)&&(n=t[n]),l&&(n=i[n]),a.operatorEnvelopes[o]=ve.q(n)}n.convertLegacySettings(a,H)}else{const a=$(0,p.maxEnvelopeCount+1,Z[e.charCodeAt(s++)]);(l&&!b||u&&!g||f)&&(n.envelopeSpeed=$(0,p.modulators.dictionary["envelope speed"].maxRawVol+1,Z[e.charCodeAt(s++)]),n.discreteEnvelope=!!Z[e.charCodeAt(s++)]);for(let o=0;o<a;o++){const a=$(0,p.instrumentAutomationTargets.length,Z[e.charCodeAt(s++)]);let o=0;const h=p.instrumentAutomationTargets[a].maxCount;h>1&&(o=$(0,h,Z[e.charCodeAt(s++)]));let u=Z[e.charCodeAt(s++)];(d&&c||r)&&(u=t[u]),l&&(u=i[u]);const f=$(0,p.envelopes.length,u);n.addEnvelope(a,o,f)}}}break;case 82:{const t=this.channels[V].instruments[j];if(y&&c)for(let i=0;i<p.operatorCount;i++){const n=[0,1,3,2,2,2,4,5],a=$(0,n.length,Z[e.charCodeAt(s++)]);3==a?t.operators[i].pulseWidth=5:4==a?t.operators[i].pulseWidth=4:5==a&&(t.operators[i].pulseWidth=6),t.operators[i].waveform=n[a]}else for(let i=0;i<(12==t.type?6:p.operatorCount);i++){if(l){const n=[0,1,3,2,4,5];t.operators[i].waveform=n[$(0,p.operatorWaves.length,Z[e.charCodeAt(s++)])]}else t.operators[i].waveform=$(0,p.operatorWaves.length,Z[e.charCodeAt(s++)]);2==t.operators[i].waveform&&(t.operators[i].pulseWidth=$(0,p.pwmOperatorWaves.length,Z[e.charCodeAt(s++)]))}}break;case 83:{const t=this.channels[V].instruments[j];if(3==t.type){const i=Math.ceil(p.spectrumControlPoints*p.spectrumControlPointBits/6),n=new ee(e,s,s+i);for(let e=0;e<p.spectrumControlPoints;e++)t.spectrumWave.spectrum[e]=n.read(p.spectrumControlPointBits);t.spectrumWave.markCustomWaveDirty(),s+=i}else{if(4!=t.type)throw new Error("Unhandled instrument type for spectrum song tag code.");{const i=Math.ceil(p.drumCount*p.spectrumControlPoints*p.spectrumControlPointBits/6),n=new ee(e,s,s+i);for(let e=0;e<p.drumCount;e++){for(let s=0;s<p.spectrumControlPoints;s++)t.drumsetSpectrumWaves[e].spectrum[s]=n.read(p.spectrumControlPointBits);t.drumsetSpectrumWaves[e].markCustomWaveDirty()}s+=i}}}break;case 72:{const t=this.channels[V].instruments[j],i=Math.ceil(p.harmonicsControlPoints*p.harmonicsControlPointBits/6),n=new ee(e,s,s+i);for(let e=0;e<p.harmonicsControlPoints;e++)t.harmonicsWave.harmonics[e]=n.read(p.harmonicsControlPointBits);t.harmonicsWave.markCustomWaveDirty(),s+=i}break;case 88:if(l&&g||c&&v){const t=this.channels[V].instruments[j];t.aliases=!!Z[e.charCodeAt(s++)],t.aliases&&(t.distortion=0,t.effects|=8)}else if(u||f){this.channels[V].instruments[j].decimalOffset=$(0,51,Z[e.charCodeAt(s++)])}break;case 98:{let t;if(y&&r){const i=Z[e.charCodeAt(s++)],n=Z[e.charCodeAt(s++)];t=Math.ceil(.5*n);const a=new ee(e,s,s+t);for(let e=0;e<n;e++)this.channels[i].bars[e]=a.read(3)+1}else if(g&&r){let i=0;for(;1<<i<this.patternsPerChannel;)i++;t=Math.ceil(this.getChannelCount()*this.barCount*i/6);const n=new ee(e,s,s+t);for(let e=0;e<this.getChannelCount();e++)for(let t=0;t<this.barCount;t++)this.channels[e].bars[t]=n.read(i)+1}else{let i=0;for(;1<<i<this.patternsPerChannel+1;)i++;t=Math.ceil(this.getChannelCount()*this.barCount*i/6);const n=new ee(e,s,s+t);for(let e=0;e<this.getChannelCount();e++)for(let t=0;t<this.barCount;t++)this.channels[e].bars[t]=n.read(i)}s+=t}break;case 112:{let t,i=0,n=!(v&&l||r),a=n?4:3,o=n?16:8;if(y&&r)t=Z[e.charCodeAt(s++)],s++,i=Z[e.charCodeAt(s++)],i<<=6,i+=Z[e.charCodeAt(s++)];else{t=0;let n=U(1,4,Z[e.charCodeAt(s++)]);for(;n>0;)i<<=6,i+=Z[e.charCodeAt(s++)],n--}const h=new ee(e,s,s+i);s+=i;const m=ve.getNeededBits(p.noteSizeMax),d=f?10:9;let b=-1,S=-1,M=-1;for(;;){const e=this.channels[t],s=this.getChannelIsNoise(t),i=this.getChannelIsMod(t),w=this.getMaxInstrumentsPerPattern(t),x=ve.getNeededBits(w-p.instrumentCountMin),k=ve.getNeededBits(e.instruments.length-1);if(i){let s=g&&l||v&&c;const i=Math.max(this.layeredInstruments?4:1,this.patternInstruments?10:1),n=Math.max(this.layeredInstruments?4:1,this.patternInstruments?10:1),a=Math.max(this.layeredInstruments?10:1,this.patternInstruments?10:1),o=this.getMaxInstrumentsPerChannel(),r=!1,f=l&&!g?i:!c||v||r?u||c&&r?a:o:n,m=s?k:ve.getNeededBits(f+2);for(let i=0;i<e.instruments.length;i++){let n=e.instruments[i];for(let e=0;e<p.modCount;e++){let a=h.read(2);switch(a){case 0:n.modChannels[e]=$(0,this.pitchChannelCount+this.noiseChannelCount+1,h.read(8)),n.modInstruments[e]=$(0,this.channels[n.modChannels[e]].instruments.length+2,h.read(m));break;case 1:n.modChannels[e]=this.pitchChannelCount+$(0,this.noiseChannelCount+1,h.read(8)),n.modInstruments[e]=$(0,this.channels[n.modChannels[e]].instruments.length+2,h.read(k));break;case 2:n.modChannels[e]=-1;break;case 3:n.modChannels[e]=-2}if(3!=a&&(n.modulators[e]=h.read(6)),s||"eq filter"!=p.modulators[n.modulators[e]].name&&"note filter"!=p.modulators[n.modulators[e]].name||(n.modFilterTypes[e]=h.read(6)),s&&n.modChannels[e]>=0){let t=P(this.channels[n.modChannels[e]].instruments[n.modInstruments[e]].effects);7==n.modulators[e]?(n.modulators[e]=t?p.modulators.dictionary["note filt cut"].index:p.modulators.dictionary["eq filt cut"].index,n.modFilterTypes[e]=1):8==n.modulators[e]&&(n.modulators[e]=t?p.modulators.dictionary["note filt peak"].index:p.modulators.dictionary["eq filt peak"].index,n.modFilterTypes[e]=2)}else s&&n.modulators[e]==p.modulators.dictionary["song reverb"].index&&(b=t,S=i,M=e);s&&12!=p.modulators[n.modulators[e]].associatedEffect&&(this.channels[n.modChannels[e]].instruments[n.modInstruments[e]].effects|=1<<p.modulators[n.modulators[e]].associatedEffect)}}}const F=[];for(let t=0;t<e.instruments.length;t++){F[t]=[];for(let s=0;s<p.modCount;s++)F[t][p.modCount-1-s]=1+3*+((g&&l||v&&c)&&i&&e.instruments[t].modulators[s]==p.modulators.dictionary.detune.index)}const q=s||i?0:12*e.octave;let I=s||i?4:q;const T=i?[0,1,2,3,4,5]:s?[4,6,7,2,3,8,0,10]:[0,7,12,19,24,-5,-12],D=[];for(let e=0;e<T.length;e++)T[e]+=q;for(let t=0;t<this.patternsPerChannel;t++){const s=e.patterns[t];if(E&&r||g&&l||v&&c)s.instruments[0]=U(0,e.instruments.length-1,h.read(k)),s.instruments.length=1;else if(this.patternInstruments){const t=U(p.instrumentCountMin,w,h.read(x)+p.instrumentCountMin);for(let n=0;n<t;n++)s.instruments[n]=U(0,e.instruments.length-1+2*+i,h.read(k));s.instruments.length=t}else s.instruments[0]=0,s.instruments.length=p.instrumentCountMin;if(!(r&&y||0!=h.read(1))){s.notes.length=0;continue}let b=0;const S=s.notes;let M=0;for(;b<this.beatsPerBar*p.partsPerBeat+ +i;){const t=1==h.read(1);let y=!1,w=0;if(t?w=U(0,D.length-1,h.readLongTail(0,0)):y=1==h.read(1),t||y){let y,x,k;if(t)y=D[w],D.splice(w,1);else{if(y={},n)1==h.read(1)?y.pitchCount=h.read(3)+2:y.pitchCount=1;else for(y.pitchCount=1;y.pitchCount<4&&1==h.read(1);)y.pitchCount++;y.pinCount=h.readPinCount(),y.initialSize=r?2*h.read(2):i?h.read(d):h.read(m),y.pins=[],y.length=0,y.bendCount=0;for(let e=0;e<y.pinCount;e++){let e={};e.pitchBend=1==h.read(1),e.pitchBend&&y.bendCount++,y.length+=C&&r?h.readLegacyPartDuration()*p.partsPerBeat/p.rhythms[this.rhythm].stepsPerBeat:h.readPartDuration(),e.time=y.length,e.size=r?2*h.read(2):i?h.read(d):h.read(m),y.pins.push(e)}}D.unshift(y),D.length>10&&D.pop(),S.length<=M?(x=new ie(0,b,b+y.length,y.initialSize),S[M++]=x):(x=S[M++],x.start=b,x.end=b+y.length,x.pins[0].size=y.initialSize);let P=0;const q=[];for(let e=0;e<y.pitchCount+y.bendCount;e++){if(1==h.read(1)){const e=U(0,T.length-1,h.read(a));k=T[e],T.splice(e,1)}else{k=I;let e=h.readPitchInterval();for(;e>0;){for(k++;-1!=T.indexOf(k);)k++;e--}for(;e<0;){for(k--;-1!=T.indexOf(k);)k--;e++}}T.unshift(k),T.length>o&&T.pop(),e<y.pitchCount?x.pitches[P++]=k:q.push(k),I=e==y.pitchCount-1?x.pitches[0]:k}x.pitches.length=P,q.unshift(x.pitches[0]),i&&(x.pins[0].size*=F[s.instruments[0]][x.pitches[0]]);let O=1;for(const e of y.pins){e.pitchBend&&q.shift();const t=q[0]-x.pitches[0];if(x.pins.length<=O)x.pins[O++]=se(t,e.time,i?e.size*F[s.instruments[0]][x.pitches[0]]:e.size);else{const n=x.pins[O++];n.interval=t,n.time=e.time,n.size=i?e.size*F[s.instruments[0]][x.pitches[0]]:e.size}}x.pins.length=O,0==x.start&&(x.continuesLastPattern=E&&r||g&&l||v&&c?!(v&&!u&&!f||r)&&e.instruments[s.instruments[0]].legacyTieOver:1==h.read(1)),b=U(0,this.beatsPerBar*p.partsPerBeat,x.end)}else if(i){const e=1==h.read(1),t=h.readPartDuration();e?b-=t:b+=t}else{b+=C&&r?h.readLegacyPartDuration()*p.partsPerBeat/p.rhythms[this.rhythm].stepsPerBeat:h.readPartDuration()}}S.length=M}if(y&&r)break;if(t++,t>=this.getChannelCount())break}if((l&&g||v&&c)&&M>=0)for(let e=0;e<this.channels.length;e++)for(let t=0;t<this.channels[e].instruments.length;t++){const s=this.channels[e].instruments[t];if(A(s.effects)&&(s.reverb=p.reverbRange-1),b==e&&S==t){const t=this.channels[e].bars[0];if(t>0){const s=this.channels[e].patterns[t-1];let i=6;for(const e of s.notes)e.pitches[0]==p.modCount-1-M&&(i=Math.min(i,e.start));i>0&&s.notes.push(new ie(p.modCount-1-M,0,i,B))}else if(this.channels[e].patterns.length<p.barCountMax){const t=new ne;if(this.channels[e].patterns.push(t),this.channels[e].bars[0]=this.channels[e].patterns.length,this.channels[e].patterns.length>this.patternsPerChannel){for(let e=0;e<this.channels.length;e++)this.channels[e].patterns.length<=this.patternsPerChannel&&this.channels[e].patterns.push(new ne);this.patternsPerChannel++}t.instruments.length=1,t.instruments[0]=S,t.notes.length=0,t.notes.push(new ie(p.modCount-1-M,0,6,B))}}}}break;default:throw new Error("Unrecognized song tag code "+String.fromCharCode(G)+" at index "+(s-1)+" "+e.substring(0,s))}p.willReloadForCustomSamples&&(window.location.hash=this.toBase64String(),setTimeout((()=>{location.reload()}),50))}static _(e){try{return Boolean(new URL(e))}catch(e){return!1}}static j(e,t,s,i,n){const a=p.chipWaves[0].samples,o=p.rawRawChipWaves[0].samples,l=t.length;t.push(e);const h=p.chipWaves.length;let c=e,u=44100,f=!1,m=60,d=!1,y=null,v=null,g=null,b=null,S=!1,M=!1,w=e.indexOf("!"),x=-1;if(0===w&&(x=e.indexOf("!",w+1),-1!==x)){const F=e.slice(w+1,x).split(",");for(const P of F){const q=P.charAt(0),I=P.slice(1,P.length);"s"===q?u=$(8e3,96001,j(I,44100)):"r"===q?m=j(I,60):"p"===q?f=!0:"a"===q?(y=_(I,null),null!=y&&(d=!0)):"b"===q?(v=_(I,null),null!=v&&(d=!0)):"c"===q?(g=_(I,null),null!=g&&(d=!0)):"d"===q?(b=_(I,null),null!=b&&(b=$(0,4,b),d=!0)):"e"===q&&(S=!0,d=!0)}c=e.slice(x+1,e.length),M=!0}let k=null;if(!ve._(c))return alert(e+" is not a valid url"),!1;if(k=new URL(c),n&&!M&&null!=k){function T(){c=e.slice(0,e.indexOf(",")),k=new URL(c),u=$(8e3,96001,j(e.slice(e.indexOf(",")+1),44100))}function D(){c=e.slice(0,e.indexOf("!")),k=new URL(c),m=j(e.slice(e.indexOf("!")+1),60)}-1!=e.indexOf("@")&&(c=e.replaceAll("@",""),k=new URL(c),f=!0),-1!=e.indexOf(",")&&-1!=e.indexOf("!")?e.indexOf(",")<e.indexOf("!")?(D(),T()):(T(),D()):(-1!=e.indexOf(",")&&T(),-1!=e.indexOf("!")&&D())}if(null!=k){let O=c;const A=[];let z;44100!==u&&A.push("s"+u),60!==m&&A.push("r"+m),f&&A.push("p"),d&&(null!=y&&A.push("a"+y),null!=v&&A.push("b"+v),null!=g&&A.push("c"+g),null!=b&&A.push("d"+b),S&&A.push("e")),A.length>0&&(O="!"+A.join(",")+"!"+c),t[l]=O,z=decodeURIComponent(k.pathname.replace(/^([^\/]*\/)+/,""));const C=1;p.chipWaves[h]={name:z,expression:C,isCustomSampled:!0,isPercussion:f,rootKey:m,sampleRate:u,samples:a,index:h},p.rawChipWaves[h]={name:z,expression:C,isCustomSampled:!0,isPercussion:f,rootKey:m,sampleRate:u,samples:o,index:h},p.rawRawChipWaves[h]={name:z,expression:C,isCustomSampled:!0,isPercussion:f,rootKey:m,sampleRate:u,samples:o,index:h};const R={type:"chip",eqFilter:[],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"harmony",wave:z,unison:"none",envelopes:[]};d&&(R.isUsingAdvancedLoopControls=!0,R.chipWaveLoopStart=null!=y?y:0,R.chipWaveLoopEnd=null!=v?v:2,R.chipWaveLoopMode=null!=b?b:0,R.chipWavePlayBackwards=S,R.chipWaveStartOffset=null!=g?g:0);const E={index:0,name:z,midiProgram:80,settings:R};if(s.push(E),!p.willReloadForCustomSamples){r(c,h,R,{isUsingAdvancedLoopControls:d,chipWaveLoopStart:y,chipWaveLoopEnd:v,chipWaveLoopMode:b,chipWavePlayBackwards:S,chipWaveStartOffset:g},u)}i.statusTable[h]=0,i.urlTable[h]=c,i.totalSamples++}return!0}static U(){p.chipWaves=S(p.chipWaves.slice(0,p.firstIndexForSamplesInChipWaveList)),p.rawChipWaves=S(p.rawChipWaves.slice(0,p.firstIndexForSamplesInChipWaveList)),p.rawRawChipWaves=S(p.rawRawChipWaves.slice(0,p.firstIndexForSamplesInChipWaveList))}static I(){z.customSamples=null,ve.U(),i.statusTable={},i.urlTable={},i.totalSamples=0,i.samplesLoaded=0,o.dispatchEvent(new n(i.totalSamples,i.samplesLoaded))}toJsonObject(e=!0,t=1,s=!0){const i=[];for(let n=0;n<this.getChannelCount();n++){const a=this.channels[n],o=[],r=this.getChannelIsNoise(n),l=this.getChannelIsMod(n);for(const e of a.instruments)o.push(e.toJsonObject());const h=[];for(const e of a.patterns)h.push(e.toJsonObject(this,a,l));const p=[];if(e)for(let e=0;e<this.loopStart;e++)p.push(a.bars[e]);for(let e=0;e<t;e++)for(let e=this.loopStart;e<this.loopStart+this.loopLength;e++)p.push(a.bars[e]);if(s)for(let e=this.loopStart+this.loopLength;e<this.barCount;e++)p.push(a.bars[e]);const c={type:l?"mod":r?"drum":"pitch",name:a.name,instruments:o,patterns:h,sequence:p};r||(c.octaveScrollBar=a.octave-1),i.push(c)}const n={name:this.title,format:ve.Y,version:ve.P,scale:p.scales[this.scale].name,customScale:this.scaleCustom,key:p.keys[this.key].name,keyOctave:this.octave,introBars:this.loopStart,loopBars:this.loopLength,beatsPerBar:this.beatsPerBar,ticksPerBeat:p.rhythms[this.rhythm].stepsPerBeat,beatsPerMinute:this.tempo,reverb:this.reverb,masterGain:this.masterGain,compressionThreshold:this.compressionThreshold,limitThreshold:this.limitThreshold,limitDecay:this.limitDecay,limitRise:this.limitRise,limitRatio:this.limitRatio,compressionRatio:this.compressionRatio,layeredInstruments:this.layeredInstruments,patternInstruments:this.patternInstruments,channels:i};return null!=z.customSamples&&z.customSamples.length>0&&(n.customSamples=z.customSamples),n}fromJsonObject(e,t="auto"){if(this.initToDefault(!0),!e)return;const s="auto"==t?e.format:t;if(null!=e.name&&(this.title=e.name),null!=e.customSamples){const t=e.customSamples;if(null==z.customSamples||z.customSamples.join(", ")!=t.join(", ")){p.willReloadForCustomSamples=!0,ve.U();let e=!1,s=!1,n=!1;const a=[],o=[];for(const r of t)if("legacysamples"===r.toLowerCase())e||(e=!0,a.push(r),h(0));else if("nintariboxsamples"===r.toLowerCase())s||(s=!0,a.push(r),h(1));else if("mariopaintboxsamples"===r.toLowerCase())n||(n=!0,a.push(r),h(2));else{const e=!1;ve.j(r,a,o,i,e)}if(a.length>0&&(z.customSamples=a),o.length>0){const e=S(o);z.presetCategories[z.presetCategories.length]={name:"Custom Sample Presets",presets:e,index:z.presetCategories.length}}}}else{let t=!1;if(null!=e.channels)for(let s=0;s<e.channels.length;s++){const i=e.channels[s];if("pitch"===i.type&&Array.isArray(i.instruments)){const e=i.instruments;for(let s=0;s<e.length;s++){const i=e[s];if("chip"!==i.type)continue;if(null==i.wave)continue;const n=i.wave,a=["paandorasbox kick","paandorasbox snare","paandorasbox piano1","paandorasbox WOW","paandorasbox overdrive","paandorasbox trumpet","paandorasbox saxophone","paandorasbox orchestrahit","paandorasbox detatched violin","paandorasbox synth","paandorasbox sonic3snare","paandorasbox come on","paandorasbox choir","paandorasbox overdriveguitar","paandorasbox flute","paandorasbox legato violin","paandorasbox tremolo violin","paandorasbox amen break","paandorasbox pizzicato violin","paandorasbox tim allen grunt","paandorasbox tuba","paandorasbox loopingcymbal","paandorasbox standardkick","paandorasbox standardsnare","paandorasbox closedhihat","paandorasbox foothihat","paandorasbox openhihat","paandorasbox crashcymbal","paandorasbox pianoC4","paandorasbox liver pad","paandorasbox marimba","paandorasbox susdotwav","paandorasbox wackyboxtts","paandorasbox peppersteak_1","paandorasbox peppersteak_2","paandorasbox vinyl_noise","paandorasbeta slap bass","paandorasbeta HD EB overdrive guitar","paandorasbeta sunsoft bass","paandorasbeta masculine choir","paandorasbeta feminine choir","paandorasbeta tololoche","paandorasbeta harp","paandorasbeta pan flute","paandorasbeta krumhorn","paandorasbeta timpani","paandorasbeta crowd hey","paandorasbeta wario land 4 brass","paandorasbeta wario land 4 rock organ","paandorasbeta wario land 4 DAOW","paandorasbeta wario land 4 hour chime","paandorasbeta wario land 4 tick","paandorasbeta kirby kick","paandorasbeta kirby snare","paandorasbeta kirby bongo","paandorasbeta kirby click","paandorasbeta sonor kick","paandorasbeta sonor snare","paandorasbeta sonor snare (left hand)","paandorasbeta sonor snare (right hand)","paandorasbeta sonor high tom","paandorasbeta sonor low tom","paandorasbeta sonor hihat (closed)","paandorasbeta sonor hihat (half opened)","paandorasbeta sonor hihat (open)","paandorasbeta sonor hihat (open tip)","paandorasbeta sonor hihat (pedal)","paandorasbeta sonor crash","paandorasbeta sonor crash (tip)","paandorasbeta sonor ride"],o=["pandoraasbox kick","pandoraasbox snare","pandoraasbox piano1","pandoraasbox WOW","pandoraasbox overdrive","pandoraasbox trumpet","pandoraasbox saxophone","pandoraasbox orchestrahit","pandoraasbox detatched violin","pandoraasbox synth","pandoraasbox sonic3snare","pandoraasbox come on","pandoraasbox choir","pandoraasbox overdriveguitar","pandoraasbox flute","pandoraasbox legato violin","pandoraasbox tremolo violin","pandoraasbox amen break","pandoraasbox pizzicato violin","pandoraasbox tim allen grunt","pandoraasbox tuba","pandoraasbox loopingcymbal","pandoraasbox standardkick","pandoraasbox standardsnare","pandoraasbox closedhihat","pandoraasbox foothihat","pandoraasbox openhihat","pandoraasbox crashcymbal","pandoraasbox pianoC4","pandoraasbox liver pad","pandoraasbox marimba","pandoraasbox susdotwav","pandoraasbox wackyboxtts","pandoraasbox peppersteak_1","pandoraasbox peppersteak_2","pandoraasbox vinyl_noise","pandoraasbeta slap bass","pandoraasbeta HD EB overdrive guitar","pandoraasbeta sunsoft bass","pandoraasbeta masculine choir","pandoraasbeta feminine choir","pandoraasbeta tololoche","pandoraasbeta harp","pandoraasbeta pan flute","pandoraasbeta krumhorn","pandoraasbeta timpani","pandoraasbeta crowd hey","pandoraasbeta wario land 4 brass","pandoraasbeta wario land 4 rock organ","pandoraasbeta wario land 4 DAOW","pandoraasbeta wario land 4 hour chime","pandoraasbeta wario land 4 tick","pandoraasbeta kirby kick","pandoraasbeta kirby snare","pandoraasbeta kirby bongo","pandoraasbeta kirby click","pandoraasbeta sonor kick","pandoraasbeta sonor snare","pandoraasbeta sonor snare (left hand)","pandoraasbeta sonor snare (right hand)","pandoraasbeta sonor high tom","pandoraasbeta sonor low tom","pandoraasbeta sonor hihat (closed)","pandoraasbeta sonor hihat (half opened)","pandoraasbeta sonor hihat (open)","pandoraasbeta sonor hihat (open tip)","pandoraasbeta sonor hihat (pedal)","pandoraasbeta sonor crash","pandoraasbeta sonor crash (tip)","pandoraasbeta sonor ride"],r=["kick","snare","piano1","WOW","overdrive","trumpet","saxophone","orchestrahit","detatched violin","synth","sonic3snare","come on","choir","overdriveguitar","flute","legato violin","tremolo violin","amen break","pizzicato violin","tim allen grunt","tuba","loopingcymbal","standardkick","standardsnare","closedhihat","foothihat","openhihat","crashcymbal","pianoC4","liver pad","marimba","susdotwav","wackyboxtts"];a.includes(n)?t=!0:o.includes(n)?(t=!0,i.wave=a[o.findIndex((e=>e===n))]):r.includes(n)&&("trumpet"===n||"flute"===n||(t=!0,i.wave=a[r.findIndex((e=>e===n))]))}}}t?(p.willReloadForCustomSamples=!0,ve.U(),h(0),z.customSamples=["legacySamples"]):null!=z.customSamples&&z.customSamples.length>0&&(p.willReloadForCustomSamples=!0,ve.I())}if(this.scale=0,null!=e.scale){const t={"romani :)":"double harmonic :)","romani :(":"double harmonic :(","dbl harmonic :)":"double harmonic :)","dbl harmonic :(":"double harmonic :(",enigma:"strange"},s=null!=t[e.scale]?t[e.scale]:e.scale,i=p.scales.findIndex((e=>e.name==s));if(-1!=i&&(this.scale=i),this.scale==p.scales.dictionary.Custom.index&&null!=e.customScale)for(var n of e.customScale.keys())this.scaleCustom[n]=e.customScale[n]}if(null!=e.key)if("number"==typeof e.key)this.key=(e.key+1200>>>0)%p.keys.length;else if("string"==typeof e.key){const t=e.key;if("C+"===t)this.key=0,this.octave=1;else if("G- (actually F#-)"===t)this.key=6,this.octave=-1;else if("C-"===t)this.key=0,this.octave=-1;else if("oh no (F-)"===t)this.key=5,this.octave=-1;else{const e=t.charAt(0).toUpperCase(),s=t.charAt(1).toLowerCase();let i={C:0,D:2,E:4,F:5,G:7,A:9,B:11}[e];const n={"#":1,"♯":1,b:-1,"♭":-1}[s];null!=i&&(null!=n&&(i+=n),i<0&&(i+=12),i%=12,this.key=i)}}null!=e.beatsPerMinute&&(this.tempo=$(p.tempoMin,p.tempoMax+1,0|e.beatsPerMinute)),null!=e.keyOctave&&(this.octave=$(p.octaveMin,p.octaveMax+1,0|e.keyOctave));let a=0;null!=e.reverb&&(a=$(0,32,0|e.reverb)),null!=e.beatsPerBar&&(this.beatsPerBar=Math.max(p.beatsPerBarMin,Math.min(p.beatsPerBarMax,0|e.beatsPerBar)));let o=4;null!=e.ticksPerBeat&&(o=0|e.ticksPerBeat||4,this.rhythm=p.rhythms.findIndex((e=>e.stepsPerBeat==o)),-1==this.rhythm&&(this.rhythm=1)),null!=e.masterGain?this.masterGain=Math.max(0,Math.min(5,e.masterGain||0)):this.masterGain=1,null!=e.limitThreshold?this.limitThreshold=Math.max(0,Math.min(2,e.limitThreshold||0)):this.limitThreshold=1,null!=e.compressionThreshold?this.compressionThreshold=Math.max(0,Math.min(1.1,e.compressionThreshold||0)):this.compressionThreshold=1,null!=e.limitRise?this.limitRise=Math.max(2e3,Math.min(1e4,e.limitRise||0)):this.limitRise=4e3,null!=e.limitDecay?this.limitDecay=Math.max(1,Math.min(30,e.limitDecay||0)):this.limitDecay=4,null!=e.limitRatio?this.limitRatio=Math.max(0,Math.min(11,e.limitRatio||0)):this.limitRatio=1,null!=e.compressionRatio?this.compressionRatio=Math.max(0,Math.min(1.168,e.compressionRatio||0)):this.compressionRatio=1;let r=1,l=1,c=1;if(null!=e.channels)for(const t of e.channels)t.instruments&&(r=Math.max(r,0|t.instruments.length)),t.patterns&&(l=Math.max(l,0|t.patterns.length)),t.sequence&&(c=Math.max(c,0|t.sequence.length));null!=e.layeredInstruments?this.layeredInstruments=!!e.layeredInstruments:this.layeredInstruments=!1,null!=e.patternInstruments?this.patternInstruments=!!e.patternInstruments:this.patternInstruments=r>1,this.patternsPerChannel=Math.min(l,p.barCountMax),this.barCount=Math.min(c,p.barCountMax),null!=e.introBars&&(this.loopStart=$(0,this.barCount,0|e.introBars)),null!=e.loopBars&&(this.loopLength=$(1,this.barCount-this.loopStart+1,0|e.loopBars));const u=[],f=[],m=[];if(null!=e.channels)for(let t=0;t<e.channels.length;t++){let i=e.channels[t];const n=new ye;let r=!1,l=!1;if(null!=i.type?(r="drum"==i.type,l="mod"==i.type):r=t>=3,r?f.push(n):l?m.push(n):u.push(n),null!=i.octaveScrollBar&&(n.octave=$(0,p.pitchOctaves,1+(0|i.octaveScrollBar)),r&&(n.octave=0)),null!=i.name?n.name=i.name:n.name="",Array.isArray(i.instruments)){const e=i.instruments;for(let t=0;t<e.length&&!(t>=this.getMaxInstrumentsPerChannel());t++){const i=new de(r,l);n.instruments[t]=i,i.fromJsonObject(e[t],r,l,!1,!1,a,s)}}for(let e=0;e<this.patternsPerChannel;e++){const t=new ne;let s;n.patterns[e]=t,i.patterns&&(s=i.patterns[e]),null!=s&&t.fromJsonObject(s,this,n,o,r,l)}n.patterns.length=this.patternsPerChannel;for(let e=0;e<this.barCount;e++)n.bars[e]=null!=i.sequence?Math.min(this.patternsPerChannel,i.sequence[e]>>>0):0;n.bars.length=this.barCount}u.length>p.pitchChannelCountMax&&(u.length=p.pitchChannelCountMax),f.length>p.noiseChannelCountMax&&(f.length=p.noiseChannelCountMax),m.length>p.modChannelCountMax&&(m.length=p.modChannelCountMax),this.pitchChannelCount=u.length,this.noiseChannelCount=f.length,this.modChannelCount=m.length,this.channels.length=0,Array.prototype.push.apply(this.channels,u),Array.prototype.push.apply(this.channels,f),Array.prototype.push.apply(this.channels,m),p.willReloadForCustomSamples&&(window.location.hash=this.toBase64String(),setTimeout((()=>{location.reload()}),50))}getPattern(e,t){if(t<0||t>=this.barCount)return null;const s=this.channels[e].bars[t];return 0==s?null:this.channels[e].patterns[s-1]}getBeatsPerMinute(){return this.tempo}static getNeededBits(e){return 32-Math.clz32(Math.ceil(e+1)-1)}restoreLimiterDefaults(){this.compressionRatio=1,this.limitRatio=1,this.limitRise=4e3,this.limitDecay=4,this.limitThreshold=1,this.compressionThreshold=1,this.masterGain=1}}ve.Y=p.jsonFormat,ve.O=2,ve.T=9,ve.H=1,ve.R=6,ve.N=1,ve.L=4,ve.V=1,ve.W=5,ve.$=0,ve.P=1,ve.k=85;class ge{constructor(){this.delayLine=null,this.allPassG=0,this.allPassGDelta=0,this.sustainFilterA1=0,this.sustainFilterA1Delta=0,this.sustainFilterA2=0,this.sustainFilterA2Delta=0,this.sustainFilterB0=0,this.sustainFilterB0Delta=0,this.sustainFilterB1=0,this.sustainFilterB1Delta=0,this.sustainFilterB2=0,this.sustainFilterB2Delta=0,this.reset()}reset(){this.delayIndex=-1,this.allPassSample=0,this.allPassPrevInput=0,this.sustainFilterSample=0,this.sustainFilterPrevOutput2=0,this.sustainFilterPrevInput1=0,this.sustainFilterPrevInput2=0,this.fractionalDelaySample=0,this.prevDelayLength=-1,this.delayResetOffset=0}update(e,t,s,i,n,a,o,r){const l=2*Math.PI*p.pickedStringDispersionCenterFreq/e.samplesPerSecond,h=this.prevDelayLength,c=s.phaseDeltas[i],u=s.phaseDeltaScales[i],f=c*Math.pow(u,n),m=2*Math.PI*c,d=2*Math.PI*f,y=2*m,v=2*d,g=Math.min(Math.PI,m*p.pickedStringDispersionFreqMult*Math.pow(l/m,p.pickedStringDispersionFreqScale)),b=Math.min(Math.PI,d*p.pickedStringDispersionFreqMult*Math.pow(l/d,p.pickedStringDispersionFreqScale)),S=2*Math.PI*p.pickedStringShelfHz/e.samplesPerSecond,M=(Math.pow(100,a)-1)/99,w=(Math.pow(100,o)-1)/99,x=1==r?.25:0,k=15.6,F=3*e.samplesPerSecond/48e3,P=Math.pow(.5,M*Math.pow(S/(m*k),1+2*x)*k),q=Math.pow(.5,w*Math.pow(S/(d*k),1+2*x)*k),I=Math.pow(P,.002),T=Math.pow(q,.002);xe.tempFilterStartCoefficients.allPass1stOrderInvertPhaseAbove(g),e.tempFrequencyResponse.analyze(xe.tempFilterStartCoefficients,y);const D=xe.tempFilterStartCoefficients.b[0],O=-e.tempFrequencyResponse.angle()/y;xe.tempFilterEndCoefficients.allPass1stOrderInvertPhaseAbove(b),e.tempFrequencyResponse.analyze(xe.tempFilterEndCoefficients,v);const A=xe.tempFilterEndCoefficients.b[0],z=-e.tempFrequencyResponse.angle()/v,C=0==r?0:1;if(0==C){const e=Math.pow(P,p.stringDecayRate),t=Math.pow(q,p.stringDecayRate);xe.tempFilterStartCoefficients.highShelf2ndOrder(S,e,.5),xe.tempFilterEndCoefficients.highShelf2ndOrder(S,t,.5)}else{const t=Math.pow(1==C?0:1,.25),s=Math.pow(F*F*m*3.3*48e3/e.samplesPerSecond,.5+x)/F/Math.pow(M,.5),i=Math.pow(F*F*d*3.3*48e3/e.samplesPerSecond,.5+x)/F/Math.pow(w,.5),n=s*Math.pow(2,.5-1.75*(1-Math.pow(1-t,.85))),a=i*Math.pow(2,.5-1.75*(1-Math.pow(1-t,.85))),o=Math.pow(2,-Math.pow(2,-Math.pow(t,.9))),r=Math.pow(2,-Math.pow(2,-Math.pow(t,.9)));xe.tempFilterStartCoefficients.lowPass2ndOrderButterworth(B(n),o),xe.tempFilterEndCoefficients.lowPass2ndOrderButterworth(B(a),r)}e.tempFrequencyResponse.analyze(xe.tempFilterStartCoefficients,y);const R=xe.tempFilterStartCoefficients.a[1],E=xe.tempFilterStartCoefficients.a[2],H=xe.tempFilterStartCoefficients.b[0]*I,L=xe.tempFilterStartCoefficients.b[1]*I,N=xe.tempFilterStartCoefficients.b[2]*I,W=-e.tempFrequencyResponse.angle()/y;e.tempFrequencyResponse.analyze(xe.tempFilterEndCoefficients,v);const G=xe.tempFilterEndCoefficients.a[1],V=xe.tempFilterEndCoefficients.a[2],$=xe.tempFilterEndCoefficients.b[0]*T,U=xe.tempFilterEndCoefficients.b[1]*T,j=xe.tempFilterEndCoefficients.b[2]*T,_=-e.tempFrequencyResponse.angle()/v,Y=1/c,K=1/f,J=Math.ceil(2*Math.max(Y,K)),Q=Y-O-W,X=K-z-_;this.prevDelayLength=Q,this.delayLengthDelta=(X-Q)/n,this.allPassG=D,this.sustainFilterA1=R,this.sustainFilterA2=E,this.sustainFilterB0=H,this.sustainFilterB1=L,this.sustainFilterB2=N,this.allPassGDelta=(A-D)/n,this.sustainFilterA1Delta=(G-R)/n,this.sustainFilterA2Delta=(V-E)/n,this.sustainFilterB0Delta=($-H)/n,this.sustainFilterB1Delta=(U-L)/n,this.sustainFilterB2Delta=(j-N)/n;const Z=Math.abs(Math.log2(Q/h))>.01,ee=-1==this.delayIndex||Z;if(null==this.delayLine||this.delayLine.length<=J){const t=Math.ceil(2*e.samplesPerSecond/de.frequencyFromPitch(12)),s=new Float32Array(xe.fittingPowerOfTwo(Math.max(t,J)));if(!ee&&null!=this.delayLine){const e=this.delayLine.length-1>>0,t=this.delayIndex+this.delayResetOffset;this.delayIndex=this.delayLine.length-this.delayResetOffset;for(let i=0;i<this.delayLine.length;i++)s[i]=this.delayLine[t+i&e]}this.delayLine=s}const te=this.delayLine,se=te.length-1>>0;if(ee){this.delayIndex=0,this.allPassSample=0,this.allPassPrevInput=0,this.sustainFilterSample=0,this.sustainFilterPrevOutput2=0,this.sustainFilterPrevInput1=0,this.sustainFilterPrevInput2=0,this.fractionalDelaySample=0;const s=-Q,i=Math.floor(s-Y/2),n=Math.ceil(i+2*Y);this.delayResetOffset=n;for(let e=i;e<=n;e++)te[e&se]=0;const a=t.wave,o=a.length-1,r=o/Y,l=Math.min(.2*Y,.003*e.samplesPerSecond),h=Math.ceil(s),p=s+Y+l,c=p;let u=(h-s)*r,f=0;for(let e=h;e<=c;e++){const t=0|u,i=t%o;let n=a[i];const h=u-t;n+=(a[i+1]-n)*h;const c=(n-f)/r,m=Math.min(1,(e-s)/l)*Math.min(1,(p-e)/l),d=m*m*(3-2*m);te[e&se]+=c*d,f=n,u+=r}}}}class be{constructor(){this.noteSecondsStart=0,this.noteSecondsStartUnscaled=0,this.noteSecondsEnd=0,this.noteSecondsEndUnscaled=0,this.noteTicksStart=0,this.noteTicksEnd=0,this.noteSizeStart=p.noteSizeMax,this.noteSizeEnd=p.noteSizeMax,this.prevNoteSize=p.noteSizeMax,this.nextNoteSize=p.noteSizeMax,this.K=p.noteSizeMax,this.prevNoteSecondsStart=0,this.prevNoteSecondsStartUnscaled=0,this.prevNoteSecondsEnd=0,this.prevNoteSecondsEndUnscaled=0,this.prevNoteTicksStart=0,this.prevNoteTicksEnd=0,this.J=p.noteSizeMax,this.prevSlideStart=!1,this.prevSlideEnd=!1,this.nextSlideStart=!1,this.nextSlideEnd=!1,this.prevSlideRatioStart=0,this.prevSlideRatioEnd=0,this.nextSlideRatioStart=0,this.nextSlideRatioEnd=0,this.envelopeStarts=[],this.envelopeEnds=[],this.X=[],this.Z=0,this.lowpassCutoffDecayVolumeCompensation=1;for(let e=0;e<41;e++)this.envelopeStarts[e]=1,this.envelopeEnds[e]=1;this.reset()}reset(){this.noteSecondsEnd=0,this.noteSecondsEndUnscaled=0,this.noteTicksEnd=0,this.K=p.noteSizeMax,this.prevNoteSecondsEnd=0,this.prevNoteSecondsEndUnscaled=0,this.prevNoteTicksEnd=0,this.J=p.noteSizeMax,this.Z=0}computeEnvelopes(e,t,s,i,n,a,o){const r=n;n*=o;const l=e.getTransition();null==a||!a.atNoteStart||l.continues||a.forceContinueAtStart||(this.prevNoteSecondsEnd=this.noteSecondsEnd,this.prevNoteSecondsEndUnscaled=this.noteSecondsEndUnscaled,this.prevNoteTicksEnd=this.noteTicksEnd,this.J=this.K,this.noteSecondsEnd=0,this.noteSecondsEndUnscaled=0,this.noteTicksEnd=0),null!=a&&(null!=a.note?this.K=a.note.pins[a.note.pins.length-1].size:this.K=p.noteSizeMax);const h=s+o,c=i+1,u=this.noteSecondsEnd,f=this.noteSecondsEndUnscaled,m=u+n,d=f+r,y=this.noteTicksEnd,v=y+1,g=this.prevNoteSecondsEnd,b=this.prevNoteSecondsEndUnscaled,S=g+n,M=b+r,w=this.prevNoteTicksEnd,x=w+1,k=1/(p.ticksPerPart*p.partsPerBeat),F=k*s,P=k*h;let q=this.K,I=this.K,T=this.J,D=0,O=!1,A=!1,z=!1,C=!1,R=0,E=0,H=0,L=0;if(null!=a&&null!=a.note&&!a.passedEndOfNote){const e=a.note.getEndPinIndex(t),s=a.note.pins[e-1],n=a.note.pins[e],o=(a.note.start+s.time)*p.ticksPerPart,r=(a.note.start+n.time)*p.ticksPerPart,h=(i-o)/(r-o),u=(c-o)/(r-o);if(q=s.size+(n.size-s.size)*h,I=s.size+(n.size-s.size)*u,l.slides){const e=a.noteStartPart*p.ticksPerPart,t=a.noteEndPart*p.ticksPerPart,s=.5*(t-e),n=Math.min(s,l.slideTicks);null==a.prevNote||a.forceContinueAtStart||(i-e<n&&(O=!0,R=.5*(1-(i-e)/n)),c-e<n&&(A=!0,E=.5*(1-(c-e)/n))),null==a.nextNote||a.forceContinueAtEnd||(D=a.nextNote.pins[0].size,t-i<n&&(z=!0,H=.5*(1-(t-i)/n)),t-c<n&&(C=!0,L=.5*(1-(t-c)/n)))}}let N=1,W=!1;for(let t=0;t<=e.envelopeCount;t++){let s,i,n;if(t==e.envelopeCount){if(W)break;s=p.instrumentAutomationTargets.dictionary.noteVolume,i=0,n=p.envelopes.dictionary["note size"]}else{let a=e.envelopes[t];s=p.instrumentAutomationTargets[a.target],i=a.index,n=p.envelopes[a.envelope],0==n.type&&(W=!0)}if(null!=s.computeIndex){const t=s.computeIndex+i;let a=be.computeEnvelope(n,u,F,q);if(O){a+=(be.computeEnvelope(n,g,F,T)-a)*R}if(z){a+=(be.computeEnvelope(n,0,F,D)-a)*H}let o=a;if(0==e.discreteEnvelope){if(o=be.computeEnvelope(n,m,P,I),A){o+=(be.computeEnvelope(n,S,P,T)-o)*E}if(C){o+=(be.computeEnvelope(n,0,P,D)-o)*L}}if(this.envelopeStarts[t]*=a,this.envelopeEnds[t]*=o,this.X[this.Z++]=t,s.isFilter){const t=null!=e.tmpNoteFilterStart?e.tmpNoteFilterStart:e.noteFilter;t.controlPointCount>i&&0==t.controlPoints[i].type&&(N=Math.max(N,be.getLowpassCutoffDecayVolumeCompensation(n)))}}}this.noteSecondsStart=u,this.noteSecondsStartUnscaled=f,this.noteSecondsEnd=m,this.noteSecondsEndUnscaled=d,this.noteTicksStart=y,this.noteTicksEnd=v,this.prevNoteSecondsStart=g,this.prevNoteSecondsStartUnscaled=b,this.prevNoteSecondsEnd=S,this.prevNoteSecondsEndUnscaled=M,this.prevNoteTicksStart=w,this.prevNoteTicksEnd=x,this.prevNoteSize=T,this.nextNoteSize=D,this.noteSizeStart=q,this.noteSizeEnd=I,this.prevSlideStart=O,this.prevSlideEnd=A,this.nextSlideStart=z,this.nextSlideEnd=C,this.prevSlideRatioStart=R,this.prevSlideRatioEnd=E,this.nextSlideRatioStart=H,this.nextSlideRatioEnd=L,this.lowpassCutoffDecayVolumeCompensation=N}clearEnvelopes(){for(let e=0;e<this.Z;e++){const t=this.X[e];this.envelopeStarts[t]=1,this.envelopeEnds[t]=1}this.Z=0}static computeEnvelope(e,t,s,i){switch(e.type){case 0:return xe.noteSizeToVolumeMult(i);case 1:return 1;case 4:return 1/(1+t*e.speed);case 5:return 1-1/(1+t*e.speed);case 6:return.5-.5*Math.cos(2*s*Math.PI*e.speed);case 7:return.75-.25*Math.cos(2*s*Math.PI*e.speed);case 2:return Math.max(1,2-10*t);case 3:const n=.25/Math.sqrt(e.speed);return t<n?t/n:1/(1+(t-n)*e.speed);case 8:return Math.pow(2,-e.speed*t);case 13:return 1*+(t<.25/Math.sqrt(e.speed));case 9:let a=.5-.5*Math.cos(s*e.speed);return a=1/(1+t*(e.speed-a/(1.5/e.speed))),a=a>0?a:0,a;case 11:{let s=1-t/(16/e.speed);return s=s>0?s:0,s}case 12:{let s=t/(16/e.speed);return s=s<1?s:1,s}default:throw new Error("Unrecognized operator envelope type.")}}static getLowpassCutoffDecayVolumeCompensation(e){return 8==e.type?1.25+.025*e.speed:4==e.type?1+.02*e.speed:1}}class Se{constructor(){this.pitches=Array(p.maxChordSize+2).fill(0),this.pitchCount=0,this.chordSize=0,this.drumsetPitch=null,this.note=null,this.prevNote=null,this.nextNote=null,this.prevNotePitchIndex=0,this.nextNotePitchIndex=0,this.freshlyAllocated=!0,this.atNoteStart=!1,this.isOnLastTick=!1,this.passedEndOfNote=!1,this.forceContinueAtStart=!1,this.forceContinueAtEnd=!1,this.noteStartPart=0,this.noteEndPart=0,this.ticksSinceReleased=0,this.liveInputSamplesHeld=0,this.lastInterval=0,this.noiseSample=0,this.noiseSampleA=0,this.noiseSampleB=0,this.stringSustainStart=0,this.stringSustainEnd=0,this.phases=[],this.operatorWaves=[],this.phaseDeltas=[],this.directions=[],this.chipWaveCompletions=[],this.chipWavePrevWaves=[],this.chipWaveCompletionsLastWave=[],this.phaseDeltaScales=[],this.expression=0,this.expressionDelta=0,this.operatorExpressions=[],this.operatorExpressionDeltas=[],this.prevPitchExpressions=Array(p.maxPitchOrOperatorCount).fill(null),this.prevVibrato=null,this.prevStringDecay=null,this.pulseWidth=0,this.pulseWidthDelta=0,this.decimalOffset=0,this.supersawDynamism=0,this.supersawDynamismDelta=0,this.supersawUnisonDetunes=[],this.supersawShape=0,this.supersawShapeDelta=0,this.supersawDelayLength=0,this.supersawDelayLengthDelta=0,this.supersawDelayLine=null,this.supersawDelayIndex=-1,this.supersawPrevPhaseDelta=null,this.pickedStrings=[],this.noteFilters=[],this.noteFilterCount=0,this.initialNoteFilterInput1=0,this.initialNoteFilterInput2=0,this.specialIntervalExpressionMult=1,this.feedbackOutputs=[],this.feedbackMult=0,this.feedbackDelta=0,this.stereoVolumeLStart=0,this.stereoVolumeRStart=0,this.stereoVolumeLDelta=0,this.stereoVolumeRDelta=0,this.stereoDelayStart=0,this.stereoDelayEnd=0,this.stereoDelayDelta=0,this.customVolumeStart=0,this.customVolumeEnd=0,this.filterResonanceStart=0,this.filterResonanceDelta=0,this.isFirstOrder=!1,this.envelopeComputer=new be,this.reset()}reset(){this.noiseSample=0,this.noiseSampleA=0,this.noiseSampleB=0;for(let e=0;e<p.maxPitchOrOperatorCount;e++)this.phases[e]=0,this.directions[e]=1,this.chipWaveCompletions[e]=0,this.chipWavePrevWaves[e]=0,this.chipWaveCompletionsLastWave[e]=0,this.operatorWaves[e]=p.operatorWaves[0],this.feedbackOutputs[e]=0,this.prevPitchExpressions[e]=null;for(let e=0;e<this.noteFilterCount;e++)this.noteFilters[e].resetOutput();this.noteFilterCount=0,this.initialNoteFilterInput1=0,this.initialNoteFilterInput2=0,this.liveInputSamplesHeld=0,this.supersawDelayIndex=-1;for(const e of this.pickedStrings)e.reset();this.envelopeComputer.reset(),this.prevVibrato=null,this.prevStringDecay=null,this.supersawPrevPhaseDelta=null,this.drumsetPitch=null}}class Me{constructor(){this.awake=!1,this.computed=!1,this.tonesAddedInThisTick=!1,this.flushingDelayLines=!1,this.deactivateAfterThisTick=!1,this.attentuationProgress=0,this.flushedSamples=0,this.activeTones=new H,this.activeModTones=new H,this.releasedTones=new H,this.liveInputTones=new H,this.type=0,this.synthesizer=null,this.wave=null,this.isUsingAdvancedLoopControls=!1,this.chipWaveLoopStart=0,this.chipWaveLoopEnd=0,this.chipWaveLoopMode=0,this.chipWavePlayBackwards=!1,this.chipWaveStartOffset=0,this.noisePitchFilterMult=1,this.unison=null,this.unisonVoices=1,this.unisonSpread=0,this.unisonOffset=0,this.unisonExpression=1.4,this.unisonSign=1,this.chord=null,this.effects=0,this.volumeScale=0,this.aliases=!1,this.arpTime=0,this.vibratoTime=0,this.nextVibratoTime=0,this.envelopeTime=0,this.dutyCycleTime=0,this.eqFilterVolume=1,this.eqFilterVolumeDelta=0,this.mixVolume=1,this.mixVolumeDelta=0,this.delayInputMult=0,this.delayInputMultDelta=0,this.distortion=0,this.distortionDelta=0,this.distortionDrive=0,this.distortionDriveDelta=0,this.distortionFractionalInput1=0,this.distortionFractionalInput2=0,this.distortionFractionalInput3=0,this.distortionPrevInput=0,this.distortionNextOutput=0,this.bitcrusherPrevInput=0,this.bitcrusherCurrentOutput=0,this.bitcrusherPhase=1,this.bitcrusherPhaseDelta=0,this.bitcrusherPhaseDeltaScale=1,this.bitcrusherScale=1,this.bitcrusherScaleScale=1,this.bitcrusherFoldLevel=1,this.bitcrusherFoldLevelScale=1,this.eqFilters=[],this.eqFilterCount=0,this.initialEqFilterInput1=0,this.initialEqFilterInput2=0,this.panningDelayLine=null,this.panningDelayPos=0,this.panningVolumeL=0,this.panningVolumeR=0,this.panningVolumeDeltaL=0,this.panningVolumeDeltaR=0,this.panningOffsetL=0,this.panningOffsetR=0,this.panningOffsetDeltaL=0,this.panningOffsetDeltaR=0,this.chorusDelayLineL=null,this.chorusDelayLineR=null,this.chorusDelayLineDirty=!1,this.chorusDelayPos=0,this.chorusPhase=0,this.chorusVoiceMult=0,this.chorusVoiceMultDelta=0,this.chorusCombinedMult=0,this.chorusCombinedMultDelta=0,this.echoDelayLineL=null,this.echoDelayLineR=null,this.echoDelayLineDirty=!1,this.echoDelayPos=0,this.echoDelayOffsetStart=0,this.echoDelayOffsetEnd=null,this.echoDelayOffsetRatio=0,this.echoDelayOffsetRatioDelta=0,this.echoMult=0,this.echoMultDelta=0,this.echoShelfA1=0,this.echoShelfB0=0,this.echoShelfB1=0,this.echoShelfSampleL=0,this.echoShelfSampleR=0,this.echoShelfPrevInputL=0,this.echoShelfPrevInputR=0,this.reverbDelayLine=null,this.reverbDelayLineDirty=!1,this.reverbDelayPos=0,this.reverbMult=0,this.reverbMultDelta=0,this.reverbShelfA1=0,this.reverbShelfB0=0,this.reverbShelfB1=0,this.reverbShelfSample0=0,this.reverbShelfSample1=0,this.reverbShelfSample2=0,this.reverbShelfSample3=0,this.reverbShelfPrevInput0=0,this.reverbShelfPrevInput1=0,this.reverbShelfPrevInput2=0,this.reverbShelfPrevInput3=0,this.spectrumWave=new he,this.harmonicsWave=new ce,this.drumsetSpectrumWaves=[];for(let e=0;e<p.drumCount;e++)this.drumsetSpectrumWaves[e]=new he}allocateNecessaryBuffers(e,t,s){if(T(t.effects)&&(null==this.panningDelayLine||this.panningDelayLine.length<e.panningDelayBufferSize)&&(this.panningDelayLine=new Float32Array(e.panningDelayBufferSize)),D(t.effects)&&((null==this.chorusDelayLineL||this.chorusDelayLineL.length<e.chorusDelayBufferSize)&&(this.chorusDelayLineL=new Float32Array(e.chorusDelayBufferSize)),(null==this.chorusDelayLineR||this.chorusDelayLineR.length<e.chorusDelayBufferSize)&&(this.chorusDelayLineR=new Float32Array(e.chorusDelayBufferSize))),O(t.effects)){const e=Math.max(p.echoDelayRange>>1,t.echoDelay+1),i=2*xe.fittingPowerOfTwo(e*p.echoDelayStepTicks*s);if(null==this.echoDelayLineL||null==this.echoDelayLineR)this.echoDelayLineL=new Float32Array(i),this.echoDelayLineR=new Float32Array(i);else if(this.echoDelayLineL.length<i||this.echoDelayLineR.length<i){const e=new Float32Array(i),t=new Float32Array(i),s=this.echoDelayLineL.length-1;for(let i=0;i<this.echoDelayLineL.length;i++)e[i]=this.echoDelayLineL[this.echoDelayPos+i&s],t[i]=this.echoDelayLineL[this.echoDelayPos+i&s];this.echoDelayPos=this.echoDelayLineL.length,this.echoDelayLineL=e,this.echoDelayLineR=t}}A(t.effects)&&null==this.reverbDelayLine&&(this.reverbDelayLine=new Float32Array(p.reverbDelayBufferSize))}deactivate(){this.bitcrusherPrevInput=0,this.bitcrusherCurrentOutput=0,this.bitcrusherPhase=1;for(let e=0;e<this.eqFilterCount;e++)this.eqFilters[e].resetOutput();if(this.eqFilterCount=0,this.initialEqFilterInput1=0,this.initialEqFilterInput2=0,this.distortionFractionalInput1=0,this.distortionFractionalInput2=0,this.distortionFractionalInput3=0,this.distortionPrevInput=0,this.distortionNextOutput=0,this.panningDelayPos=0,null!=this.panningDelayLine)for(let e=0;e<this.panningDelayLine.length;e++)this.panningDelayLine[e]=0;this.echoDelayOffsetEnd=null,this.echoShelfSampleL=0,this.echoShelfSampleR=0,this.echoShelfPrevInputL=0,this.echoShelfPrevInputR=0,this.reverbShelfSample0=0,this.reverbShelfSample1=0,this.reverbShelfSample2=0,this.reverbShelfSample3=0,this.reverbShelfPrevInput0=0,this.reverbShelfPrevInput1=0,this.reverbShelfPrevInput2=0,this.reverbShelfPrevInput3=0,this.volumeScale=1,this.aliases=!1,this.awake=!1,this.flushingDelayLines=!1,this.deactivateAfterThisTick=!1,this.attentuationProgress=0,this.flushedSamples=0}resetAllEffects(){if(this.deactivate(),this.vibratoTime=0,this.nextVibratoTime=0,this.arpTime=0,this.envelopeTime=0,this.chorusDelayLineDirty){for(let e=0;e<this.chorusDelayLineL.length;e++)this.chorusDelayLineL[e]=0;for(let e=0;e<this.chorusDelayLineR.length;e++)this.chorusDelayLineR[e]=0}if(this.echoDelayLineDirty){for(let e=0;e<this.echoDelayLineL.length;e++)this.echoDelayLineL[e]=0;for(let e=0;e<this.echoDelayLineR.length;e++)this.echoDelayLineR[e]=0}if(this.reverbDelayLineDirty)for(let e=0;e<this.reverbDelayLine.length;e++)this.reverbDelayLine[e]=0;this.chorusPhase=0}compute(e,t,s,i,n,a,o){this.computed=!0,this.type=t.type,this.synthesizer=xe.getInstrumentSynthFunction(t),this.unison=p.unisons[t.unison],this.chord=t.getChord(),this.noisePitchFilterMult=p.chipNoises[t.chipNoise].pitchFilterMult,this.effects=t.effects,this.aliases=t.aliases,this.volumeScale=1,this.allocateNecessaryBuffers(e,t,s);const r=e.samplesPerSecond;this.updateWaves(t,r);const l=q(this.effects),h=I(this.effects),c=T(this.effects),u=D(this.effects),f=O(this.effects),m=A(this.effects);if(l){let s=t.distortion,n=t.distortion;e.isModActive(p.modulators.dictionary.distortion.index,a,o)&&(s=e.getModValue(p.modulators.dictionary.distortion.index,a,o,!1),n=e.getModValue(p.modulators.dictionary.distortion.index,a,o,!0));const r=Math.min(1,s/(p.distortionRange-1)),l=Math.min(1,n/(p.distortionRange-1)),h=Math.pow(1-.895*(Math.pow(20,r)-1)/19,2),c=Math.pow(1-.895*(Math.pow(20,l)-1)/19,2),u=(1+2*r)/p.distortionBaseVolume,f=(1+2*l)/p.distortionBaseVolume;this.distortion=h,this.distortionDelta=(c-h)/i,this.distortionDrive=u,this.distortionDriveDelta=(f-u)/i}if(h){let s=t.bitcrusherFreq,n=t.bitcrusherFreq;e.isModActive(p.modulators.dictionary["freq crush"].index,a,o)&&(s=e.getModValue(p.modulators.dictionary["freq crush"].index,a,o,!1),n=e.getModValue(p.modulators.dictionary["freq crush"].index,a,o,!0));let l=t.bitcrusherQuantization,h=t.bitcrusherQuantization;e.isModActive(p.modulators.dictionary["bit crush"].index,a,o)&&(l=e.getModValue(p.modulators.dictionary["bit crush"].index,a,o,!1),h=e.getModValue(p.modulators.dictionary["bit crush"].index,a,o,!0));const c=p.keys[e.song.key].basePitch+p.pitchesPerOctave*e.song.octave,u=de.frequencyFromPitch(c+60)*Math.pow(2,(p.bitcrusherFreqRange-1-s)*p.bitcrusherOctaveStep),f=de.frequencyFromPitch(c+60)*Math.pow(2,(p.bitcrusherFreqRange-1-n)*p.bitcrusherOctaveStep),m=Math.min(1,u/r),d=Math.min(1,f/r);this.bitcrusherPhaseDelta=m,this.bitcrusherPhaseDeltaScale=Math.pow(d/m,1/i);const y=2*p.bitcrusherBaseVolume*Math.pow(2,1-Math.pow(2,.5*(p.bitcrusherQuantizationRange-1-l))),v=2*p.bitcrusherBaseVolume*Math.pow(2,1-Math.pow(2,.5*(p.bitcrusherQuantizationRange-1-h)));this.bitcrusherScale=y,this.bitcrusherScaleScale=Math.pow(v/y,1/i);const g=2*p.bitcrusherBaseVolume*Math.pow(1.5,p.bitcrusherQuantizationRange-1-l),b=2*p.bitcrusherBaseVolume*Math.pow(1.5,p.bitcrusherQuantizationRange-1-h);this.bitcrusherFoldLevel=g,this.bitcrusherFoldLevelScale=Math.pow(b/g,1/i)}let d=1;if(t.eqFilterType){const s=t.eqFilter;null==t.eqSubFilters[1]&&(t.eqSubFilters[1]=new fe);const n=t.eqSubFilters[1];let l,h=t.eqFilterSimpleCut,c=t.eqFilterSimplePeak,u=t.eqFilterSimpleCut,f=t.eqFilterSimplePeak,m=!1;if(e.isModActive(p.modulators.dictionary["eq filt cut"].index,a,o)&&(h=e.getModValue(p.modulators.dictionary["eq filt cut"].index,a,o,!1),u=e.getModValue(p.modulators.dictionary["eq filt cut"].index,a,o,!0),m=!0),e.isModActive(p.modulators.dictionary["eq filt peak"].index,a,o)&&(c=e.getModValue(p.modulators.dictionary["eq filt peak"].index,a,o,!1),f=e.getModValue(p.modulators.dictionary["eq filt peak"].index,a,o,!0),m=!0),m){s.convertLegacySettingsForSynth(h,c),n.convertLegacySettingsForSynth(u,f),l=s.controlPoints[0];let e=n.controlPoints[0];l.toCoefficients(xe.tempFilterStartCoefficients,r,1,1),e.toCoefficients(xe.tempFilterEndCoefficients,r,1,1),this.eqFilters.length<1&&(this.eqFilters[0]=new G),this.eqFilters[0].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterEndCoefficients,1/i,0==l.type)}else s.convertLegacySettingsForSynth(h,c,!0),l=s.controlPoints[0],l.toCoefficients(xe.tempFilterStartCoefficients,r,1,1),this.eqFilters.length<1&&(this.eqFilters[0]=new G),this.eqFilters[0].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterStartCoefficients,1/i,0==l.type);d*=l.getVolumeCompensationMult(),this.eqFilterCount=1,d=Math.min(3,d)}else{const e=null!=t.tmpEqFilterStart?t.tmpEqFilterStart:t.eqFilter;for(let s=0;s<e.controlPointCount;s++){let n=e.controlPoints[s],a=null!=t.tmpEqFilterEnd&&null!=t.tmpEqFilterEnd.controlPoints[s]?t.tmpEqFilterEnd.controlPoints[s]:e.controlPoints[s];n.type!=a.type&&(n=a),n.toCoefficients(xe.tempFilterStartCoefficients,r,1,1),a.toCoefficients(xe.tempFilterEndCoefficients,r,1,1),this.eqFilters.length<=s&&(this.eqFilters[s]=new G),this.eqFilters[s].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterEndCoefficients,1/i,0==n.type),d*=n.getVolumeCompensationMult()}this.eqFilterCount=e.controlPointCount,d=Math.min(3,d)}const y=xe.instrumentVolumeToVolumeMult(t.volume);this.mixVolume=y;let v=y;if(e.isModActive(p.modulators.dictionary["mix volume"].index,a,o)){const t=e.getModValue(p.modulators.dictionary["mix volume"].index,a,o,!1),s=e.getModValue(p.modulators.dictionary["mix volume"].index,a,o,!0);this.mixVolume*=t<=0?(t+p.volumeRange/2)/(p.volumeRange/2):xe.instrumentVolumeToVolumeMult(t),v*=s<=0?(s+p.volumeRange/2)/(p.volumeRange/2):xe.instrumentVolumeToVolumeMult(s)}e.isModActive(p.modulators.dictionary["song volume"].index)&&(this.mixVolume*=e.getModValue(p.modulators.dictionary["song volume"].index,void 0,void 0,!1)/100,v*=e.getModValue(p.modulators.dictionary["song volume"].index,void 0,void 0,!0)/100),this.mixVolumeDelta=(v-this.mixVolume)/i;let g=d,b=d,S=1,M=1;if(c){let s=t.pan,n=t.pan;e.isModActive(p.modulators.dictionary.pan.index,a,o)&&(s=e.getModValue(p.modulators.dictionary.pan.index,a,o,!1),n=e.getModValue(p.modulators.dictionary.pan.index,a,o,!0));let l=Math.max(-1,Math.min(1,(s-p.panCenter)/p.panCenter)),h=Math.max(-1,Math.min(1,(n-p.panCenter)/p.panCenter));const c=1.414*Math.cos((1+l)*Math.PI*.25),u=1.414*Math.cos((1-l)*Math.PI*.25),f=1.414*Math.cos((1+h)*Math.PI*.25),m=1.414*Math.cos((1-h)*Math.PI*.25),d=r*p.panDelaySecondsMax;let y=t.panDelay,v=t.panDelay;e.isModActive(p.modulators.dictionary["pan delay"].index,a,o)&&(y=e.getModValue(p.modulators.dictionary["pan delay"].index,a,o,!1),v=e.getModValue(p.modulators.dictionary["pan delay"].index,a,o,!0));const g=l*y*d/10,b=h*v*d/10,S=Math.max(0,g),M=Math.max(0,-g),w=Math.max(0,b),x=Math.max(0,-b);this.panningVolumeL=c,this.panningVolumeR=u,this.panningVolumeDeltaL=(f-c)/i,this.panningVolumeDeltaR=(m-u)/i,this.panningOffsetL=this.panningDelayPos-S+e.panningDelayBufferSize,this.panningOffsetR=this.panningDelayPos-M+e.panningDelayBufferSize,this.panningOffsetDeltaL=(w-S)/i,this.panningOffsetDeltaR=(x-M)/i}if(u){let s=t.chorus,n=t.chorus;e.isModActive(p.modulators.dictionary.chorus.index,a,o)&&(s=e.getModValue(p.modulators.dictionary.chorus.index,a,o,!1),n=e.getModValue(p.modulators.dictionary.chorus.index,a,o,!0));let r=Math.min(1,s/(p.chorusRange-1)),l=Math.min(1,n/(p.chorusRange-1));r=.6*r+.4*Math.pow(r,6),l=.6*l+.4*Math.pow(l,6);const h=1/Math.sqrt(3*r*r+1),c=1/Math.sqrt(3*l*l+1);this.chorusVoiceMult=r,this.chorusVoiceMultDelta=(l-r)/i,this.chorusCombinedMult=h,this.chorusCombinedMultDelta=(c-h)/i}let w=0,x=0;if(f){let n=t.echoSustain,l=t.echoSustain;e.isModActive(p.modulators.dictionary.echo.index,a,o)&&(n=Math.max(0,e.getModValue(p.modulators.dictionary.echo.index,a,o,!1)),l=Math.max(0,e.getModValue(p.modulators.dictionary.echo.index,a,o,!0)));const h=.9*Math.min(1,Math.pow(n/p.echoSustainRange,1.1)),c=.9*Math.min(1,Math.pow(l/p.echoSustainRange,1.1));this.echoMult=h,this.echoMultDelta=Math.max(0,(c-h)/i),w=Math.max(h,c);let u=t.echoDelay,f=t.echoDelay,m=!1;e.isModActive(p.modulators.dictionary["echo delay"].index,a,o)&&(u=e.getModValue(p.modulators.dictionary["echo delay"].index,a,o,!1),f=e.getModValue(p.modulators.dictionary["echo delay"].index,a,o,!0),m=!0);const d=Math.round((u+1)*p.echoDelayStepTicks*s),y=Math.round((f+1)*p.echoDelayStepTicks*s);null==this.echoDelayOffsetEnd||m?this.echoDelayOffsetStart=d:this.echoDelayOffsetStart=this.echoDelayOffsetEnd,this.echoDelayOffsetEnd=y,x=.5*(this.echoDelayOffsetStart+this.echoDelayOffsetEnd)/r,this.echoDelayOffsetRatio=0,this.echoDelayOffsetRatioDelta=1/i;const v=2*Math.PI*p.echoShelfHz/e.samplesPerSecond;xe.tempFilterStartCoefficients.highShelf1stOrder(v,p.echoShelfGain),this.echoShelfA1=xe.tempFilterStartCoefficients.a[1],this.echoShelfB0=xe.tempFilterStartCoefficients.b[0],this.echoShelfB1=xe.tempFilterStartCoefficients.b[1]}let k=0;if(m){let s=t.reverb,n=t.reverb;e.isModActive(p.modulators.dictionary.reverb.index,a,o)&&(s=e.getModValue(p.modulators.dictionary.reverb.index,a,o,!1),n=e.getModValue(p.modulators.dictionary.reverb.index,a,o,!0)),e.isModActive(p.modulators.dictionary["song reverb"].index,a,o)&&(s*=(e.getModValue(p.modulators.dictionary["song reverb"].index,void 0,void 0,!1)-p.modulators.dictionary["song reverb"].convertRealFactor)/p.reverbRange,n*=(e.getModValue(p.modulators.dictionary["song reverb"].index,void 0,void 0,!0)-p.modulators.dictionary["song reverb"].convertRealFactor)/p.reverbRange);const r=.425*Math.min(1,Math.pow(s/p.reverbRange,.667)),l=.425*Math.min(1,Math.pow(n/p.reverbRange,.667));this.reverbMult=r,this.reverbMultDelta=(l-r)/i,k=Math.max(r,l);const h=2*Math.PI*p.reverbShelfHz/e.samplesPerSecond;xe.tempFilterStartCoefficients.highShelf1stOrder(h,p.reverbShelfGain),this.reverbShelfA1=xe.tempFilterStartCoefficients.a[1],this.reverbShelfB0=xe.tempFilterStartCoefficients.b[0],this.reverbShelfB1=xe.tempFilterStartCoefficients.b[1]}if(this.tonesAddedInThisTick)this.attentuationProgress=0,this.flushedSamples=0,this.flushingDelayLines=!1;else if(this.flushingDelayLines){g=0,b=0,S=0,M=0;let t=0;u&&(t+=e.chorusDelayBufferSize),f&&(t+=this.echoDelayLineL.length),m&&(t+=p.reverbDelayBufferSize),this.flushedSamples+=i,this.flushedSamples>=t&&(this.deactivateAfterThisTick=!0)}else{0==this.attentuationProgress||(g=0),b=0;const e=1/256,t=-Math.log2(e);let i=0;if(u&&(i+=p.chorusMaxDelay),f){const e=Math.pow(w,1/x);i+=-1/Math.log2(e)*t}if(m){const e=2*k,s=p.reverbDelayBufferSize/4/r,n=Math.pow(e,1/s);i+=-1/Math.log2(n)*t}const n=s/r/i,a=this.attentuationProgress+n;a>=1&&(M=0),this.attentuationProgress=a,this.attentuationProgress>=1&&(this.flushingDelayLines=!0)}this.eqFilterVolume=g,this.eqFilterVolumeDelta=(b-g)/i,this.delayInputMult=S,this.delayInputMultDelta=(M-S)/i}updateWaves(e,t){if(this.volumeScale=1,0==e.type)this.wave=this.aliases?p.rawChipWaves[e.chipWave].samples:p.chipWaves[e.chipWave].samples,this.isUsingAdvancedLoopControls=e.isUsingAdvancedLoopControls,this.chipWaveLoopStart=e.chipWaveLoopStart,this.chipWaveLoopEnd=e.chipWaveLoopEnd,this.chipWaveLoopMode=e.chipWaveLoopMode,this.chipWavePlayBackwards=e.chipWavePlayBackwards,this.chipWaveStartOffset=e.chipWaveStartOffset,this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(6==e.type)this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(7==e.type)this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(10==e.type)this.wave=this.aliases?e.customChipWave:e.customChipWaveIntegral,this.volumeScale=.05,this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(2==e.type)this.wave=d(e.chipNoise,E,C),this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(5==e.type)this.wave=this.harmonicsWave.getCustomWave(e.harmonicsWave,e.type),this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(8==e.type)this.wave=this.harmonicsWave.getCustomWave(e.harmonicsWave,e.type),this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(3==e.type)this.wave=this.spectrumWave.getCustomWave(e.spectrumWave,8),this.unisonVoices=e.unisonVoices,this.unisonSpread=e.unisonSpread,this.unisonOffset=e.unisonOffset,this.unisonExpression=e.unisonExpression,this.unisonSign=e.unisonSign;else if(4==e.type){for(let t=0;t<p.drumCount;t++)this.drumsetSpectrumWaves[t].getCustomWave(e.drumsetSpectrumWaves[t],Me.ee(t));this.wave=null}else this.wave=null}getDrumsetWave(e){if(4==this.type)return this.drumsetSpectrumWaves[e].wave;throw new Error("Unhandled instrument type in getDrumsetWave")}static drumsetIndexReferenceDelta(e){return de.frequencyFromPitch(p.spectrumBasePitch+6*e)/44100}static ee(e){return 15+Math.log2(Me.drumsetIndexReferenceDelta(e))}}class we{constructor(){this.instruments=[],this.muted=!1,this.singleSeamlessInstrument=null}}class xe{syncSongState(){const e=this.song.getChannelCount();for(let t=this.channels.length;t<e;t++)this.channels[t]=new we;this.channels.length=e;for(let t=0;t<e;t++){const e=this.song.channels[t],s=this.channels[t];for(let t=s.instruments.length;t<e.instruments.length;t++)s.instruments[t]=new Me;if(s.instruments.length=e.instruments.length,s.muted!=e.muted&&(s.muted=e.muted,s.muted))for(const e of s.instruments)e.resetAllEffects()}}initModFilters(e){if(null!=e)for(let t=0;t<e.getChannelCount();t++)for(let s=0;s<e.channels[t].instruments.length;s++){const i=e.channels[t].instruments[s];i.tmpEqFilterStart=i.eqFilter,i.tmpEqFilterEnd=null,i.tmpNoteFilterStart=i.noteFilter,i.tmpNoteFilterEnd=null}}warmUpSynthesizer(e){if(null!=e){this.syncSongState();const t=this.getSamplesPerTick();for(let s=0;s<e.getChannelCount();s++)for(let i=0;i<e.channels[s].instruments.length;i++){const n=e.channels[s].instruments[i],a=this.channels[s].instruments[i];xe.getInstrumentSynthFunction(n),a.vibratoTime=0,a.nextVibratoTime=0,a.envelopeTime=0,a.arpTime=0,a.updateWaves(n,this.samplesPerSecond),a.allocateNecessaryBuffers(this,n,t)}}var t=new Float32Array(1);this.isPlayingSong=!0,this.synthesize(t,t,1,!0),this.isPlayingSong=!1}computeLatestModValues(){if(null!=this.song&&this.song.modChannelCount>0){let e=[],t=[];this.modValues=[],this.nextModValues=[],this.modInsValues=[],this.nextModInsValues=[],this.heldMods=[];for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++){t[e]=[],this.modInsValues[e]=[],this.nextModInsValues[e]=[];for(let s=0;s<this.song.channels[e].instruments.length;s++)this.modInsValues[e][s]=[],this.nextModInsValues[e][s]=[],t[e][s]=[]}let s=this.beat*p.partsPerBeat+this.part;for(let i=this.song.pitchChannelCount+this.song.noiseChannelCount;i<this.song.getChannelCount();i++)if(!this.song.channels[i].muted){let n;for(let a=this.bar;a>=0;a--)if(n=this.song.getPattern(i,a),null!=n){let o=n.instruments[0],r=this.song.channels[i].instruments[o],l=[],h=[],c=a==this.bar?s:this.findPartsInBar(a);for(const e of n.notes)if(e.start<=c&&(null==l[p.modCount-1-e.pitches[0]]||e.end>l[p.modCount-1-e.pitches[0]]))if(e.start==c&&(l[p.modCount-1-e.pitches[0]]=e.start,h[p.modCount-1-e.pitches[0]]=e.pins[0].size),e.end<=c)l[p.modCount-1-e.pitches[0]]=e.end,h[p.modCount-1-e.pitches[0]]=e.pins[e.pins.length-1].size;else{l[p.modCount-1-e.pitches[0]]=c;for(let t=0;t<e.pins.length;t++)if(e.pins[t].time+e.start>c){const s=e.pins[t].time-e.pins[t-1].time,i=c-e.start-e.pins[t-1].time,n=e.pins[t].size-e.pins[t-1].size;h[p.modCount-1-e.pitches[0]]=Math.round(e.pins[t-1].size+n*i/s),t=e.pins.length}}for(let s=0;s<p.modCount;s++)if(null!=l[s])if(p.modulators[r.modulators[s]].forSong)(null==e[r.modulators[s]]||a*p.partsPerBeat*this.song.beatsPerBar+l[s]>e[r.modulators[s]])&&(this.setModValue(h[s],h[s],r.modChannels[s],r.modInstruments[s],r.modulators[s]),e[r.modulators[s]]=a*p.partsPerBeat*this.song.beatsPerBar+l[s]);else{let e=[];if(r.modInstruments[s]==this.song.channels[r.modChannels[s]].instruments.length)for(let t=0;t<this.song.channels[r.modChannels[s]].instruments.length;t++)e.push(t);else if(r.modInstruments[s]>this.song.channels[r.modChannels[s]].instruments.length){const t=this.song.getPattern(r.modChannels[s],a);null!=t&&(e=t.instruments)}else e.push(r.modInstruments[s]);for(let i=0;i<e.length;i++){const n=r.modulators[s]==p.modulators.dictionary["eq filter"].index,o=r.modulators[s]==p.modulators.dictionary["note filter"].index;let c=r.modulators[s];if(n?c=p.modulators.length+(0|r.modFilterTypes[s]):o&&(c=p.modulators.length+1+2*p.filterMaxPoints+(0|r.modFilterTypes[s])),null==t[r.modChannels[s]][e[i]][c]||a*p.partsPerBeat*this.song.beatsPerBar+l[s]>t[r.modChannels[s]][e[i]][c]){if(n){let t=this.song.channels[r.modChannels[s]].instruments[e[i]];if(0==r.modFilterTypes[s])t.tmpEqFilterStart=t.eqSubFilters[h[s]];else{for(let e=0;e<p.filterMorphCount;e++)null!=t.tmpEqFilterStart&&t.tmpEqFilterStart==t.eqSubFilters[e]&&(t.tmpEqFilterStart=new fe,t.tmpEqFilterStart.fromJsonObject(t.eqSubFilters[e].toJsonObject()),e=p.filterMorphCount);null!=t.tmpEqFilterStart&&Math.floor((r.modFilterTypes[s]-1)/2)<t.tmpEqFilterStart.controlPointCount&&(r.modFilterTypes[s]%2?t.tmpEqFilterStart.controlPoints[Math.floor((r.modFilterTypes[s]-1)/2)].freq=h[s]:t.tmpEqFilterStart.controlPoints[Math.floor((r.modFilterTypes[s]-1)/2)].gain=h[s])}t.tmpEqFilterEnd=t.tmpEqFilterStart}else if(o){let t=this.song.channels[r.modChannels[s]].instruments[e[i]];if(0==r.modFilterTypes[s])t.tmpNoteFilterStart=t.noteSubFilters[h[s]];else{for(let e=0;e<p.filterMorphCount;e++)null!=t.tmpNoteFilterStart&&t.tmpNoteFilterStart==t.noteSubFilters[e]&&(t.tmpNoteFilterStart=new fe,t.tmpNoteFilterStart.fromJsonObject(t.noteSubFilters[e].toJsonObject()),e=p.filterMorphCount);null!=t.tmpNoteFilterStart&&Math.floor((r.modFilterTypes[s]-1)/2)<t.tmpNoteFilterStart.controlPointCount&&(r.modFilterTypes[s]%2?t.tmpNoteFilterStart.controlPoints[Math.floor((r.modFilterTypes[s]-1)/2)].freq=h[s]:t.tmpNoteFilterStart.controlPoints[Math.floor((r.modFilterTypes[s]-1)/2)].gain=h[s])}t.tmpNoteFilterEnd=t.tmpNoteFilterStart}else this.setModValue(h[s],h[s],r.modChannels[s],e[i],c);t[r.modChannels[s]][e[i]][c]=a*p.partsPerBeat*this.song.beatsPerBar+l[s]}}}}}}}determineInvalidModulators(e){if(null!=this.song)for(let t=0;t<p.modCount;t++){if(e.invalidModulators[t]=!0,-1==e.modChannels[t]){0!=e.modulators[t]&&(e.invalidModulators[t]=!1);continue}const s=this.song.channels[e.modChannels[t]];if(null==s)continue;let i=[];i=e.modInstruments[t]>=s.instruments.length?s.instruments:[s.instruments[e.modInstruments[t]]];for(let s=0;s<i.length;s++){const n=i[s];if(null==n)continue;const a=p.modulators[e.modulators[t]].name;12!=p.modulators[e.modulators[t]].associatedEffect&&!(n.effects&1<<p.modulators[e.modulators[t]].associatedEffect)||1!=n.type&&12!=n.type&&("fm slider 1"==a||"fm slider 2"==a||"fm slider 3"==a||"fm slider 4"==a||"fm feedback"==a)||12!=n.type&&("fm slider 5"==a||"fm slider 6"==a)||6!=n.type&&7!=n.type&&9!=n.type&&("pulse width"==a||"decimal offset"==a)||9!=n.type&&("dynamism"==a||"spread"==a||"saw shape"==a)||!n.getChord().arpeggiates&&("arp speed"==a||"reset arp"==a)||n.eqFilterType&&"eq filter"==a||!n.eqFilterType&&("eq filt cut"==a||"eq filt peak"==a)||"eq filter"==a&&Math.floor((e.modFilterTypes[t]+1)/2)>n.getLargestControlPointCount(!1)||n.noteFilterType&&"note filter"==a||!n.noteFilterType&&("note filt cut"==a||"note filt peak"==a)||"note filter"==a&&Math.floor((e.modFilterTypes[t]+1)/2)>n.getLargestControlPointCount(!0)||(e.invalidModulators[t]=!1,s=i.length)}}}static operatorAmplitudeCurve(e){return(Math.pow(16,e/15)-1)/15}get playing(){return this.isPlayingSong}get recording(){return this.isRecording}get playhead(){return this.playheadInternal}set playhead(e){if(null!=this.song){this.playheadInternal=Math.max(0,Math.min(this.song.barCount,e));let t=this.playheadInternal;this.bar=Math.floor(t),t=this.song.beatsPerBar*(t-this.bar),this.beat=Math.floor(t),t=p.partsPerBeat*(t-this.beat),this.part=Math.floor(t),t=p.ticksPerPart*(t-this.part),this.tick=Math.floor(t),this.tickSampleCountdown=0,this.isAtStartOfTick=!0,this.prevBar=null}}getSamplesPerBar(){if(null==this.song)throw new Error;return this.getSamplesPerTick()*p.ticksPerPart*p.partsPerBeat*this.song.beatsPerBar}getTicksIntoBar(){return(this.beat*p.partsPerBeat+this.part)*p.ticksPerPart+this.tick}getCurrentPart(){return this.beat*p.partsPerBeat+this.part}findPartsInBar(e){if(null==this.song)return 0;let t=p.partsPerBeat*this.song.beatsPerBar;for(let s=this.song.pitchChannelCount+this.song.noiseChannelCount;s<this.song.getChannelCount();s++){let i=this.song.getPattern(s,e);if(null!=i){let e=this.song.channels[s].instruments[i.instruments[0]];for(let s=0;s<p.modCount;s++)if(e.modulators[s]==p.modulators.dictionary["next bar"].index)for(const e of i.notes)e.pitches[0]==p.modCount-1-s&&t>e.start&&(t=e.start)}}return t}getTotalSamples(e,t,s){if(null==this.song)return-1;let i=e?0:this.song.loopStart,n=t?this.song.barCount:this.song.loopStart+this.song.loopLength,a=!1,o=!1,r=this.song.tempo;for(let e=this.song.getChannelCount()-1;e>=this.song.pitchChannelCount+this.song.noiseChannelCount;e--)for(let t=i;t<n;t++){let s=this.song.getPattern(e,t);if(null!=s){let t=this.song.channels[e].instruments[s.instruments[0]];for(let e=0;e<p.modCount;e++)t.modulators[e]==p.modulators.dictionary.tempo.index&&(a=!0),t.modulators[e]==p.modulators.dictionary["next bar"].index&&(o=!0)}}if(i>0){let e=null,t=0;for(let s=i-1;s>=0;s--){for(let i=this.song.getChannelCount()-1;i>=this.song.pitchChannelCount+this.song.noiseChannelCount;i--){let n=this.song.getPattern(i,s);if(null!=n){let a=n.instruments[0],o=this.song.channels[i].instruments[a],r=this.findPartsInBar(s);for(const s of n.notes)if(o.modulators[p.modCount-1-s.pitches[0]]==p.modulators.dictionary.tempo.index&&s.start<r&&(null==e||s.end>e))if(s.end<=r)e=s.end,t=s.pins[s.pins.length-1].size;else{e=r;for(let e=0;e<s.pins.length;e++)if(s.pins[e].time+s.start>r){const i=s.pins[e].time-s.pins[e-1].time,n=r-s.start-s.pins[e-1].time,a=s.pins[e].size-s.pins[e-1].size;t=Math.round(s.pins[e-1].size+a*n/i),e=s.pins.length}}}}null!=e&&(r=t+p.modulators.dictionary.tempo.convertRealFactor,s=-1)}}if(a||o){let e=i,t=!1,l=0;for(;!t;){let i=p.partsPerBeat*this.song.beatsPerBar,h=0;if(o&&(i=this.findPartsInBar(e)),a){let t=!1;for(let s=this.song.getChannelCount()-1;s>=this.song.pitchChannelCount+this.song.noiseChannelCount;s--)if(0==t){let n=this.song.getPattern(s,e);if(null!=n){let e=this.song.channels[s].instruments[n.instruments[0]];for(let s=0;s<p.modCount;s++)if(0==t&&e.modulators[s]==p.modulators.dictionary.tempo.index&&n.notes.find((e=>e.pitches[0]==p.modCount-1-s))){t=!0,n.notes.sort((function(e,t){return e.start==t.start?e.pitches[0]-t.pitches[0]:e.start-t.start}));for(const e of n.notes)if(e.pitches[0]==p.modCount-1-s&&(l+=Math.min(i-h,e.start-h)*p.ticksPerPart*this.getSamplesPerTickSpecificBPM(r),e.start<i))for(let t=1;t<e.pins.length;t++){if(e.pins[t-1].time+e.start<=i){const s=p.ticksPerPart*Math.min(i-(e.start+e.pins[t-1].time),e.pins[t].time-e.pins[t-1].time),n=e.pins[t-1].size+p.modulators.dictionary.tempo.convertRealFactor;let a=e.pins[t].size+p.modulators.dictionary.tempo.convertRealFactor;e.pins[t].time+e.start>i&&(a=e.pins[t-1].size+(e.pins[t].size-e.pins[t-1].size)*(i-(e.start+e.pins[t-1].time))/(e.pins[t].time-e.pins[t-1].time)+p.modulators.dictionary.tempo.convertRealFactor);let o=p.partsPerBeat*p.ticksPerPart/60;l+=a!=n?-this.samplesPerSecond*s*(Math.log(o*a*s)-Math.log(o*n*s))/(o*(n-a)):s*this.getSamplesPerTickSpecificBPM(a),r=a}h=Math.min(e.start+e.pins[t].time,i)}}}}}l+=(i-h)*p.ticksPerPart*this.getSamplesPerTickSpecificBPM(r),e++,0!=s&&e==this.song.loopStart+this.song.loopLength&&(e=this.song.loopStart,s>0&&s--),e>=n&&(t=!0)}return Math.ceil(l)}return this.getSamplesPerBar()*this.getTotalBars(e,t,s)}getTotalBars(e,t,s=this.loopRepeatCount){if(null==this.song)throw new Error;let i=this.song.loopLength*(s+1);return e&&(i+=this.song.loopStart),t&&(i+=this.song.barCount-(this.song.loopStart+this.song.loopLength)),i}constructor(e=null){this.samplesPerSecond=44100,this.song=null,this.preferLowerLatency=!1,this.anticipatePoorPerformance=!1,this.liveInputDuration=0,this.liveBassInputDuration=0,this.liveInputStarted=!1,this.liveBassInputStarted=!1,this.liveInputPitches=[],this.liveBassInputPitches=[],this.liveInputChannel=0,this.liveBassInputChannel=0,this.liveInputInstruments=[],this.liveBassInputInstruments=[],this.loopRepeatCount=-1,this.volume=1,this.oscRefreshEventTimer=0,this.oscEnabled=!0,this.enableMetronome=!1,this.countInMetronome=!1,this.renderingSong=!1,this.heldMods=[],this.wantToSkip=!1,this.playheadInternal=0,this.bar=0,this.prevBar=null,this.nextBar=null,this.beat=0,this.part=0,this.tick=0,this.isAtStartOfTick=!0,this.isAtEndOfTick=!0,this.tickSampleCountdown=0,this.modValues=[],this.modInsValues=[],this.nextModValues=[],this.nextModInsValues=[],this.isPlayingSong=!1,this.isRecording=!1,this.liveInputEndTime=0,this.browserAutomaticallyClearsAudioBuffer=!0,this.tempDrumSetControlPoint=new ue,this.tempFrequencyResponse=new W,this.loopBarStart=-1,this.loopBarEnd=-1,this.channels=[],this.tonePool=new H,this.tempMatchedPitchTones=Array(p.maxChordSize).fill(null),this.startedMetronome=!1,this.metronomeSamplesRemaining=-1,this.metronomeAmplitude=0,this.metronomePrevAmplitude=0,this.metronomeFilter=0,this.limit=0,this.tempMonoInstrumentSampleBuffer=null,this.audioCtx=null,this.scriptNode=null,this.audioProcessCallback=e=>{const t=e.outputBuffer,s=t.getChannelData(0),i=t.getChannelData(1);if(!this.browserAutomaticallyClearsAudioBuffer||0==s[0]&&0==i[0]&&0==s[t.length-1]&&0==i[t.length-1]||(this.browserAutomaticallyClearsAudioBuffer=!1),!this.browserAutomaticallyClearsAudioBuffer){const e=t.length;for(let t=0;t<e;t++)s[t]=0,i[t]=0}!this.isPlayingSong&&performance.now()>=this.liveInputEndTime?this.deactivateAudio():(this.synthesize(s,i,t.length,this.isPlayingSong),this.oscEnabled&&(this.oscRefreshEventTimer<=0?(L.raise("oscillascopeUpdate",s,i),this.oscRefreshEventTimer=2):this.oscRefreshEventTimer--))},this.computeDelayBufferSizes(),null!=e&&this.setSong(e)}setSong(e){"string"==typeof e?this.song=new ve(e):e instanceof ve&&(this.song=e),this.prevBar=null}computeDelayBufferSizes(){this.panningDelayBufferSize=xe.fittingPowerOfTwo(this.samplesPerSecond*p.panDelaySecondsMax),this.panningDelayBufferMask=this.panningDelayBufferSize-1,this.chorusDelayBufferSize=xe.fittingPowerOfTwo(this.samplesPerSecond*p.chorusMaxDelay),this.chorusDelayBufferMask=this.chorusDelayBufferSize-1}activateAudio(){const e=this.anticipatePoorPerformance?this.preferLowerLatency?2048:4096:this.preferLowerLatency?512:2048;if(null==this.audioCtx||null==this.scriptNode||this.scriptNode.bufferSize!=e){null!=this.scriptNode&&this.deactivateAudio();const t=this.anticipatePoorPerformance?this.preferLowerLatency?"balanced":"playback":this.preferLowerLatency?"interactive":"balanced";this.audioCtx=this.audioCtx||new(window.AudioContext||window.webkitAudioContext)({latencyHint:t}),this.samplesPerSecond=this.audioCtx.sampleRate,this.scriptNode=this.audioCtx.createScriptProcessor?this.audioCtx.createScriptProcessor(e,0,2):this.audioCtx.createJavaScriptNode(e,0,2),this.scriptNode.onaudioprocess=this.audioProcessCallback,this.scriptNode.channelCountMode="explicit",this.scriptNode.channelInterpretation="speakers",this.scriptNode.connect(this.audioCtx.destination),this.computeDelayBufferSizes()}this.audioCtx.resume()}deactivateAudio(){null!=this.audioCtx&&null!=this.scriptNode&&(this.scriptNode.disconnect(this.audioCtx.destination),this.scriptNode=null,this.audioCtx.close&&this.audioCtx.close(),this.audioCtx=null)}maintainLiveInput(){this.activateAudio(),this.liveInputEndTime=performance.now()+1e4}play(){this.isPlayingSong||(this.initModFilters(this.song),this.computeLatestModValues(),this.activateAudio(),this.warmUpSynthesizer(this.song),this.isPlayingSong=!0)}pause(){if(this.isPlayingSong&&(this.isPlayingSong=!1,this.isRecording=!1,this.modValues=[],this.nextModValues=[],this.heldMods=[],null!=this.song)){this.song.inVolumeCap=0,this.song.outVolumeCap=0;for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)this.modInsValues[e]=[],this.nextModInsValues[e]=[]}}startRecording(){this.preferLowerLatency=!0,this.isRecording=!0,this.play()}resetEffects(){if(this.limit=0,this.freeAllTones(),null!=this.song)for(const e of this.channels)for(const t of e.instruments)t.resetAllEffects()}setModValue(e,t,s,i,n){let a=e+p.modulators[n].convertRealFactor,o=t+p.modulators[n].convertRealFactor;return p.modulators[n].forSong?null!=this.modValues[n]&&this.modValues[n]==a&&this.nextModValues[n]==o||(this.modValues[n]=a,this.nextModValues[n]=o):null!=this.modInsValues[s][i][n]&&this.modInsValues[s][i][n]==a&&this.nextModInsValues[s][i][n]==o||(this.modInsValues[s][i][n]=a,this.nextModInsValues[s][i][n]=o),a}getModValue(e,t,s,i){if(p.modulators[e].forSong){if(null!=this.modValues[e]&&null!=this.nextModValues[e])return i?this.nextModValues[e]:this.modValues[e]}else if(null!=t&&null!=s&&null!=this.modInsValues[t][s][e]&&null!=this.nextModInsValues[t][s][e])return i?this.nextModInsValues[t][s][e]:this.modInsValues[t][s][e];return-1}isAnyModActive(e,t){for(let s=0;s<p.modulators.length;s++)if(null!=this.modValues&&null!=this.modValues[s]||null!=this.modInsValues&&null!=this.modInsValues[e]&&null!=this.modInsValues[e][t]&&null!=this.modInsValues[e][t][s])return!0;return!1}unsetMod(e,t,s){if(this.isModActive(e)||null!=t&&null!=s&&this.isModActive(e,t,s)){this.modValues[e]=null,this.nextModValues[e]=null;for(let i=0;i<this.heldMods.length;i++)null!=t&&null!=s?this.heldMods[i].channelIndex==t&&this.heldMods[i].instrumentIndex==s&&this.heldMods[i].setting==e&&this.heldMods.splice(i,1):this.heldMods[i].setting==e&&this.heldMods.splice(i,1);null!=t&&null!=s&&(this.modInsValues[t][s][e]=null,this.nextModInsValues[t][s][e]=null)}}isFilterModActive(e,t,s){const i=this.song.channels[t].instruments[s];if(e){if(i.noteFilterType)return!1;if(null!=i.tmpNoteFilterEnd)return!0}else{if(i.eqFilterType)return!1;if(null!=i.tmpEqFilterEnd)return!0}return!1}isModActive(e,t,s){return p.modulators[e].forSong?null!=this.modValues&&null!=this.modValues[e]:null!=t&&null!=s&&null!=this.modInsValues&&null!=this.modInsValues[t]&&null!=this.modInsValues[t][s]&&null!=this.modInsValues[t][s][e]}forceHoldMods(e,t,s,i){let n=!1;for(let a=0;a<this.heldMods.length;a++)this.heldMods[a].channelIndex==t&&this.heldMods[a].instrumentIndex==s&&this.heldMods[a].setting==i&&(this.heldMods[a].volume=e,this.heldMods[a].holdFor=24,n=!0);n||this.heldMods.push({volume:e,channelIndex:t,instrumentIndex:s,setting:i,holdFor:24})}snapToStart(){this.bar=0,this.resetEffects(),this.snapToBar()}goToBar(e){this.bar=e,this.resetEffects(),this.playheadInternal=this.bar}snapToBar(){this.playheadInternal=this.bar,this.beat=0,this.part=0,this.tick=0,this.tickSampleCountdown=0}jumpIntoLoop(){if(this.song&&(this.bar<this.song.loopStart||this.bar>=this.song.loopStart+this.song.loopLength)){const e=this.bar;this.bar=this.song.loopStart,this.playheadInternal+=this.bar-e,this.playing&&this.computeLatestModValues()}}goToNextBar(){if(!this.song)return;this.prevBar=this.bar;const e=this.bar;this.bar++,this.bar>=this.song.barCount&&(this.bar=0),this.playheadInternal+=this.bar-e,this.playing&&this.computeLatestModValues()}goToPrevBar(){if(!this.song)return;this.prevBar=null;const e=this.bar;this.bar--,(this.bar<0||this.bar>=this.song.barCount)&&(this.bar=this.song.barCount-1),this.playheadInternal+=this.bar-e,this.playing&&this.computeLatestModValues()}getNextBar(){let e=this.bar+1;return this.isRecording?e>=this.song.barCount&&(e=this.song.barCount-1):this.bar!=this.loopBarEnd||this.renderingSong?0!=this.loopRepeatCount&&e==Math.max(this.loopBarEnd+1,this.song.loopStart+this.song.loopLength)&&(e=this.song.loopStart):e=this.loopBarStart,e}skipBar(){if(!this.song)return;const e=this.getSamplesPerTick();this.prevBar=this.bar,this.loopBarEnd!=this.bar?this.bar++:this.bar=this.loopBarStart,this.beat=0,this.part=0,this.tick=0,this.tickSampleCountdown=e,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,this.isAtStartOfTick=!0,0!=this.loopRepeatCount&&this.bar==Math.max(this.song.loopStart+this.song.loopLength,this.loopBarEnd)&&(this.bar=this.song.loopStart,-1!=this.loopBarStart&&(this.bar=this.loopBarStart),this.loopRepeatCount>0&&this.loopRepeatCount--)}synthesize(e,t,s,i=!0){if(null==this.song){for(let i=0;i<s;i++)e[i]=0,t[i]=0;return void this.deactivateAudio()}const n=this.song;this.song.inVolumeCap=0,this.song.outVolumeCap=0;let a=this.getSamplesPerTick(),o=!1;(this.tickSampleCountdown<=0||this.tickSampleCountdown>a)&&(this.tickSampleCountdown=a,this.isAtStartOfTick=!0),i&&(this.beat>=n.beatsPerBar&&(this.beat=0,this.part=0,this.tick=0,this.tickSampleCountdown=a,this.isAtStartOfTick=!0,this.prevBar=this.bar,this.bar=this.getNextBar(),this.bar<=this.prevBar&&this.loopRepeatCount>0&&this.loopRepeatCount--),this.bar>=n.barCount&&(this.bar=0,-1!=this.loopRepeatCount&&(o=!0,this.pause()))),this.syncSongState(),(null==this.tempMonoInstrumentSampleBuffer||this.tempMonoInstrumentSampleBuffer.length<s)&&(this.tempMonoInstrumentSampleBuffer=new Float32Array(s));const r=+this.volume,l=1-Math.pow(.5,this.song.limitDecay/this.samplesPerSecond),h=1-Math.pow(.5,this.song.limitRise/this.samplesPerSecond);let c=+this.limit,u=[],f=-1,m=0;for(;m<s&&!o;){this.nextBar=this.getNextBar(),this.nextBar>=n.barCount&&(this.nextBar=null);const d=s-m,y=Math.ceil(this.tickSampleCountdown),v=Math.min(y,d),g=m+v;if(this.isPlayingSong||this.renderingSong){for(let e=n.pitchChannelCount+n.noiseChannelCount;e<n.getChannelCount();e++){const t=n.channels[e],s=this.channels[e];this.determineCurrentActiveTones(n,e,a,i);for(let i=0;i<t.instruments.length;i++){const t=s.instruments[i];for(let s=0;s<t.activeModTones.count();s++){const i=t.activeModTones.get(s),o=n.channels[e].instruments[i.instrumentIndex];let r=p.modCount-1-i.pitches[0];(o.modulators[r]==p.modulators.dictionary["note filter"].index||o.modulators[r]==p.modulators.dictionary["eq filter"].index)&&null!=o.modFilterTypes[r]&&o.modFilterTypes[r]>0||this.playModTone(n,e,a,m,v,i,!1,!1)}}}for(let e=n.pitchChannelCount+n.noiseChannelCount;e<n.getChannelCount();e++){const t=n.channels[e],s=this.channels[e];for(let i=0;i<t.instruments.length;i++){const t=s.instruments[i];for(let s=0;s<t.activeModTones.count();s++){const i=t.activeModTones.get(s),o=n.channels[e].instruments[i.instrumentIndex];let r=p.modCount-1-i.pitches[0];(o.modulators[r]==p.modulators.dictionary["note filter"].index||o.modulators[r]==p.modulators.dictionary["eq filter"].index)&&null!=o.modFilterTypes[r]&&o.modFilterTypes[r]>0&&this.playModTone(n,e,a,m,v,i,!1,!1)}}}}if(this.wantToSkip){let e=u.includes(this.bar);if(e&&m==f)return void this.pause();-1==f&&(f=m),e||u.push(this.bar),this.wantToSkip=!1,this.skipBar()}else{for(let s=0;s<n.pitchChannelCount+n.noiseChannelCount;s++){const o=n.channels[s],r=this.channels[s];this.isAtStartOfTick&&(this.determineCurrentActiveTones(n,s,a,i&&!this.countInMetronome),this.determineLiveInputTones(n,s,a));for(let i=0;i<o.instruments.length;i++){const l=o.instruments[i],h=r.instruments[i];if(this.isAtStartOfTick){let e=h.activeTones.count()+h.liveInputTones.count();for(let t=0;t<h.releasedTones.count();t++){const i=h.releasedTones.get(t);if(i.ticksSinceReleased>=Math.abs(l.getFadeOutTicks())){this.freeReleasedTone(h,t),t--;continue}const o=e>=p.maximumTonesPerChannel;this.computeTone(n,s,a,i,!0,o),e++}h.awake&&(h.computed||h.compute(this,l,a,Math.ceil(a),null,s,i),h.computed=!1)}for(let e=0;e<h.activeTones.count();e++){const t=h.activeTones.get(e);this.playTone(s,m,v,t)}for(let e=0;e<h.liveInputTones.count();e++){const t=h.liveInputTones.get(e);this.playTone(s,m,v,t)}for(let e=0;e<h.releasedTones.count();e++){const t=h.releasedTones.get(e);this.playTone(s,m,v,t)}h.awake&&xe.effectsSynth(this,e,t,m,v,h);const c=this.tickSampleCountdown,u=1-c/a,f=1-(c-v)/a,d=(this.beat*p.partsPerBeat+this.part)*p.ticksPerPart+this.tick,y=d/p.ticksPerPart,g=(d+1)/p.ticksPerPart,b=y+(g-y)*u,S=y+(g-y)*f;let M=l.vibratoSpeed;h.vibratoTime=h.nextVibratoTime,this.isModActive(p.modulators.dictionary["vibrato speed"].index,s,i)&&(M=this.getModValue(p.modulators.dictionary["vibrato speed"].index,s,i)),0==M?(h.vibratoTime=0,h.nextVibratoTime=0):h.nextVibratoTime+=.1*M*(S-b)}}if(this.enableMetronome||this.countInMetronome)if(0==this.part){if(!this.startedMetronome){const e=n.beatsPerBar>4&&n.beatsPerBar%2==0&&this.beat==n.beatsPerBar/2,t=0==this.beat?8:e?6:4,s=0==this.beat?1600:e?1200:800,i=0==this.beat?.06:e?.05:.04,a=this.samplesPerSecond/s,o=2*Math.PI/a;this.metronomeSamplesRemaining=Math.floor(a*t),this.metronomeFilter=2*Math.cos(o),this.metronomeAmplitude=i*Math.sin(o),this.metronomePrevAmplitude=0,this.startedMetronome=!0}if(this.metronomeSamplesRemaining>0){const s=Math.min(g,m+this.metronomeSamplesRemaining);this.metronomeSamplesRemaining-=s-m;for(let i=m;i<s;i++){e[i]+=this.metronomeAmplitude,t[i]+=this.metronomeAmplitude;const s=this.metronomeFilter*this.metronomeAmplitude-this.metronomePrevAmplitude;this.metronomePrevAmplitude=this.metronomeAmplitude,this.metronomeAmplitude=s}}}else this.startedMetronome=!1;for(let s=m;s<g;s++){const i=e[s]*n.masterGain*n.masterGain,a=t[s]*n.masterGain*n.masterGain,o=i<0?-i:i,p=a<0?-a:a,u=o>p?o:p;this.song.inVolumeCap=this.song.inVolumeCap>u?this.song.inVolumeCap:u;const f=+(u>n.compressionThreshold)+ +(u>n.limitThreshold),m=+(0==f)*((.8*(u+1-n.compressionThreshold)+.25)*n.compressionRatio+1.05*(1-n.compressionRatio))+1.05*+(1==f)+ +(2==f)*(1.05*((u+1-n.limitThreshold)*n.limitRatio+(1-n.limitThreshold)));c+=(m-c)*(c<m?h:l);const d=r/(c>=1?1.05*c:.8*c+.25);e[s]=i*d,t[s]=a*d,this.song.outVolumeCap=this.song.outVolumeCap>u*d?this.song.outVolumeCap:u*d}if(m+=v,this.isAtStartOfTick=!1,this.tickSampleCountdown-=v,this.tickSampleCountdown<=0){this.isAtStartOfTick=!0;for(const e of this.channels)for(const t of e.instruments){for(let e=0;e<t.releasedTones.count();e++){const s=t.releasedTones.get(e);s.isOnLastTick?(this.freeReleasedTone(t,e),e--):s.ticksSinceReleased++}t.deactivateAfterThisTick&&t.deactivate(),t.tonesAddedInThisTick=!1}for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)for(let t=0;t<this.song.channels[e].instruments.length;t++){let s=this.song.channels[e].instruments[t],i=this.channels[e].instruments[t];if(7==s.type){const e=s.dutyCycleSequence.length;let t=p.dutyCycleSpeedScale[s.dutyCycleSpeed];t<=0||e<=0||(i.dutyCycleTime=(i.dutyCycleTime+t*(1/(p.ticksPerPart*p.partsPerBeat)))%e)}let n=s.arpeggioSpeed;this.isModActive(p.modulators.dictionary["arp speed"].index,e,t)?(n=Math.max(0,Math.min(p.arpSpeedScale.length-1,this.getModValue(p.modulators.dictionary["arp speed"].index,e,t,!1))),Number.isInteger(n)?i.arpTime+=p.arpSpeedScale[n]:i.arpTime+=(1-n%1)*p.arpSpeedScale[Math.floor(n)]+n%1*p.arpSpeedScale[Math.ceil(n)]):i.arpTime+=p.arpSpeedScale[n];let a=s.envelopeSpeed;this.isModActive(p.modulators.dictionary["envelope speed"].index,e,t)?(a=Math.max(0,Math.min(p.arpSpeedScale.length-1,this.getModValue(p.modulators.dictionary["envelope speed"].index,e,t,!1))),Number.isInteger(a)?i.envelopeTime+=p.arpSpeedScale[a]:i.envelopeTime+=(1-a%1)*p.arpSpeedScale[Math.floor(a)]+a%1*p.arpSpeedScale[Math.ceil(a)]):i.envelopeTime+=p.arpSpeedScale[a]}for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)for(let t=0;t<this.song.channels[e].instruments.length;t++){let s=this.song.channels[e].instruments[t];null!=s.tmpEqFilterEnd?s.tmpEqFilterStart=s.tmpEqFilterEnd:s.tmpEqFilterStart=s.eqFilter,null!=s.tmpNoteFilterEnd?s.tmpNoteFilterStart=s.tmpNoteFilterEnd:s.tmpNoteFilterStart=s.noteFilter}if(this.tick++,this.tickSampleCountdown+=a,this.tick==p.ticksPerPart){this.tick=0,this.part++,this.liveInputDuration--,this.liveBassInputDuration--;for(let e=0;e<this.heldMods.length;e++)this.heldMods[e].holdFor--,this.heldMods[e].holdFor<=0&&this.heldMods.splice(e,1);this.part==p.partsPerBeat&&(this.part=0,i&&(this.beat++,this.beat==n.beatsPerBar&&(this.beat=0,this.countInMetronome?this.countInMetronome=!1:(this.prevBar=this.bar,this.bar=this.getNextBar(),this.bar<=this.prevBar&&this.loopRepeatCount>0&&this.loopRepeatCount--,this.bar>=n.barCount&&(this.bar=0,-1!=this.loopRepeatCount&&(o=!0,this.resetEffects(),this.pause()))))))}}for(let e=0;e<p.modulators.length;e++)null!=this.nextModValues&&null!=this.nextModValues[e]&&(this.modValues[e]=this.nextModValues[e]);this.isModActive(p.modulators.dictionary.tempo.index)&&(a=this.getSamplesPerTick(),this.tickSampleCountdown=Math.min(this.tickSampleCountdown,a));for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)for(let t=0;t<this.channels[e].instruments.length;t++){const s=this.channels[e].instruments[t],i=this.song.channels[e].instruments[t];s.nextVibratoTime=s.nextVibratoTime%(p.vibratoTypes[i.vibratoType].period/(p.ticksPerPart*a/this.samplesPerSecond)),s.arpTime=s.arpTime%(2520*p.ticksPerArpeggio),s.envelopeTime=s.envelopeTime%(p.partsPerBeat*p.ticksPerPart*this.song.beatsPerBar)}for(let e=0;e<p.modulators.length;e++)for(let t=0;t<this.song.pitchChannelCount+this.song.noiseChannelCount;t++)for(let s=0;s<this.song.getMaxInstrumentsPerChannel();s++)null!=this.nextModInsValues&&null!=this.nextModInsValues[t]&&null!=this.nextModInsValues[t][s]&&null!=this.nextModInsValues[t][s][e]&&(this.modInsValues[t][s][e]=this.nextModInsValues[t][s][e])}}(!Number.isFinite(c)||Math.abs(c)<V)&&(c=0),this.limit=c,i&&!this.countInMetronome&&(this.playheadInternal=(((this.tick+1-this.tickSampleCountdown/a)/2+this.part)/p.partsPerBeat+this.beat)/n.beatsPerBar+this.bar)}freeTone(e){this.tonePool.pushBack(e)}newTone(){if(this.tonePool.count()>0){const e=this.tonePool.popBack();return e.freshlyAllocated=!0,e}return new Se}releaseTone(e,t){e.releasedTones.pushFront(t),t.atNoteStart=!1,t.passedEndOfNote=!0}freeReleasedTone(e,t){this.freeTone(e.releasedTones.get(t)),e.releasedTones.remove(t)}freeAllTones(){for(const e of this.channels)for(const t of e.instruments){for(;t.activeTones.count()>0;)this.freeTone(t.activeTones.popBack());for(;t.activeModTones.count()>0;)this.freeTone(t.activeModTones.popBack());for(;t.releasedTones.count()>0;)this.freeTone(t.releasedTones.popBack());for(;t.liveInputTones.count()>0;)this.freeTone(t.liveInputTones.popBack())}}determineLiveInputTones(e,t,s){const i=e.channels[t],n=this.channels[t],a=this.liveInputPitches,o=this.liveBassInputPitches;for(let r=0;r<i.instruments.length;r++){const l=n.instruments[r],h=l.liveInputTones;let p=0;if(this.liveInputDuration>0&&t==this.liveInputChannel&&a.length>0&&-1!=this.liveInputInstruments.indexOf(r)){const n=i.instruments[r];if(n.getChord().singleTone){let i;h.count()<=p?(i=this.newTone(),h.pushBack(i)):!n.getTransition().isSeamless&&this.liveInputStarted?(this.releaseTone(l,h.get(p)),i=this.newTone(),h.set(p,i)):i=h.get(p),p++;for(let e=0;e<a.length;e++)i.pitches[e]=a[e];i.pitchCount=a.length,i.chordSize=1,i.instrumentIndex=r,i.note=i.prevNote=i.nextNote=null,i.atNoteStart=this.liveInputStarted,i.forceContinueAtStart=!1,i.forceContinueAtEnd=!1,this.computeTone(e,t,s,i,!1,!1)}else{this.moveTonesIntoOrderedTempMatchedList(h,a);for(let i=0;i<a.length;i++){let n;null!=this.tempMatchedPitchTones[p]?(n=this.tempMatchedPitchTones[p],this.tempMatchedPitchTones[p]=null,1==n.pitchCount&&n.pitches[0]==a[i]||(this.releaseTone(l,n),n=this.newTone()),h.pushBack(n)):(n=this.newTone(),h.pushBack(n)),p++,n.pitches[0]=a[i],n.pitchCount=1,n.chordSize=a.length,n.instrumentIndex=r,n.note=n.prevNote=n.nextNote=null,n.atNoteStart=this.liveInputStarted,n.forceContinueAtStart=!1,n.forceContinueAtEnd=!1,this.computeTone(e,t,s,n,!1,!1)}}}if(this.liveBassInputDuration>0&&t==this.liveBassInputChannel&&o.length>0&&-1!=this.liveBassInputInstruments.indexOf(r)){const n=i.instruments[r];if(n.getChord().singleTone){let i;h.count()<=p?(i=this.newTone(),h.pushBack(i)):!n.getTransition().isSeamless&&this.liveInputStarted?(this.releaseTone(l,h.get(p)),i=this.newTone(),h.set(p,i)):i=h.get(p),p++;for(let e=0;e<o.length;e++)i.pitches[e]=o[e];i.pitchCount=o.length,i.chordSize=1,i.instrumentIndex=r,i.note=i.prevNote=i.nextNote=null,i.atNoteStart=this.liveBassInputStarted,i.forceContinueAtStart=!1,i.forceContinueAtEnd=!1,this.computeTone(e,t,s,i,!1,!1)}else{this.moveTonesIntoOrderedTempMatchedList(h,o);for(let i=0;i<o.length;i++){let n;null!=this.tempMatchedPitchTones[p]?(n=this.tempMatchedPitchTones[p],this.tempMatchedPitchTones[p]=null,1==n.pitchCount&&n.pitches[0]==o[i]||(this.releaseTone(l,n),n=this.newTone()),h.pushBack(n)):(n=this.newTone(),h.pushBack(n)),p++,n.pitches[0]=o[i],n.pitchCount=1,n.chordSize=o.length,n.instrumentIndex=r,n.note=n.prevNote=n.nextNote=null,n.atNoteStart=this.liveBassInputStarted,n.forceContinueAtStart=!1,n.forceContinueAtEnd=!1,this.computeTone(e,t,s,n,!1,!1)}}}for(;h.count()>p;)this.releaseTone(l,h.popBack());this.clearTempMatchedPitchTones(p,l)}this.liveInputStarted=!1,this.liveBassInputStarted=!1}adjacentPatternHasCompatibleInstrumentTransition(e,t,s,i,n,a,o,r,l,h){if(e.patternInstruments&&-1==i.instruments.indexOf(n)){if(s.instruments.length>1||i.instruments.length>1)return null;const e=t.instruments[i.instruments[0]];if(h)return e.getChord();const n=e.getTransition();return a.includeAdjacentPatterns&&n.includeAdjacentPatterns&&n.slides==a.slides?e.getChord():null}return h||a.includeAdjacentPatterns?o:null}static adjacentNotesHaveMatchingPitches(e,t){if(e.pitches.length!=t.pitches.length)return!1;const s=e.pins[e.pins.length-1].interval;for(const i of e.pitches)if(-1==t.pitches.indexOf(i+s))return!1;return!0}moveTonesIntoOrderedTempMatchedList(e,t){for(let s=0;s<e.count();s++){const i=e.get(s),n=i.pitches[0]+i.lastInterval;for(let a=0;a<t.length;a++)if(t[a]==n){this.tempMatchedPitchTones[a]=i,e.remove(s),s--;break}}for(;e.count()>0;){const t=e.popFront();for(let e=0;e<this.tempMatchedPitchTones.length;e++)if(null==this.tempMatchedPitchTones[e]){this.tempMatchedPitchTones[e]=t;break}}}determineCurrentActiveTones(e,t,s,i){const n=e.channels[t],a=this.channels[t],o=e.getPattern(t,this.bar),r=this.getCurrentPart(),l=this.tick+p.ticksPerPart*r;if(i&&e.getChannelIsMod(t)){let s=[],i=[],h=[],c=p.modCount;for(;c--;)s.push(null),i.push(null),h.push(null);if(null!=o&&!n.muted)for(let e=0;e<o.notes.length;e++)o.notes[e].end<=r?(null==i[o.notes[e].pitches[0]]||o.notes[e].end>i[o.notes[e].pitches[0]].start)&&(i[o.notes[e].pitches[0]]=o.notes[e]):o.notes[e].start<=r&&o.notes[e].end>r?s[o.notes[e].pitches[0]]=o.notes[e]:o.notes[e].start>r&&(null==h[o.notes[e].pitches[0]]||o.notes[e].start<h[o.notes[e].pitches[0]].start)&&(h[o.notes[e].pitches[0]]=o.notes[e]);let u=0;const f=e.patternInstruments&&null!=o?o.instruments[0]:0,m=a.instruments[f],d=m.activeModTones;for(let e=0;e<p.modCount;e++){if(null!=s[e]&&(null!=i[e]&&i[e].end!=s[e].start&&(i[e]=null),null!=h[e]&&h[e].start!=s[e].end&&(h[e]=null)),null!=a.singleSeamlessInstrument&&a.singleSeamlessInstrument!=f&&a.singleSeamlessInstrument<a.instruments.length){const e=a.instruments[a.singleSeamlessInstrument],t=a.instruments[f];for(;e.activeModTones.count()>0;)t.activeModTones.pushFront(e.activeModTones.popBack())}if(a.singleSeamlessInstrument=f,null!=s[e]){let t=i[e],n=h[e],a=!1,o=!1;const r=p.ticksPerPart*s[e].start==l&&this.isAtStartOfTick;let c;if(d.count()<=u)c=this.newTone(),d.pushBack(c);else if(r&&null==t){const e=d.get(u);e.isOnLastTick?this.freeTone(e):this.releaseTone(m,e),c=this.newTone(),d.set(u,c)}else c=d.get(u);u++;for(let t=0;t<s[e].pitches.length;t++)c.pitches[t]=s[e].pitches[t];c.pitchCount=s[e].pitches.length,c.chordSize=1,c.instrumentIndex=f,c.note=s[e],c.noteStartPart=s[e].start,c.noteEndPart=s[e].end,c.prevNote=t,c.nextNote=n,c.prevNotePitchIndex=0,c.nextNotePitchIndex=0,c.atNoteStart=r,c.passedEndOfNote=!1,c.forceContinueAtStart=a,c.forceContinueAtEnd=o}}for(;d.count()>u;){const s=d.popBack(),i=e.channels[t];if(s.instrumentIndex<i.instruments.length&&!s.isOnLastTick){const e=this.channels[t].instruments[s.instrumentIndex];this.releaseTone(e,s)}else this.freeTone(s)}}else if(!e.getChannelIsMod(t)){let h=null,c=null,u=null;if(i&&null!=o&&!n.muted&&(!this.isRecording||this.liveInputChannel!=t)){for(let e=0;e<o.notes.length;e++)if(o.notes[e].end<=r)c=o.notes[e];else if(o.notes[e].start<=r&&o.notes[e].end>r)h=o.notes[e];else if(o.notes[e].start>r){u=o.notes[e];break}null!=h&&(null!=c&&c.end!=h.start&&(c=null),null!=u&&u.start!=h.end&&(u=null))}if(null!=o&&(!e.layeredInstruments||1==n.instruments.length||e.patternInstruments&&1==o.instruments.length)){const t=e.patternInstruments?o.instruments[0]:0;if(null!=a.singleSeamlessInstrument&&a.singleSeamlessInstrument!=t&&a.singleSeamlessInstrument<a.instruments.length){const e=a.instruments[a.singleSeamlessInstrument],s=a.instruments[t];for(;e.activeTones.count()>0;)s.activeTones.pushFront(e.activeTones.popBack())}a.singleSeamlessInstrument=t}else a.singleSeamlessInstrument=null;for(let i=0;i<n.instruments.length;i++){const f=a.instruments[i],m=f.activeTones;let d=0;if(null!=h&&(!e.patternInstruments||-1!=o.instruments.indexOf(i))){const a=n.instruments[i];let y=c,v=u;const g=p.partsPerBeat*e.beatsPerBar,b=a.getTransition(),S=a.getChord();let M=!1,w=!1,x=0,k=0;if(0==h.start){let s=null==this.prevBar?null:e.getPattern(t,this.prevBar);if(null!=s){const t=s.notes.length<=0?null:s.notes[s.notes.length-1];if(null!=t&&t.end==g){const a=h.continuesLastPattern&&xe.adjacentNotesHaveMatchingPitches(t,h),r=this.adjacentPatternHasCompatibleInstrumentTransition(e,n,o,s,i,b,S,h,t,a);null!=r&&(y=t,x=r.singleTone?1:y.pitches.length,M=a)}}}else null!=y&&(x=S.singleTone?1:y.pitches.length);if(h.end==g){let s=null==this.nextBar?null:e.getPattern(t,this.nextBar);if(null!=s){const t=s.notes.length<=0?null:s.notes[0];if(null!=t&&0==t.start){const a=t.continuesLastPattern&&xe.adjacentNotesHaveMatchingPitches(h,t),r=this.adjacentPatternHasCompatibleInstrumentTransition(e,n,o,s,i,b,S,h,t,a);null!=r&&(v=t,k=r.singleTone?1:v.pitches.length,w=a)}}}else null!=v&&(k=S.singleTone?1:v.pitches.length);if(S.singleTone){const n=p.ticksPerPart*h.start==l;let o;if(m.count()<=d)o=this.newTone(),m.pushBack(o);else if(!n||(b.isSeamless||a.clicklessTransition||M)&&null!=y)o=m.get(d);else{const e=m.get(d);e.isOnLastTick?this.freeTone(e):this.releaseTone(f,e),o=this.newTone(),m.set(d,o)}d++;for(let e=0;e<h.pitches.length;e++)o.pitches[e]=h.pitches[e];o.pitchCount=h.pitches.length,o.chordSize=1,o.instrumentIndex=i,o.note=h,o.noteStartPart=h.start,o.noteEndPart=h.end,o.prevNote=y,o.nextNote=v,o.prevNotePitchIndex=0,o.nextNotePitchIndex=0,o.atNoteStart=n,o.passedEndOfNote=!1,o.forceContinueAtStart=M,o.forceContinueAtEnd=w,this.computeTone(e,t,s,o,!1,!1)}else{const n=a.getTransition();(n.isSeamless&&!n.slides&&0==S.strumParts||M)&&p.ticksPerPart*h.start==l&&null!=y&&this.moveTonesIntoOrderedTempMatchedList(m,h.pitches);let o=0;for(let a=0;a<h.pitches.length;a++){let c=x>a?y:null,u=h,g=k>a?v:null,b=u.start+o,F=!1;if(b>r){if(!(m.count()>a&&(n.isSeamless||M)&&null!=c))break;g=u,u=c,c=null,b=u.start+o,F=!0}let P=u.end;(n.isSeamless||M)&&null!=g&&(P=Math.min(p.partsPerBeat*this.song.beatsPerBar,P+o)),(n.continues||M)&&null!=c||(o+=S.strumParts);const q=p.ticksPerPart*b==l;let I;if(null!=this.tempMatchedPitchTones[d])I=this.tempMatchedPitchTones[d],this.tempMatchedPitchTones[d]=null,m.pushBack(I);else if(m.count()<=d)I=this.newTone(),m.pushBack(I);else if(!q||(n.isSeamless||M)&&null!=c)I=m.get(d);else{const e=m.get(d);e.isOnLastTick?this.freeTone(e):this.releaseTone(f,e),I=this.newTone(),m.set(d,I)}d++,I.pitches[0]=u.pitches[a],I.pitchCount=1,I.chordSize=u.pitches.length,I.instrumentIndex=i,I.note=u,I.noteStartPart=b,I.noteEndPart=P,I.prevNote=c,I.nextNote=g,I.prevNotePitchIndex=a,I.nextNotePitchIndex=a,I.atNoteStart=q,I.passedEndOfNote=F,I.forceContinueAtStart=M&&null!=c,I.forceContinueAtEnd=w&&null!=g,this.computeTone(e,t,s,I,!1,!1)}}}for(;m.count()>d;){const s=m.popBack(),i=e.channels[t];if(s.instrumentIndex<i.instruments.length&&!s.isOnLastTick){const e=a.instruments[s.instrumentIndex];this.releaseTone(e,s)}else this.freeTone(s)}this.clearTempMatchedPitchTones(d,f)}}}clearTempMatchedPitchTones(e,t){for(let s=e;s<this.tempMatchedPitchTones.length;s++){const e=this.tempMatchedPitchTones[s];null!=e&&(e.isOnLastTick?this.freeTone(e):this.releaseTone(t,e),this.tempMatchedPitchTones[s]=null)}}playTone(e,t,s,i){const n=this.channels[e].instruments[i.instrumentIndex];null!=n.synthesizer&&n.synthesizer(this,t,s,i,n),i.envelopeComputer.clearEnvelopes()}playModTone(e,t,s,i,n,a,o,r){const l=e.channels[t].instruments[a.instrumentIndex];if(null!=a.note){const e=this.getTicksIntoBar(),t=e/p.ticksPerPart,o=(e+1)/p.ticksPerPart,r=this.tickSampleCountdown,h=t+(o-t)*(1-r/s),c=t+(o-t)*(1-(r-n)/s),u=p.ticksPerPart*h,f=p.ticksPerPart*c,m=a.note.getEndPinIndex(this.getCurrentPart()),d=a.note.pins[m-1],y=a.note.pins[m],v=(a.note.start+d.time)*p.ticksPerPart,g=(a.note.start+y.time)*p.ticksPerPart,b=(u-v)/(g-v),S=(f-v)/(g-v);a.expression=d.size+(y.size-d.size)*b,a.expressionDelta=d.size+(y.size-d.size)*S-a.expression,xe.modSynth(this,i,n,a,l)}}static computeChordExpression(e){return 1/(.25*(e-1)+1)}computeTone(e,t,s,i,n,a){const o=Math.ceil(s),r=e.channels[t],l=this.channels[t],h=r.instruments[i.instrumentIndex],c=l.instruments[i.instrumentIndex];c.awake=!0,c.tonesAddedInThisTick=!0,c.computed||c.compute(this,h,s,o,i,t,i.instrumentIndex);const u=h.getTransition(),f=h.getChord(),d=f.singleTone?1:xe.computeChordExpression(i.chordSize),y=e.getChannelIsNoise(t),v=y?p.noiseInterval:1,g=p.ticksPerPart*s/this.samplesPerSecond,S=1/this.samplesPerSecond,M=1/p.partsPerBeat,w=this.getTicksIntoBar(),q=w/p.ticksPerPart,I=(w+1)/p.ticksPerPart,T=this.getCurrentPart();let D=1;i.specialIntervalExpressionMult=1;let O=a,A=0,z=0,C=1,R=1,E=d,H=d,L=16,N=p.keys[e.key].basePitch+p.pitchesPerOctave*e.octave,W=1,B=48;if(3==h.type)W=p.spectrumBaseExpression,y&&(N=p.spectrumBasePitch,W*=2),L=p.spectrumBasePitch,B=28;else if(4==h.type)N=p.spectrumBasePitch,W=p.drumsetBaseExpression,L=N;else if(2==h.type)N=y?p.chipNoises[h.chipNoise].basePitch:N+p.chipNoises[h.chipNoise].basePitch-12,W=p.noiseBaseExpression,L=N,B=p.chipNoises[h.chipNoise].isSoft?24:60;else if(1==h.type||12==h.type)W=p.fmBaseExpression;else if(0==h.type)W=p.chipBaseExpression,p.chipWaves[h.chipWave].isCustomSampled?p.chipWaves[h.chipWave].isPercussion?N=-12*Math.log2(p.chipWaves[h.chipWave].samples.length/p.chipWaves[h.chipWave].sampleRate)-84.37-(-60+p.chipWaves[h.chipWave].rootKey):N+=-12*Math.log2(p.chipWaves[h.chipWave].samples.length/p.chipWaves[h.chipWave].sampleRate)-96.37-(-60+p.chipWaves[h.chipWave].rootKey):p.chipWaves[h.chipWave].isSampled&&!p.chipWaves[h.chipWave].isPercussion?N=N-63+p.chipWaves[h.chipWave].extraSampleDetune:p.chipWaves[h.chipWave].isSampled&&p.chipWaves[h.chipWave].isPercussion&&(N=-51+p.chipWaves[h.chipWave].extraSampleDetune);else if(10==h.type)W=p.chipBaseExpression;else if(5==h.type)W=p.harmonicsBaseExpression;else if(6==h.type)W=p.pwmBaseExpression;else if(7==h.type)W=p.pwmBaseExpression;else if(9==h.type)W=p.supersawBaseExpression;else if(8==h.type)W=p.pickedStringBaseExpression;else{if(11!=h.type)throw new Error("Unknown instrument type in computeTone.");W=1,L=0,B=1,N=0}if((i.atNoteStart&&!u.isSeamless&&!i.forceContinueAtStart||i.freshlyAllocated)&&(i.reset(),0==h.type&&h.isUsingAdvancedLoopControls)){const e=p.rawRawChipWaves[h.chipWave].samples.length-1,t=h.chipWaveStartOffset/e,s=.999999999999999;for(let e=0;e<p.maxPitchOrOperatorCount;e++)i.phases[e]=h.chipWavePlayBackwards?Math.max(0,Math.min(s,t)):Math.max(0,t),i.directions[e]=h.chipWavePlayBackwards?-1:1,i.chipWaveCompletions[e]=0,i.chipWavePrevWaves[e]=0,i.chipWaveCompletionsLastWave[e]=0}i.freshlyAllocated=!1;for(let e=0;e<p.maxPitchOrOperatorCount;e++)i.phaseDeltas[e]=0,i.phaseDeltaScales[e]=0,i.operatorExpressions[e]=0,i.operatorExpressionDeltas[e]=0;i.expression=0,i.expressionDelta=0;for(let e=0;e<(12==h.type?6:p.operatorCount);e++)i.operatorWaves[e]=xe.getOperatorWave(h.operators[e].waveform,h.operators[e].pulseWidth);if(n){const e=i.ticksSinceReleased,t=i.ticksSinceReleased+1;A=z=i.lastInterval;const s=Math.abs(h.getFadeOutTicks());C=xe.noteSizeToVolumeMult((1-e/s)*p.noteSizeMax),R=xe.noteSizeToVolumeMult((1-t/s)*p.noteSizeMax),a&&(R=0),i.ticksSinceReleased+1>=s&&(O=!0)}else if(null==i.note)C=R=1,i.lastInterval=0,i.ticksSinceReleased=0,i.liveInputSamplesHeld+=o;else{const e=i.note,t=i.nextNote,s=i.noteStartPart,n=i.noteEndPart,a=e.getEndPinIndex(T),o=e.pins[a-1],r=e.pins[a],l=s*p.ticksPerPart,c=n*p.ticksPerPart,f=(e.start+o.time)*p.ticksPerPart,m=(e.start+r.time)*p.ticksPerPart;i.ticksSinceReleased=0;const d=T*p.ticksPerPart+this.tick,y=d+1,v=d-l,g=y-l,b=Math.min(1,(d-f)/(m-f)),S=Math.min(1,(y-f)/(m-f));if(C=1,R=1,A=o.interval+(r.interval-o.interval)*b,z=o.interval+(r.interval-o.interval)*S,i.lastInterval=z,!u.isSeamless&&!i.forceContinueAtEnd||null==t){const e=-h.getFadeOutTicks();if(e>0){const t=c-l;C*=Math.min(1,(t-v)/e),R*=Math.min(1,(t-g)/e),y>=l+t&&(O=!0)}}}i.isOnLastTick=O;let V,$,U=h.noteFilter;if(h.noteFilterType){const e=h.noteFilter;null==h.noteSubFilters[1]&&(h.noteSubFilters[1]=new fe);const s=h.noteSubFilters[1];let n=h.noteFilterSimpleCut,a=h.noteFilterSimplePeak,o=h.noteFilterSimpleCut,r=h.noteFilterSimplePeak,l=!1;this.isModActive(p.modulators.dictionary["note filt cut"].index,t,i.instrumentIndex)&&(n=this.getModValue(p.modulators.dictionary["note filt cut"].index,t,i.instrumentIndex,!1),o=this.getModValue(p.modulators.dictionary["note filt cut"].index,t,i.instrumentIndex,!0),l=!0),this.isModActive(p.modulators.dictionary["note filt peak"].index,t,i.instrumentIndex)&&(a=this.getModValue(p.modulators.dictionary["note filt peak"].index,t,i.instrumentIndex,!1),r=this.getModValue(p.modulators.dictionary["note filt peak"].index,t,i.instrumentIndex,!0),l=!0),e.convertLegacySettingsForSynth(n,a,!l),s.convertLegacySettingsForSynth(o,r,!l),V=e.controlPoints[0],$=s.controlPoints[0],h.noteFilter=e,h.tmpNoteFilterStart=e}const j=i.envelopeComputer;let _=p.arpSpeedScale[h.envelopeSpeed];this.isModActive(p.modulators.dictionary["envelope speed"].index,t,i.instrumentIndex)&&(_=Math.max(0,Math.min(p.arpSpeedScale.length-1,this.getModValue(p.modulators.dictionary["envelope speed"].index,t,i.instrumentIndex,!1))),_=Number.isInteger(_)?p.arpSpeedScale[_]:(1-_%1)*p.arpSpeedScale[Math.floor(_)]+_%1*p.arpSpeedScale[Math.ceil(_)]),j.computeEnvelopes(h,T,c.envelopeTime,p.ticksPerPart*q,s/this.samplesPerSecond,i,_);const Y=i.envelopeComputer.envelopeStarts,K=i.envelopeComputer.envelopeEnds;if(h.noteFilter=U,null!=i.note&&u.slides){const e=i.prevNote,t=i.nextNote;if(null!=e){const t=e.pitches[i.prevNotePitchIndex]+e.pins[e.pins.length-1].interval-i.pitches[0];if(j.prevSlideStart&&(A+=t*j.prevSlideRatioStart),j.prevSlideEnd&&(z+=t*j.prevSlideRatioEnd),!f.singleTone){const t=e.pitches.length-i.chordSize;j.prevSlideStart&&(E=xe.computeChordExpression(i.chordSize+t*j.prevSlideRatioStart)),j.prevSlideEnd&&(H=xe.computeChordExpression(i.chordSize+t*j.prevSlideRatioEnd))}}if(null!=t){const e=t.pitches[i.nextNotePitchIndex]-(i.pitches[0]+i.note.pins[i.note.pins.length-1].interval);if(j.nextSlideStart&&(A+=e*j.nextSlideRatioStart),j.nextSlideEnd&&(z+=e*j.nextSlideRatioEnd),!f.singleTone){const e=t.pitches.length-i.chordSize;j.nextSlideStart&&(E=xe.computeChordExpression(i.chordSize+e*j.nextSlideRatioStart)),j.nextSlideEnd&&(H=xe.computeChordExpression(i.chordSize+e*j.nextSlideRatioEnd))}}}if(x(h.effects)){let e=p.justIntonationSemitones[h.pitchShift]/v,s=1,n=1;this.isModActive(p.modulators.dictionary["pitch shift"].index,t,i.instrumentIndex)&&(e=p.justIntonationSemitones[p.justIntonationSemitones.length-1],s=this.getModValue(p.modulators.dictionary["pitch shift"].index,t,i.instrumentIndex,!1)/p.pitchShiftCenter,n=this.getModValue(p.modulators.dictionary["pitch shift"].index,t,i.instrumentIndex,!0)/p.pitchShiftCenter);A+=e*Y[18]*s,z+=e*K[18]*n}if(k(h.effects)||this.isModActive(p.modulators.dictionary["song detune"].index,t,i.instrumentIndex)){const e=Y[19],s=K[19];let n=h.detune,a=h.detune;this.isModActive(p.modulators.dictionary.detune.index,t,i.instrumentIndex)&&(n=this.getModValue(p.modulators.dictionary.detune.index,t,i.instrumentIndex,!1)+p.detuneCenter,a=this.getModValue(p.modulators.dictionary.detune.index,t,i.instrumentIndex,!0)+p.detuneCenter),this.isModActive(p.modulators.dictionary["song detune"].index,t,i.instrumentIndex)&&(n+=4*this.getModValue(p.modulators.dictionary["song detune"].index,t,i.instrumentIndex,!1),a+=4*this.getModValue(p.modulators.dictionary["song detune"].index,t,i.instrumentIndex,!0)),A+=xe.detuneToCents(n)*e*p.pitchesPerOctave/1200,z+=xe.detuneToCents(a)*s*p.pitchesPerOctave/1200}if(F(h.effects)){let e,s,n,a;if(h.vibrato==p.vibratos.length?(e=2*h.vibratoDelay,h.vibratoDelay==p.modulators.dictionary["vibrato delay"].maxRawVol&&(e=Number.POSITIVE_INFINITY),s=h.vibratoDepth,n=s):(e=p.vibratos[h.vibrato].delayTicks,s=p.vibratos[h.vibrato].amplitude,n=s),this.isModActive(p.modulators.dictionary["vibrato delay"].index,t,i.instrumentIndex)&&(e=2*this.getModValue(p.modulators.dictionary["vibrato delay"].index,t,i.instrumentIndex,!1),e==2*p.modulators.dictionary["vibrato delay"].maxRawVol&&(e=Number.POSITIVE_INFINITY)),this.isModActive(p.modulators.dictionary["vibrato depth"].index,t,i.instrumentIndex)&&(s=this.getModValue(p.modulators.dictionary["vibrato depth"].index,t,i.instrumentIndex,!1)/25,n=this.getModValue(p.modulators.dictionary["vibrato depth"].index,t,i.instrumentIndex,!0)/25),null!=i.prevVibrato)a=i.prevVibrato;else{if(a=s*xe.getLFOAmplitude(h,g*c.vibratoTime)*Y[20],e>0){const t=e-j.noteTicksStart;a*=Math.max(0,Math.min(1,1-t/2))}}let o=xe.getLFOAmplitude(h,g*c.nextVibratoTime);const r=K[20];if(11!=h.type){let t=n*o*r;if(e>0){const s=e-j.noteTicksEnd;t*=Math.max(0,Math.min(1,1-s/2))}i.prevVibrato=t,A+=a,z+=t}}if(!u.isSeamless&&!i.forceContinueAtStart||null==i.prevNote){const e=h.getFadeInSeconds();e>0&&(C*=Math.min(1,j.noteSecondsStartUnscaled/e),R*=Math.min(1,j.noteSecondsEndUnscaled/e))}4==h.type&&null==i.drumsetPitch&&(i.drumsetPitch=i.pitches[0],null!=i.note&&(i.drumsetPitch+=i.note.pickMainInterval()),i.drumsetPitch=Math.max(0,Math.min(p.drumCount-1,i.drumsetPitch)));let J=j.lowpassCutoffDecayVolumeCompensation;if(P(h.effects)){const e=Y[1],t=K[1];if(h.noteFilterType){const s=Y[21],n=K[21],a=Y[29],r=K[29];V.toCoefficients(xe.tempFilterStartCoefficients,this.samplesPerSecond,e*s,a),$.toCoefficients(xe.tempFilterEndCoefficients,this.samplesPerSecond,t*n,r),i.noteFilters.length<1&&(i.noteFilters[0]=new G),i.noteFilters[0].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterEndCoefficients,1/o,0==V.type),J*=V.getVolumeCompensationMult(),i.noteFilterCount=1}else{const s=null!=h.tmpNoteFilterStart?h.tmpNoteFilterStart:h.noteFilter;for(let n=0;n<s.controlPointCount;n++){const a=Y[21+n],r=K[21+n],l=Y[29+n],p=K[29+n];let c=s.controlPoints[n];const u=null!=h.tmpNoteFilterEnd&&null!=h.tmpNoteFilterEnd.controlPoints[n]?h.tmpNoteFilterEnd.controlPoints[n]:s.controlPoints[n];c.type!=u.type&&(c=u),c.toCoefficients(xe.tempFilterStartCoefficients,this.samplesPerSecond,e*a,l),u.toCoefficients(xe.tempFilterEndCoefficients,this.samplesPerSecond,t*r,p),i.noteFilters.length<=n&&(i.noteFilters[n]=new G),i.noteFilters[n].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterEndCoefficients,1/o,0==c.type),J*=c.getVolumeCompensationMult()}i.noteFilterCount=s.controlPointCount}}else i.noteFilterCount=0;if(4==h.type){const e=h.getDrumsetEnvelope(i.drumsetPitch);J*=be.getLowpassCutoffDecayVolumeCompensation(e);let t=be.computeEnvelope(e,j.noteSecondsStart,M*q,j.noteSizeStart);if(j.prevSlideStart){t+=(be.computeEnvelope(e,j.prevNoteSecondsStart,M*q,j.prevNoteSize)-t)*j.prevSlideRatioStart}if(j.nextSlideStart){t+=(be.computeEnvelope(e,0,M*q,j.nextNoteSize)-t)*j.nextSlideRatioStart}let s=t;if(0==h.discreteEnvelope){if(s=be.computeEnvelope(e,j.noteSecondsEnd,M*I,j.noteSizeEnd),j.prevSlideEnd){s+=(be.computeEnvelope(e,j.prevNoteSecondsEnd,M*I,j.prevNoteSize)-s)*j.prevSlideRatioEnd}if(j.nextSlideEnd){s+=(be.computeEnvelope(e,0,M*I,j.nextNoteSize)-s)*j.nextSlideRatioEnd}}const n=this.tempDrumSetControlPoint;n.type=0,n.gain=ue.getRoundedSettingValueFromLinearGain(.5),n.freq=ue.getRoundedSettingValueFromHz(8e3),n.toCoefficients(xe.tempFilterStartCoefficients,this.samplesPerSecond,t*(1+t),1),n.toCoefficients(xe.tempFilterEndCoefficients,this.samplesPerSecond,s*(1+s),1),i.noteFilters.length==i.noteFilterCount&&(i.noteFilters[i.noteFilterCount]=new G),i.noteFilters[i.noteFilterCount].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterEndCoefficients,1/o,!0),i.noteFilterCount++}if(J=Math.min(3,J),1==h.type||12==h.type){let e=1,s=0,n=0;const a=f.arpeggiates;if(i.pitchCount>1&&a){const e=Math.floor(c.arpTime/p.ticksPerArpeggio);n=i.pitches[b(i.pitchCount,h.fastTwoNoteArp,e)]-i.pitches[0]}const r=12==h.type?h.customAlgorithm.carrierCount:p.algorithms[h.algorithm].carrierCount;for(let l=0;l<(12==h.type?6:p.operatorCount);l++){const c=12==h.type?h.customAlgorithm.associatedCarrier[l]-1:p.algorithms[h.algorithm].associatedCarrier[l]-1,u=i.pitches[a?0:l<i.pitchCount?l:c<i.pitchCount?c:0],f=p.operatorFrequencies[h.operators[l].frequency].mult,m=p.operatorCarrierInterval[c]+n,d=N+(u+A)*v+m,y=N+(u+z)*v+m,g=de.frequencyFromPitch(d),b=de.frequencyFromPitch(y),M=p.operatorFrequencies[h.operators[l].frequency].hzOffset,w=f*g+M,x=f*b+M,k=Y[5+l],F=K[5+l];let P,q;1!=k||1!=F?(P=Math.pow(2,Math.log2(w/g)*k)*g,q=Math.pow(2,Math.log2(x/b)*F)*b):(P=w,q=x),i.phaseDeltas[l]=P*S,i.phaseDeltaScales[l]=Math.pow(q/P,1/o);let I=h.operators[l].amplitude,T=h.operators[l].amplitude;l<4?this.isModActive(p.modulators.dictionary["fm slider 1"].index+l,t,i.instrumentIndex)&&(I*=this.getModValue(p.modulators.dictionary["fm slider 1"].index+l,t,i.instrumentIndex,!1)/15,T*=this.getModValue(p.modulators.dictionary["fm slider 1"].index+l,t,i.instrumentIndex,!0)/15):this.isModActive(p.modulators.dictionary["fm slider 5"].index+l-4,t,i.instrumentIndex)&&(I*=this.getModValue(p.modulators.dictionary["fm slider 5"].index+l-4,t,i.instrumentIndex,!1)/15,T*=this.getModValue(p.modulators.dictionary["fm slider 5"].index+l-4,t,i.instrumentIndex,!0)/15);const D=xe.operatorAmplitudeCurve(I),O=xe.operatorAmplitudeCurve(T);let C=D*p.operatorFrequencies[h.operators[l].frequency].amplitudeSign,R=O*p.operatorFrequencies[h.operators[l].frequency].amplitudeSign;if(l<r){let e;e=null!=i.prevPitchExpressions[l]?i.prevPitchExpressions[l]:Math.pow(2,-(d-L)/B);const t=Math.pow(2,-(y-L)/B);i.prevPitchExpressions[l]=t,C*=e,R*=t,s+=O}else C*=1.5*p.sineWaveLength,R*=1.5*p.sineWaveLength,e*=1-Math.min(1,h.operators[l].amplitude/15);if(C*=Y[11+l],R*=K[11+l],this.isModActive(p.modulators.dictionary["note volume"].index,t,i.instrumentIndex)){const e=this.getModValue(p.modulators.dictionary["note volume"].index,t,i.instrumentIndex,!1),s=this.getModValue(p.modulators.dictionary["note volume"].index,t,i.instrumentIndex,!0);C*=e<=0?(e+p.volumeRange/2)/(p.volumeRange/2):xe.instrumentVolumeToVolumeMult(e),R*=s<=0?(s+p.volumeRange/2)/(p.volumeRange/2):xe.instrumentVolumeToVolumeMult(s)}i.operatorExpressions[l]=C,i.operatorExpressionDeltas[l]=(R-C)/o}e*=(Math.pow(2,2-1.4*h.feedbackAmplitude/15)-1)/3,e*=1-Math.min(1,Math.max(0,s-1)/2),e=1+3*e;const l=W*e*J*C*E*Y[0],u=W*e*J*R*H*K[0];i.expression=l,i.expressionDelta=(u-l)/o;let m=h.feedbackAmplitude,d=h.feedbackAmplitude;this.isModActive(p.modulators.dictionary["fm feedback"].index,t,i.instrumentIndex)&&(m*=this.getModValue(p.modulators.dictionary["fm feedback"].index,t,i.instrumentIndex,!1)/15,d*=this.getModValue(p.modulators.dictionary["fm feedback"].index,t,i.instrumentIndex,!0)/15);let y=.3*p.sineWaveLength*m/15;const g=.3*p.sineWaveLength*d/15;let M=y*Y[17],w=g*K[17];i.feedbackMult=M,i.feedbackDelta=(w-M)/o}else{const e=Math.pow(2,(z-A)*v/12),s=Math.pow(e,1/o);let n=i.pitches[0];if(i.pitchCount>1&&(f.arpeggiates||f.customInterval)){const e=Math.floor(c.arpTime/p.ticksPerArpeggio);if(f.customInterval){const t=i.pitches[1+b(i.pitchCount-1,h.fastTwoNoteArp,e)]-i.pitches[0];D=Math.pow(2,t/12),i.specialIntervalExpressionMult=Math.pow(2,-t/B)}else n=i.pitches[b(i.pitchCount,h.fastTwoNoteArp,e)]}const a=N+(n+A)*v,r=N+(n+z)*v;let l;l=null!=i.prevPitchExpressions[0]?i.prevPitchExpressions[0]:Math.pow(2,-(a-L)/B);const d=Math.pow(2,-(r-L)/B);i.prevPitchExpressions[0]=d;let y=W*J;if(2==h.type&&(y*=p.chipNoises[h.chipNoise].expression),0==h.type&&(y*=p.chipWaves[h.chipWave].expression),6==h.type){const e=m(h.pulseWidth);let s=e,n=e;this.isModActive(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex)&&(s=this.getModValue(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!1)/(2*p.pulseWidthRange),n=this.getModValue(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!0)/(2*p.pulseWidthRange));const a=s*Y[2],r=n*K[2];i.pulseWidth=a,i.pulseWidthDelta=(r-a)/o;let l=h.decimalOffset;this.isModActive(p.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex)&&(l=this.getModValue(p.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex,!1));const c=l*Y[37];i.decimalOffset=c,i.pulseWidth-=i.decimalOffset/1e4}if(7==h.type){const e=m(h.dutyCycleSequence[Math.floor(c.dutyCycleTime)]);let s=e,n=e;this.isModActive(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex)&&(s=this.getModValue(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!1)/(2*p.pulseWidthRange),n=this.getModValue(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!0)/(2*p.pulseWidthRange));const a=s*Y[2],r=n*K[2];i.pulseWidth=a,i.pulseWidthDelta=(r-a)/o;let l=h.decimalOffset;this.isModActive(p.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex)&&(l=this.getModValue(p.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex,!1));const u=l*Y[37];i.decimalOffset=u,i.pulseWidth-=i.decimalOffset/1e4}if(8==h.type){let e=h.stringSustain,s=h.stringSustain;this.isModActive(p.modulators.dictionary.sustain.index,t,i.instrumentIndex)&&(e=this.getModValue(p.modulators.dictionary.sustain.index,t,i.instrumentIndex,!1),s=this.getModValue(p.modulators.dictionary.sustain.index,t,i.instrumentIndex,!0)),i.stringSustainStart=e,i.stringSustainEnd=s,y*=Math.pow(2,.7*(1-e/(p.stringSustainRange-1)))}const g=de.frequencyFromPitch(a);if(0==h.type||10==h.type||5==h.type||8==h.type||3==h.type||6==h.type||7==h.type||2==h.type){const e=h.unisonVoices,t=h.unisonSpread,n=h.unisonOffset;y*=h.unisonExpression*(8==h.type?1:e/2);const a=Y[4],r=K[4],l=Math.pow(2,(n+t)*a/12),p=Math.pow(2,(n+t)*r/12),c=Math.pow(2,(n-t)*a/12)*D,u=Math.pow(2,(n-t)*r/12)*D;i.phaseDeltas[0]=g*S*l,i.phaseDeltas[1]=g*S*c,i.phaseDeltaScales[0]=s*Math.pow(p/l,1/o),i.phaseDeltaScales[1]=s*Math.pow(u/c,1/o)}else i.phaseDeltas[0]=g*S,i.phaseDeltaScales[0]=s;let M=1,w=1;if(9==h.type){const s=1/Math.sqrt(p.supersawVoiceCount);let n=h.supersawDynamism/p.supersawDynamismMax,a=h.supersawDynamism/p.supersawDynamismMax;this.isModActive(p.modulators.dictionary.dynamism.index,t,i.instrumentIndex)&&(n=this.getModValue(p.modulators.dictionary.dynamism.index,t,i.instrumentIndex,!1)/p.supersawDynamismMax,a=this.getModValue(p.modulators.dictionary.dynamism.index,t,i.instrumentIndex,!0)/p.supersawDynamismMax);const r=1-Math.pow(Math.max(0,1-n*Y[38]),.2),l=1-Math.pow(Math.max(0,1-a*K[38]),.2),c=Math.pow(2,Math.log2(s)*r),u=Math.pow(2,Math.log2(s)*l),f=Math.sqrt((1/Math.pow(c,2)-1)/(p.supersawVoiceCount-1)),d=Math.sqrt((1/Math.pow(u,2)-1)/(p.supersawVoiceCount-1));i.supersawDynamism=f,i.supersawDynamismDelta=(d-f)/o;const y=-1==i.supersawDelayIndex;if(y){let e=0;for(let t=0;t<p.supersawVoiceCount;t++)i.phases[t]=e,e+=-Math.log(Math.random());const t=1+(p.supersawVoiceCount-1)*f;let s=0;for(let t=0;t<p.supersawVoiceCount;t++){const n=0==t?1:f,a=i.phases[t]/e;i.phases[t]=a,s+=(a-.5)*n}let n=1,a=0;for(let e=p.supersawVoiceCount-1;e>=0;e--){const o=1-i.phases[e],r=o-a;if(s<0){const e=-s/t;if(e<r){n=a+e;break}}s+=r*t-(0==e?1:f),a=o}for(let e=0;e<p.supersawVoiceCount;e++)i.phases[e]+=n;for(let e=1;e<p.supersawVoiceCount-1;e++){const t=e+Math.floor(Math.random()*(p.supersawVoiceCount-e)),s=i.phases[e];i.phases[e]=i.phases[t],i.phases[t]=s}}const v=h.supersawSpread/p.supersawSpreadMax;let b=v,x=v;this.isModActive(p.modulators.dictionary.spread.index,t,i.instrumentIndex)&&(b=this.getModValue(p.modulators.dictionary.spread.index,t,i.instrumentIndex,!1)/p.supersawSpreadMax,x=this.getModValue(p.modulators.dictionary.spread.index,t,i.instrumentIndex,!0)/p.supersawSpreadMax);const k=.5*(b*Y[39]+x*K[39]),F=Math.pow(1-Math.sqrt(Math.max(0,1-k)),1.75);for(let e=0;e<p.supersawVoiceCount;e++){const t=0==e?0:Math.pow(((e+1>>1)-.5+.025*((2&e)-1))/(p.supersawVoiceCount>>1),1.1)*(2*(1&e)-1);i.supersawUnisonDetunes[e]=Math.pow(2,F*t/12)}const P=h.supersawShape/p.supersawShapeMax;let q=P*Y[40],I=P*K[40];this.isModActive(p.modulators.dictionary["saw shape"].index,t,i.instrumentIndex)&&(q=this.getModValue(p.modulators.dictionary["saw shape"].index,t,i.instrumentIndex,!1)/p.supersawShapeMax,I=this.getModValue(p.modulators.dictionary["saw shape"].index,t,i.instrumentIndex,!0)/p.supersawShapeMax);const T=q*Y[40],D=I*K[40];i.supersawShape=T,i.supersawShapeDelta=(D-T)/o;let O=h.decimalOffset;this.isModActive(p.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex)&&(O=this.getModValue(p.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex,!1));const A=O*Y[37];i.decimalOffset=A;const z=m(h.pulseWidth);let C=z,R=z;this.isModActive(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex)&&(C=this.getModValue(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!1)/(2*p.pulseWidthRange),R=this.getModValue(p.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!0)/(2*p.pulseWidthRange));let E=C*Y[2],H=R*K[2];E-=A/1e4,H-=A/1e4;const L=null!=i.supersawPrevPhaseDelta?i.supersawPrevPhaseDelta:g*S,N=g*S*e;i.supersawPrevPhaseDelta=N;const W=E/L,G=H/N;i.supersawDelayLength=W,i.supersawDelayLengthDelta=(G-W)/o;const B=Math.ceil(Math.max(W,G))+2;if(null==i.supersawDelayLine||i.supersawDelayLine.length<=B){const e=Math.ceil(.5*this.samplesPerSecond/de.frequencyFromPitch(24)),t=new Float32Array(xe.fittingPowerOfTwo(Math.max(e,B)));if(!y&&null!=i.supersawDelayLine){const e=i.supersawDelayLine.length-1>>0,s=i.supersawDelayIndex;for(let n=0;n<i.supersawDelayLine.length;n++)t[n]=i.supersawDelayLine[s+n&e]}i.supersawDelayLine=t,i.supersawDelayIndex=i.supersawDelayLine.length}else y&&(i.supersawDelayLine.fill(0),i.supersawDelayIndex=i.supersawDelayLine.length);const V=p.pwmBaseExpression/p.supersawBaseExpression;M*=(1+(V-1)*T)/Math.sqrt(1+(p.supersawVoiceCount-1)*f*f),w*=(1+(V-1)*D)/Math.sqrt(1+(p.supersawVoiceCount-1)*d*d)}let x=y*C*E*l*Y[0]*M,k=y*R*H*d*K[0]*w;if(this.isModActive(p.modulators.dictionary["note volume"].index,t,i.instrumentIndex)){const e=this.getModValue(p.modulators.dictionary["note volume"].index,t,i.instrumentIndex,!1),s=this.getModValue(p.modulators.dictionary["note volume"].index,t,i.instrumentIndex,!0);x*=e<=0?(e+p.volumeRange/2)/(p.volumeRange/2):xe.instrumentVolumeToVolumeMult(e),k*=s<=0?(s+p.volumeRange/2)/(p.volumeRange/2):xe.instrumentVolumeToVolumeMult(s)}if(i.expression=x,i.expressionDelta=(k-x)/o,8==h.type){let e;if(null!=i.prevStringDecay)e=i.prevStringDecay;else{const t=i.envelopeComputer.envelopeStarts[3];e=1-Math.min(1,t*i.stringSustainStart/(p.stringSustainRange-1))}const t=i.envelopeComputer.envelopeEnds[3];let s=1-Math.min(1,t*i.stringSustainEnd/(p.stringSustainRange-1));i.prevStringDecay=s;const n=h.unisonVoices;for(let e=i.pickedStrings.length;e<n;e++)i.pickedStrings[e]=new ge;if(i.atNoteStart&&!u.continues&&!i.forceContinueAtStart)for(const e of i.pickedStrings)e.delayIndex=-1;for(let t=0;t<n;t++)i.pickedStrings[t].update(this,c,i,t,o,e,s,h.stringSustainType)}}}static getLFOAmplitude(e,t){let s=0;for(const i of p.vibratoTypes[e.vibratoType].periodsSeconds)s+=Math.sin(2*Math.PI*t/i);return s}static getInstrumentSynthFunction(e){if(1==e.type){const t=e.algorithm+"_"+e.feedbackType;if(null==xe.fmSynthFunctionCache[t]){const s=[];for(const t of xe.fmSourceTemplate)if(-1!=t.indexOf("// CARRIER OUTPUTS")){const i=[];for(let t=0;t<p.algorithms[e.algorithm].carrierCount;t++)i.push("operator"+t+"Scaled");s.push(t.replace("/*operator#Scaled*/",i.join(" + ")))}else if(-1!=t.indexOf("// INSERT OPERATOR COMPUTATION HERE"))for(let t=p.operatorCount-1;t>=0;t--)for(const i of xe.operatorSourceTemplate)if(-1!=i.indexOf("/* + operator@Scaled*/")){let n="";for(const s of p.algorithms[e.algorithm].modulatedBy[t])n+=" + operator"+(s-1)+"Scaled";const a=p.feedbacks[e.feedbackType].indices[t];if(a.length>0){n+=" + feedbackMult * (";const e=[];for(const t of a)e.push("operator"+(t-1)+"Output");n+=e.join(" + ")+")"}s.push(i.replace(/\#/g,t+"").replace("/* + operator@Scaled*/",n))}else s.push(i.replace(/\#/g,t+""));else if(-1!=t.indexOf("#"))for(let e=0;e<p.operatorCount;e++)s.push(t.replace(/\#/g,e+""));else s.push(t);const i="return (synth, bufferIndex, roundedSamplesPerTick, tone, instrument) => {"+s.join("\n")+"}";xe.fmSynthFunctionCache[t]=new Function("Config","Synth",i)(p,xe)}return xe.fmSynthFunctionCache[t]}if(0==e.type)return e.isUsingAdvancedLoopControls?xe.loopableChipSynth:xe.chipSynth;if(10==e.type)return xe.chipSynth;if(5==e.type)return xe.harmonicsSynth;if(6==e.type)return xe.pulseWidthSynth;if(7==e.type)return xe.pulseWidthSynth;if(9==e.type)return xe.supersawSynth;if(8==e.type)return xe.pickedStringSynth;if(2==e.type)return xe.noiseSynth;if(3==e.type)return xe.spectrumSynth;if(4==e.type)return xe.drumsetSynth;if(11==e.type)return xe.modSynth;if(12==e.type){const t=e.customAlgorithm.name+"_"+e.customFeedbackType.name;if(null==xe.fm6SynthFunctionCache[t]){const s=[];for(const t of xe.fmSourceTemplate)if(-1!=t.indexOf("// CARRIER OUTPUTS")){const i=[];for(let t=0;t<e.customAlgorithm.carrierCount;t++)i.push("operator"+t+"Scaled");s.push(t.replace("/*operator#Scaled*/",i.join(" + ")))}else if(-1!=t.indexOf("// INSERT OPERATOR COMPUTATION HERE"))for(let t=p.operatorCount+2-1;t>=0;t--)for(const i of xe.operatorSourceTemplate)if(-1!=i.indexOf("/* + operator@Scaled*/")){let n="";for(const s of e.customAlgorithm.modulatedBy[t])n+=" + operator"+(s-1)+"Scaled";const a=e.customFeedbackType.indices[t];if(a.length>0){n+=" + feedbackMult * (";const e=[];for(const t of a)e.push("operator"+(t-1)+"Output");n+=e.join(" + ")+")"}s.push(i.replace(/\#/g,t+"").replace("/* + operator@Scaled*/",n))}else s.push(i.replace(/\#/g,t+""));else if(-1!=t.indexOf("#"))for(let e=0;e<p.operatorCount+2;e++)s.push(t.replace(/\#/g,e+""));else s.push(t);const i="return (synth, bufferIndex, roundedSamplesPerTick, tone, instrument) => {"+s.join("\n")+"}";xe.fm6SynthFunctionCache[t]=new Function("Config","Synth",i)(p,xe)}return xe.fm6SynthFunctionCache[t]}throw new Error("Unrecognized instrument type: "+e.type)}static wrap(e,t){return(e%t+t)%t}static loopableChipSynth(e,t,s,i,n){const a=q(n.effects)&&n.aliases,o=e.tempMonoInstrumentSampleBuffer,r=n.wave,l=n.volumeScale,h=a&&8==n.type?r.length:r.length-1;let p=Math.max(0,Math.min(h,n.chipWaveLoopEnd)),c=Math.max(0,Math.min(p-1,n.chipWaveLoopStart)),u=p-c;u<2&&(c=0,p=h,u=h);const f=n.chipWaveLoopMode,m=n.chipWavePlayBackwards,d=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let y=i.phaseDeltas[0]*h,v=i.phaseDeltas[1]*h,g=i.directions[0],b=i.directions[1],S=i.chipWaveCompletions[0],M=i.chipWaveCompletions[1];3!==f&&2!==f&&0!==f||(m?(g=-1,b=-1):(g=1,b=1)),0!==f&&1!==f||(S=0,M=0);let w=i.chipWaveCompletionsLastWave[0],x=i.chipWaveCompletionsLastWave[1];const k=1e3,F=+i.phaseDeltaScales[0],P=+i.phaseDeltaScales[1];let I=+i.expression;const T=+i.expressionDelta;let D=xe.wrap(i.phases[0],1)*h,O=xe.wrap(i.phases[1],1)*h,A=0,z=0;if(!a){const e=Math.floor(D),t=Math.floor(O),s=xe.wrap(e,h),i=xe.wrap(t,h),n=D-e,a=O-t;A=+r[s],z=+r[i],A+=(r[xe.wrap(s+1,h)]-A)*n,z+=(r[xe.wrap(i+1,h)]-z)*a}const C=i.noteFilters,R=0|i.noteFilterCount;let E=+i.initialNoteFilterInput1,H=+i.initialNoteFilterInput2;const L=xe.applyFilters,N=t+s;let W=i.chipWavePrevWaves[0],G=i.chipWavePrevWaves[1];for(let e=t;e<N;e++){S>0&&S<k&&S++,M>0&&M<k&&M++;let t=0;D+=y*g,O+=v*b,2===f?(1===g?D>h&&(S<=0&&(w=W,S++),t=1):-1===g&&D<0&&(S<=0&&(w=W,S++),t=1),1===b?O>h&&(M<=0&&(x=G,M++),t=1):-1===g&&O<0&&(M<=0&&(x=G,M++),t=1)):3===f?(1===g?D>p&&(S<=0&&(w=W,S++),t=1):-1===g&&D<c&&(S<=0&&(w=W,S++),t=1),1===b?O>p&&(M<=0&&(x=G,M++),t=1):-1===g&&O<c&&(M<=0&&(x=G,M++),t=1)):0===f?(1===g?D>p&&(D=c+xe.wrap(D-p,u),t=1):-1===g&&D<c&&(D=p-xe.wrap(c-D,u),t=1),1===b?O>p&&(O=c+xe.wrap(O-p,u),t=1):-1===b&&O<c&&(O=p-xe.wrap(c-O,u),t=1)):1===f&&(1===g?D>p&&(D=p-xe.wrap(D-p,u),g=-1,t=1):-1===g&&D<c&&(D=c+xe.wrap(c-D,u),g=1,t=1),1===b?O>p&&(O=p-xe.wrap(O-p,u),b=-1,t=1):-1===b&&O<c&&(O=c+xe.wrap(c-O,u),b=1,t=1));let s=0,i=0,n=0;if(a){s=r[xe.wrap(Math.floor(D),h)],i=r[xe.wrap(Math.floor(O),h)],W=s,G=i;const e=S>0?(k-Math.min(S,k))/k:1,t=M>0?(k-Math.min(M,k))/k:1;n=0,n+=S>0?w*e:s,n+=M>0?x*t:i}else{const e=Math.floor(D),a=Math.floor(O),o=xe.wrap(e,h),l=xe.wrap(a,h);let u=r[o],m=r[l];const F=D-e,P=O-a;if(u+=(r[xe.wrap(o+1,h)]-u)*F,m+=(r[xe.wrap(l+1,h)]-m)*P,(0!==f||0!==c||p!==h)&&0!==t){let e=0,t=0;const s=Math.max(0,D-y*g),i=Math.max(0,O-v*b),n=Math.floor(s),a=Math.floor(i),o=xe.wrap(n,h),l=xe.wrap(a,h);e=r[o],t=r[l],e+=(r[xe.wrap(o+1,h)]-e)*(s-n)*g,t+=(r[xe.wrap(l+1,h)]-t)*(i-a)*b,A=e,z=t}1===f&&0!==t?(s=W,i=G):(s=(u-A)/(y*g),i=(m-z)/(v*b)),W=s,G=i,A=u,z=m;const q=S>0?(k-Math.min(S,k))/k:1,I=M>0?(k-Math.min(M,k))/k:1;n+=S>0?w*q:s,n+=M>0?x*I:i*d}const m=L(n*l,E,H,R,C);H=E,E=n*l,y*=F,v*=P;const q=m*I;I+=T,o[e]+=q}i.phases[0]=D/h,i.phases[1]=O/h,i.phaseDeltas[0]=y/h,i.phaseDeltas[1]=v/h,i.directions[0]=g,i.directions[1]=b,i.chipWaveCompletions[0]=S,i.chipWaveCompletions[1]=M,i.chipWavePrevWaves[0]=W,i.chipWavePrevWaves[1]=G,i.chipWaveCompletionsLastWave[0]=w,i.chipWaveCompletionsLastWave[1]=x,i.expression=I,e.sanitizeFilters(C),i.initialNoteFilterInput1=E,i.initialNoteFilterInput2=H}static chipSynth(e,t,s,i,n){const a=q(n.effects)&&n.aliases,o=e.tempMonoInstrumentSampleBuffer,r=n.wave,l=n.volumeScale,h=a&&8==n.type?r.length:r.length-1,p=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let c=i.phaseDeltas[0]*h,u=i.phaseDeltas[1]*h;const f=+i.phaseDeltaScales[0],m=+i.phaseDeltaScales[1];let d=+i.expression;const y=+i.expressionDelta;let v=i.phases[0]%1*h,g=i.phases[1]%1*h;const b=i.noteFilters,S=0|i.noteFilterCount;let M=+i.initialNoteFilterInput1,w=+i.initialNoteFilterInput2;const x=xe.applyFilters;let k=0,F=0;if(!a){const e=0|v,t=0|g,s=e%h,i=t%h,n=v-e,a=g-t;k=+r[s],F=+r[i],k+=(r[s+1]-k)*n,F+=(r[i+1]-F)*a}const P=t+s;for(let e=t;e<P;e++){let t,s,i;if(v+=c,g+=u,a)t=r[(0|v)%h],s=r[(0|g)%h],i=t+s;else{const e=0|v,n=0|g,a=e%h,o=n%h;let l=r[a],f=r[o];const m=v-e,d=g-n;l+=(r[a+1]-l)*m,f+=(r[o+1]-f)*d,t=(l-k)/c,s=(f-F)/u,k=l,F=f,i=t+s*p}const n=x(i*l,M,w,S,b);w=M,M=i*l,c*=f,u*=m;const P=n*d;d+=y,o[e]+=P}i.phases[0]=v/h,i.phases[1]=g/h,i.phaseDeltas[0]=c/h,i.phaseDeltas[1]=u/h,i.expression=d,e.sanitizeFilters(b),i.initialNoteFilterInput1=M,i.initialNoteFilterInput2=w}static harmonicsSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer,o=n.wave,r=o.length-1,l=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let h=i.phaseDeltas[0]*r,p=i.phaseDeltas[1]*r;const c=+i.phaseDeltaScales[0],u=+i.phaseDeltaScales[1];let f=+i.expression;const m=+i.expressionDelta;let d=i.phases[0]%1*r,y=i.phases[1]%1*r;const v=i.noteFilters,g=0|i.noteFilterCount;let b=+i.initialNoteFilterInput1,S=+i.initialNoteFilterInput2;const M=xe.applyFilters,w=0|d,x=0|y,k=w%r,F=x%r,P=d-w,q=y-x;let I=+o[k],T=+o[F];I+=(o[k+1]-I)*P,T+=(o[F+1]-T)*q;const D=t+s;for(let e=t;e<D;e++){d+=h,y+=p;const t=0|d,s=0|y,i=t%r,n=s%r;let w=o[i],x=o[n];const k=d-t,F=y-s;w+=(o[i+1]-w)*k,x+=(o[n+1]-x)*F;const P=(w-I)/h,q=(x-T)/p;I=w,T=x;const D=P+q*l,O=M(D,b,S,g,v);S=b,b=D,h*=c,p*=u;const A=O*f;f+=m,a[e]+=A}i.phases[0]=d/r,i.phases[1]=y/r,i.phaseDeltas[0]=h/r,i.phaseDeltas[1]=p/r,i.expression=f,e.sanitizeFilters(v),i.initialNoteFilterInput1=b,i.initialNoteFilterInput2=S}static pickedStringSynth(e,t,s,i,n){const a=n.unisonVoices;let o=xe.pickedStringFunctionCache[a];if(null==o){let e="return (synth, bufferIndex, runLength, tone, instrumentState) => {";e+="\n\t\t\t\tconst Config = beepbox.Config;\n\t\t\t\tconst Synth = beepbox.Synth;\n\t\t\t\tconst data = synth.tempMonoInstrumentSampleBuffer;\n\t\t\t\t\n\t\t\t\tlet pickedString# = tone.pickedStrings[#];\n\t\t\t\tlet allPassSample# = +pickedString#.allPassSample;\n\t\t\t\tlet allPassPrevInput# = +pickedString#.allPassPrevInput;\n\t\t\t\tlet sustainFilterSample# = +pickedString#.sustainFilterSample;\n\t\t\t\tlet sustainFilterPrevOutput2# = +pickedString#.sustainFilterPrevOutput2;\n\t\t\t\tlet sustainFilterPrevInput1# = +pickedString#.sustainFilterPrevInput1;\n\t\t\t\tlet sustainFilterPrevInput2# = +pickedString#.sustainFilterPrevInput2;\n\t\t\t\tlet fractionalDelaySample# = +pickedString#.fractionalDelaySample;\n\t\t\t\tconst delayLine# = pickedString#.delayLine;\n\t\t\t\tconst delayBufferMask# = (delayLine#.length - 1) >> 0;\n\t\t\t\tlet delayIndex# = pickedString#.delayIndex|0;\n\t\t\t\tdelayIndex# = (delayIndex# & delayBufferMask#) + delayLine#.length;\n\t\t\t\tlet delayLength# = +pickedString#.prevDelayLength;\n\t\t\t\tconst delayLengthDelta# = +pickedString#.delayLengthDelta;\n\t\t\t\tlet allPassG# = +pickedString#.allPassG;\n\t\t\t\tlet sustainFilterA1# = +pickedString#.sustainFilterA1;\n\t\t\t\tlet sustainFilterA2# = +pickedString#.sustainFilterA2;\n\t\t\t\tlet sustainFilterB0# = +pickedString#.sustainFilterB0;\n\t\t\t\tlet sustainFilterB1# = +pickedString#.sustainFilterB1;\n\t\t\t\tlet sustainFilterB2# = +pickedString#.sustainFilterB2;\n\t\t\t\tconst allPassGDelta# = +pickedString#.allPassGDelta;\n\t\t\t\tconst sustainFilterA1Delta# = +pickedString#.sustainFilterA1Delta;\n\t\t\t\tconst sustainFilterA2Delta# = +pickedString#.sustainFilterA2Delta;\n\t\t\t\tconst sustainFilterB0Delta# = +pickedString#.sustainFilterB0Delta;\n\t\t\t\tconst sustainFilterB1Delta# = +pickedString#.sustainFilterB1Delta;\n\t\t\t\tconst sustainFilterB2Delta# = +pickedString#.sustainFilterB2Delta;\n\t\t\t\t\n\t\t\t\tlet expression = +tone.expression;\n\t\t\t\tconst expressionDelta = +tone.expressionDelta;\n\t\t\t\t\n\t\t\t\tconst unisonSign = tone.specialIntervalExpressionMult * instrumentState.unisonSign;\n\t\t\t\tconst delayResetOffset# = pickedString#.delayResetOffset|0;\n\t\t\t\t\n\t\t\t\tconst filters = tone.noteFilters;\n\t\t\t\tconst filterCount = tone.noteFilterCount|0;\n\t\t\t\tlet initialFilterInput1 = +tone.initialNoteFilterInput1;\n\t\t\t\tlet initialFilterInput2 = +tone.initialNoteFilterInput2;\n\t\t\t\tconst applyFilters = Synth.applyFilters;\n\t\t\t\t\n\t\t\t\tconst stopIndex = bufferIndex + runLength;\n\t\t\t\tfor (let sampleIndex = bufferIndex; sampleIndex < stopIndex; sampleIndex++) {\n\t\t\t\t\tconst targetSampleTime# = delayIndex# - delayLength#;\n\t\t\t\t\tconst lowerIndex# = (targetSampleTime# + 0.125) | 0; // Offset to improve stability of all-pass filter.\n\t\t\t\t\tconst upperIndex# = lowerIndex# + 1;\n\t\t\t\t\tconst fractionalDelay# = upperIndex# - targetSampleTime#;\n\t\t\t\t\tconst fractionalDelayG# = (1.0 - fractionalDelay#) / (1.0 + fractionalDelay#); // Inlined version of FilterCoefficients.prototype.allPass1stOrderFractionalDelay\n\t\t\t\t\tconst prevInput# = delayLine#[lowerIndex# & delayBufferMask#];\n\t\t\t\t\tconst input# = delayLine#[upperIndex# & delayBufferMask#];\n\t\t\t\t\tfractionalDelaySample# = fractionalDelayG# * input# + prevInput# - fractionalDelayG# * fractionalDelaySample#;\n\t\t\t\t\t\n\t\t\t\t\tallPassSample# = fractionalDelaySample# * allPassG# + allPassPrevInput# - allPassG# * allPassSample#;\n\t\t\t\t\tallPassPrevInput# = fractionalDelaySample#;\n\t\t\t\t\t\n\t\t\t\t\tconst sustainFilterPrevOutput1# = sustainFilterSample#;\n\t\t\t\t\tsustainFilterSample# = sustainFilterB0# * allPassSample# + sustainFilterB1# * sustainFilterPrevInput1# + sustainFilterB2# * sustainFilterPrevInput2# - sustainFilterA1# * sustainFilterSample# - sustainFilterA2# * sustainFilterPrevOutput2#;\n\t\t\t\t\tsustainFilterPrevOutput2# = sustainFilterPrevOutput1#;\n\t\t\t\t\tsustainFilterPrevInput2# = sustainFilterPrevInput1#;\n\t\t\t\t\tsustainFilterPrevInput1# = allPassSample#;\n\t\t\t\t\t\n\t\t\t\t\tdelayLine#[delayIndex# & delayBufferMask#] += sustainFilterSample#;\n\t\t\t\t\tdelayLine#[(delayIndex# + delayResetOffset#) & delayBufferMask#] = 0.0;\n\t\t\t\t\tdelayIndex#++;\n\t\t\t\t\t\n\t\t\t\t\tconst inputSample = (";const t=[];for(let e=0;e<a;e++)t.push("fractionalDelaySample"+e+(1==e?" * unisonSign":""));e+=t.join(" + "),e+=") * expression;\n\t\t\t\t\tconst sample = applyFilters(inputSample, initialFilterInput1, initialFilterInput2, filterCount, filters);\n\t\t\t\t\tinitialFilterInput2 = initialFilterInput1;\n\t\t\t\t\tinitialFilterInput1 = inputSample;\n\t\t\t\t\tdata[sampleIndex] += sample;\n\t\t\t\t\t\n\t\t\t\t\texpression += expressionDelta;\n\t\t\t\t\tdelayLength# += delayLengthDelta#;\n\t\t\t\t\tallPassG# += allPassGDelta#;\n\t\t\t\t\tsustainFilterA1# += sustainFilterA1Delta#;\n\t\t\t\t\tsustainFilterA2# += sustainFilterA2Delta#;\n\t\t\t\t\tsustainFilterB0# += sustainFilterB0Delta#;\n\t\t\t\t\tsustainFilterB1# += sustainFilterB1Delta#;\n\t\t\t\t\tsustainFilterB2# += sustainFilterB2Delta#;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Avoid persistent denormal or NaN values in the delay buffers and filter history.\n\t\t\t\tconst epsilon = (1.0e-24);\n\t\t\t\tif (!Number.isFinite(allPassSample#) || Math.abs(allPassSample#) < epsilon) allPassSample# = 0.0;\n\t\t\t\tif (!Number.isFinite(allPassPrevInput#) || Math.abs(allPassPrevInput#) < epsilon) allPassPrevInput# = 0.0;\n\t\t\t\tif (!Number.isFinite(sustainFilterSample#) || Math.abs(sustainFilterSample#) < epsilon) sustainFilterSample# = 0.0;\n\t\t\t\tif (!Number.isFinite(sustainFilterPrevOutput2#) || Math.abs(sustainFilterPrevOutput2#) < epsilon) sustainFilterPrevOutput2# = 0.0;\n\t\t\t\tif (!Number.isFinite(sustainFilterPrevInput1#) || Math.abs(sustainFilterPrevInput1#) < epsilon) sustainFilterPrevInput1# = 0.0;\n\t\t\t\tif (!Number.isFinite(sustainFilterPrevInput2#) || Math.abs(sustainFilterPrevInput2#) < epsilon) sustainFilterPrevInput2# = 0.0;\n\t\t\t\tif (!Number.isFinite(fractionalDelaySample#) || Math.abs(fractionalDelaySample#) < epsilon) fractionalDelaySample# = 0.0;\n\t\t\t\tpickedString#.allPassSample = allPassSample#;\n\t\t\t\tpickedString#.allPassPrevInput = allPassPrevInput#;\n\t\t\t\tpickedString#.sustainFilterSample = sustainFilterSample#;\n\t\t\t\tpickedString#.sustainFilterPrevOutput2 = sustainFilterPrevOutput2#;\n\t\t\t\tpickedString#.sustainFilterPrevInput1 = sustainFilterPrevInput1#;\n\t\t\t\tpickedString#.sustainFilterPrevInput2 = sustainFilterPrevInput2#;\n\t\t\t\tpickedString#.fractionalDelaySample = fractionalDelaySample#;\n\t\t\t\tpickedString#.delayIndex = delayIndex#;\n\t\t\t\tpickedString#.prevDelayLength = delayLength#;\n\t\t\t\tpickedString#.allPassG = allPassG#;\n\t\t\t\tpickedString#.sustainFilterA1 = sustainFilterA1#;\n\t\t\t\tpickedString#.sustainFilterA2 = sustainFilterA2#;\n\t\t\t\tpickedString#.sustainFilterB0 = sustainFilterB0#;\n\t\t\t\tpickedString#.sustainFilterB1 = sustainFilterB1#;\n\t\t\t\tpickedString#.sustainFilterB2 = sustainFilterB2#;\n\t\t\t\t\n\t\t\t\ttone.expression = expression;\n\t\t\t\t\n\t\t\t\tsynth.sanitizeFilters(filters);\n\t\t\t\ttone.initialNoteFilterInput1 = initialFilterInput1;\n\t\t\t\ttone.initialNoteFilterInput2 = initialFilterInput2;\n\t\t\t}",e=e.replace(/^.*\#.*$/gm,(e=>{const t=[];for(let s=0;s<a;s++)t.push(e.replace(/\#/g,String(s)));return t.join("\n")})),o=new Function("Config","Synth",e)(p,xe),xe.pickedStringFunctionCache[a]=o}o(e,t,s,i,n)}static effectsSynth(e,t,s,i,n,a){const o=q(a.effects),r=I(a.effects),l=a.eqFilterCount>0,h=T(a.effects),c=D(a.effects),u=O(a.effects),f=A(a.effects);let m=0;o&&(m|=1),m<<=1,r&&(m|=1),m<<=1,l&&(m|=1),m<<=1,h&&(m|=1),m<<=1,c&&(m|=1),m<<=1,u&&(m|=1),m<<=1,f&&(m|=1);let d=xe.effectsFunctionCache[m];if(null==d){let e="return (synth, outputDataL, outputDataR, bufferIndex, runLength, instrumentState) => {";const t=c||f||u;e+="\n\t\t\t\tconst tempMonoInstrumentSampleBuffer = synth.tempMonoInstrumentSampleBuffer;\n\t\t\t\t\n\t\t\t\tlet mixVolume = +instrumentState.mixVolume;\n\t\t\t\tconst mixVolumeDelta = +instrumentState.mixVolumeDelta;",t&&(e+="\n\t\t\t\t\n\t\t\t\tlet delayInputMult = +instrumentState.delayInputMult;\n\t\t\t\tconst delayInputMultDelta = +instrumentState.delayInputMultDelta;"),o&&(e+="\n\t\t\t\t\n\t\t\t\tconst distortionBaseVolume = +Config.distortionBaseVolume;\n\t\t\t\tlet distortion = instrumentState.distortion;\n\t\t\t\tconst distortionDelta = instrumentState.distortionDelta;\n\t\t\t\tlet distortionDrive = instrumentState.distortionDrive;\n\t\t\t\tconst distortionDriveDelta = instrumentState.distortionDriveDelta;\n\t\t\t\tconst distortionFractionalResolution = 4.0;\n\t\t\t\tconst distortionOversampleCompensation = distortionBaseVolume / distortionFractionalResolution;\n\t\t\t\tconst distortionFractionalDelay1 = 1.0 / distortionFractionalResolution;\n\t\t\t\tconst distortionFractionalDelay2 = 2.0 / distortionFractionalResolution;\n\t\t\t\tconst distortionFractionalDelay3 = 3.0 / distortionFractionalResolution;\n\t\t\t\tconst distortionFractionalDelayG1 = (1.0 - distortionFractionalDelay1) / (1.0 + distortionFractionalDelay1); // Inlined version of FilterCoefficients.prototype.allPass1stOrderFractionalDelay\n\t\t\t\tconst distortionFractionalDelayG2 = (1.0 - distortionFractionalDelay2) / (1.0 + distortionFractionalDelay2); // Inlined version of FilterCoefficients.prototype.allPass1stOrderFractionalDelay\n\t\t\t\tconst distortionFractionalDelayG3 = (1.0 - distortionFractionalDelay3) / (1.0 + distortionFractionalDelay3); // Inlined version of FilterCoefficients.prototype.allPass1stOrderFractionalDelay\n\t\t\t\tconst distortionNextOutputWeight1 = Math.cos(Math.PI * distortionFractionalDelay1) * 0.5 + 0.5;\n\t\t\t\tconst distortionNextOutputWeight2 = Math.cos(Math.PI * distortionFractionalDelay2) * 0.5 + 0.5;\n\t\t\t\tconst distortionNextOutputWeight3 = Math.cos(Math.PI * distortionFractionalDelay3) * 0.5 + 0.5;\n\t\t\t\tconst distortionPrevOutputWeight1 = 1.0 - distortionNextOutputWeight1;\n\t\t\t\tconst distortionPrevOutputWeight2 = 1.0 - distortionNextOutputWeight2;\n\t\t\t\tconst distortionPrevOutputWeight3 = 1.0 - distortionNextOutputWeight3;\n\t\t\t\t\n\t\t\t\tlet distortionFractionalInput1 = +instrumentState.distortionFractionalInput1;\n\t\t\t\tlet distortionFractionalInput2 = +instrumentState.distortionFractionalInput2;\n\t\t\t\tlet distortionFractionalInput3 = +instrumentState.distortionFractionalInput3;\n\t\t\t\tlet distortionPrevInput = +instrumentState.distortionPrevInput;\n\t\t\t\tlet distortionNextOutput = +instrumentState.distortionNextOutput;"),r&&(e+="\n\t\t\t\t\n\t\t\t\tlet bitcrusherPrevInput = +instrumentState.bitcrusherPrevInput;\n\t\t\t\tlet bitcrusherCurrentOutput = +instrumentState.bitcrusherCurrentOutput;\n\t\t\t\tlet bitcrusherPhase = +instrumentState.bitcrusherPhase;\n\t\t\t\tlet bitcrusherPhaseDelta = +instrumentState.bitcrusherPhaseDelta;\n\t\t\t\tconst bitcrusherPhaseDeltaScale = +instrumentState.bitcrusherPhaseDeltaScale;\n\t\t\t\tlet bitcrusherScale = +instrumentState.bitcrusherScale;\n\t\t\t\tconst bitcrusherScaleScale = +instrumentState.bitcrusherScaleScale;\n\t\t\t\tlet bitcrusherFoldLevel = +instrumentState.bitcrusherFoldLevel;\n\t\t\t\tconst bitcrusherFoldLevelScale = +instrumentState.bitcrusherFoldLevelScale;"),l&&(e+="\n\t\t\t\t\n\t\t\t\tlet filters = instrumentState.eqFilters;\n\t\t\t\tconst filterCount = instrumentState.eqFilterCount|0;\n\t\t\t\tlet initialFilterInput1 = +instrumentState.initialEqFilterInput1;\n\t\t\t\tlet initialFilterInput2 = +instrumentState.initialEqFilterInput2;\n\t\t\t\tconst applyFilters = Synth.applyFilters;"),e+="\n\t\t\t\t\n\t\t\t\tlet eqFilterVolume = +instrumentState.eqFilterVolume;\n\t\t\t\tconst eqFilterVolumeDelta = +instrumentState.eqFilterVolumeDelta;",h&&(e+="\n\t\t\t\t\n\t\t\t\tconst panningMask = synth.panningDelayBufferMask >>> 0;\n\t\t\t\tconst panningDelayLine = instrumentState.panningDelayLine;\n\t\t\t\tlet panningDelayPos = instrumentState.panningDelayPos & panningMask;\n\t\t\t\tlet panningVolumeL = +instrumentState.panningVolumeL;\n\t\t\t\tlet panningVolumeR = +instrumentState.panningVolumeR;\n\t\t\t\tconst panningVolumeDeltaL = +instrumentState.panningVolumeDeltaL;\n\t\t\t\tconst panningVolumeDeltaR = +instrumentState.panningVolumeDeltaR;\n\t\t\t\tlet panningOffsetL = +instrumentState.panningOffsetL;\n\t\t\t\tlet panningOffsetR = +instrumentState.panningOffsetR;\n\t\t\t\tconst panningOffsetDeltaL = 1.0 - instrumentState.panningOffsetDeltaL;\n\t\t\t\tconst panningOffsetDeltaR = 1.0 - instrumentState.panningOffsetDeltaR;"),c&&(e+="\n\t\t\t\t\n\t\t\t\tconst chorusMask = synth.chorusDelayBufferMask >>> 0;\n\t\t\t\tconst chorusDelayLineL = instrumentState.chorusDelayLineL;\n\t\t\t\tconst chorusDelayLineR = instrumentState.chorusDelayLineR;\n\t\t\t\tinstrumentState.chorusDelayLineDirty = true;\n\t\t\t\tlet chorusDelayPos = instrumentState.chorusDelayPos & chorusMask;\n\t\t\t\t\n\t\t\t\tlet chorusVoiceMult = +instrumentState.chorusVoiceMult;\n\t\t\t\tconst chorusVoiceMultDelta = +instrumentState.chorusVoiceMultDelta;\n\t\t\t\tlet chorusCombinedMult = +instrumentState.chorusCombinedMult;\n\t\t\t\tconst chorusCombinedMultDelta = +instrumentState.chorusCombinedMultDelta;\n\t\t\t\t\n\t\t\t\tconst chorusDuration = +beepbox.Config.chorusPeriodSeconds;\n\t\t\t\tconst chorusAngle = Math.PI * 2.0 / (chorusDuration * synth.samplesPerSecond);\n\t\t\t\tconst chorusRange = synth.samplesPerSecond * beepbox.Config.chorusDelayRange;\n\t\t\t\tconst chorusOffset0 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[0][0] * chorusRange;\n\t\t\t\tconst chorusOffset1 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[0][1] * chorusRange;\n\t\t\t\tconst chorusOffset2 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[0][2] * chorusRange;\n\t\t\t\tconst chorusOffset3 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[1][0] * chorusRange;\n\t\t\t\tconst chorusOffset4 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[1][1] * chorusRange;\n\t\t\t\tconst chorusOffset5 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[1][2] * chorusRange;\n\t\t\t\tlet chorusPhase = instrumentState.chorusPhase % (Math.PI * 2.0);\n\t\t\t\tlet chorusTap0Index = chorusDelayPos + chorusOffset0 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][0]);\n\t\t\t\tlet chorusTap1Index = chorusDelayPos + chorusOffset1 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][1]);\n\t\t\t\tlet chorusTap2Index = chorusDelayPos + chorusOffset2 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][2]);\n\t\t\t\tlet chorusTap3Index = chorusDelayPos + chorusOffset3 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][0]);\n\t\t\t\tlet chorusTap4Index = chorusDelayPos + chorusOffset4 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][1]);\n\t\t\t\tlet chorusTap5Index = chorusDelayPos + chorusOffset5 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][2]);\n\t\t\t\tchorusPhase += chorusAngle * runLength;\n\t\t\t\tconst chorusTap0End = chorusDelayPos + chorusOffset0 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][0]) + runLength;\n\t\t\t\tconst chorusTap1End = chorusDelayPos + chorusOffset1 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][1]) + runLength;\n\t\t\t\tconst chorusTap2End = chorusDelayPos + chorusOffset2 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][2]) + runLength;\n\t\t\t\tconst chorusTap3End = chorusDelayPos + chorusOffset3 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][0]) + runLength;\n\t\t\t\tconst chorusTap4End = chorusDelayPos + chorusOffset4 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][1]) + runLength;\n\t\t\t\tconst chorusTap5End = chorusDelayPos + chorusOffset5 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][2]) + runLength;\n\t\t\t\tconst chorusTap0Delta = (chorusTap0End - chorusTap0Index) / runLength;\n\t\t\t\tconst chorusTap1Delta = (chorusTap1End - chorusTap1Index) / runLength;\n\t\t\t\tconst chorusTap2Delta = (chorusTap2End - chorusTap2Index) / runLength;\n\t\t\t\tconst chorusTap3Delta = (chorusTap3End - chorusTap3Index) / runLength;\n\t\t\t\tconst chorusTap4Delta = (chorusTap4End - chorusTap4Index) / runLength;\n\t\t\t\tconst chorusTap5Delta = (chorusTap5End - chorusTap5Index) / runLength;"),u&&(e+="\n\t\t\t\t\n\t\t\t\tlet echoMult = +instrumentState.echoMult;\n\t\t\t\tconst echoMultDelta = +instrumentState.echoMultDelta;\n\t\t\t\t\n\t\t\t\tconst echoDelayLineL = instrumentState.echoDelayLineL;\n\t\t\t\tconst echoDelayLineR = instrumentState.echoDelayLineR;\n\t\t\t\tconst echoMask = (echoDelayLineL.length - 1) >>> 0;\n\t\t\t\tinstrumentState.echoDelayLineDirty = true;\n\t\t\t\t\n\t\t\t\tlet echoDelayPos = instrumentState.echoDelayPos & echoMask;\n\t\t\t\tconst echoDelayOffsetStart = (echoDelayLineL.length - instrumentState.echoDelayOffsetStart) & echoMask;\n\t\t\t\tconst echoDelayOffsetEnd = (echoDelayLineL.length - instrumentState.echoDelayOffsetEnd) & echoMask;\n\t\t\t\tlet echoDelayOffsetRatio = +instrumentState.echoDelayOffsetRatio;\n\t\t\t\tconst echoDelayOffsetRatioDelta = +instrumentState.echoDelayOffsetRatioDelta;\n\t\t\t\t\n\t\t\t\tconst echoShelfA1 = +instrumentState.echoShelfA1;\n\t\t\t\tconst echoShelfB0 = +instrumentState.echoShelfB0;\n\t\t\t\tconst echoShelfB1 = +instrumentState.echoShelfB1;\n\t\t\t\tlet echoShelfSampleL = +instrumentState.echoShelfSampleL;\n\t\t\t\tlet echoShelfSampleR = +instrumentState.echoShelfSampleR;\n\t\t\t\tlet echoShelfPrevInputL = +instrumentState.echoShelfPrevInputL;\n\t\t\t\tlet echoShelfPrevInputR = +instrumentState.echoShelfPrevInputR;"),f&&(e+="\n\t\t\t\t\n\t\t\t\tconst reverbMask = Config.reverbDelayBufferMask >>> 0; //TODO: Dynamic reverb buffer size.\n\t\t\t\tconst reverbDelayLine = instrumentState.reverbDelayLine;\n\t\t\t\tinstrumentState.reverbDelayLineDirty = true;\n\t\t\t\tlet reverbDelayPos = instrumentState.reverbDelayPos & reverbMask;\n\t\t\t\t\n\t\t\t\tlet reverb = +instrumentState.reverbMult;\n\t\t\t\tconst reverbDelta = +instrumentState.reverbMultDelta;\n\t\t\t\t\n\t\t\t\tconst reverbShelfA1 = +instrumentState.reverbShelfA1;\n\t\t\t\tconst reverbShelfB0 = +instrumentState.reverbShelfB0;\n\t\t\t\tconst reverbShelfB1 = +instrumentState.reverbShelfB1;\n\t\t\t\tlet reverbShelfSample0 = +instrumentState.reverbShelfSample0;\n\t\t\t\tlet reverbShelfSample1 = +instrumentState.reverbShelfSample1;\n\t\t\t\tlet reverbShelfSample2 = +instrumentState.reverbShelfSample2;\n\t\t\t\tlet reverbShelfSample3 = +instrumentState.reverbShelfSample3;\n\t\t\t\tlet reverbShelfPrevInput0 = +instrumentState.reverbShelfPrevInput0;\n\t\t\t\tlet reverbShelfPrevInput1 = +instrumentState.reverbShelfPrevInput1;\n\t\t\t\tlet reverbShelfPrevInput2 = +instrumentState.reverbShelfPrevInput2;\n\t\t\t\tlet reverbShelfPrevInput3 = +instrumentState.reverbShelfPrevInput3;"),e+="\n\t\t\t\t\n\t\t\t\tconst stopIndex = bufferIndex + runLength;\n\t\t\t\tfor (let sampleIndex = bufferIndex; sampleIndex < stopIndex; sampleIndex++) {\n\t\t\t\t\tlet sample = tempMonoInstrumentSampleBuffer[sampleIndex];\n\t\t\t\t\ttempMonoInstrumentSampleBuffer[sampleIndex] = 0.0;",o&&(e+="\n\t\t\t\t\t\n\t\t\t\t\tconst distortionReverse = 1.0 - distortion;\n\t\t\t\t\tconst distortionNextInput = sample * distortionDrive;\n\t\t\t\t\tsample = distortionNextOutput;\n\t\t\t\t\tdistortionNextOutput = distortionNextInput / (distortionReverse * Math.abs(distortionNextInput) + distortion);\n\t\t\t\t\tdistortionFractionalInput1 = distortionFractionalDelayG1 * distortionNextInput + distortionPrevInput - distortionFractionalDelayG1 * distortionFractionalInput1;\n\t\t\t\t\tdistortionFractionalInput2 = distortionFractionalDelayG2 * distortionNextInput + distortionPrevInput - distortionFractionalDelayG2 * distortionFractionalInput2;\n\t\t\t\t\tdistortionFractionalInput3 = distortionFractionalDelayG3 * distortionNextInput + distortionPrevInput - distortionFractionalDelayG3 * distortionFractionalInput3;\n\t\t\t\t\tconst distortionOutput1 = distortionFractionalInput1 / (distortionReverse * Math.abs(distortionFractionalInput1) + distortion);\n\t\t\t\t\tconst distortionOutput2 = distortionFractionalInput2 / (distortionReverse * Math.abs(distortionFractionalInput2) + distortion);\n\t\t\t\t\tconst distortionOutput3 = distortionFractionalInput3 / (distortionReverse * Math.abs(distortionFractionalInput3) + distortion);\n\t\t\t\t\tdistortionNextOutput += distortionOutput1 * distortionNextOutputWeight1 + distortionOutput2 * distortionNextOutputWeight2 + distortionOutput3 * distortionNextOutputWeight3;\n\t\t\t\t\tsample += distortionOutput1 * distortionPrevOutputWeight1 + distortionOutput2 * distortionPrevOutputWeight2 + distortionOutput3 * distortionPrevOutputWeight3;\n\t\t\t\t\tsample *= distortionOversampleCompensation;\n\t\t\t\t\tdistortionPrevInput = distortionNextInput;\n\t\t\t\t\tdistortion += distortionDelta;\n\t\t\t\t\tdistortionDrive += distortionDriveDelta;"),r&&(e+="\n\t\t\t\t\t\n\t\t\t\t\tbitcrusherPhase += bitcrusherPhaseDelta;\n\t\t\t\t\tif (bitcrusherPhase < 1.0) {\n\t\t\t\t\t\tbitcrusherPrevInput = sample;\n\t\t\t\t\t\tsample = bitcrusherCurrentOutput;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tbitcrusherPhase = bitcrusherPhase % 1.0;\n\t\t\t\t\t\tconst ratio = bitcrusherPhase / bitcrusherPhaseDelta;\n\t\t\t\t\t\t\n\t\t\t\t\t\tconst lerpedInput = sample + (bitcrusherPrevInput - sample) * ratio;\n\t\t\t\t\t\tbitcrusherPrevInput = sample;\n\t\t\t\t\t\t\n\t\t\t\t\t\tconst bitcrusherWrapLevel = bitcrusherFoldLevel * 4.0;\n\t\t\t\t\t\tconst wrappedSample = (((lerpedInput + bitcrusherFoldLevel) % bitcrusherWrapLevel) + bitcrusherWrapLevel) % bitcrusherWrapLevel;\n\t\t\t\t\t\tconst foldedSample = bitcrusherFoldLevel - Math.abs(bitcrusherFoldLevel * 2.0 - wrappedSample);\n\t\t\t\t\t\tconst scaledSample = foldedSample / bitcrusherScale;\n\t\t\t\t\t\tconst oldValue = bitcrusherCurrentOutput;\n\t\t\t\t\t\tconst newValue = (((scaledSample > 0 ? scaledSample + 1 : scaledSample)|0)-.5) * bitcrusherScale;\n\t\t\t\t\t\t\n\t\t\t\t\t\tsample = oldValue + (newValue - oldValue) * ratio;\n\t\t\t\t\t\tbitcrusherCurrentOutput = newValue;\n\t\t\t\t\t}\n\t\t\t\t\tbitcrusherPhaseDelta *= bitcrusherPhaseDeltaScale;\n\t\t\t\t\tbitcrusherScale *= bitcrusherScaleScale;\n\t\t\t\t\tbitcrusherFoldLevel *= bitcrusherFoldLevelScale;"),l&&(e+="\n\t\t\t\t\t\n\t\t\t\t\tconst inputSample = sample;\n\t\t\t\t\tsample = applyFilters(inputSample, initialFilterInput1, initialFilterInput2, filterCount, filters);\n\t\t\t\t\tinitialFilterInput2 = initialFilterInput1;\n\t\t\t\t\tinitialFilterInput1 = inputSample;"),e+="\n\t\t\t\t\t\n\t\t\t\t\tsample *= eqFilterVolume;\n\t\t\t\t\teqFilterVolume += eqFilterVolumeDelta;",e+=h?"\n\t\t\t\t\t\n\t\t\t\t\tpanningDelayLine[panningDelayPos] = sample;\n\t\t\t\t\tconst panningRatioL = panningOffsetL % 1;\n\t\t\t\t\tconst panningRatioR = panningOffsetR % 1;\n\t\t\t\t\tconst panningTapLA = panningDelayLine[(panningOffsetL) & panningMask];\n\t\t\t\t\tconst panningTapLB = panningDelayLine[(panningOffsetL + 1) & panningMask];\n\t\t\t\t\tconst panningTapRA = panningDelayLine[(panningOffsetR) & panningMask];\n\t\t\t\t\tconst panningTapRB = panningDelayLine[(panningOffsetR + 1) & panningMask];\n\t\t\t\t\tconst panningTapL = panningTapLA + (panningTapLB - panningTapLA) * panningRatioL;\n\t\t\t\t\tconst panningTapR = panningTapRA + (panningTapRB - panningTapRA) * panningRatioR;\n\t\t\t\t\tlet sampleL = panningTapL * panningVolumeL;\n\t\t\t\t\tlet sampleR = panningTapR * panningVolumeR;\n\t\t\t\t\tpanningDelayPos = (panningDelayPos + 1) & panningMask;\n\t\t\t\t\tpanningVolumeL += panningVolumeDeltaL;\n\t\t\t\t\tpanningVolumeR += panningVolumeDeltaR;\n\t\t\t\t\tpanningOffsetL += panningOffsetDeltaL;\n\t\t\t\t\tpanningOffsetR += panningOffsetDeltaR;":"\n\t\t\t\t\t\n\t\t\t\t\tlet sampleL = sample;\n\t\t\t\t\tlet sampleR = sample;",c&&(e+="\n\t\t\t\t\t\n\t\t\t\t\tconst chorusTap0Ratio = chorusTap0Index % 1;\n\t\t\t\t\tconst chorusTap1Ratio = chorusTap1Index % 1;\n\t\t\t\t\tconst chorusTap2Ratio = chorusTap2Index % 1;\n\t\t\t\t\tconst chorusTap3Ratio = chorusTap3Index % 1;\n\t\t\t\t\tconst chorusTap4Ratio = chorusTap4Index % 1;\n\t\t\t\t\tconst chorusTap5Ratio = chorusTap5Index % 1;\n\t\t\t\t\tconst chorusTap0A = chorusDelayLineL[(chorusTap0Index) & chorusMask];\n\t\t\t\t\tconst chorusTap0B = chorusDelayLineL[(chorusTap0Index + 1) & chorusMask];\n\t\t\t\t\tconst chorusTap1A = chorusDelayLineL[(chorusTap1Index) & chorusMask];\n\t\t\t\t\tconst chorusTap1B = chorusDelayLineL[(chorusTap1Index + 1) & chorusMask];\n\t\t\t\t\tconst chorusTap2A = chorusDelayLineL[(chorusTap2Index) & chorusMask];\n\t\t\t\t\tconst chorusTap2B = chorusDelayLineL[(chorusTap2Index + 1) & chorusMask];\n\t\t\t\t\tconst chorusTap3A = chorusDelayLineR[(chorusTap3Index) & chorusMask];\n\t\t\t\t\tconst chorusTap3B = chorusDelayLineR[(chorusTap3Index + 1) & chorusMask];\n\t\t\t\t\tconst chorusTap4A = chorusDelayLineR[(chorusTap4Index) & chorusMask];\n\t\t\t\t\tconst chorusTap4B = chorusDelayLineR[(chorusTap4Index + 1) & chorusMask];\n\t\t\t\t\tconst chorusTap5A = chorusDelayLineR[(chorusTap5Index) & chorusMask];\n\t\t\t\t\tconst chorusTap5B = chorusDelayLineR[(chorusTap5Index + 1) & chorusMask];\n\t\t\t\t\tconst chorusTap0 = chorusTap0A + (chorusTap0B - chorusTap0A) * chorusTap0Ratio;\n\t\t\t\t\tconst chorusTap1 = chorusTap1A + (chorusTap1B - chorusTap1A) * chorusTap1Ratio;\n\t\t\t\t\tconst chorusTap2 = chorusTap2A + (chorusTap2B - chorusTap2A) * chorusTap2Ratio;\n\t\t\t\t\tconst chorusTap3 = chorusTap3A + (chorusTap3B - chorusTap3A) * chorusTap3Ratio;\n\t\t\t\t\tconst chorusTap4 = chorusTap4A + (chorusTap4B - chorusTap4A) * chorusTap4Ratio;\n\t\t\t\t\tconst chorusTap5 = chorusTap5A + (chorusTap5B - chorusTap5A) * chorusTap5Ratio;\n\t\t\t\t\tchorusDelayLineL[chorusDelayPos] = sampleL * delayInputMult;\n\t\t\t\t\tchorusDelayLineR[chorusDelayPos] = sampleR * delayInputMult;\n\t\t\t\t\tsampleL = chorusCombinedMult * (sampleL + chorusVoiceMult * (chorusTap1 - chorusTap0 - chorusTap2));\n\t\t\t\t\tsampleR = chorusCombinedMult * (sampleR + chorusVoiceMult * (chorusTap4 - chorusTap3 - chorusTap5));\n\t\t\t\t\tchorusDelayPos = (chorusDelayPos + 1) & chorusMask;\n\t\t\t\t\tchorusTap0Index += chorusTap0Delta;\n\t\t\t\t\tchorusTap1Index += chorusTap1Delta;\n\t\t\t\t\tchorusTap2Index += chorusTap2Delta;\n\t\t\t\t\tchorusTap3Index += chorusTap3Delta;\n\t\t\t\t\tchorusTap4Index += chorusTap4Delta;\n\t\t\t\t\tchorusTap5Index += chorusTap5Delta;\n\t\t\t\t\tchorusVoiceMult += chorusVoiceMultDelta;\n\t\t\t\t\tchorusCombinedMult += chorusCombinedMultDelta;"),u&&(e+="\n\t\t\t\t\t\n\t\t\t\t\tconst echoTapStartIndex = (echoDelayPos + echoDelayOffsetStart) & echoMask;\n\t\t\t\t\tconst echoTapEndIndex = (echoDelayPos + echoDelayOffsetEnd ) & echoMask;\n\t\t\t\t\tconst echoTapStartL = echoDelayLineL[echoTapStartIndex];\n\t\t\t\t\tconst echoTapEndL = echoDelayLineL[echoTapEndIndex];\n\t\t\t\t\tconst echoTapStartR = echoDelayLineR[echoTapStartIndex];\n\t\t\t\t\tconst echoTapEndR = echoDelayLineR[echoTapEndIndex];\n\t\t\t\t\tconst echoTapL = (echoTapStartL + (echoTapEndL - echoTapStartL) * echoDelayOffsetRatio) * echoMult;\n\t\t\t\t\tconst echoTapR = (echoTapStartR + (echoTapEndR - echoTapStartR) * echoDelayOffsetRatio) * echoMult;\n\t\t\t\t\t\n\t\t\t\t\techoShelfSampleL = echoShelfB0 * echoTapL + echoShelfB1 * echoShelfPrevInputL - echoShelfA1 * echoShelfSampleL;\n\t\t\t\t\techoShelfSampleR = echoShelfB0 * echoTapR + echoShelfB1 * echoShelfPrevInputR - echoShelfA1 * echoShelfSampleR;\n\t\t\t\t\techoShelfPrevInputL = echoTapL;\n\t\t\t\t\techoShelfPrevInputR = echoTapR;\n\t\t\t\t\tsampleL += echoShelfSampleL;\n\t\t\t\t\tsampleR += echoShelfSampleR;\n\t\t\t\t\t\n\t\t\t\t\techoDelayLineL[echoDelayPos] = sampleL * delayInputMult;\n\t\t\t\t\techoDelayLineR[echoDelayPos] = sampleR * delayInputMult;\n\t\t\t\t\techoDelayPos = (echoDelayPos + 1) & echoMask;\n\t\t\t\t\techoDelayOffsetRatio += echoDelayOffsetRatioDelta;\n\t\t\t\t\techoMult += echoMultDelta;\n "),f&&(e+="\n\t\t\t\t\t\n\t\t\t\t\t// Reverb, implemented using a feedback delay network with a Hadamard matrix and lowpass filters.\n\t\t\t\t\t// good ratios: 0.555235 + 0.618033 + 0.818 + 1.0 = 2.991268\n\t\t\t\t\t// Delay lengths: 3041 + 3385 + 4481 + 5477 = 16384 = 2^14\n\t\t\t\t\t// Buffer offsets: 3041 -> 6426 -> 10907 -> 16384\n\t\t\t\t\tconst reverbDelayPos1 = (reverbDelayPos + 3041) & reverbMask;\n\t\t\t\t\tconst reverbDelayPos2 = (reverbDelayPos + 6426) & reverbMask;\n\t\t\t\t\tconst reverbDelayPos3 = (reverbDelayPos + 10907) & reverbMask;\n\t\t\t\t\tconst reverbSample0 = (reverbDelayLine[reverbDelayPos]);\n\t\t\t\t\tconst reverbSample1 = reverbDelayLine[reverbDelayPos1];\n\t\t\t\t\tconst reverbSample2 = reverbDelayLine[reverbDelayPos2];\n\t\t\t\t\tconst reverbSample3 = reverbDelayLine[reverbDelayPos3];\n\t\t\t\t\tconst reverbTemp0 = -(reverbSample0 + sampleL) + reverbSample1;\n\t\t\t\t\tconst reverbTemp1 = -(reverbSample0 + sampleR) - reverbSample1;\n\t\t\t\t\tconst reverbTemp2 = -reverbSample2 + reverbSample3;\n\t\t\t\t\tconst reverbTemp3 = -reverbSample2 - reverbSample3;\n\t\t\t\t\tconst reverbShelfInput0 = (reverbTemp0 + reverbTemp2) * reverb;\n\t\t\t\t\tconst reverbShelfInput1 = (reverbTemp1 + reverbTemp3) * reverb;\n\t\t\t\t\tconst reverbShelfInput2 = (reverbTemp0 - reverbTemp2) * reverb;\n\t\t\t\t\tconst reverbShelfInput3 = (reverbTemp1 - reverbTemp3) * reverb;\n\t\t\t\t\treverbShelfSample0 = reverbShelfB0 * reverbShelfInput0 + reverbShelfB1 * reverbShelfPrevInput0 - reverbShelfA1 * reverbShelfSample0;\n\t\t\t\t\treverbShelfSample1 = reverbShelfB0 * reverbShelfInput1 + reverbShelfB1 * reverbShelfPrevInput1 - reverbShelfA1 * reverbShelfSample1;\n\t\t\t\t\treverbShelfSample2 = reverbShelfB0 * reverbShelfInput2 + reverbShelfB1 * reverbShelfPrevInput2 - reverbShelfA1 * reverbShelfSample2;\n\t\t\t\t\treverbShelfSample3 = reverbShelfB0 * reverbShelfInput3 + reverbShelfB1 * reverbShelfPrevInput3 - reverbShelfA1 * reverbShelfSample3;\n\t\t\t\t\treverbShelfPrevInput0 = reverbShelfInput0;\n\t\t\t\t\treverbShelfPrevInput1 = reverbShelfInput1;\n\t\t\t\t\treverbShelfPrevInput2 = reverbShelfInput2;\n\t\t\t\t\treverbShelfPrevInput3 = reverbShelfInput3;\n\t\t\t\t\treverbDelayLine[reverbDelayPos1] = reverbShelfSample0 * delayInputMult;\n\t\t\t\t\treverbDelayLine[reverbDelayPos2] = reverbShelfSample1 * delayInputMult;\n\t\t\t\t\treverbDelayLine[reverbDelayPos3] = reverbShelfSample2 * delayInputMult;\n\t\t\t\t\treverbDelayLine[reverbDelayPos ] = reverbShelfSample3 * delayInputMult;\n\t\t\t\t\treverbDelayPos = (reverbDelayPos + 1) & reverbMask;\n\t\t\t\t\tsampleL += reverbSample1 + reverbSample2 + reverbSample3;\n\t\t\t\t\tsampleR += reverbSample0 + reverbSample2 - reverbSample3;\n\t\t\t\t\treverb += reverbDelta;"),e+="\n\t\t\t\t\t\n\t\t\t\t\toutputDataL[sampleIndex] += sampleL * mixVolume;\n\t\t\t\t\toutputDataR[sampleIndex] += sampleR * mixVolume;\n\t\t\t\t\tmixVolume += mixVolumeDelta;",t&&(e+="\n\t\t\t\t\t\n\t\t\t\t\tdelayInputMult += delayInputMultDelta;"),e+="\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tinstrumentState.mixVolume = mixVolume;\n\t\t\t\tinstrumentState.eqFilterVolume = eqFilterVolume;\n\t\t\t\t\n\t\t\t\t// Avoid persistent denormal or NaN values in the delay buffers and filter history.\n\t\t\t\tconst epsilon = (1.0e-24);",t&&(e+="\n\t\t\t\t\n\t\t\t\tinstrumentState.delayInputMult = delayInputMult;"),o&&(e+="\n\t\t\t\t\n\t\t\t\tinstrumentState.distortion = distortion;\n\t\t\t\tinstrumentState.distortionDrive = distortionDrive;\n\t\t\t\t\n\t\t\t\tif (!Number.isFinite(distortionFractionalInput1) || Math.abs(distortionFractionalInput1) < epsilon) distortionFractionalInput1 = 0.0;\n\t\t\t\tif (!Number.isFinite(distortionFractionalInput2) || Math.abs(distortionFractionalInput2) < epsilon) distortionFractionalInput2 = 0.0;\n\t\t\t\tif (!Number.isFinite(distortionFractionalInput3) || Math.abs(distortionFractionalInput3) < epsilon) distortionFractionalInput3 = 0.0;\n\t\t\t\tif (!Number.isFinite(distortionPrevInput) || Math.abs(distortionPrevInput) < epsilon) distortionPrevInput = 0.0;\n\t\t\t\tif (!Number.isFinite(distortionNextOutput) || Math.abs(distortionNextOutput) < epsilon) distortionNextOutput = 0.0;\n\t\t\t\t\n\t\t\t\tinstrumentState.distortionFractionalInput1 = distortionFractionalInput1;\n\t\t\t\tinstrumentState.distortionFractionalInput2 = distortionFractionalInput2;\n\t\t\t\tinstrumentState.distortionFractionalInput3 = distortionFractionalInput3;\n\t\t\t\tinstrumentState.distortionPrevInput = distortionPrevInput;\n\t\t\t\tinstrumentState.distortionNextOutput = distortionNextOutput;"),r&&(e+="\n\t\t\t\t\t\n\t\t\t\tif (Math.abs(bitcrusherPrevInput) < epsilon) bitcrusherPrevInput = 0.0;\n\t\t\t\tif (Math.abs(bitcrusherCurrentOutput) < epsilon) bitcrusherCurrentOutput = 0.0;\n\t\t\t\tinstrumentState.bitcrusherPrevInput = bitcrusherPrevInput;\n\t\t\t\tinstrumentState.bitcrusherCurrentOutput = bitcrusherCurrentOutput;\n\t\t\t\tinstrumentState.bitcrusherPhase = bitcrusherPhase;\n\t\t\t\tinstrumentState.bitcrusherPhaseDelta = bitcrusherPhaseDelta;\n\t\t\t\tinstrumentState.bitcrusherScale = bitcrusherScale;\n\t\t\t\tinstrumentState.bitcrusherFoldLevel = bitcrusherFoldLevel;"),l&&(e+="\n\t\t\t\t\t\n\t\t\t\tsynth.sanitizeFilters(filters);\n\t\t\t\t// The filter input here is downstream from another filter so we\n\t\t\t\t// better make sure it's safe too.\n\t\t\t\tif (!(initialFilterInput1 < 100) || !(initialFilterInput2 < 100)) {\n\t\t\t\t\tinitialFilterInput1 = 0.0;\n\t\t\t\t\tinitialFilterInput2 = 0.0;\n\t\t\t\t}\n\t\t\t\tif (Math.abs(initialFilterInput1) < epsilon) initialFilterInput1 = 0.0;\n\t\t\t\tif (Math.abs(initialFilterInput2) < epsilon) initialFilterInput2 = 0.0;\n\t\t\t\tinstrumentState.initialEqFilterInput1 = initialFilterInput1;\n\t\t\t\tinstrumentState.initialEqFilterInput2 = initialFilterInput2;"),h&&(e+="\n\t\t\t\t\n\t\t\t\tSynth.sanitizeDelayLine(panningDelayLine, panningDelayPos, panningMask);\n\t\t\t\tinstrumentState.panningDelayPos = panningDelayPos;\n\t\t\t\tinstrumentState.panningVolumeL = panningVolumeL;\n\t\t\t\tinstrumentState.panningVolumeR = panningVolumeR;\n\t\t\t\tinstrumentState.panningOffsetL = panningOffsetL;\n\t\t\t\tinstrumentState.panningOffsetR = panningOffsetR;"),c&&(e+="\n\t\t\t\t\n\t\t\t\tSynth.sanitizeDelayLine(chorusDelayLineL, chorusDelayPos, chorusMask);\n\t\t\t\tSynth.sanitizeDelayLine(chorusDelayLineR, chorusDelayPos, chorusMask);\n\t\t\t\tinstrumentState.chorusPhase = chorusPhase;\n\t\t\t\tinstrumentState.chorusDelayPos = chorusDelayPos;\n\t\t\t\tinstrumentState.chorusVoiceMult = chorusVoiceMult;\n\t\t\t\tinstrumentState.chorusCombinedMult = chorusCombinedMult;"),u&&(e+="\n\t\t\t\t\n\t\t\t\tSynth.sanitizeDelayLine(echoDelayLineL, echoDelayPos, echoMask);\n\t\t\t\tSynth.sanitizeDelayLine(echoDelayLineR, echoDelayPos, echoMask);\n\t\t\t\tinstrumentState.echoDelayPos = echoDelayPos;\n\t\t\t\tinstrumentState.echoMult = echoMult;\n\t\t\t\tinstrumentState.echoDelayOffsetRatio = echoDelayOffsetRatio;\n\t\t\t\t\n\t\t\t\tif (!Number.isFinite(echoShelfSampleL) || Math.abs(echoShelfSampleL) < epsilon) echoShelfSampleL = 0.0;\n\t\t\t\tif (!Number.isFinite(echoShelfSampleR) || Math.abs(echoShelfSampleR) < epsilon) echoShelfSampleR = 0.0;\n\t\t\t\tif (!Number.isFinite(echoShelfPrevInputL) || Math.abs(echoShelfPrevInputL) < epsilon) echoShelfPrevInputL = 0.0;\n\t\t\t\tif (!Number.isFinite(echoShelfPrevInputR) || Math.abs(echoShelfPrevInputR) < epsilon) echoShelfPrevInputR = 0.0;\n\t\t\t\tinstrumentState.echoShelfSampleL = echoShelfSampleL;\n\t\t\t\tinstrumentState.echoShelfSampleR = echoShelfSampleR;\n\t\t\t\tinstrumentState.echoShelfPrevInputL = echoShelfPrevInputL;\n\t\t\t\tinstrumentState.echoShelfPrevInputR = echoShelfPrevInputR;"),f&&(e+="\n\t\t\t\t\n\t\t\t\tSynth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos , reverbMask);\n\t\t\t\tSynth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos + 3041, reverbMask);\n\t\t\t\tSynth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos + 6426, reverbMask);\n\t\t\t\tSynth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos + 10907, reverbMask);\n\t\t\t\tinstrumentState.reverbDelayPos = reverbDelayPos;\n\t\t\t\tinstrumentState.reverbMult = reverb;\n\t\t\t\t\n\t\t\t\tif (!Number.isFinite(reverbShelfSample0) || Math.abs(reverbShelfSample0) < epsilon) reverbShelfSample0 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfSample1) || Math.abs(reverbShelfSample1) < epsilon) reverbShelfSample1 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfSample2) || Math.abs(reverbShelfSample2) < epsilon) reverbShelfSample2 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfSample3) || Math.abs(reverbShelfSample3) < epsilon) reverbShelfSample3 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfPrevInput0) || Math.abs(reverbShelfPrevInput0) < epsilon) reverbShelfPrevInput0 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfPrevInput1) || Math.abs(reverbShelfPrevInput1) < epsilon) reverbShelfPrevInput1 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfPrevInput2) || Math.abs(reverbShelfPrevInput2) < epsilon) reverbShelfPrevInput2 = 0.0;\n\t\t\t\tif (!Number.isFinite(reverbShelfPrevInput3) || Math.abs(reverbShelfPrevInput3) < epsilon) reverbShelfPrevInput3 = 0.0;\n\t\t\t\tinstrumentState.reverbShelfSample0 = reverbShelfSample0;\n\t\t\t\tinstrumentState.reverbShelfSample1 = reverbShelfSample1;\n\t\t\t\tinstrumentState.reverbShelfSample2 = reverbShelfSample2;\n\t\t\t\tinstrumentState.reverbShelfSample3 = reverbShelfSample3;\n\t\t\t\tinstrumentState.reverbShelfPrevInput0 = reverbShelfPrevInput0;\n\t\t\t\tinstrumentState.reverbShelfPrevInput1 = reverbShelfPrevInput1;\n\t\t\t\tinstrumentState.reverbShelfPrevInput2 = reverbShelfPrevInput2;\n\t\t\t\tinstrumentState.reverbShelfPrevInput3 = reverbShelfPrevInput3;"),e+="}",d=new Function("Config","Synth",e)(p,xe),xe.effectsFunctionCache[m]=d}d(e,t,s,i,n,a)}static pulseWidthSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer,o=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let r=i.phaseDeltas[0],l=i.phaseDeltas[1];const h=+i.phaseDeltaScales[0],p=+i.phaseDeltaScales[1];let c=+i.expression;const u=+i.expressionDelta;let f=i.phases[0]%1,m=i.phases[1]%1,d=i.pulseWidth;const y=i.pulseWidthDelta,v=i.noteFilters,g=0|i.noteFilterCount;let b=+i.initialNoteFilterInput1,S=+i.initialNoteFilterInput2;const M=xe.applyFilters,w=t+s;for(let e=t;e<w;e++){const t=f%1,s=(f+d)%1,i=m%1,w=(m+d)%1;let k=s-t,F=w-i;if(!n.aliases){if(t<r)k+=.5*((x=t/r)+x-x*x-1);else if(t>1-r){k+=.5*((x=(t-1)/r)+x+x*x+1)}if(s<r)k-=.5*((x=s/r)+x-x*x-1);else if(s>1-r){k-=.5*((x=(s-1)/r)+x+x*x+1)}if(i<l)F+=.5*((x=i/l)+x-x*x-1);else if(i>1-l){F+=.5*((x=(i-1)/l)+x+x*x+1)}if(w<l)F-=.5*((x=w/l)+x-x*x-1);else if(w>1-l){var x;F-=.5*((x=(w-1)/l)+x+x*x+1)}}const P=k+F*o,q=M(P,b,S,g,v);S=b,b=P,f+=r,m+=l,r*=h,l*=p,d+=y;const I=q*c;c+=u,a[e]+=I}i.phases[0]=f,i.phases[1]=m,i.phaseDeltas[0]=r,i.phaseDeltas[1]=l,i.expression=c,i.pulseWidth=d,e.sanitizeFilters(v),i.initialNoteFilterInput1=b,i.initialNoteFilterInput2=S}static supersawSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer,o=0|p.supersawVoiceCount;let r=i.phaseDeltas[0];const l=+i.phaseDeltaScales[0];let h=+i.expression;const c=+i.expressionDelta;let u=i.phases,f=+i.supersawDynamism;const m=+i.supersawDynamismDelta,d=i.supersawUnisonDetunes;let y=+i.supersawShape;const v=+i.supersawShapeDelta;let g=+i.supersawDelayLength;const b=+i.supersawDelayLengthDelta,S=i.supersawDelayLine,M=S.length-1>>0;let w=0|i.supersawDelayIndex;w=(w&M)+S.length;const x=i.noteFilters,k=0|i.noteFilterCount;let F=+i.initialNoteFilterInput1,P=+i.initialNoteFilterInput2;const q=xe.applyFilters,I=t+s;for(let e=t;e<I;e++){let t=(u[0]+r)%1,s=t-.5*(1+(o-1)*f);if(!n.aliases)if(t<r)s-=.5*((T=t/r)+T-T*T-1);else if(t>1-r){var T;s-=.5*((T=(t-1)/r)+T+T*T+1)}u[0]=t;for(let e=1;e<o;e++){const t=r*d[e];let i=(u[e]+t)%1;if(s+=i*f,!n.aliases)if(i<t){const e=i/t;s-=.5*(e+e-e*e-1)*f}else if(i>1-t){const e=(i-1)/t;s-=.5*(e+e+e*e+1)*f}u[e]=i}S[w&M]=s;const i=w-g,p=0|i,I=p+1,D=i-p,O=S[p&M];w++;const A=s-(O+(S[I&M]-O)*D)*y,z=q(A,F,P,k,x);P=F,F=A,r*=l,f+=m,y+=v,g+=b;const C=z*h;h+=c,a[e]+=C}i.phaseDeltas[0]=r,i.expression=h,i.supersawDynamism=f,i.supersawShape=y,i.supersawDelayLength=g,i.supersawDelayIndex=w,e.sanitizeFilters(x),i.initialNoteFilterInput1=F,i.initialNoteFilterInput2=P}static noiseSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer,o=n.wave,r=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let l=i.phaseDeltas[0],h=i.phaseDeltas[1];const c=+i.phaseDeltaScales[0],u=+i.phaseDeltaScales[1];let f=+i.expression;const m=+i.expressionDelta;let d=i.phases[0]%1*p.chipNoiseLength,y=i.phases[1]%1*p.chipNoiseLength;0==i.phases[0]&&(d=Math.random()*p.chipNoiseLength,1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(y=d)),0!=i.phases[1]||1==n.unisonVoices&&0==n.unisonSpread&&!n.chord.customInterval||(y=Math.random()*p.chipNoiseLength);const v=p.chipNoiseLength-1;let g=+i.noiseSampleA,b=+i.noiseSampleB;const S=i.noteFilters,M=0|i.noteFilterCount;let w=+i.initialNoteFilterInput1,x=+i.initialNoteFilterInput2;const k=xe.applyFilters,F=Math.min(1,l*n.noisePitchFilterMult),P=Math.min(1,h*n.noisePitchFilterMult),q=t+s;for(let e=t;e<q;e++){g+=(o[d&v]-g)*F,b+=(o[y&v]-b)*P;const t=g+b*r,s=k(t,w,x,M,S);x=w,w=t,d+=l,y+=h,l*=c,h*=u;const i=s*f;f+=m,a[e]+=i}i.phases[0]=d/p.chipNoiseLength,i.phases[1]=y/p.chipNoiseLength,i.phaseDeltas[0]=l,i.phaseDeltas[1]=h,i.expression=f,i.noiseSampleA=g,i.noiseSampleB=b,e.sanitizeFilters(S),i.initialNoteFilterInput1=w,i.initialNoteFilterInput2=x}static spectrumSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer,o=n.wave,r=128,l=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let h=i.phaseDeltas[0]*r,c=i.phaseDeltas[1]*r;const u=+i.phaseDeltaScales[0],f=+i.phaseDeltaScales[1];let m=+i.expression;const d=+i.expressionDelta;let y=+i.noiseSampleA,v=+i.noiseSampleB;const g=i.noteFilters,b=0|i.noteFilterCount;let S=+i.initialNoteFilterInput1,M=+i.initialNoteFilterInput2;const w=xe.applyFilters;let x=i.phases[0]%1*p.spectrumNoiseLength,k=i.phases[1]%1*p.spectrumNoiseLength;0==i.phases[0]&&(x=xe.findRandomZeroCrossing(o,p.spectrumNoiseLength)+h,1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(k=x)),0!=i.phases[1]||1==n.unisonVoices&&0==n.unisonSpread&&!n.chord.customInterval||(k=xe.findRandomZeroCrossing(o,p.spectrumNoiseLength)+c);const F=p.spectrumNoiseLength-1,P=Math.min(1,h),q=Math.min(1,c),I=t+s;for(let e=t;e<I;e++){const t=0|x,s=0|k,i=t&F,n=s&F;let r=o[i],p=o[n];const I=x-t,T=k-s;r+=(o[i+1]-r)*I,p+=(o[n+1]-p)*T,y+=(r-y)*P,v+=(p-v)*q;const D=y+v*l,O=w(D,S,M,b,g);M=S,S=D,x+=h,k+=c,h*=u,c*=f;const A=O*m;m+=d,a[e]+=A}i.phases[0]=x/p.spectrumNoiseLength,i.phases[1]=k/p.spectrumNoiseLength,i.phaseDeltas[0]=h/r,i.phaseDeltas[1]=c/r,i.expression=m,i.noiseSampleA=y,i.noiseSampleB=v,e.sanitizeFilters(g),i.initialNoteFilterInput1=S,i.initialNoteFilterInput2=M}static drumsetSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer;let o=n.getDrumsetWave(i.drumsetPitch);const r=Me.drumsetIndexReferenceDelta(i.drumsetPitch);let l=i.phaseDeltas[0]/r;const h=+i.phaseDeltaScales[0];let c=+i.expression;const u=+i.expressionDelta,f=i.noteFilters,m=0|i.noteFilterCount;let d=+i.initialNoteFilterInput1,y=+i.initialNoteFilterInput2;const v=xe.applyFilters;let g=i.phases[0]%1*p.spectrumNoiseLength;0==i.phases[0]&&(g=xe.findRandomZeroCrossing(o,p.spectrumNoiseLength)+l);const b=p.spectrumNoiseLength-1,S=t+s;for(let e=t;e<S;e++){const t=0|g,s=t&b;let i=o[s];const n=g-t;i+=(o[s+1]-i)*n;const r=i,p=v(r,d,y,m,f);y=d,d=r,g+=l,l*=h;const S=p*c;c+=u,a[e]+=S}i.phases[0]=g/p.spectrumNoiseLength,i.phaseDeltas[0]=l*r,i.expression=c,e.sanitizeFilters(f),i.initialNoteFilterInput1=d,i.initialNoteFilterInput2=y}static modSynth(e,t,s,i,n){if(!e.song)return;let a=p.modCount-1-i.pitches[0];if(n.invalidModulators[a])return;let o=n.modulators[a],r=[];if(p.modulators[n.modulators[a]].forSong)r.push(0);else if(n.modInstruments[a]==e.song.channels[n.modChannels[a]].instruments.length)for(let t=0;t<e.song.channels[n.modChannels[a]].instruments.length;t++)r.push(t);else n.modInstruments[a]>e.song.channels[n.modChannels[a]].instruments.length?null!=e.song.getPattern(n.modChannels[a],e.bar)&&(r=e.song.getPattern(n.modChannels[a],e.bar).instruments):r.push(n.modInstruments[a]);for(let t=0;t<r.length;t++){e.setModValue(i.expression,i.expression+i.expressionDelta,n.modChannels[a],r[t],o);for(let s=0;s<e.heldMods.length;s++)p.modulators[n.modulators[a]].forSong?e.heldMods[s].setting==o&&e.setModValue(e.heldMods[s].volume,e.heldMods[s].volume,n.modChannels[a],r[t],o):e.heldMods[s].channelIndex==n.modChannels[a]&&e.heldMods[s].instrumentIndex==r[t]&&e.heldMods[s].setting==o&&e.setModValue(e.heldMods[s].volume,e.heldMods[s].volume,n.modChannels[a],r[t],o);if(o==p.modulators.dictionary["reset arp"].index&&0==e.tick&&i.noteStartPart==e.beat*p.partsPerBeat+e.part)e.channels[n.modChannels[a]].instruments[r[t]].arpTime=0;else if(o==p.modulators.dictionary["next bar"].index)e.wantToSkip=!0;else if(o==p.modulators.dictionary["eq filter"].index){const o=e.song.channels[n.modChannels[a]].instruments[r[t]];if(!o.eqFilterType){let t=0|n.modFilterTypes[a];if(0==t){let t=0;const n=e.getTicksIntoBar()/p.ticksPerPart;for(;i.note.start+i.note.pins[t].time<=n;)t++;let a=(n-i.note.start+s/(e.getSamplesPerTick()*p.ticksPerPart)*p.ticksPerPart-i.note.pins[t-1].time)/(i.note.pins[t].time-i.note.pins[t-1].time);null!=o.eqSubFilters[i.note.pins[t-1].size]||null!=o.eqSubFilters[i.note.pins[t].size]?o.tmpEqFilterEnd=fe.lerpFilters(o.eqSubFilters[i.note.pins[t-1].size],o.eqSubFilters[i.note.pins[t].size],a):o.tmpEqFilterEnd=o.eqFilter}else{for(let e=0;e<p.filterMorphCount;e++)o.tmpEqFilterEnd==o.eqSubFilters[e]&&null!=o.tmpEqFilterEnd&&(o.tmpEqFilterEnd=new fe,o.tmpEqFilterEnd.fromJsonObject(o.eqSubFilters[e].toJsonObject()));null==o.tmpEqFilterEnd&&(o.tmpEqFilterEnd=new fe,o.tmpEqFilterEnd.fromJsonObject(o.eqFilter.toJsonObject())),o.tmpEqFilterEnd.controlPointCount>Math.floor((t-1)/2)&&(t%2?o.tmpEqFilterEnd.controlPoints[Math.floor((t-1)/2)].freq=i.expression+i.expressionDelta:o.tmpEqFilterEnd.controlPoints[Math.floor((t-1)/2)].gain=i.expression+i.expressionDelta)}}}else if(o==p.modulators.dictionary["note filter"].index){const o=e.song.channels[n.modChannels[a]].instruments[r[t]];if(!o.noteFilterType){let t=0|n.modFilterTypes[a];if(0==t){let t=0;const n=e.getTicksIntoBar()/p.ticksPerPart;for(;i.note.start+i.note.pins[t].time<=n;)t++;let a=(n-i.note.start+s/(e.getSamplesPerTick()*p.ticksPerPart)*p.ticksPerPart-i.note.pins[t-1].time)/(i.note.pins[t].time-i.note.pins[t-1].time);null!=o.noteSubFilters[i.note.pins[t-1].size]||null!=o.noteSubFilters[i.note.pins[t].size]?o.tmpNoteFilterEnd=fe.lerpFilters(o.noteSubFilters[i.note.pins[t-1].size],o.noteSubFilters[i.note.pins[t].size],a):o.tmpNoteFilterEnd=o.noteFilter}else{for(let e=0;e<p.filterMorphCount;e++)o.tmpNoteFilterEnd==o.noteSubFilters[e]&&null!=o.tmpNoteFilterEnd&&(o.tmpNoteFilterEnd=new fe,o.tmpNoteFilterEnd.fromJsonObject(o.noteSubFilters[e].toJsonObject()));null==o.tmpNoteFilterEnd&&(o.tmpNoteFilterEnd=new fe,o.tmpNoteFilterEnd.fromJsonObject(o.noteFilter.toJsonObject())),o.tmpNoteFilterEnd.controlPointCount>Math.floor((t-1)/2)&&(t%2?o.tmpNoteFilterEnd.controlPoints[Math.floor((t-1)/2)].freq=i.expression+i.expressionDelta:o.tmpNoteFilterEnd.controlPoints[Math.floor((t-1)/2)].gain=i.expression+i.expressionDelta)}}}}}static findRandomZeroCrossing(e,t){let s=Math.random()*t;const i=t-1;let n=s&i,a=e[n];for(let o=128;o>0;o--){const o=n+16&i,r=e[o];if(a*r<=0){for(let o=0;o<16;o++){const o=n+1&i,r=e[o];if(a*r<=0){const e=r-a;s=n,Math.abs(e)>1e-8&&(s+=-a/e),s=Math.max(0,s)%t;break}n=o,a=r}break}n=o,a=r}return s}static instrumentVolumeToVolumeMult(e){return e==-p.volumeRange/2?0:Math.pow(2,p.volumeLogScale*e)}static volumeMultToInstrumentVolume(e){return e<=0?-p.volumeRange/2:Math.min(p.volumeRange,Math.log(e)/Math.LN2/p.volumeLogScale)}static noteSizeToVolumeMult(e){return Math.pow(Math.max(0,e)/p.noteSizeMax,1.5)}static volumeMultToNoteSize(e){return Math.pow(Math.max(0,e),1/1.5)*p.noteSizeMax}static fadeInSettingToSeconds(e){return.0125*(.95*e+.05*e*e)}static secondsToFadeInSetting(e){return $(0,p.fadeInRange,Math.round((-.95+Math.sqrt(.9025+.2*e/.0125))/.1))}static fadeOutSettingToTicks(e){return p.fadeOutTicks[e]}static ticksToFadeOutSetting(e){let t=p.fadeOutTicks[0];if(e<=t)return 0;for(let s=1;s<p.fadeOutTicks.length;s++){let i=p.fadeOutTicks[s];if(e<=i)return e<(t+i)/2?s-1:s;t=i}return p.fadeOutTicks.length-1}static detuneToCents(e){return e-p.detuneCenter}static centsToDetune(e){return e+p.detuneCenter}static getOperatorWave(e,t){return 2!=e?p.operatorWaves[e]:p.pwmOperatorWaves[t]}getSamplesPerTick(){if(null==this.song)return 0;let e=this.song.getBeatsPerMinute();return this.isModActive(p.modulators.dictionary.tempo.index)&&(e=this.getModValue(p.modulators.dictionary.tempo.index)),this.getSamplesPerTickSpecificBPM(e)}getSamplesPerTickSpecificBPM(e){const t=e/60,s=p.partsPerBeat*t,i=p.ticksPerPart*s;return this.samplesPerSecond/i}static fittingPowerOfTwo(e){return 1<<32-Math.clz32(Math.ceil(e)-1)}sanitizeFilters(e){let t=!1;for(const s of e){const e=Math.abs(s.output1),i=Math.abs(s.output2);if(!(e<100&&i<100)){t=!0;break}e<V&&(s.output1=0),i<V&&(s.output2=0)}if(t)for(const t of e)t.output1=0,t.output2=0}static sanitizeDelayLine(e,t,s){for(;;){const i=--t&s,n=Math.abs(e[i]);if(Number.isFinite(n)&&(0==n||n>=V))break;e[i]=0}}static applyFilters(e,t,s,i,n){for(let a=0;a<i;a++){const i=n[a],o=i.output1,r=i.output2,l=i.a1,h=i.a2,p=i.b0,c=i.b1,u=i.b2;e=p*e+c*t+u*s-l*o-h*r,i.a1=l+i.a1Delta,i.a2=h+i.a2Delta,i.useMultiplicativeInputCoefficients?(i.b0=p*i.b0Delta,i.b1=c*i.b1Delta,i.b2=u*i.b2Delta):(i.b0=p+i.b0Delta,i.b1=c+i.b1Delta,i.b2=u+i.b2Delta),i.output2=o,i.output1=e,s=r,t=o}return e}}return xe.tempFilterStartCoefficients=new N,xe.tempFilterEndCoefficients=new N,xe.fmSynthFunctionCache={},xe.fm6SynthFunctionCache={},xe.effectsFunctionCache=Array(128).fill(void 0),xe.pickedStringFunctionCache=Array(3).fill(void 0),xe.fmSourceTemplate=("\n\t\tconst data = synth.tempMonoInstrumentSampleBuffer;\n\t\tconst sineWave = Config.sineWave;\n\t\t\t\n\t\t// I'm adding 1000 to the phase to ensure that it's never negative even when modulated by other waves because negative numbers don't work with the modulus operator very well.\n\t\tlet operator#Phase = +((tone.phases[#] % 1) + 1000) * "+p.sineWaveLength+";\n\t\tlet operator#PhaseDelta = +tone.phaseDeltas[#] * "+p.sineWaveLength+";\n\t\tlet operator#PhaseDeltaScale = +tone.phaseDeltaScales[#];\n\t\tlet operator#OutputMult = +tone.operatorExpressions[#];\n\t\tconst operator#OutputDelta = +tone.operatorExpressionDeltas[#];\n\t\tlet operator#Output = +tone.feedbackOutputs[#];\n const operator#Wave = tone.operatorWaves[#].samples;\n\t\tlet feedbackMult = +tone.feedbackMult;\n\t\tconst feedbackDelta = +tone.feedbackDelta;\n let expression = +tone.expression;\n\t\tconst expressionDelta = +tone.expressionDelta;\n\t\t\n\t\tconst filters = tone.noteFilters;\n\t\tconst filterCount = tone.noteFilterCount|0;\n\t\tlet initialFilterInput1 = +tone.initialNoteFilterInput1;\n\t\tlet initialFilterInput2 = +tone.initialNoteFilterInput2;\n\t\tconst applyFilters = Synth.applyFilters;\n\t\t\n\t\tconst stopIndex = bufferIndex + roundedSamplesPerTick;\n\t\tfor (let sampleIndex = bufferIndex; sampleIndex < stopIndex; sampleIndex++) {\n\t\t\t\t// INSERT OPERATOR COMPUTATION HERE\n\t\t\t\tconst fmOutput = (/*operator#Scaled*/); // CARRIER OUTPUTS\n\t\t\t\t\n\t\t\tconst inputSample = fmOutput;\n\t\t\tconst sample = applyFilters(inputSample, initialFilterInput1, initialFilterInput2, filterCount, filters);\n\t\t\tinitialFilterInput2 = initialFilterInput1;\n\t\t\tinitialFilterInput1 = inputSample;\n\t\t\t\t\n\t\t\t\tfeedbackMult += feedbackDelta;\n\t\t\t\toperator#OutputMult += operator#OutputDelta;\n\t\t\t\toperator#Phase += operator#PhaseDelta;\n\t\t\toperator#PhaseDelta *= operator#PhaseDeltaScale;\n\t\t\t\n\t\t\tconst output = sample * expression;\n\t\t\texpression += expressionDelta;\n\n\t\t\tdata[sampleIndex] += output;\n\t\t\t}\n\t\t\t\n\t\t\ttone.phases[#] = operator#Phase / "+p.sineWaveLength+";\n\t\t\ttone.phaseDeltas[#] = operator#PhaseDelta / "+p.sineWaveLength+";\n\t\t\ttone.operatorExpressions[#] = operator#OutputMult;\n\t\t tone.feedbackOutputs[#] = operator#Output;\n\t\t tone.feedbackMult = feedbackMult;\n\t\t tone.expression = expression;\n\t\t\t\n\t\tsynth.sanitizeFilters(filters);\n\t\ttone.initialNoteFilterInput1 = initialFilterInput1;\n\t\ttone.initialNoteFilterInput2 = initialFilterInput2;\n\t\t").split("\n"),xe.operatorSourceTemplate=("\n\t\t\t\tconst operator#PhaseMix = operator#Phase/* + operator@Scaled*/;\n\t\t\t\tconst operator#PhaseInt = operator#PhaseMix|0;\n\t\t\t\tconst operator#Index = operator#PhaseInt & "+p.sineWaveMask+";\n const operator#Sample = operator#Wave[operator#Index];\n operator#Output = operator#Sample + (operator#Wave[operator#Index + 1] - operator#Sample) * (operator#PhaseMix - operator#PhaseInt);\n\t\t\t\tconst operator#Scaled = operator#OutputMult * operator#Output;\n\t\t").split("\n"),e.Channel=ye,e.Config=p,e.CustomAlgorithm=oe,e.CustomFeedBack=re,e.EnvelopeSettings=me,e.FilterControlPoint=ue,e.FilterSettings=fe,e.HarmonicsWave=pe,e.Instrument=de,e.Note=ie,e.Operator=ae,e.Pattern=ne,e.Song=ve,e.SpectrumWave=le,e.Synth=xe,e.clamp=$,e.makeNotePin=se,e.parseFloatWithDefault=j,e.parseIntWithDefault=_,Object.defineProperty(e,"te",{value:!0}),e}({});
//# sourceMappingURL=beepbox_synth.min.js.map