diff --git a/extensions/DogeisCut/BeepBoxPlayer.js b/extensions/DogeisCut/BeepBoxPlayer.js new file mode 100644 index 0000000000..15050f4c4f --- /dev/null +++ b/extensions/DogeisCut/BeepBoxPlayer.js @@ -0,0 +1,596 @@ +// Name: Beepbox Player +// ID: dogeiscutbeepboxplayer +// Description: Play, edit, and read songs from any BeepBox mod directly from the URL! +// By: DogeisCut +// License: MPL-2.0 + +// Version 1.1.1 + +//TODO: Synth deletion (and naming perhaps?) +//TODO: Song validation blocks. +//TODO: Wait for samples loaded blocks +//TODO: channel (x) current (y) block (like current pitch(s) n stuff) +//TODO: loop point blocks +//TODO: set channel (x) current (y) to (z) block (like volume n stuff, things that modulation can affect) (and it's currasponding change by block) +//TODO: song length in seconds, and perhaps how far in the song you are in seconds (rn you have to calculate it with the bpm) +// make sure this has outro, intro and loop options +//TODO: optimise song json and url to only generate on song change +//TODO: beats per bar data n stuff, and amount of bars +//TODO: song completion percentage (((((((bar*24)*beatsPerBar)+((beat*24)+part))+(tick/2))/beatsPerBar)/24)/totalBars) +//TODO: All option on unmute and mute block +//TODO: perhaps split some of the "current" and "song" block functionality into seperate blocks + +//MAYBETODO: raw synth/beepbox function block somehow? + +(function (Scratch) { + "use strict"; + + if (!Scratch.extensions.unsandboxed) { + throw new Error("'BeepBox Player' must run unsandboxed!"); + } + + /* eslint-disable*/ + // prettier-ignore + 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. + */ + //@ts-ignore + var t=e&&e.t||function(e,t,s,i){return new(s||(s=Promise))((function(n,a){function r(e){try{l(i.next(e))}catch(e){a(e)}}function o(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(r,o)}l((i=i.apply(e,t||[])).next())}))};const s=["chip","FM","noise","spectrum","drumset","harmonics","pulse width","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 r=new a;function o(e,s,a,o,l){return t(this,void 0,void 0,(function*(){const t=new AudioContext({sampleRate:l});let h=!1;const p=u.chipWaves[s],m=u.rawChipWaves[s],d=u.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))),u=f(l);p.samples=u,m.samples=l,d.samples=l,o.isUsingAdvancedLoopControls&&(a.chipWaveLoopStart=null!=o.chipWaveLoopStart?o.chipWaveLoopStart:0,a.chipWaveLoopEnd=null!=o.chipWaveLoopEnd?o.chipWaveLoopEnd:l.length-1,a.chipWaveLoopMode=null!=o.chipWaveLoopMode?o.chipWaveLoopMode:0,a.chipWavePlayBackwards=o.chipWavePlayBackwards,a.chipWaveStartOffset=null!=o.chipWaveStartOffset?o.chipWaveStartOffset:0),i.samplesLoaded++,i.statusTable[s]=1,r.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(!u.willReloadForCustomSamples){const s=document.createElement("script");s.src=e,document.head.appendChild(s),s.addEventListener("load",(e=>{t()}))}}))}function h(e){const t=u.chipWaves[0].samples,s=u.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=u.rawRawChipWaves.length;for(const n of e){const e=u.rawRawChipWaves.length,a={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:s},o={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:t};u.rawRawChipWaves[e]=r,u.rawRawChipWaves.dictionary[n.name]=r,u.rawChipWaves[e]=a,u.rawChipWaves.dictionary[n.name]=a,u.chipWaves[e]=o,u.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;u.rawChipWaves[e].samples=s,u.rawRawChipWaves[e].samples=s,u.chipWaves[e].samples=f(s),i.statusTable[e]=1,i.samplesLoaded++,r.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=u.rawRawChipWaves.length;for(const n of e){const e=u.rawRawChipWaves.length,a={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:s},o={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:t};u.rawRawChipWaves[e]=r,u.rawRawChipWaves.dictionary[n.name]=r,u.rawChipWaves[e]=a,u.rawChipWaves.dictionary[n.name]=a,u.chipWaves[e]=o,u.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;u.rawChipWaves[e].samples=s,u.rawRawChipWaves[e].samples=s,u.chipWaves[e].samples=f(s),i.statusTable[e]=1,i.samplesLoaded++,r.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=u.rawRawChipWaves.length;for(const n of e){const e=u.rawRawChipWaves.length,a={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:s},o={index:e,name:n.name,expression:n.expression,isSampled:n.isSampled,isPercussion:n.isPercussion,extraSampleDetune:n.extraSampleDetune,samples:t};u.rawRawChipWaves[e]=r,u.rawRawChipWaves.dictionary[n.name]=r,u.rawChipWaves[e]=a,u.rawChipWaves.dictionary[n.name]=a,u.chipWaves[e]=o,u.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;u.rawChipWaves[e].samples=s,u.rawRawChipWaves[e].samples=s,u.chipWaves[e].samples=f(s),i.statusTable[e]=1,i.samplesLoaded++,r.dispatchEvent(new n(i.totalSamples,i.samplesLoaded)),t++}}))}else console.log("invalid set of built-in samples")}class u{}function c(e){let t=0;for(let s=0;s>1;1==(e+s&1)&&(s+=16384),e=s}}else if(1==e)for(let e=0;e>1;1==(e+s&1)&&(s+=32768),e=s}}else if(3==e){let e=1;for(let t=0;t>1;1==(e+s&1)&&(s+=40),e=s}}else if(4==e)y(i,u.chipNoiseLength,10,11,1,1,0),y(i,u.chipNoiseLength,11,14,.6578,.6578,0),t(i,u.chipNoiseLength),s(i,1/Math.sqrt(u.chipNoiseLength));else if(5==e)for(var n=1,a=0;a>1)&1)&&(r+=40),n=r}else if(6==e)y(i,u.chipNoiseLength,1,10,1,1,0),y(i,u.chipNoiseLength,20,14,-2,-2,0),t(i,u.chipNoiseLength),s(i,1/Math.sqrt(u.chipNoiseLength));else if(7==e)for(n=1,a=0;a>1)&1)&&(r+=60),n=r}else if(8==e)for(n=1,a=0;a>1)&1)&&(r-=40),n=r}else if(9==e){let e=1;for(let t=0;t>1;1==(e+s&1)&&(s+=131080),e=s}}else if(10==e)for(let e=0;e>1)&1)&&(r-=40),n=r}else if(12==e)for(let e=0;e>1,0|Math.pow(2,i)),h=d(0,null,null);let u=0;for(let c=o;cMath.max(e,t)))),u.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}]),u.maxChordSize=9,u.operatorCount=4,u.maxPitchOrOperatorCount=Math.max(u.maxChordSize,u.operatorCount+2),u.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],[]]}]),u.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],[],[],[]]}]),u.operatorCarrierInterval=[0,.04,-.073,.091,.061,.024],u.operatorAmplitudeMax=15,u.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}]),u.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}]),u.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]]}]),u.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]]}]),u.chipNoiseLength=32768,u.spectrumNoiseLength=32768,u.spectrumBasePitch=24,u.spectrumControlPoints=30,u.spectrumControlPointsPerOctave=7,u.spectrumControlPointBits=3,u.spectrumMax=(1<Math.log2(e)*u.pitchesPerOctave)),u.pitchShiftRange=u.justIntonationSemitones.length,u.pitchShiftCenter=u.pitchShiftRange>>1,u.detuneCenter=200,u.detuneMax=400,u.detuneMin=0,u.songDetuneMin=0,u.songDetuneMax=500,u.unisonVoicesMin=1,u.unisonVoicesMax=2,u.unisonSpreadMin=-96,u.unisonSpreadMax=96,u.unisonOffsetMin=-96,u.unisonOffsetMax=96,u.unisonExpressionMin=-2,u.unisonExpressionMax=2,u.unisonSignMin=-2,u.unisonSignMax=2,u.sineWaveLength=256,u.sineWaveMask=u.sineWaveLength-1,u.sineWave=function(){const e=new Float32Array(u.sineWaveLength+1);for(let t=0;t>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=2;i--){const s=1<>1,a=s<<1,r=2*Math.PI/a,o=Math.cos(r),l=Math.sin(r),h=2*o;for(let i=0;i16)throw new Error("FFT array length must not be greater than 2^16.");const i=16-s;for(let s=0;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="2.2.9",z.versionDisplayName="UltraBox "+z.version,z.releaseNotesURL="./patch_notes.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[11],customType:11}])},{name:"Retro Presets",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 E{constructor(){this.i=1,this.o=[void 0],this.l=0,this.h=0,this.u=0}pushFront(e){this.u>=this.i&&this.p(),this.h=this.h-1&this.l,this.o[this.h]=e,this.u++}pushBack(e){this.u>=this.i&&this.p(),this.o[this.h+this.u&this.l]=e,this.u++}popFront(){if(this.u<=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.u--,e}popBack(){if(this.u<=0)throw new Error("No elements left to pop.");this.u--;const e=this.h+this.u&this.l,t=this.o[e];return this.o[e]=void 0,t}peakFront(){if(this.u<=0)throw new Error("No elements left to pop.");return this.o[this.h]}peakBack(){if(this.u<=0)throw new Error("No elements left to pop.");return this.o[this.h+this.u-1&this.l]}count(){return this.u}set(e,t){if(e<0||e>=this.u)throw new Error("Invalid index");this.o[this.h+e&this.l]=t}get(e){if(e<0||e>=this.u)throw new Error("Invalid index");return this.o[this.h+e&this.l]}remove(e){if(e<0||e>=this.u)throw new Error("Invalid index");if(e<=this.u>>1){for(;e>0;)this.set(e,this.get(e-1)),e--;this.popFront()}else{for(e++;e=1073741824)throw new Error("Capacity too big.");this.i=this.i<<1;const e=this.o,t=new Array(this.i),s=0|this.u,i=0|this.h;for(let n=0;n=1?i:1/i),a=Math.tan(.5*n),r=1+a/i;this.b[0]=(1+a*i)/r,this.b[1]=this.a[1]=-2*Math.cos(e)/r,this.b[2]=(1-a*i)/r,this.a[2]=(1-a/i)/r,this.order=2}}class G{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,r=-s;let o=n[0]+n[1]*a,l=n[1]*r,h=1+i[1]*a,u=i[1]*r,c=a,p=r;for(let t=2;t<=e.order;t++){const e=c*r+p*a;c=c*a-p*r,p=e,o+=n[t]*c,l+=n[t]*p,h+=i[t]*c,u+=i[t]*p}this.denom=h*h+u*u,this.real=o*h+l*u,this.imag=l*h-o*u}magnitude(){return Math.sqrt(this.real*this.real+this.imag*this.imag)/this.denom}angle(){return Math.atan2(this.imag,this.real)}}class V{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 $=1e-24;function W(e,t,s){return s<=(t-=1)?s>=e?s:e:t}function j(e,t,s){if(e<=s&&s<=t)return s;throw new Error(`Value ${s} not in range [${e}, ${t}]`)}function U(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 K(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 J(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 Q(e,t,s,i,n,a){e.push(X[t]),e.push(X[Number(s>0)]);let r=Math.round(1e3*Math.abs(s)),o=Math.floor(r/63);e.push(X[r%63],X[o%63],X[Math.floor(o/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 u=Math.round(1e3*Math.abs(n));e.push(X[u%63],X[Math.floor(u/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 Y(e){let t=W(0,u.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>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<0;)i--,this.m[this.v++]&&(s+=1<=0;)this.m[this.g++]=t>>>e&1,e--}writeLongTail(e,t,s){if(s=1<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;te);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]],r=Math.max(0,u.modCount-n.pitches[0]-1),o=e.getVolumeCapForSetting(s,a.modulators[r],a.modFilterTypes[r]);const l=[];for(const t of n.pins){let i=s?Math.round(t.size):Math.round(100*t.size/o);l.push({tick:(t.time+n.start)*u.rhythms[e.rhythm].stepsPerBeat/u.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=W(u.instrumentCountMin,t.getMaxInstrumentsPerPatternForChannel(s)+1,i.length);for(let e=0;e0){const r=Math.min(t.beatsPerBar*u.partsPerBeat*(a?u.modCount:1),e.notes.length>>>0);for(let o=0;o=r);o++){const r=e.notes[o];if(!(r&&r.pitches&&r.pitches.length>=1&&r.points&&r.points.length>=2))continue;const l=new ie(0,0,0,0);l.pitches=[],l.pins=[];for(let e=0;e=u.maxChordSize))break}if(l.pitches.length<1)continue;let h=0;for(let e=0;e0?Math.round(0|n.volume):Math.max(0,Math.min(d,Math.round((0|n.volume)*d/100))),c>t.beatsPerBar*u.partsPerBeat||(0==l.pins.length&&(l.start=c,h=o),l.pins.push(se(o-h,c-l.start,p)))}if(l.pins.length<2)continue;l.end=l.pins[l.pins.length-1].time+l.start;const c=n?u.drumCount-1:u.maxPitch;let p=c,f=0;for(let e=0;ec)&&(l.pitches.splice(e,1),e--),l.pitches[e]f&&(f=l.pitches[e]);if(!(l.pitches.length<1)){for(let e=0;ec&&(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===r.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?u.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 re{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;se-1&&(this.associatedCarrier[t[s][i]-1]=s+1),this.name+=",";this.name+=s=25;this.spectrum[t]=e?Math.max(0,Math.round(u.spectrumMax*(1-t/30))):0}this.markCustomWaveDirty()}markCustomWaveDirty(){const e=xe.fittingPowerOfTwo(u.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=u.spectrumNoiseLength;null!=this.wave&&this.wave.length==s+1||(this.wave=new Float32Array(s+1));const i=this.wave;for(let e=0;e=u.spectrumControlPoints?e.spectrum[u.spectrumControlPoints-1]:e.spectrum[t],l=a(t-1);let h=a(t);t>=u.spectrumControlPoints&&(h=14+.25*(h-14)),0==n&&0==o||(r+=.02*y(i,s,l,h,n/u.spectrumMax,o/u.spectrumMax,-.5))}return e.spectrum[u.spectrumControlPoints-1]>0&&(r+=.02*y(i,s,14+.25*(a(u.spectrumControlPoints)-14),14,e.spectrum[u.spectrumControlPoints-1]/u.spectrumMax,0,-.5)),H(i,s),A(i,5/(Math.sqrt(s)*Math.pow(r,.75))),i[s]=i[0],i}}class ue{constructor(){this.harmonics=[],this.hash=-1,this.reset()}reset(){for(let e=0;e>>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=7==t?u.harmonicsRenderedForPickedString:u.harmonicsRendered,i=u.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=u.harmonicsControlPoints&&(l*=1-(t-u.harmonicsControlPoints)/(s-u.harmonicsControlPoints));const h=l/u.harmonicsMax;let c=Math.pow(2,l-u.harmonicsMax+1)*Math.sqrt(h);t=1?t:e}convertLegacySettings(e,t,s){this.reset();const i=2*Math.asin(.475),n=t>1,a=0==t,r=10==e,o=3==s.type||4==s.type||8==s.type||0==s.type,l=48e3,h=8e3*Math.pow(2,.5*(e-10)),u=Math.min(i,2*Math.PI*h/l);if(1==s.type&&!n&&r);else if(a){const e=3.5,t=u*Math.pow(2,e),s=l*(t/(1+t/Math.PI))/(2*Math.PI),i=pe.getRoundedSettingValueFromHz(s),n=pe.getHzFromSettingValue(i),a=2*Math.PI*n/l,r=new N;r.lowPass1stOrderSimplified(u);const h=new G;h.analyze(r,a);const c=h.magnitude();let p=Math.log2(c);p=.82*(p+e)-e,o&&(p=Math.min(p,-1));const f=Math.pow(2,p),m=pe.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=u+(u*(u/(2*Math.PI*8e3/l)*Math.pow(s,.9)+1)-u)*s;let a;a=o?l*Math.min(i,u*Math.pow(2,.25))/(2*Math.PI):l*i/(2*Math.PI);const r=pe.getRoundedSettingValueFromHz(a);let h;if(o)h=e;else{const t=new N;t.lowPass2ndOrderSimplified(u,e);const s=new G;s.analyze(t,i),h=s.magnitude()}n||(h=Math.min(h,Math.sqrt(.5)));const c=pe.getRoundedSettingValueFromLinearGain(h);this.addPoint(0,r,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,r=8e3*Math.pow(2,.5*(e-10)),o=Math.min(i,2*Math.PI*r/a);if(n){const e=3.5,t=o*Math.pow(2,e),s=a*(t/(1+t/Math.PI))/(2*Math.PI),i=pe.getRoundedSettingValueFromHz(s),n=pe.getHzFromSettingValue(i),r=2*Math.PI*n/a,l=new N;l.lowPass1stOrderSimplified(o);const h=new G;h.analyze(l,r);const u=h.magnitude();let c=Math.log2(u);c=.82*(c+e)-e;const p=Math.pow(2,c),f=pe.getRoundedSettingValueFromLinearGain(p);this.addPoint(0,i,f)}else{const e=.5/(1-.95*Math.sqrt(Math.max(0,t-1)/6)),s=.5/e,i=o+(o*(o/(2*Math.PI*8e3/a)*Math.pow(s,.9)+1)-o)*s;let n;n=a*i/(2*Math.PI);const r=pe.getSettingValueFromHz(n);let l;const h=new N;h.lowPass2ndOrderSimplified(o,e);const u=new G;u.analyze(h,i),l=u.magnitude();const c=pe.getRoundedSettingValueFromLinearGain(l);this.addPoint(0,r,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:u.instrumentAutomationTargets[this.target].name,envelope:u.envelopes[this.envelope].name};return u.instrumentAutomationTargets[this.target].maxCount>1&&(e.index=this.index),e}fromJsonObject(e){this.reset();let t=u.instrumentAutomationTargets.dictionary[e.target];null==t&&(t=u.instrumentAutomationTargets.dictionary.noteVolume),this.target=t.index;let s=u.envelopes.dictionary[e.envelope];null==s&&(s=u.envelopes.dictionary.none),this.envelope=s.index,null!=e.index?this.index=W(0,u.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=u.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=u.filterSimpleCutRange-1,this.eqFilterSimplePeak=0,this.noteFilter=new fe,this.noteFilterType=!1,this.noteFilterSimpleCut=u.filterSimpleCutRange-1,this.noteFilterSimplePeak=0,this.eqSubFilters=[],this.noteSubFilters=[],this.envelopes=[],this.fadeIn=0,this.fadeOut=u.fadeOutNeutral,this.envelopeCount=0,this.transition=u.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=u.panCenter,this.panDelay=10,this.arpeggioSpeed=12,this.fastTwoNoteArp=!1,this.legacyTieOver=!1,this.clicklessTransition=!1,this.aliases=!1,this.pulseWidth=u.pulseWidthRange,this.decimalOffset=0,this.supersawDynamism=u.supersawDynamismMax,this.supersawSpread=Math.ceil(u.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 re,this.customFeedbackType=new oe,this.feedbackAmplitude=0,this.customChipWave=new Float32Array(64),this.customChipWaveIntegral=new Float32Array(65),this.operators=[],this.harmonicsWave=new ue,this.drumsetEnvelopes=[],this.drumsetSpectrumWaves=[],this.modChannels=[],this.modInstruments=[],this.modulators=[],this.modFilterTypes=[],this.invalidModulators=[],t)for(let e=0;e>>0),null!=e.volume?this.volume="jummbox"==o||"midbox"==o||"synthbox"==o||"goldbox"==o||"paandorasbox"==o||"ultrabox"==o?W(-u.volumeRange/2,u.volumeRange/2+1,0|e.volume):Math.round(25*-W(0,8,Math.round(5-(0|e.volume)/20))/7):this.volume=0,null!=e.envelopeSpeed?this.envelopeSpeed=W(0,u.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;st.name==e.wave)),"pink noise"==e.wave&&(this.chipNoise=u.chipNoises.findIndex((e=>"pink"==e.name))),"brownian noise"==e.wave&&(this.chipNoise=u.chipNoises.findIndex((e=>"brownian"==e.name))),-1==this.chipNoise&&(this.chipNoise=1));const f={custom:"note size",steady:"none","pluck 1":"twang 1","pluck 2":"twang 2","pluck 3":"twang 3"},m=e=>null!=f[e]?u.envelopes.dictionary[f[e]]:u.envelopes.dictionary[e];if(4==this.type&&null!=e.drums)for(let t=0;te.name==o));-1!=e&&(this.chipWave=e)}-1==this.chipWave&&(this.chipWave=1)}if(1==this.type||11==this.type){if(1==this.type)this.algorithm=u.algorithms.findIndex((t=>t.name==e.algorithm)),-1==this.algorithm&&(this.algorithm=0),this.feedbackType=u.feedbacks.findIndex((t=>t.name==e.feedbackType)),-1==this.feedbackType&&(this.feedbackType=0);else{if(this.algorithm6Op=u.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=u.feedbacks6Op.findIndex((t=>t.name==e.feedbackType)),-1==this.feedbackType6Op){let t=S([{name:"2⟲ 3⟲",indices:[[],[2],[3],[],[],[]]},{name:"3⟲ 4⟲",indices:[[],[],[3],[4],[],[]]},{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;null!=s?(this.feedbackType6Op=0,this.customFeedbackType.set(s)):this.feedbackType6Op=1}0==this.feedbackType6Op&&null!=e.customFeedback?this.customFeedbackType.set(e.customFeedback.mods):this.customFeedbackType.fromPreset(this.feedbackType6Op)}null!=e.feedbackAmplitude?this.feedbackAmplitude=W(0,u.operatorAmplitudeMax+1,0|e.feedbackAmplitude):this.feedbackAmplitude=0;for(let t=0;te.name==i.frequency)),-1==s.frequency&&(s.frequency=0),null!=i.amplitude?s.amplitude=W(0,u.operatorAmplitudeMax+1,0|i.amplitude):s.amplitude=0,null!=i.waveform){if("goldbox"==o&&t>3){s.waveform=0;continue}s.waveform=u.operatorWaves.findIndex((e=>e.name==i.waveform)),-1==s.waveform&&("square"==i.waveform?(s.waveform=u.operatorWaves.dictionary["pulse width"].index,s.pulseWidth=5):s.waveform=0)}else s.waveform=0;null!=i.pulseWidth?s.pulseWidth=0|i.pulseWidth:s.pulseWidth=5}}else if(9==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=u.maxEnvelopeCount);e++){const s=new me;s.fromJsonObject(t[e]),this.addEnvelope(s.target,s.index,s.envelope)}}}0===l&&(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=u.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;et&&(t=this.noteSubFilters[e].controlPointCount)}else{t=this.eqFilter.controlPointCount;for(let e=0;et&&(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>=u.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?u.instrumentAutomationTargets.dictionary.none.index:e,n.index=i?0:t,n.envelope=s,this.envelopeCount++}supportsEnvelopeTarget(e,t){const s=u.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<=e)return!1}return"operatorFrequency"!=s.name&&"operatorAmplitude"!=s.name||!(t>=4+(11==this.type?2:0))}clearInvalidEnvelopeTargets(){for(let e=0;e{if(e&&null!=t&&null!=s&&null!=i){i=u.modCount-i-1;let e=u.modulators[this.channels[t].instruments[s].modulators[i]].newNoteVol,n=u.modulators.dictionary.tempo.index;return this.channels[t].instruments[s].modulators[i]==n&&(e=this.tempo-u.modulators[n].convertRealFactor),null!=e?e:6}return 6},this.getVolumeCap=(e,t,s,i)=>{if(e&&null!=t&&null!=s&&null!=i){i=u.modCount-i-1;let e=this.channels[t].instruments[s],n=u.modulators[e.modulators[i]],a=n.maxRawVol;return null!=a?("eq filter"!=n.name&&"note filter"!=n.name||(a=u.filterMorphCount-1,e.modFilterTypes[i]>0&&e.modFilterTypes[i]%2?a=u.filterFreqRange:e.modFilterTypes[i]>0&&(a=u.filterGainRange)),a):6}return 6},this.getVolumeCapForSetting=(e,t,s)=>{if(e){let e=u.modulators[t].maxRawVol;return null!=e?(null==s||"eq filter"!=u.modulators[t].name&&"note filter"!=u.modulators[t].name||(e=u.filterMorphCount-1,s>0&&s%2?e=u.filterFreqRange:s>0&&(e=u.filterGainRange)),e):u.noteSizeMax}return u.noteSizeMax},null!=e?this.fromBase64String(e):this.initToDefault(!0)}getChannelCount(){return this.pitchChannelCount+this.noiseChannelCount+this.modChannelCount}getMaxInstrumentsPerChannel(){return Math.max(this.layeredInstruments?u.layeredInstrumentCountMax:u.instrumentCountMin,this.patternInstruments?u.patternInstrumentCountMax:u.instrumentCountMin)}getMaxInstrumentsPerPattern(e){return this.getMaxInstrumentsPerPatternForChannel(this.channels[e])}getMaxInstrumentsPerPatternForChannel(e){return this.layeredInstruments?Math.min(u.layeredInstrumentCountMax,e.instruments.length):1}getChannelIsNoise(e){return e>=this.pitchChannelCount&&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="Untitled",e){this.pitchChannelCount=3,this.noiseChannelCount=1,this.modChannelCount=0;for(let e=0;e=this.pitchChannelCount&&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>6],X[63&s.length]);for(let e=0;e>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>6],X[63&n.length]);for(let e=0;e>6],X[i.volume+u.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>6],X[63&n]);for(let e=0;e>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>6],X[63&n]);for(let e=0;e>6],X[i.detune-u.detuneMin&63]),F(i.effects)&&(t.push(X[i.vibrato]),i.vibrato==u.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]))),I(i.effects)&&(t.push(X[i.distortion]),t.push(X[+i.aliases])),q(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]),R(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||7==i.type){t.push(72);const e=new te;for(let t=0;t186?(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==u.unisons.length&&Q(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign),t.push(121);const e=W(0,32,i.chipWaveLoopMode)<<1|(i.isUsingAdvancedLoopControls?1:0);t.push(X[e]);const s=W(0,32,0)<<1|(i.chipWavePlayBackwards?1:0);t.push(X[s]),K(t,i.chipWaveLoopStart),K(t,i.chipWaveLoopEnd),K(t,i.chipWaveStartOffset)}else if(1==i.type||11==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;e186?(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==u.unisons.length&&Q(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==u.unisons.length&&Q(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>6],X[63&i.decimalOffset]),t.push(104,X[i.unison]),i.unison==u.unisons.length&&Q(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign);else if(8==i.type)t.push(120,X[i.supersawDynamism],X[i.supersawSpread],X[i.supersawShape]),t.push(87,X[i.pulseWidth]),t.push(X[i.decimalOffset>>6],X[63&i.decimalOffset]);else if(7==i.type){if(u.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==u.unisons.length&&Q(t,i.unisonVoices,i.unisonSpread,i.unisonOffset,i.unisonExpression,i.unisonSign),t.push(73,X[i.stringSustain|i.stringSustainType<<5])}else if(10!=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;e1&&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<0){e.write(1,1);let s=0;for(const i of t.notes){i.starts&&(e.write(2,0),a&&e.write(1,0),e.writePartDuration(i.start-s)),r.clear(),1==i.pitches.length?r.write(1,0):(r.write(1,1),r.write(3,i.pitches.length-2)),r.writePinCount(i.pins.length-1),a?r.write(9,i.pins[0].size):r.write(o,i.pins[0].size);let t=0,n=i.pitches[0],l=n;const h=[];for(let e=1;e10&&m.pop();const d=i.pitches.concat(h);for(let t=0;t16&&f.pop(),p=t==i.pitches.length-1?i.pitches[0]:s}0==i.start&&e.write(1,i.continuesLastPattern?1:0),s=i.end}s0;)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 p="";if(null!=z.customSamples&&z.customSamples.length>0&&(p="|"+z.customSamples.join("|")),t.lengthve.T||fve.R||fve.L||fve.P||f0&&(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}}}}if(d&&o){for(const e of this.channels)e.instruments[0].transition=u.transitions.dictionary.interrupt.index,e.instruments[0].effects|=1024;this.channels[3].instruments[0].chipNoise=0}let N=null;if(o&&C||l&&v||y&&c){N=[];for(let e=N.length;e1;for(let e=0;e=this.pitchChannelCount&&e=this.pitchChannelCount+this.noiseChannelCount;for(let n=this.channels[e].instruments.length;n=u.rhythms.dictionary["÷6 (sextuplets)"].index&&(_=!0))}break;case 111:if(d&&o){const t=Z[e.charCodeAt(s++)];this.channels[t].octave=W(0,u.pitchOctaves,Z[e.charCodeAt(s++)]+1),t>=this.pitchChannelCount&&(this.channels[t].octave=0)}else if(C&&o||l&&v||y&&c)for(let t=0;t=this.pitchChannelCount&&(this.channels[t].octave=0);else{for(let t=0;t=this.channels[B].instruments.length&&(B++,$=0),j(0,this.channels.length-1,B);const t=this.channels[B].instruments[$];let i=j(0,11,Z[e.charCodeAt(s++)]);l&&v||y&&c?7!=i&&8!=i||(i+=2):(l&&g||c&&!y||p&&v)&&(8!=i&&9!=i&&10!=i||(i+=1)),t.setTypeAndReset(i,B>=this.pitchChannelCount&&B=this.pitchChannelCount+this.noiseChannelCount),!(b&&o||m&&l)||0!=i&&9!=i&&6!=i||(t.aliases=!0,t.distortion=0,t.effects|=8),U&&(t.arpeggioSpeed=9),_&&(t.fastTwoNoteArp=!0),b&&o&&t.chord!=u.chords.dictionary.simultaneous.index&&(t.effects|=2048)}break;case 117:{const t=Z[e.charCodeAt(s++)]<<6|Z[e.charCodeAt(s++)];this.channels[B].instruments[$].preset=t,l&&v||y&&c?7==this.channels[B].instruments[$].preset&&(this.channels[B].instruments[$].preset=9,this.channels[B].instruments[$].type=9):(l&&g||p&&v)&&(8==this.channels[B].instruments[$].preset&&(this.channels[B].instruments[$].preset=9,this.channels[B].instruments[$].type=9),10==this.channels[B].instruments[$].preset&&(this.channels[B].instruments[$].preset=11,this.channels[B].instruments[$].type=11)),o&&t==z.nameToPresetValue("grand piano 1")&&(this.channels[B].instruments[$].preset=z.nameToPresetValue("grand piano 3"))}break;case 119:if(d&&o){const t=[1,2,3,4,5,6,7,8,0],i=Z[e.charCodeAt(s++)],n=this.channels[i].instruments[0];n.chipWave=W(0,u.chipWaves.length,0|t[Z[e.charCodeAt(s++)]]),n.convertLegacySettings(N[i][0],H)}else if(g&&o){const t=[1,2,3,4,5,6,7,8,0];for(let i=0;i=this.pitchChannelCount?n.chipNoise=W(0,u.chipNoises.length,Z[e.charCodeAt(s++)]):n.chipWave=W(0,u.chipWaves.length,0|t[Z[e.charCodeAt(s++)]])}else if(b&&o){const t=[1,2,3,4,5,6,7,8,0];B>=this.pitchChannelCount?this.channels[B].instruments[$].chipNoise=W(0,u.chipNoises.length,Z[e.charCodeAt(s++)]):this.channels[B].instruments[$].chipWave=W(0,u.chipWaves.length,0|t[Z[e.charCodeAt(s++)]])}else if(2==this.channels[B].instruments[$].type)this.channels[B].instruments[$].chipNoise=W(0,u.chipNoises.length,Z[e.charCodeAt(s++)]);else if(p){const t=Z[e.charCodeAt(s++)],i=Z[e.charCodeAt(s++)];this.channels[B].instruments[$].chipWave=W(0,u.chipWaves.length,3==i?t+186:2==i?t+124:1==i?t+62:t)}else this.channels[B].instruments[$].chipWave=W(0,u.chipWaves.length,Z[e.charCodeAt(s++)]);break;case 102:if(C&&o||v&&l||y&&c)if(b&&o){const t=[10,6,3,0,8,5,2],i=["none","none","none","none","decay 1","decay 2","decay 3"];if(d&&o){const n=Z[e.charCodeAt(s++)],a=this.channels[n].instruments[0],r=N[n][0],o=[1,3,4,5][W(0,t.length,Z[e.charCodeAt(s++)])];r.filterCutoff=t[o],r.filterResonance=0,r.filterEnvelope=u.envelopes.dictionary[i[o]],a.convertLegacySettings(r,H)}else if(g&&o)for(let n=0;n>1,a=Z[e.charCodeAt(s++)],r=Boolean(1&a),o=J(e,s);s+=6;const l=J(e,s);s+=6;const h=J(e,s);s+=6;const u=this.channels[B].instruments[$];u.isUsingAdvancedLoopControls=i,u.chipWaveLoopStart=o,u.chipWaveLoopEnd=l,u.chipWaveLoopMode=n,u.chipWavePlayBackwards=r,u.chipWaveStartOffset=h}else if(c&&!y&&g)"legacysamples"!=document.URL.substring(document.URL.length-13).toLowerCase()&&(E||(E=!0,u.willReloadForCustomSamples=!1,z.customSamples=["legacySamples"],h(0))),this.channels[B].instruments[$].chipWave=W(0,u.chipWaves.length,Z[e.charCodeAt(s++)]+125);else if(C&&o||l&&v||y&&c){const t=8,i=this.channels[B].instruments[$],n=N[B][$];n.filterResonance=W(0,t,Z[e.charCodeAt(s++)]),i.convertLegacySettings(n,H)}break;case 122:{const t=this.channels[B].instruments[$],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(C&&o||v&&l||y&&c)if(4==t.type)for(let n=0;n>5):0}break;case 100:if(C&&o||l&&v||y&&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(d&&o){const i=Z[e.charCodeAt(s++)],n=t[W(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=u.transitions.dictionary[n.transition].index,a.transition!=u.transitions.dictionary.normal.index&&(a.effects|=1024)}else if(g&&o)for(let i=0;i0&&(n.legacyTieOver=!0),n.clicklessTransition=!!Z[e.charCodeAt(s++)],(n.transition!=u.transitions.dictionary.normal.index||n.clicklessTransition)&&(n.effects|=1024)}}else{const t=this.channels[B].instruments[$];t.fadeIn=W(0,u.fadeInRange,Z[e.charCodeAt(s++)]),t.fadeOut=W(0,u.fadeOutTicks.length,Z[e.charCodeAt(s++)]),(l||c||p)&&(t.clicklessTransition=!!Z[e.charCodeAt(s++)])}break;case 99:if(C&&o||l&&v||y&&c)if(b&&o)if(d&&o){const t=[0,3,2,0],i=["none","none","none","tremolo2"],n=Z[e.charCodeAt(s++)],a=W(0,t.length,Z[e.charCodeAt(s++)]),r=this.channels[n].instruments[0],o=N[n][0];r.vibrato=t[a],null!=o.filterEnvelope&&1!=o.filterEnvelope.type||(o.filterEnvelope=u.envelopes.dictionary[i[a]],r.convertLegacySettings(o,H)),r.vibrato!=u.vibratos.dictionary.none.index&&(r.effects|=512)}else if(g&&o){const t=[0,1,2,3,0,0],i=["none","none","none","none","tremolo5","tremolo2"];for(let n=0;n85&&"legacysamples"!=document.URL.substring(document.URL.length-13).toLowerCase()&&(E||(E=!0,u.willReloadForCustomSamples=!1,z.customSamples=["legacySamples"],h(0))),this.channels[B].instruments[$].chipWave=t+62>78?W(0,u.chipWaves.length,t+63):t+62>67?W(0,u.chipWaves.length,t+61):t+62==67?40:W(0,u.chipWaves.length,t+62)}else{const t=this.channels[B].instruments[$];t.supersawDynamism=W(0,u.supersawDynamismMax+1,Z[e.charCodeAt(s++)]),t.supersawSpread=W(0,u.supersawSpreadMax+1,Z[e.charCodeAt(s++)]),t.supersawShape=W(0,u.supersawShapeMax+1,Z[e.charCodeAt(s++)])}break;case 70:{const t=this.channels[B].instruments[$];if(1==t.type)t.feedbackType=W(0,u.feedbacks.length,Z[e.charCodeAt(s++)]);else{t.feedbackType6Op=W(0,u.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]=W(1,u.operatorCount+2,Z[e.charCodeAt(s)]),t++,s++;n++,s++}t.customFeedbackType.set(i),s++}}}break;case 66:this.channels[B].instruments[$].feedbackAmplitude=W(0,u.operatorAmplitudeMax+1,Z[e.charCodeAt(s++)]);break;case 86:if(C&&o||v&&l||y&&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[B].instruments[$],n=N[B][$];let a=Z[e.charCodeAt(s++)];(m&&c||!c&&!p)&&(a=t[a]),n.feedbackEnvelope=ve.I(Z[a]),i.convertLegacySettings(n,H)}break;case 81:{const t=this.channels[B].instruments[$];if(d&&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<(11==t.type?6:u.operatorCount);n++)t.operators[n].frequency=i[W(0,i.length,Z[e.charCodeAt(s++)])]}else if(c||p)for(let i=0;i<(11==t.type?6:u.operatorCount);i++)t.operators[i].frequency=W(0,u.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<(11==t.type?6:u.operatorCount);n++)t.operators[n].frequency=i[W(0,i.length,Z[e.charCodeAt(s++)])]}}break;case 80:{const t=this.channels[B].instruments[$];for(let i=0;i<(11==t.type?6:u.operatorCount);i++)t.operators[i].amplitude=W(0,u.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[B].instruments[$];if(C&&o||v&&l||y&&c){const a=N[B][$];a.operatorEnvelopes=[];for(let r=0;r<(11==n.type?6:u.operatorCount);r++){let n=Z[e.charCodeAt(s++)];(m&&c||o)&&(n=t[n]),l&&(n=i[n]),a.operatorEnvelopes[r]=ve.I(n)}n.convertLegacySettings(a,H)}else{const a=W(0,u.maxEnvelopeCount+1,Z[e.charCodeAt(s++)]);(l&&!g||p&&!v)&&(n.envelopeSpeed=W(0,u.modulators.dictionary["envelope speed"].maxRawVol+1,Z[e.charCodeAt(s++)]),n.discreteEnvelope=!!Z[e.charCodeAt(s++)]);for(let r=0;r1&&(r=W(0,h,Z[e.charCodeAt(s++)]));let p=Z[e.charCodeAt(s++)];(m&&c||o)&&(p=t[p]),l&&(p=i[p]);const f=W(0,u.envelopes.length,p);n.addEnvelope(a,r,f)}}}break;case 82:{const t=this.channels[B].instruments[$];if(d&&c)for(let i=0;i0;)i<<=6,i+=Z[e.charCodeAt(s++)],n--}const h=new ee(e,s,s+i);s+=i;const f=ve.getNeededBits(u.noteSizeMax);let m=-1,g=-1,S=-1;for(;;){const e=this.channels[t],s=this.getChannelIsNoise(t),i=this.getChannelIsMod(t),M=this.getMaxInstrumentsPerPattern(t),w=ve.getNeededBits(M-u.instrumentCountMin),x=ve.getNeededBits(e.instruments.length-1);if(i){let s=v&&l||y&&c;const i=s?x:ve.getNeededBits(this.getMaxInstrumentsPerChannel()+2);for(let n=0;n=0){let t=P(this.channels[a.modChannels[e]].instruments[a.modInstruments[e]].effects);7==a.modulators[e]?(a.modulators[e]=t?u.modulators.dictionary["note filt cut"].index:u.modulators.dictionary["eq filt cut"].index,a.modFilterTypes[e]=1):8==a.modulators[e]&&(a.modulators[e]=t?u.modulators.dictionary["note filt peak"].index:u.modulators.dictionary["eq filt peak"].index,a.modFilterTypes[e]=2)}else s&&a.modulators[e]==u.modulators.dictionary["song reverb"].index&&(m=t,g=n,S=e);s&&12!=u.modulators[a.modulators[e]].associatedEffect&&(this.channels[a.modChannels[e]].instruments[a.modInstruments[e]].effects|=1<10&&T.pop(),g.length<=S?(w=new ie(0,m,m+d.length,d.initialSize),g[S++]=w):(w=g[S++],w.start=m,w.end=m+d.length,w.pins[0].size=d.initialSize);let F=0;const P=[];for(let e=0;e0;){for(x++;-1!=q.indexOf(x);)x++;e--}for(;e<0;){for(x--;-1!=q.indexOf(x);)x--;e++}}q.unshift(x),q.length>r&&q.pop(),e=this.getChannelCount())break}if((l&&v||y&&c)&&S>=0)for(let e=0;e0){const s=this.channels[e].patterns[t-1];let i=6;for(const e of s.notes)e.pitches[0]==u.modCount-1-S&&(i=Math.min(i,e.start));i>0&&s.notes.push(new ie(u.modCount-1-S,0,i,V))}else if(this.channels[e].patterns.lengththis.patternsPerChannel){for(let e=0;e0&&(O="!"+R.join(",")+"!"+c),t[l]=O,z=decodeURIComponent(k.pathname.replace(/^([^\/]*\/)+/,""));const A=1;u.chipWaves[h]={name:z,expression:A,isCustomSampled:!0,isPercussion:f,rootKey:m,sampleRate:p,samples:a,index:h},u.rawChipWaves[h]={name:z,expression:A,isCustomSampled:!0,isPercussion:f,rootKey:m,sampleRate:p,samples:r,index:h},u.rawRawChipWaves[h]={name:z,expression:A,isCustomSampled:!0,isPercussion:f,rootKey:m,sampleRate:p,samples:r,index:h};const C={type:"chip",eqFilter:[],effects:[],transition:"normal",fadeInSeconds:0,fadeOutTicks:-3,chord:"harmony",wave:z,unison:"none",envelopes:[]};d&&(C.isUsingAdvancedLoopControls=!0,C.chipWaveLoopStart=null!=y?y:0,C.chipWaveLoopEnd=null!=v?v:2,C.chipWaveLoopMode=null!=b?b:0,C.chipWavePlayBackwards=S,C.chipWaveStartOffset=null!=g?g:0);const H={index:0,name:z,midiProgram:80,settings:C};s.push(H);o(c,h,C,{isUsingAdvancedLoopControls:d,chipWaveLoopStart:y,chipWaveLoopEnd:v,chipWaveLoopMode:b,chipWavePlayBackwards:S,chipWaveStartOffset:g},p),i.statusTable[h]=0,i.urlTable[h]=c,i.totalSamples++}return!0}static $(){u.chipWaves=S(u.chipWaves.slice(0,u.firstIndexForSamplesInChipWaveList)),u.rawChipWaves=S(u.rawChipWaves.slice(0,u.firstIndexForSamplesInChipWaveList)),u.rawRawChipWaves=S(u.rawRawChipWaves.slice(0,u.firstIndexForSamplesInChipWaveList))}static q(){z.customSamples=null,ve.$(),i.statusTable={},i.urlTable={},i.totalSamples=0,i.samplesLoaded=0,r.dispatchEvent(new n(i.totalSamples,i.samplesLoaded))}toJsonObject(e=!0,t=1,s=!0){const i=[];for(let n=0;n0&&(n.customSamples=z.customSamples),n}fromJsonObject(e,t="auto"){if(this.initToDefault(!0),!e)return;"auto"==t&&"BeepBox"==e.format&&(null!=e.riff&&(t="modbox"),null!=e.masterGain&&(t="jummbox"));const s=("auto"==t?e.format:t).toLowerCase();if(null!=e.name&&(this.title=e.name),null!=e.customSamples){const t=e.customSamples;if(null==z.customSamples||z.customSamples.join(", ")!=t.join(", ")){u.willReloadForCustomSamples=!1,ve.$();let e=!1,s=!1,n=!1;const a=[],r=[];for(const o of t)if("legacysamples"===o.toLowerCase())e||(e=!0,a.push(o),h(0));else if("nintariboxsamples"===o.toLowerCase())s||(s=!0,a.push(o),h(1));else if("mariopaintboxsamples"===o.toLowerCase())n||(n=!0,a.push(o),h(2));else{const e=!1;ve.W(o,a,r,i,e)}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}}}}else{let t=!1;if(null!=e.channels)for(let i=0;ie===a))]):l.includes(a)&&("trumpet"!==a&&"flute"!==a||"paandorasbox"==s)&&(t=!0,n.wave=r[l.findIndex((e=>e===a))])}}}t?(u.willReloadForCustomSamples=!1,ve.$(),h(0),z.customSamples=["legacySamples"]):null!=z.customSamples&&z.customSamples.length>0&&(u.willReloadForCustomSamples=!1,ve.q())}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=u.scales.findIndex((e=>e.name==s));if(-1!=i&&(this.scale=i),this.scale==u.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)%u.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=W(u.tempoMin,u.tempoMax+1,0|e.beatsPerMinute)),null!=e.keyOctave&&(this.octave=W(u.octaveMin,u.octaveMax+1,0|e.keyOctave));let a=0;null!=e.reverb&&(a=W(0,32,0|e.reverb)),null!=e.beatsPerBar&&(this.beatsPerBar=Math.max(u.beatsPerBarMin,Math.min(u.beatsPerBarMax,0|e.beatsPerBar)));let r=4;null!=e.ticksPerBeat&&(r=0|e.ticksPerBeat||4,this.rhythm=u.rhythms.findIndex((e=>e.stepsPerBeat==r)),-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 o=1,l=1,c=1;if(null!=e.channels)for(const t of e.channels)t.instruments&&(o=Math.max(o,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=o>1,this.patternsPerChannel=Math.min(l,u.barCountMax),this.barCount=Math.min(c,u.barCountMax),null!=e.introBars&&(this.loopStart=W(0,this.barCount,0|e.introBars)),null!=e.loopBars&&(this.loopLength=W(1,this.barCount-this.loopStart+1,0|e.loopBars));const p=[],f=[],m=[];if(null!=e.channels)for(let t=0;t=3,o?f.push(n):l?m.push(n):p.push(n),null!=i.octaveScrollBar&&(n.octave=W(0,u.pitchOctaves,1+(0|i.octaveScrollBar)),o&&(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=this.getMaxInstrumentsPerChannel());t++){const i=new de(o,l);n.instruments[t]=i,i.fromJsonObject(e[t],o,l,!1,!1,a,s)}}for(let e=0;e>>0):0;n.bars.length=this.barCount}p.length>u.pitchChannelCountMax&&(p.length=u.pitchChannelCountMax),f.length>u.noiseChannelCountMax&&(f.length=u.noiseChannelCountMax),m.length>u.modChannelCountMax&&(m.length=u.modChannelCountMax),this.pitchChannelCount=p.length,this.noiseChannelCount=f.length,this.modChannelCount=m.length,this.channels.length=0,Array.prototype.push.apply(this.channels,p),Array.prototype.push.apply(this.channels,f),Array.prototype.push.apply(this.channels,m),u.willReloadForCustomSamples}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.U=u.jsonFormat,ve.O=2,ve.T=9,ve.H=1,ve.R=6,ve.N=1,ve.L=4,ve.V=1,ve.P=5,ve.k=117;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,r,o){const l=2*Math.PI*u.pickedStringDispersionCenterFreq/e.samplesPerSecond,h=this.prevDelayLength,c=s.phaseDeltas[i],p=s.phaseDeltaScales[i],f=c*Math.pow(p,n),m=2*Math.PI*c,d=2*Math.PI*f,y=2*m,v=2*d,g=Math.min(Math.PI,m*u.pickedStringDispersionFreqMult*Math.pow(l/m,u.pickedStringDispersionFreqScale)),b=Math.min(Math.PI,d*u.pickedStringDispersionFreqMult*Math.pow(l/d,u.pickedStringDispersionFreqScale)),S=2*Math.PI*u.pickedStringShelfHz/e.samplesPerSecond,M=(Math.pow(100,a)-1)/99,w=(Math.pow(100,r)-1)/99,x=1==o?.25:0,k=15.6,F=3*e.samplesPerSecond/48e3,P=Math.pow(.5,M*Math.pow(S/(m*k),1+2*x)*k),I=Math.pow(.5,w*Math.pow(S/(d*k),1+2*x)*k),q=Math.pow(P,.002),T=Math.pow(I,.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 R=xe.tempFilterEndCoefficients.b[0],z=-e.tempFrequencyResponse.angle()/v,A=0==o?0:1;if(0==A){const e=Math.pow(P,u.stringDecayRate),t=Math.pow(I,u.stringDecayRate);xe.tempFilterStartCoefficients.highShelf2ndOrder(S,e,.5),xe.tempFilterEndCoefficients.highShelf2ndOrder(S,t,.5)}else{const t=Math.pow(1==A?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))),r=Math.pow(2,-Math.pow(2,-Math.pow(t,.9))),o=Math.pow(2,-Math.pow(2,-Math.pow(t,.9)));xe.tempFilterStartCoefficients.lowPass2ndOrderButterworth(B(n),r),xe.tempFilterEndCoefficients.lowPass2ndOrderButterworth(B(a),o)}e.tempFrequencyResponse.analyze(xe.tempFilterStartCoefficients,y);const C=xe.tempFilterStartCoefficients.a[1],H=xe.tempFilterStartCoefficients.a[2],E=xe.tempFilterStartCoefficients.b[0]*q,L=xe.tempFilterStartCoefficients.b[1]*q,N=xe.tempFilterStartCoefficients.b[2]*q,G=-e.tempFrequencyResponse.angle()/y;e.tempFrequencyResponse.analyze(xe.tempFilterEndCoefficients,v);const V=xe.tempFilterEndCoefficients.a[1],$=xe.tempFilterEndCoefficients.a[2],W=xe.tempFilterEndCoefficients.b[0]*T,j=xe.tempFilterEndCoefficients.b[1]*T,U=xe.tempFilterEndCoefficients.b[2]*T,_=-e.tempFrequencyResponse.angle()/v,K=1/c,J=1/f,Q=Math.ceil(2*Math.max(K,J)),Y=K-O-G,X=J-z-_;this.prevDelayLength=Y,this.delayLengthDelta=(X-Y)/n,this.allPassG=D,this.sustainFilterA1=C,this.sustainFilterA2=H,this.sustainFilterB0=E,this.sustainFilterB1=L,this.sustainFilterB2=N,this.allPassGDelta=(R-D)/n,this.sustainFilterA1Delta=(V-C)/n,this.sustainFilterA2Delta=($-H)/n,this.sustainFilterB0Delta=(W-E)/n,this.sustainFilterB1Delta=(j-L)/n,this.sustainFilterB2Delta=(U-N)/n;const Z=Math.abs(Math.log2(Y/h))>.01,ee=-1==this.delayIndex||Z;if(null==this.delayLine||this.delayLine.length<=Q){const t=Math.ceil(2*e.samplesPerSecond/de.frequencyFromPitch(12)),s=new Float32Array(xe.fittingPowerOfTwo(Math.max(t,Q)));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>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=-Y,i=Math.floor(s-K/2),n=Math.ceil(i+2*K);this.delayResetOffset=n;for(let e=i;e<=n;e++)te[e&se]=0;const a=t.wave,r=a.length-1,o=r/K,l=Math.min(.2*K,.003*e.samplesPerSecond),h=Math.ceil(s),u=s+K+l,c=u;let p=(h-s)*o,f=0;for(let e=h;e<=c;e++){const t=0|p,i=t%r;let n=a[i];const h=p-t;n+=(a[i+1]-n)*h;const c=(n-f)/o,m=Math.min(1,(e-s)/l)*Math.min(1,(u-e)/l),d=m*m*(3-2*m);te[e&se]+=c*d,f=n,p+=o}}}}class be{constructor(){this.noteSecondsStart=0,this.noteSecondsStartUnscaled=0,this.noteSecondsEnd=0,this.noteSecondsEndUnscaled=0,this.noteTicksStart=0,this.noteTicksEnd=0,this.noteSizeStart=u.noteSizeMax,this.noteSizeEnd=u.noteSizeMax,this.prevNoteSize=u.noteSizeMax,this.nextNoteSize=u.noteSizeMax,this._=u.noteSizeMax,this.prevNoteSecondsStart=0,this.prevNoteSecondsStartUnscaled=0,this.prevNoteSecondsEnd=0,this.prevNoteSecondsEndUnscaled=0,this.prevNoteTicksStart=0,this.prevNoteTicksEnd=0,this.K=u.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.J=[],this.Y=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._=u.noteSizeMax,this.prevNoteSecondsEnd=0,this.prevNoteSecondsEndUnscaled=0,this.prevNoteTicksEnd=0,this.K=u.noteSizeMax,this.Y=0}computeEnvelopes(e,t,s,i,n,a,r){const o=n;n*=r;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.K=this._,this.noteSecondsEnd=0,this.noteSecondsEndUnscaled=0,this.noteTicksEnd=0),null!=a&&(null!=a.note?this._=a.note.pins[a.note.pins.length-1].size:this._=u.noteSizeMax);const h=s+r,c=i+1,p=this.noteSecondsEnd,f=this.noteSecondsEndUnscaled,m=p+n,d=f+o,y=this.noteTicksEnd,v=y+1,g=this.prevNoteSecondsEnd,b=this.prevNoteSecondsEndUnscaled,S=g+n,M=b+o,w=this.prevNoteTicksEnd,x=w+1,k=1/(u.ticksPerPart*u.partsPerBeat),F=k*s,P=k*h;let I=this._,q=this._,T=this.K,D=0,O=!1,R=!1,z=!1,A=!1,C=0,H=0,E=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],r=(a.note.start+s.time)*u.ticksPerPart,o=(a.note.start+n.time)*u.ticksPerPart,h=(i-r)/(o-r),p=(c-r)/(o-r);if(I=s.size+(n.size-s.size)*h,q=s.size+(n.size-s.size)*p,l.slides){const e=a.noteStartPart*u.ticksPerPart,t=a.noteEndPart*u.ticksPerPart,s=.5*(t-e),n=Math.min(s,l.slideTicks);null==a.prevNote||a.forceContinueAtStart||(i-ei&&0==t.controlPoints[i].type&&(N=Math.max(N,be.getLowpassCutoffDecayVolumeCompensation(n)))}}}this.noteSecondsStart=p,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=I,this.noteSizeEnd=q,this.prevSlideStart=O,this.prevSlideEnd=R,this.nextSlideStart=z,this.nextSlideEnd=A,this.prevSlideRatioStart=C,this.prevSlideRatioEnd=H,this.nextSlideRatioStart=E,this.nextSlideRatioEnd=L,this.lowpassCutoffDecayVolumeCompensation=N}clearEnvelopes(){for(let e=0;e0?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(u.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(u.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>1,t.echoDelay+1),i=2*xe.fittingPowerOfTwo(e*u.echoDelayStepTicks*s);if(null==this.echoDelayLineL||null==this.echoDelayLineR)this.echoDelayLineL=new Float32Array(i),this.echoDelayLineR=new Float32Array(i);else if(this.echoDelayLineL.length=t&&(this.deactivateAfterThisTick=!0)}else{0==this.attentuationProgress||(g=0),b=0;const e=1/256,t=-Math.log2(e);let i=0;if(p&&(i+=u.chorusMaxDelay),f){const e=Math.pow(w,1/x);i+=-1/Math.log2(e)*t}if(m){const e=2*k,s=u.reverbDelayBufferSize/4/o,n=Math.pow(e,1/s);i+=-1/Math.log2(n)*t}const n=s/o/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?u.rawChipWaves[e.chipWave].samples:u.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(9==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,H,A),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(7==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;t0){let e=[],t=[];this.modValues=[],this.nextModValues=[],this.modInsValues=[],this.nextModInsValues=[],this.heldMods=[];for(let e=0;e=0;a--)if(n=this.song.getPattern(i,a),null!=n){let r=n.instruments[0],o=this.song.channels[i].instruments[r],l=[],h=[],c=a==this.bar?s:this.findPartsInBar(a);for(const e of n.notes)if(e.start<=c&&(null==l[u.modCount-1-e.pitches[0]]||e.end>l[u.modCount-1-e.pitches[0]]))if(e.start==c&&(l[u.modCount-1-e.pitches[0]]=e.start,h[u.modCount-1-e.pitches[0]]=e.pins[0].size),e.end<=c)l[u.modCount-1-e.pitches[0]]=e.end,h[u.modCount-1-e.pitches[0]]=e.pins[e.pins.length-1].size;else{l[u.modCount-1-e.pitches[0]]=c;for(let t=0;tc){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[u.modCount-1-e.pitches[0]]=Math.round(e.pins[t-1].size+n*i/s),t=e.pins.length}}for(let s=0;se[o.modulators[s]])&&(this.setModValue(h[s],h[s],o.modChannels[s],o.modInstruments[s],o.modulators[s]),e[o.modulators[s]]=a*u.partsPerBeat*this.song.beatsPerBar+l[s]);else{let e=[];if(o.modInstruments[s]==this.song.channels[o.modChannels[s]].instruments.length)for(let t=0;tthis.song.channels[o.modChannels[s]].instruments.length){const t=this.song.getPattern(o.modChannels[s],a);null!=t&&(e=t.instruments)}else e.push(o.modInstruments[s]);for(let i=0;it[o.modChannels[s]][e[i]][c]){if(n){let t=this.song.channels[o.modChannels[s]].instruments[e[i]];if(0==o.modFilterTypes[s])t.tmpEqFilterStart=t.eqSubFilters[h[s]];else{for(let e=0;e=s.instruments.length?s.instruments:[s.instruments[e.modInstruments[t]]];for(let s=0;sn.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=u.partsPerBeat*(t-this.beat),this.part=Math.floor(t),t=u.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()*u.ticksPerPart*u.partsPerBeat*this.song.beatsPerBar}getTicksIntoBar(){return(this.beat*u.partsPerBeat+this.part)*u.ticksPerPart+this.tick}getCurrentPart(){return this.beat*u.partsPerBeat+this.part}findPartsInBar(e){if(null==this.song)return 0;let t=u.partsPerBeat*this.song.beatsPerBar;for(let s=this.song.pitchChannelCount+this.song.noiseChannelCount;se.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,r=!1,o=this.song.tempo;for(let e=this.song.getChannelCount()-1;e>=this.song.pitchChannelCount+this.song.noiseChannelCount;e--)for(let t=i;t0){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],r=this.song.channels[i].instruments[a],o=this.findPartsInBar(s);for(const s of n.notes)if(r.modulators[u.modCount-1-s.pitches[0]]==u.modulators.dictionary.tempo.index&&s.starte))if(s.end<=o)e=s.end,t=s.pins[s.pins.length-1].size;else{e=o;for(let e=0;eo){const i=s.pins[e].time-s.pins[e-1].time,n=o-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&&(o=t+u.modulators.dictionary.tempo.convertRealFactor,s=-1)}}if(a||r){let e=i,t=!1,l=0;for(;!t;){let i=u.partsPerBeat*this.song.beatsPerBar,h=0;if(r&&(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;se.pitches[0]==u.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]==u.modCount-1-s&&(l+=Math.min(i-h,e.start-h)*u.ticksPerPart*this.getSamplesPerTickSpecificBPM(o),e.starti&&(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)+u.modulators.dictionary.tempo.convertRealFactor);let r=u.partsPerBeat*u.ticksPerPart/60;l+=a!=n?-this.samplesPerSecond*s*(Math.log(r*a*s)-Math.log(r*n*s))/(r*(n-a)):s*this.getSamplesPerTickSpecificBPM(a),o=a}h=Math.min(e.start+e.pins[t].time,i)}}}}}l+=(i-h)*u.ticksPerPart*this.getSamplesPerTickSpecificBPM(o),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 pe,this.tempFrequencyResponse=new G,this.loopBarStart=-1,this.loopBarEnd=-1,this.channels=[],this.tonePool=new E,this.tempMatchedPitchTones=Array(u.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=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*u.panDelaySecondsMax),this.panningDelayBufferMask=this.panningDelayBufferSize-1,this.chorusDelayBufferSize=xe.fittingPowerOfTwo(this.samplesPerSecond*u.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.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,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;ia)&&(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&&(r=!0,this.pause()))),this.syncSongState(),(null==this.tempMonoInstrumentSampleBuffer||this.tempMonoInstrumentSampleBuffer.length=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;e0||this.playModTone(n,e,a,m,v,i,!1,!1)}}}for(let e=n.pitchChannelCount+n.noiseChannelCount;e0&&this.playModTone(n,e,a,m,v,i,!1,!1)}}}}if(this.wantToSkip){let e=p.includes(this.bar);if(e&&m==f)return void this.pause();-1==f&&(f=m),e||p.push(this.bar),this.wantToSkip=!1,this.skipBar()}else{for(let s=0;s=Math.abs(l.getFadeOutTicks())){this.freeReleasedTone(h,t),t--;continue}const r=e>=u.maximumTonesPerChannel;this.computeTone(n,s,a,i,!0,r),e++}h.awake&&(h.computed||h.compute(this,l,a,Math.ceil(a),null,s,i),h.computed=!1)}for(let e=0;e4&&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,r=2*Math.PI/a;this.metronomeSamplesRemaining=Math.floor(a*t),this.metronomeFilter=2*Math.cos(r),this.metronomeAmplitude=i*Math.sin(r),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;iu?r:u;this.song.inVolumeCap=this.song.inVolumeCap>p?this.song.inVolumeCap:p;const f=+(p>n.compressionThreshold)+ +(p>n.limitThreshold),m=+(0==f)*((.8*(p+1-n.compressionThreshold)+.25)*n.compressionRatio+1.05*(1-n.compressionRatio))+1.05*+(1==f)+ +(2==f)*(1.05*((p+1-n.limitThreshold)*n.limitRatio+(1-n.limitThreshold)));c+=(m-c)*(c=1?1.05*c:.8*c+.25);e[s]=i*d,t[s]=a*d,this.song.outVolumeCap=this.song.outVolumeCap>p*d?this.song.outVolumeCap:p*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;e0&&this.loopRepeatCount--,this.bar>=n.barCount&&(this.bar=0,-1!=this.loopRepeatCount&&(r=!0,this.resetEffects(),this.pause()))))))}}for(let e=0;e0){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,r=this.liveBassInputPitches;for(let o=0;o0&&t==this.liveInputChannel&&a.length>0&&-1!=this.liveInputInstruments.indexOf(o)){const n=i.instruments[o];if(n.getChord().singleTone){let i;h.count()<=u?(i=this.newTone(),h.pushBack(i)):!n.getTransition().isSeamless&&this.liveInputStarted?(this.releaseTone(l,h.get(u)),i=this.newTone(),h.set(u,i)):i=h.get(u),u++;for(let e=0;e0&&t==this.liveBassInputChannel&&r.length>0&&-1!=this.liveBassInputInstruments.indexOf(o)){const n=i.instruments[o];if(n.getChord().singleTone){let i;h.count()<=u?(i=this.newTone(),h.pushBack(i)):!n.getTransition().isSeamless&&this.liveInputStarted?(this.releaseTone(l,h.get(u)),i=this.newTone(),h.set(u,i)):i=h.get(u),u++;for(let e=0;eu;)this.releaseTone(l,h.popBack());this.clearTempMatchedPitchTones(u,l)}this.liveInputStarted=!1,this.liveBassInputStarted=!1}adjacentPatternHasCompatibleInstrumentTransition(e,t,s,i,n,a,r,o,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?r: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;s0;){const t=e.popFront();for(let e=0;ei[r.notes[e].pitches[0]].start)&&(i[r.notes[e].pitches[0]]=r.notes[e]):r.notes[e].start<=o&&r.notes[e].end>o?s[r.notes[e].pitches[0]]=r.notes[e]:r.notes[e].start>o&&(null==h[r.notes[e].pitches[0]]||r.notes[e].start0;)t.activeModTones.pushFront(e.activeModTones.popBack())}if(a.singleSeamlessInstrument=f,null!=s[e]){let t=i[e],n=h[e],a=!1,r=!1;const o=u.ticksPerPart*s[e].start==l&&this.isAtStartOfTick;let c;if(d.count()<=p)c=this.newTone(),d.pushBack(c);else if(o&&null==t){const e=d.get(p);e.isOnLastTick?this.freeTone(e):this.releaseTone(m,e),c=this.newTone(),d.set(p,c)}else c=d.get(p);p++;for(let t=0;tp;){const s=d.popBack(),i=e.channels[t];if(s.instrumentIndexo)h=r.notes[e];else if(r.notes[e].start>o){p=r.notes[e];break}null!=h&&(null!=c&&c.end!=h.start&&(c=null),null!=p&&p.start!=h.end&&(p=null))}if(null!=r&&(!e.layeredInstruments||1==n.instruments.length||e.patternInstruments&&1==r.instruments.length)){const t=e.patternInstruments?r.instruments[0]:0;if(null!=a.singleSeamlessInstrument&&a.singleSeamlessInstrument!=t&&a.singleSeamlessInstrument0;)s.activeTones.pushFront(e.activeTones.popBack())}a.singleSeamlessInstrument=t}else a.singleSeamlessInstrument=null;for(let i=0;ia?y:null,p=h,g=k>a?v:null,b=p.start+r,F=!1;if(b>o){if(!(m.count()>a&&(n.isSeamless||M)&&null!=c))break;g=p,p=c,c=null,b=p.start+r,F=!0}let P=p.end;(n.isSeamless||M)&&null!=g&&(P=Math.min(u.partsPerBeat*this.song.beatsPerBar,P+r)),(n.continues||M)&&null!=c||(r+=S.strumParts);const I=u.ticksPerPart*b==l;let q;if(null!=this.tempMatchedPitchTones[d])q=this.tempMatchedPitchTones[d],this.tempMatchedPitchTones[d]=null,m.pushBack(q);else if(m.count()<=d)q=this.newTone(),m.pushBack(q);else if(!I||(n.isSeamless||M)&&null!=c)q=m.get(d);else{const e=m.get(d);e.isOnLastTick?this.freeTone(e):this.releaseTone(f,e),q=this.newTone(),m.set(d,q)}d++,q.pitches[0]=p.pitches[a],q.pitchCount=1,q.chordSize=p.pitches.length,q.instrumentIndex=i,q.note=p,q.noteStartPart=b,q.noteEndPart=P,q.prevNote=c,q.nextNote=g,q.prevNotePitchIndex=a,q.nextNotePitchIndex=a,q.atNoteStart=I,q.passedEndOfNote=F,q.forceContinueAtStart=M&&null!=c,q.forceContinueAtEnd=w&&null!=g,this.computeTone(e,t,s,q,!1,!1)}}}for(;m.count()>d;){const s=m.popBack(),i=e.channels[t];if(s.instrumentIndex=s&&(O=!0)}else if(null==i.note)A=C=1,i.lastInterval=0,i.ticksSinceReleased=0,i.liveInputSamplesHeld+=r;else{const e=i.note,t=i.nextNote,s=i.noteStartPart,n=i.noteEndPart,a=e.getEndPinIndex(T),r=e.pins[a-1],o=e.pins[a],l=s*u.ticksPerPart,c=n*u.ticksPerPart,f=(e.start+r.time)*u.ticksPerPart,m=(e.start+o.time)*u.ticksPerPart;i.ticksSinceReleased=0;const d=T*u.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(A=1,C=1,R=r.interval+(o.interval-r.interval)*b,z=r.interval+(o.interval-r.interval)*S,i.lastInterval=z,!p.isSeamless&&!i.forceContinueAtEnd||null==t){const e=-h.getFadeOutTicks();if(e>0){const t=c-l;A*=Math.min(1,(t-v)/e),C*=Math.min(1,(t-g)/e),y>=l+t&&(O=!0)}}}i.isOnLastTick=O;let $,W,j=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,r=h.noteFilterSimpleCut,o=h.noteFilterSimplePeak,l=!1;this.isModActive(u.modulators.dictionary["note filt cut"].index,t,i.instrumentIndex)&&(n=this.getModValue(u.modulators.dictionary["note filt cut"].index,t,i.instrumentIndex,!1),r=this.getModValue(u.modulators.dictionary["note filt cut"].index,t,i.instrumentIndex,!0),l=!0),this.isModActive(u.modulators.dictionary["note filt peak"].index,t,i.instrumentIndex)&&(a=this.getModValue(u.modulators.dictionary["note filt peak"].index,t,i.instrumentIndex,!1),o=this.getModValue(u.modulators.dictionary["note filt peak"].index,t,i.instrumentIndex,!0),l=!0),e.convertLegacySettingsForSynth(n,a,!l),s.convertLegacySettingsForSynth(r,o,!l),$=e.controlPoints[0],W=s.controlPoints[0],h.noteFilter=e,h.tmpNoteFilterStart=e}const U=i.envelopeComputer;let _=u.arpSpeedScale[h.envelopeSpeed];this.isModActive(u.modulators.dictionary["envelope speed"].index,t,i.instrumentIndex)&&(_=Math.max(0,Math.min(u.arpSpeedScale.length-1,this.getModValue(u.modulators.dictionary["envelope speed"].index,t,i.instrumentIndex,!1))),_=Number.isInteger(_)?u.arpSpeedScale[_]:(1-_%1)*u.arpSpeedScale[Math.floor(_)]+_%1*u.arpSpeedScale[Math.ceil(_)]),U.computeEnvelopes(h,T,c.envelopeTime,u.ticksPerPart*I,s/this.samplesPerSecond,i,_);const K=i.envelopeComputer.envelopeStarts,J=i.envelopeComputer.envelopeEnds;if(h.noteFilter=j,null!=i.note&&p.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(U.prevSlideStart&&(R+=t*U.prevSlideRatioStart),U.prevSlideEnd&&(z+=t*U.prevSlideRatioEnd),!f.singleTone){const t=e.pitches.length-i.chordSize;U.prevSlideStart&&(H=xe.computeChordExpression(i.chordSize+t*U.prevSlideRatioStart)),U.prevSlideEnd&&(E=xe.computeChordExpression(i.chordSize+t*U.prevSlideRatioEnd))}}if(null!=t){const e=t.pitches[i.nextNotePitchIndex]-(i.pitches[0]+i.note.pins[i.note.pins.length-1].interval);if(U.nextSlideStart&&(R+=e*U.nextSlideRatioStart),U.nextSlideEnd&&(z+=e*U.nextSlideRatioEnd),!f.singleTone){const e=t.pitches.length-i.chordSize;U.nextSlideStart&&(H=xe.computeChordExpression(i.chordSize+e*U.nextSlideRatioStart)),U.nextSlideEnd&&(E=xe.computeChordExpression(i.chordSize+e*U.nextSlideRatioEnd))}}}if(x(h.effects)){let e=u.justIntonationSemitones[h.pitchShift]/v,s=1,n=1;this.isModActive(u.modulators.dictionary["pitch shift"].index,t,i.instrumentIndex)&&(e=u.justIntonationSemitones[u.justIntonationSemitones.length-1],s=this.getModValue(u.modulators.dictionary["pitch shift"].index,t,i.instrumentIndex,!1)/u.pitchShiftCenter,n=this.getModValue(u.modulators.dictionary["pitch shift"].index,t,i.instrumentIndex,!0)/u.pitchShiftCenter);R+=e*K[18]*s,z+=e*J[18]*n}if(k(h.effects)||this.isModActive(u.modulators.dictionary["song detune"].index,t,i.instrumentIndex)){const e=K[19],s=J[19];let n=h.detune,a=h.detune;this.isModActive(u.modulators.dictionary.detune.index,t,i.instrumentIndex)&&(n=this.getModValue(u.modulators.dictionary.detune.index,t,i.instrumentIndex,!1)+u.detuneCenter,a=this.getModValue(u.modulators.dictionary.detune.index,t,i.instrumentIndex,!0)+u.detuneCenter),this.isModActive(u.modulators.dictionary["song detune"].index,t,i.instrumentIndex)&&(n+=4*this.getModValue(u.modulators.dictionary["song detune"].index,t,i.instrumentIndex,!1),a+=4*this.getModValue(u.modulators.dictionary["song detune"].index,t,i.instrumentIndex,!0)),R+=xe.detuneToCents(n)*e*u.pitchesPerOctave/1200,z+=xe.detuneToCents(a)*s*u.pitchesPerOctave/1200}if(F(h.effects)){let e,s,n,a;if(h.vibrato==u.vibratos.length?(e=2*h.vibratoDelay,h.vibratoDelay==u.modulators.dictionary["vibrato delay"].maxRawVol&&(e=Number.POSITIVE_INFINITY),s=h.vibratoDepth,n=s):(e=u.vibratos[h.vibrato].delayTicks,s=u.vibratos[h.vibrato].amplitude,n=s),this.isModActive(u.modulators.dictionary["vibrato delay"].index,t,i.instrumentIndex)&&(e=2*this.getModValue(u.modulators.dictionary["vibrato delay"].index,t,i.instrumentIndex,!1),e==2*u.modulators.dictionary["vibrato delay"].maxRawVol&&(e=Number.POSITIVE_INFINITY)),this.isModActive(u.modulators.dictionary["vibrato depth"].index,t,i.instrumentIndex)&&(s=this.getModValue(u.modulators.dictionary["vibrato depth"].index,t,i.instrumentIndex,!1)/25,n=this.getModValue(u.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)*K[20],e>0){const t=e-U.noteTicksStart;a*=Math.max(0,Math.min(1,1-t/2))}}let r=xe.getLFOAmplitude(h,g*c.nextVibratoTime);const o=J[20];if(10!=h.type){let t=n*r*o;if(e>0){const s=e-U.noteTicksEnd;t*=Math.max(0,Math.min(1,1-s/2))}i.prevVibrato=t,R+=a,z+=t}}if(!p.isSeamless&&!i.forceContinueAtStart||null==i.prevNote){const e=h.getFadeInSeconds();e>0&&(A*=Math.min(1,U.noteSecondsStartUnscaled/e),C*=Math.min(1,U.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(u.drumCount-1,i.drumsetPitch)));let Q=U.lowpassCutoffDecayVolumeCompensation;if(P(h.effects)){const e=K[1],t=J[1];if(h.noteFilterType){const s=K[21],n=J[21],a=K[29],o=J[29];$.toCoefficients(xe.tempFilterStartCoefficients,this.samplesPerSecond,e*s,a),W.toCoefficients(xe.tempFilterEndCoefficients,this.samplesPerSecond,t*n,o),i.noteFilters.length<1&&(i.noteFilters[0]=new V),i.noteFilters[0].loadCoefficientsWithGradient(xe.tempFilterStartCoefficients,xe.tempFilterEndCoefficients,1/r,0==$.type),Q*=$.getVolumeCompensationMult(),i.noteFilterCount=1}else{const s=null!=h.tmpNoteFilterStart?h.tmpNoteFilterStart:h.noteFilter;for(let n=0;n1&&a){const e=Math.floor(c.arpTime/u.ticksPerArpeggio);n=i.pitches[b(i.pitchCount,h.fastTwoNoteArp,e)]-i.pitches[0]}const o=11==h.type?h.customAlgorithm.carrierCount:u.algorithms[h.algorithm].carrierCount;for(let l=0;l<(11==h.type?6:u.operatorCount);l++){const c=11==h.type?h.customAlgorithm.associatedCarrier[l]-1:u.algorithms[h.algorithm].associatedCarrier[l]-1,p=i.pitches[a?0:l1&&(f.arpeggiates||f.customInterval)){const e=Math.floor(c.arpTime/u.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+R)*v,o=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,-(o-L)/B);i.prevPitchExpressions[0]=d;let y=G*Q;if(2==h.type&&(y*=u.chipNoises[h.chipNoise].expression),0==h.type&&(y*=u.chipWaves[h.chipWave].expression),6==h.type){const e=m(h.pulseWidth);let s=e,n=e;this.isModActive(u.modulators.dictionary["pulse width"].index,t,i.instrumentIndex)&&(s=this.getModValue(u.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!1)/(2*u.pulseWidthRange),n=this.getModValue(u.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!0)/(2*u.pulseWidthRange));const a=s*K[2],o=n*J[2];i.pulseWidth=a,i.pulseWidthDelta=(o-a)/r;let l=h.decimalOffset;this.isModActive(u.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex)&&(l=this.getModValue(u.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex,!1));const c=l*K[37];i.decimalOffset=c,i.pulseWidth-=i.decimalOffset/1e4}if(7==h.type){let e=h.stringSustain,s=h.stringSustain;this.isModActive(u.modulators.dictionary.sustain.index,t,i.instrumentIndex)&&(e=this.getModValue(u.modulators.dictionary.sustain.index,t,i.instrumentIndex,!1),s=this.getModValue(u.modulators.dictionary.sustain.index,t,i.instrumentIndex,!0)),i.stringSustainStart=e,i.stringSustainEnd=s,y*=Math.pow(2,.7*(1-e/(u.stringSustainRange-1)))}const g=de.frequencyFromPitch(a);if(0==h.type||9==h.type||5==h.type||7==h.type||3==h.type||6==h.type||2==h.type){const e=h.unisonVoices,t=h.unisonSpread,n=h.unisonOffset;y*=h.unisonExpression*(7==h.type?1:e/2);const a=K[4],o=J[4],l=Math.pow(2,(n+t)*a/12),u=Math.pow(2,(n+t)*o/12),c=Math.pow(2,(n-t)*a/12)*D,p=Math.pow(2,(n-t)*o/12)*D;i.phaseDeltas[0]=g*S*l,i.phaseDeltas[1]=g*S*c,i.phaseDeltaScales[0]=s*Math.pow(u/l,1/r),i.phaseDeltaScales[1]=s*Math.pow(p/c,1/r)}else i.phaseDeltas[0]=g*S,i.phaseDeltaScales[0]=s;let M=1,w=1;if(8==h.type){const s=1/Math.sqrt(u.supersawVoiceCount);let n=h.supersawDynamism/u.supersawDynamismMax,a=h.supersawDynamism/u.supersawDynamismMax;this.isModActive(u.modulators.dictionary.dynamism.index,t,i.instrumentIndex)&&(n=this.getModValue(u.modulators.dictionary.dynamism.index,t,i.instrumentIndex,!1)/u.supersawDynamismMax,a=this.getModValue(u.modulators.dictionary.dynamism.index,t,i.instrumentIndex,!0)/u.supersawDynamismMax);const o=1-Math.pow(Math.max(0,1-n*K[38]),.2),l=1-Math.pow(Math.max(0,1-a*J[38]),.2),c=Math.pow(2,Math.log2(s)*o),p=Math.pow(2,Math.log2(s)*l),f=Math.sqrt((1/Math.pow(c,2)-1)/(u.supersawVoiceCount-1)),d=Math.sqrt((1/Math.pow(p,2)-1)/(u.supersawVoiceCount-1));i.supersawDynamism=f,i.supersawDynamismDelta=(d-f)/r;const y=-1==i.supersawDelayIndex;if(y){let e=0;for(let t=0;t=0;e--){const r=1-i.phases[e],o=r-a;if(s<0){const e=-s/t;if(e>1)-.5+.025*((2&e)-1))/(u.supersawVoiceCount>>1),1.1)*(2*(1&e)-1);i.supersawUnisonDetunes[e]=Math.pow(2,F*t/12)}const P=h.supersawShape/u.supersawShapeMax;let I=P*K[40],q=P*J[40];this.isModActive(u.modulators.dictionary["saw shape"].index,t,i.instrumentIndex)&&(I=this.getModValue(u.modulators.dictionary["saw shape"].index,t,i.instrumentIndex,!1)/u.supersawShapeMax,q=this.getModValue(u.modulators.dictionary["saw shape"].index,t,i.instrumentIndex,!0)/u.supersawShapeMax);const T=I*K[40],D=q*J[40];i.supersawShape=T,i.supersawShapeDelta=(D-T)/r;let O=h.decimalOffset;this.isModActive(u.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex)&&(O=this.getModValue(u.modulators.dictionary["decimal offset"].index,t,i.instrumentIndex,!1));const R=O*K[37];i.decimalOffset=R;const z=m(h.pulseWidth);let A=z,C=z;this.isModActive(u.modulators.dictionary["pulse width"].index,t,i.instrumentIndex)&&(A=this.getModValue(u.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!1)/(2*u.pulseWidthRange),C=this.getModValue(u.modulators.dictionary["pulse width"].index,t,i.instrumentIndex,!0)/(2*u.pulseWidthRange));let H=A*K[2],E=C*J[2];H-=R/1e4,E-=R/1e4;const L=null!=i.supersawPrevPhaseDelta?i.supersawPrevPhaseDelta:g*S,N=g*S*e;i.supersawPrevPhaseDelta=N;const G=H/L,V=E/N;i.supersawDelayLength=G,i.supersawDelayLengthDelta=(V-G)/r;const B=Math.ceil(Math.max(G,V))+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=0;t--)for(const i of xe.operatorSourceTemplate)if(-1!=i.indexOf("/* + operator@Scaled*/")){let n="";for(const s of u.algorithms[e.algorithm].modulatedBy[t])n+=" + operator"+(s-1)+"Scaled";const a=u.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=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;e0&&S0&&Mh&&(S<=0&&(w=G,S++),t=1):-1===g&&D<0&&(S<=0&&(w=G,S++),t=1),1===b?O>h&&(M<=0&&(x=V,M++),t=1):-1===g&&O<0&&(M<=0&&(x=V,M++),t=1)):3===f?(1===g?D>u&&(S<=0&&(w=G,S++),t=1):-1===g&&Du&&(M<=0&&(x=V,M++),t=1):-1===g&&Ou&&(D=c+xe.wrap(D-u,p),t=1):-1===g&&Du&&(O=c+xe.wrap(O-u,p),t=1):-1===b&&Ou&&(D=u-xe.wrap(D-u,p),g=-1,t=1):-1===g&&Du&&(O=u-xe.wrap(O-u,p),b=-1,t=1):-1===b&&O0?(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),r=xe.wrap(e,h),l=xe.wrap(a,h);let p=o[r],m=o[l];const F=D-e,P=O-a;if(p+=(o[xe.wrap(r+1,h)]-p)*F,m+=(o[xe.wrap(l+1,h)]-m)*P,(0!==f||0!==c||u!==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),r=xe.wrap(n,h),l=xe.wrap(a,h);e=o[r],t=o[l],e+=(o[xe.wrap(r+1,h)]-e)*(s-n)*g,t+=(o[xe.wrap(l+1,h)]-t)*(i-a)*b,R=e,z=t}1===f&&0!==t?(s=G,i=V):(s=(p-R)/(y*g),i=(m-z)/(v*b)),G=s,V=i,R=p,z=m;const I=S>0?(k-Math.min(S,k))/k:1,q=M>0?(k-Math.min(M,k))/k:1;n+=S>0?w*I:s,n+=M>0?x*q:i*d}const m=L(n*l,H,E,C,A);E=H,H=n*l,y*=F,v*=P;const I=m*q;q+=T,r[e]+=I}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]=G,i.chipWavePrevWaves[1]=V,i.chipWaveCompletionsLastWave[0]=w,i.chipWaveCompletionsLastWave[1]=x,i.expression=q,e.sanitizeFilters(A),i.initialNoteFilterInput1=H,i.initialNoteFilterInput2=E}static chipSynth(e,t,s,i,n){const a=I(n.effects)&&n.aliases,r=e.tempMonoInstrumentSampleBuffer,o=n.wave,l=n.volumeScale,h=a&&8==n.type?o.length:o.length-1,u=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,p=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=+o[s],F=+o[i],k+=(o[s+1]-k)*n,F+=(o[i+1]-F)*a}const P=t+s;for(let e=t;e{const t=[];for(let s=0;s0,h=T(a.effects),c=D(a.effects),p=O(a.effects),f=R(a.effects);let m=0;r&&(m|=1),m<<=1,o&&(m|=1),m<<=1,l&&(m|=1),m<<=1,h&&(m|=1),m<<=1,c&&(m|=1),m<<=1,p&&(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||p;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;"),r&&(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;"),o&&(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 = +Config.chorusPeriodSeconds;\n\t\t\t\tconst chorusAngle = Math.PI * 2.0 / (chorusDuration * synth.samplesPerSecond);\n\t\t\t\tconst chorusRange = synth.samplesPerSecond * Config.chorusDelayRange;\n\t\t\t\tconst chorusOffset0 = synth.chorusDelayBufferSize - Config.chorusDelayOffsets[0][0] * chorusRange;\n\t\t\t\tconst chorusOffset1 = synth.chorusDelayBufferSize - Config.chorusDelayOffsets[0][1] * chorusRange;\n\t\t\t\tconst chorusOffset2 = synth.chorusDelayBufferSize - Config.chorusDelayOffsets[0][2] * chorusRange;\n\t\t\t\tconst chorusOffset3 = synth.chorusDelayBufferSize - Config.chorusDelayOffsets[1][0] * chorusRange;\n\t\t\t\tconst chorusOffset4 = synth.chorusDelayBufferSize - Config.chorusDelayOffsets[1][1] * chorusRange;\n\t\t\t\tconst chorusOffset5 = synth.chorusDelayBufferSize - 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 + Config.chorusPhaseOffsets[0][0]);\n\t\t\t\tlet chorusTap1Index = chorusDelayPos + chorusOffset1 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[0][1]);\n\t\t\t\tlet chorusTap2Index = chorusDelayPos + chorusOffset2 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[0][2]);\n\t\t\t\tlet chorusTap3Index = chorusDelayPos + chorusOffset3 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[1][0]);\n\t\t\t\tlet chorusTap4Index = chorusDelayPos + chorusOffset4 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[1][1]);\n\t\t\t\tlet chorusTap5Index = chorusDelayPos + chorusOffset5 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[1][2]);\n\t\t\t\tchorusPhase += chorusAngle * runLength;\n\t\t\t\tconst chorusTap0End = chorusDelayPos + chorusOffset0 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[0][0]) + runLength;\n\t\t\t\tconst chorusTap1End = chorusDelayPos + chorusOffset1 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[0][1]) + runLength;\n\t\t\t\tconst chorusTap2End = chorusDelayPos + chorusOffset2 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[0][2]) + runLength;\n\t\t\t\tconst chorusTap3End = chorusDelayPos + chorusOffset3 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[1][0]) + runLength;\n\t\t\t\tconst chorusTap4End = chorusDelayPos + chorusOffset4 - chorusRange * Math.sin(chorusPhase + Config.chorusPhaseOffsets[1][1]) + runLength;\n\t\t\t\tconst chorusTap5End = chorusDelayPos + chorusOffset5 - chorusRange * Math.sin(chorusPhase + 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;"),p&&(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;",r&&(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;"),o&&(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;"),p&&(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;"),r&&(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;"),o&&(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;"),p&&(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)(u,xe),xe.effectsFunctionCache[m]=d}d(e,t,s,i,n,a)}static pulseWidthSynth(e,t,s,i,n){const a=e.tempMonoInstrumentSampleBuffer,r=i.specialIntervalExpressionMult*n.unisonSign;1!=n.unisonVoices||0!=n.unisonSpread||n.chord.customInterval||(i.phases[1]=i.phases[0]);let o=i.phaseDeltas[0],l=i.phaseDeltas[1];const h=+i.phaseDeltaScales[0],u=+i.phaseDeltaScales[1];let c=+i.expression;const p=+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;e1-o){k+=.5*((x=(t-1)/o)+x+x*x+1)}if(s1-o){k-=.5*((x=(s-1)/o)+x+x*x+1)}if(i1-l){F+=.5*((x=(i-1)/l)+x+x*x+1)}if(w1-l){var x;F-=.5*((x=(w-1)/l)+x+x*x+1)}}const P=k+F*r,I=M(P,b,S,g,v);S=b,b=P,f+=o,m+=l,o*=h,l*=u,d+=y;const q=I*c;c+=p,a[e]+=q}i.phases[0]=f,i.phases[1]=m,i.phaseDeltas[0]=o,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,r=0|u.supersawVoiceCount;let o=i.phaseDeltas[0];const l=+i.phaseDeltaScales[0];let h=+i.expression;const c=+i.expressionDelta;let p=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 I=xe.applyFilters,q=t+s;for(let e=t;e1-o){var T;s-=.5*((T=(t-1)/o)+T+T*T+1)}p[0]=t;for(let e=1;e1-t){const e=(i-1)/t;s-=.5*(e+e+e*e+1)*f}p[e]=i}S[w&M]=s;const i=w-g,u=0|i,q=u+1,D=i-u,O=S[u&M];w++;const R=s-(O+(S[q&M]-O)*D)*y,z=I(R,F,P,k,x);P=F,F=R,o*=l,f+=m,y+=v,g+=b;const A=z*h;h+=c,a[e]+=A}i.phaseDeltas[0]=o,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,r=n.wave,o=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],p=+i.phaseDeltaScales[1];let f=+i.expression;const m=+i.expressionDelta;let d=i.phases[0]%1*u.chipNoiseLength,y=i.phases[1]%1*u.chipNoiseLength;0==i.phases[0]&&(d=Math.random()*u.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()*u.chipNoiseLength);const v=u.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),I=t+s;for(let e=t;ee.song.channels[n.modChannels[a]].instruments.length?null!=e.song.getPattern(n.modChannels[a],e.bar)&&(o=e.song.getPattern(n.modChannels[a],e.bar).instruments):o.push(n.modInstruments[a]);for(let t=0;tMath.floor((t-1)/2)&&(t%2?r.tmpEqFilterEnd.controlPoints[Math.floor((t-1)/2)].freq=i.expression+i.expressionDelta:r.tmpEqFilterEnd.controlPoints[Math.floor((t-1)/2)].gain=i.expression+i.expressionDelta)}}}else if(r==u.modulators.dictionary["note filter"].index){const r=e.song.channels[n.modChannels[a]].instruments[o[t]];if(!r.noteFilterType){let t=0|n.modFilterTypes[a];if(0==t){let t=0;const n=e.getTicksIntoBar()/u.ticksPerPart;for(;i.note.start+i.note.pins[t].time<=n;)t++;let a=(n-i.note.start+s/(e.getSamplesPerTick()*u.ticksPerPart)*u.ticksPerPart-i.note.pins[t-1].time)/(i.note.pins[t].time-i.note.pins[t-1].time);null!=r.noteSubFilters[i.note.pins[t-1].size]||null!=r.noteSubFilters[i.note.pins[t].size]?r.tmpNoteFilterEnd=fe.lerpFilters(r.noteSubFilters[i.note.pins[t-1].size],r.noteSubFilters[i.note.pins[t].size],a):r.tmpNoteFilterEnd=r.noteFilter}else{for(let e=0;eMath.floor((t-1)/2)&&(t%2?r.tmpNoteFilterEnd.controlPoints[Math.floor((t-1)/2)].freq=i.expression+i.expressionDelta:r.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 r=128;r>0;r--){const r=n+16&i,o=e[r];if(a*o<=0){for(let r=0;r<16;r++){const r=n+1&i,o=e[r];if(a*o<=0){const e=o-a;s=n,Math.abs(e)>1e-8&&(s+=-a/e),s=Math.max(0,s)%t;break}n=r,a=o}break}n=r,a=o}return s}static instrumentVolumeToVolumeMult(e){return e==-u.volumeRange/2?0:Math.pow(2,u.volumeLogScale*e)}static volumeMultToInstrumentVolume(e){return e<=0?-u.volumeRange/2:Math.min(u.volumeRange,Math.log(e)/Math.LN2/u.volumeLogScale)}static noteSizeToVolumeMult(e){return Math.pow(Math.max(0,e)/u.noteSizeMax,1.5)}static volumeMultToNoteSize(e){return Math.pow(Math.max(0,e),1/1.5)*u.noteSizeMax}static fadeInSettingToSeconds(e){return.0125*(.95*e+.05*e*e)}static secondsToFadeInSetting(e){return W(0,u.fadeInRange,Math.round((-.95+Math.sqrt(.9025+.2*e/.0125))/.1))}static fadeOutSettingToTicks(e){return u.fadeOutTicks[e]}static ticksToFadeOutSetting(e){let t=u.fadeOutTicks[0];if(e<=t)return 0;for(let s=1;s=$))break;e[i]=0}}static applyFilters(e,t,s,i,n){for(let a=0;a { + this.clearSynths(); + }); + runtime.on("PROJECT_START", () => { + this.clearSynths(); + }); + } + getInfo() { + return { + id: "dogeiscutbeepboxplayer", + name: "BeepBox Player", + color1: "#000000", + color2: "#7744FF", + color3: "#7744FF", + menuIconURI: icon, + blockIconURI: icon, + blocks: [ + { + opcode: "current", + blockType: Scratch.BlockType.REPORTER, + text: "current [WHAT]", + arguments: { + WHAT: { + type: Scratch.ArgumentType.STRING, + menu: "CURRENT_MENU", + }, + }, + disableMonitor: false, + }, + { + opcode: "song", + blockType: Scratch.BlockType.REPORTER, + text: "song [WHAT]", + arguments: { + WHAT: { + type: Scratch.ArgumentType.STRING, + menu: "SONG_MENU", + }, + }, + disableMonitor: false, + }, + { + opcode: "playingSong", + blockType: Scratch.BlockType.BOOLEAN, + text: "playing song?", + }, + "---", + { + opcode: "setSong", + blockType: Scratch.BlockType.COMMAND, + text: "set song to [SONG]", + arguments: { + SONG: { + type: Scratch.ArgumentType.STRING, + defaultValue: defaultSong, + }, + }, + }, + { + opcode: "setCurrentValue", + blockType: Scratch.BlockType.COMMAND, + text: "set current [WHAT] to [VALUE]", + arguments: { + WHAT: { + type: Scratch.ArgumentType.STRING, + menu: "CURRENT_MENU_LIMITED", + }, + VALUE: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 2, + }, + }, + disableMonitor: false, + }, + { + opcode: "setSongValue", + blockType: Scratch.BlockType.COMMAND, + text: "set song [WHAT] to [VALUE]", + arguments: { + WHAT: { + type: Scratch.ArgumentType.STRING, + menu: "SONG_MENU_LIMITED", + }, + VALUE: { + type: Scratch.ArgumentType.STRING, + defaultValue: "150", + }, + }, + disableMonitor: false, + }, + "---", + { + opcode: "playSong", + blockType: Scratch.BlockType.COMMAND, + text: "play current song", + }, + { + opcode: "playSongWait", + blockType: Scratch.BlockType.COMMAND, + text: "play current song until done", + }, + { + opcode: "pauseSong", + blockType: Scratch.BlockType.COMMAND, + text: "pause current song", + }, + { + opcode: "stopSong", + blockType: Scratch.BlockType.COMMAND, + text: "stop current song", + }, + { + opcode: "restartSong", + blockType: Scratch.BlockType.COMMAND, + text: "restart current song", + }, + "---", + { + opcode: "setSongVolume", + blockType: Scratch.BlockType.COMMAND, + text: "set song volume to [VOLUME]%", + arguments: { + VOLUME: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 100, + }, + }, + }, + { + opcode: "changeSongVolume", + blockType: Scratch.BlockType.COMMAND, + text: "change song volume by [VOLUME]%", + arguments: { + VOLUME: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 25, + }, + }, + }, + "---", + { + opcode: "muteChannel", + blockType: Scratch.BlockType.COMMAND, + text: "mute channel [CHANNEL]", + arguments: { + CHANNEL: { + type: Scratch.ArgumentType.NUMBER, + menu: "CHANNELS_MENU", + }, + }, + }, + { + opcode: "unmuteChannel", + blockType: Scratch.BlockType.COMMAND, + text: "unmute channel [CHANNEL]", + arguments: { + CHANNEL: { + type: Scratch.ArgumentType.NUMBER, + menu: "CHANNELS_MENU", + }, + }, + }, + "---", + { + opcode: "enableLooping", + blockType: Scratch.BlockType.COMMAND, + text: "enable looping", + }, + { + opcode: "disableLooping", + blockType: Scratch.BlockType.COMMAND, + text: "disable looping", + }, + { + opcode: "looping", + blockType: Scratch.BlockType.BOOLEAN, + text: "looping?", + }, + "---", + { + opcode: "synths", + blockType: Scratch.BlockType.REPORTER, + text: "synths", + }, + { + opcode: "targetSynth", + blockType: Scratch.BlockType.REPORTER, + text: "target synth", + }, + { + opcode: "createSynth", + blockType: Scratch.BlockType.COMMAND, + text: "create new synth", + }, + { + opcode: "setTargetSynth", + blockType: Scratch.BlockType.COMMAND, + text: "set target synth to [SYNTH]", + arguments: { + SYNTH: { + type: Scratch.ArgumentType.NUMBER, + menu: "SYNTHS_MENU", + }, + }, + }, + /* + { + opcode: 'deleteSynth', + blockType: Scratch.BlockType.COMMAND, + text: 'delete synth [SYNTH]', + arguments: { + SYNTH: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 1 + }, + }, + }, + */ + { + opcode: "clearSynths", + blockType: Scratch.BlockType.COMMAND, + text: "clear synths", + }, + ], + menus: { + CURRENT_MENU: { + acceptReporters: false, + items: ["song", "bar", "beat", "part", "tick"], + }, + SONG_MENU: { + acceptReporters: false, + items: ["tempo", "channels", "volume", "title", "json", "url"], + }, + CURRENT_MENU_LIMITED: { + acceptReporters: false, + items: ["bar", "beat", "part"], + }, + SONG_MENU_LIMITED: { + acceptReporters: false, + items: ["tempo", "title"], + }, + SYNTHS_MENU: { + acceptReporters: true, + items: "getSynths", + }, + CHANNELS_MENU: { + acceptReporters: true, + items: "getChannels", + }, + }, + }; + } + + caluclateSongCompletionPercentage() { + return (synth.bar * 24 * synth.beatsPerBar + synth.beat * 24 + synth.part + synth.tick / 2) / (synth.beatsPerBar * 24 * synth.barCount); + } + + samplesToTime(samples) { + const rawSeconds = Math.round(samples / synth.samplesPerSecond); + const rawSecondsUnrounded = samples / synth.samplesPerSecond; + const seconds = rawSeconds % 60; + const minutes = Math.floor(rawSeconds / 60); + return {'rawSeconds': rawSeconds, 'rawSecondsUnrounded': rawSecondsUnrounded, 'minutes': minutes, 'fullTimeString': (minutes + ":" + (seconds < 10 ? "0" : "") + seconds)}; + } + + /*menus*/ + + getSynths() { + const gettingSynths = []; + for (let i in synths) { + let javascriptMoment = Scratch.Cast.toNumber(i) + 1; + gettingSynths.push({ + text: Scratch.Cast.toString(javascriptMoment), + value: Scratch.Cast.toString(javascriptMoment), + }); + } + return gettingSynths; + } + + getChannels() { + const gettingChannels = []; + for (let i in synth.song.channels) { + let javascriptMoment = Scratch.Cast.toNumber(i) + 1; + gettingChannels.push({ + text: Scratch.Cast.toString(javascriptMoment), + value: Scratch.Cast.toString(javascriptMoment), + }); + } + return gettingChannels; + } + + current(args) { + switch (args.WHAT) { + case "song": + return Scratch.Cast.toString(url); + case "bar": + return synth.bar; + case "beat": + return synth.beat; + case "part": + return synth.part; + case "tick": + return synth.tick; + case "progress ratio": + return this.caluclateSongCompletionPercentage(); + case "progress seconds": + return this.samplesToTime(synth.getTotalSamples(true, true, 0))["rawSecondsUnrounded"] * this.caluclateSongCompletionPercentage(); + } + } + setCurrentValue(args) { + switch (args.WHAT) { + case "bar": + synth.bar = Math.min(Math.max(args.VALUE, 0), synth.song.barCount); + synth.snapToBar(); + break; + case "beat": + synth.beat = Math.min( + Math.max(args.VALUE, 0), + synth.song.beatsPerBar + ); + synth.part = 0; + synth.tick = 0; + synth.tickSampleCountdown = 0; + break; + case "part": + synth.part = args.VALUE; + break; + } + } + + song(args) { + switch (args.WHAT) { + case "tempo": + return synth.song.tempo; + case "channels": + return synth.song.getChannelCount(); + case "volume": + return synth.volume * 100; + case "title": + return synth.song.title; + case "json": + return JSON.stringify(synth.song.toJsonObject()); + case "url": + return synth.song.toBase64String(); + case "samples ()": + return synth.getTotalSamples; + case "length": + return this.samplesToTime(synth.getTotalSamples(true, true, 0))["rawSecondsUnrounded"]; + } + } + setSongValue(args) { + switch (args.WHAT) { + case "tempo": + synth.song.tempo = Math.max(Scratch.Cast.toNumber(args.VALUE), 0); + return; + case "title": + synth.song.title = Scratch.Cast.toString(args.VALUE); + return; + } + } + + /*blocks*/ + + playingSong(args) { + return synth.isPlayingSong; + } + + setSong(args) { + try { + let song = Scratch.Cast.toString(args.SONG); + song = isValidJSON(song) ? song : song.replace(/.*?#/, ""); + console.log("Loaded BeepBox Song: " + song); + url = song; + synth.setSong(song); + } catch (error) { + console.error(error); + } + } + + playSong(args) { + try { + synth.activateAudio(); + synth.play(); + } catch (error) { + console.error(error); + } + } + + playSongWait(args, util) { + if (synth.waitBlockNotPlay == false || synth.waitBlockNotPlay == null) { + this.playSong(args); + synth.waitBlockNotPlay = true; + } + if (synth.isPlayingSong) { + util.yield(); + } else { + synth.waitBlockNotPlay = false; + } + } + + pauseSong(args) { + synth.pause(); + } + stopSong(args) { + synth.snapToStart(); + synth.pause(); + } + restartSong() { + synth.snapToStart(); + synth.activateAudio(); + synth.play(); + } + + setSongVolume(args) { + synth.volume = Math.max(Math.min(args.VOLUME / 100, 2), 0); + } + changeSongVolume(args) { + synth.volume += args.VOLUME / 100; + synth.volume = Math.max(Math.min(synth.volume * 100, 200), 0) / 100; + } + + muteChannel(args) { + var targetChannel = Scratch.Cast.toNumber(args.CHANNEL) - 1; + targetChannel = Math.min( + Math.max(targetChannel, 0), + synth.song.getChannelCount() - 1 + ); + synth.song.channels[targetChannel].muted = true; + } + unmuteChannel(args) { + var targetChannel = Scratch.Cast.toNumber(args.CHANNEL) - 1; + targetChannel = Math.min( + Math.max(targetChannel, 0), + synth.song.getChannelCount() - 1 + ); + synth.song.channels[targetChannel].muted = false; + } + + disableLooping(args) { + synth.loopRepeatCount = 0; + } + enableLooping(args) { + synth.loopRepeatCount = -1; + } + looping(args) { + return synth.loopRepeatCount === -1; + } + + createSynth(args) { + if (synths.length > synthLimit) { + console.warn( + `BeepBox Player: Can't create more than ${synthLimit + 1} synths!` + ); + return; + } + //@ts-ignore + synth = new beepbox.Synth(url); + synths.push(synth); + synth.volume = 1; + targetSynth = synths.length - 1; + } + + synths(args) { + return synths.length; + } + + targetSynth(args) { + return targetSynth + 1; + } + + setTargetSynth(args) { + let length = synths.length - 1; + targetSynth = Math.max( + 0, + Math.min(Scratch.Cast.toNumber(args.SYNTH) - 1, length) + ); + synth = synths[targetSynth]; + } + + /* + deleteSynth(args) { + let length = synths.length-1; + targetSynth = Math.max(0,Math.min(args.SYNTH-1,length)); + synths[targetSynth] = undefined; + } + */ + clearSynths(args) { + for (let i of synths) { + i.deactivateAudio(); + i = undefined; + } + targetSynth = 0; + synths = []; + //@ts-ignore + synth = new beepbox.Synth(url); + synths.push(synth); + synth.volume = 1; + } + } + //@ts-ignore + Scratch.extensions.register(new BeepBoxPlayer()); +})(Scratch); diff --git a/extensions/extensions.json b/extensions/extensions.json index 2781ff7955..d784a2614f 100644 --- a/extensions/extensions.json +++ b/extensions/extensions.json @@ -38,6 +38,7 @@ "XeroName/Deltatime", "ar", "encoding", + "DogeisCut/BeepBoxPlayer", "Lily/SoundExpanded", "Lily/TempVariables2", "Lily/MoreTimers", diff --git a/images/DogeisCut/BeepBoxPlayer.svg b/images/DogeisCut/BeepBoxPlayer.svg new file mode 100644 index 0000000000..6439b23d56 --- /dev/null +++ b/images/DogeisCut/BeepBoxPlayer.svg @@ -0,0 +1 @@ + \ No newline at end of file