-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbeepbox_synth.min.js
More file actions
23 lines (20 loc) · 399 KB
/
beepbox_synth.min.js
File metadata and controls
23 lines (20 loc) · 399 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
var beepbox=function(e){"use strict";
/*!
Copyright (c) 2012-2022 John Nesky and contributing authors
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/class t{}function i(e){let t=0;for(let i=0;i<e.length;i++)t+=e[i];const i=t/e.length;for(let t=0;t<e.length;t++)e[t]-=i;return s(e),e.push(0),new Float32Array(e)}function n(e){let t=0;i(e);for(let i=0;i<e.length-1;i++)t+=Math.abs(e[i]);const n=t/(e.length-1);for(let t=0;t<e.length-1;t++)e[t]=e[t]/n;return new Float32Array(e)}function s(e){let t=0,i=new Float32Array(e.length);for(let n=0;n<e.length;n++)i[n]=t,t+=e[n];return i}function a(e,i,n){let s=t.chipNoises[e].samples;if(null==s){if(s=new Float32Array(t.chipNoiseLength+1),t.chipNoises[e].samples=s,0==e){let e=1;for(let i=0;i<t.chipNoiseLength;i++){s[i]=2*(1&e)-1;let t=e>>1;1==(e+t&1)&&(t+=16384),e=t}}else if(1==e)for(let e=0;e<t.chipNoiseLength;e++)s[e]=2*Math.random()-1;else if(2==e){let e=1;for(let i=0;i<t.chipNoiseLength;i++){s[i]=2*(1&e)-1;let t=e>>1;1==(e+t&1)&&(t+=32768),e=t}}else if(3==e){let e=1;for(let i=0;i<t.chipNoiseLength;i++){s[i]=2*(1&e)-1;let t=e>>1;1==(e+t&1)&&(t+=40),e=t}}else if(4==e)r(s,t.chipNoiseLength,10,11,1,1,0),r(s,t.chipNoiseLength,11,14,.6578,.6578,0),i(s,t.chipNoiseLength),n(s,1/Math.sqrt(t.chipNoiseLength));else if(5==e)for(var a=1,o=0;o<t.chipNoiseLength;o++){s[o]=2*(1&a)-1,1==(a+(l=a>>1)&1)&&(l+=40),a=l}else if(6==e)r(s,t.chipNoiseLength,1,10,1,1,0),r(s,t.chipNoiseLength,20,14,-2,-2,0),i(s,t.chipNoiseLength),n(s,1/Math.sqrt(t.chipNoiseLength));else if(7==e)for(a=1,o=0;o<t.chipNoiseLength;o++){s[o]=4*(1&a)*(14*Math.random()+1),1==(a+(l=a>>1)&1)&&(l+=60),a=l}else{if(8!=e)throw new Error("Unrecognized drum index: "+e);for(a=1,o=0;o<32768;o++){var l;s[o]=(1&a)/2+.5,1==(a+(l=a>>1)&1)&&(l-=40),a=l}}s[t.chipNoiseLength]=s[0]}return s}function r(e,t,i,n,s,r,o){const l=0|Math.pow(2,i),h=Math.min(t>>1,0|Math.pow(2,n)),u=a(0,null,null);let c=0;for(let a=l;a<h;a++){let l=s+(r-s)*(Math.log2(a)-i)/(n-i),h=Math.pow(2,7*(l-1)+1)*l;h*=Math.pow(a/2048,o),c+=h,h*=u[a];const p=.61803398875*a*a*Math.PI*2;e[a]=Math.cos(p)*h,e[t-a]=Math.sin(p)*h}return c}function o(e=0){const i=new Float32Array(t.sineWaveLength+1),n=t.sineWaveLength/4;for(let s=0;s<t.sineWaveLength+1;s++)i[s]=2*+(Math.abs(s-n)<e*t.sineWaveLength/2||Math.abs(s-t.sineWaveLength-n)<e*t.sineWaveLength/2)-1;return i}function l(e=!1){const i=new Float32Array(t.sineWaveLength+1);for(let n=0;n<t.sineWaveLength+1;n++)i[n]=2*(n+t.sineWaveLength/4)/t.sineWaveLength%2-1,i[n]=e?-i[n]:i[n];return i}function h(e,i,n,s){let a;if(0==n)a=t.normalArpeggioPatterns[e-1];else if(1==n)a=t.legacyArpeggioPatterns[e-1];else if(2==n)a=t.scrambleArpeggioPatterns[e-1];else if(3==n)a=t.oscillateArpeggioPatterns[e-1];else if(4==n)a=t.escalateArpeggioPatterns[e-1];else if(5==n)a=t.shiftArpeggioPatterns[e-1];else if(6==n)a=t.normalBounceArpeggioPatterns[e-1];else if(7==n)a=t.scrambleBounceArpeggioPatterns[e-1];else if(8==n)a=t.oscillateBounceArpeggioPatterns[e-1];else if(9==n)a=t.escalateBounceArpeggioPatterns[e-1];else{if(10!=n)throw new Error("Unknown arpeggio pattern type in getArpeggioPitchIndex: "+n);a=t.shiftBounceArpeggioPatterns[e-1]}let r=a;return null!=r?(2==e&&0==i&&(r=[0,0,1,1]),r[s%r.length]):s%e}function u(e){const t={};for(let i=0;i<e.length;i++){const n=e[i];n.index=i,t[n.name]=n}const i=e;return i.dictionary=t,i}function c(e){return 0!=(1024&e)}function p(e){return 0!=(2048&e)}function f(e){return 0!=(128&e)}function m(e){return 0!=(256&e)}function d(e){return 0!=(512&e)}function y(e){return 0!=(32&e)}function v(e){return 0!=(8&e)}function g(e){return 0!=(16&e)}function b(e){return 0!=(4&e)}function S(e){return 0!=(2&e)}function w(e){return 0!=(64&e)}function k(e){return 0!=(1&e)}t.thresholdVal=-10,t.kneeVal=40,t.ratioVal=12,t.attackVal=0,t.releaseVal=.25,t.scales=u([{name:"Free",realName:"chromatic",flags:[!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0,!0]},{name:"Major",realName:"ionian",flags:[!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!1,!0]},{name:"Minor",realName:"aeolian",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!0,!1,!0,!1]},{name:"Mixolydian",realName:"mixolydian",flags:[!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!0,!1]},{name:"Lydian",realName:"lydian",flags:[!0,!1,!0,!1,!0,!1,!0,!0,!1,!0,!1,!0]},{name:"Dorian",realName:"dorian",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!1,!0,!0,!1]},{name:"Phrygian",realName:"phrygian",flags:[!0,!0,!1,!0,!1,!0,!1,!0,!0,!1,!0,!1]},{name:"Locrian",realName:"locrian",flags:[!0,!0,!1,!0,!1,!0,!0,!1,!0,!1,!0,!1]},{name:"Lydian Dominant",realName:"lydian dominant",flags:[!0,!1,!0,!1,!0,!1,!0,!0,!1,!0,!0,!1]},{name:"Phrygian Dominant",realName:"phrygian dominant",flags:[!0,!0,!1,!1,!0,!0,!1,!0,!0,!1,!0,!1]},{name:"Harmonic Major",realName:"harmonic major",flags:[!0,!1,!0,!1,!0,!0,!1,!0,!0,!1,!1,!0]},{name:"Harmonic Minor",realName:"harmonic minor",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!0,!1,!1,!0]},{name:"Melodic Minor",realName:"melodic minor",flags:[!0,!1,!0,!0,!1,!0,!1,!0,!1,!0,!1,!0]},{name:"Blues",realName:"blues",flags:[!0,!1,!1,!0,!1,!0,!0,!0,!1,!1,!0,!1]},{name:"Altered",realName:"altered",flags:[!0,!0,!1,!0,!0,!1,!0,!1,!0,!1,!0,!1]},{name:"Major Pentatonic",realName:"major pentatonic",flags:[!0,!1,!0,!1,!0,!1,!1,!0,!1,!0,!1,!1]},{name:"Minor Pentatonic",realName:"minor pentatonic",flags:[!0,!1,!1,!0,!1,!0,!1,!0,!1,!1,!0,!1]},{name:"Whole Tone",realName:"whole tone",flags:[!0,!1,!0,!1,!0,!1,!0,!1,!0,!1,!0,!1]},{name:"Octatonic",realName:"octatonic",flags:[!0,!1,!0,!0,!1,!0,!0,!1,!0,!0,!1,!0]},{name:"Hexatonic",realName:"hexatonic",flags:[!0,!1,!1,!0,!0,!1,!1,!0,!0,!1,!1,!0]}]),t.keys=u([{name:"C",isWhiteKey:!0,basePitch:12},{name:"C♯",isWhiteKey:!1,basePitch:13},{name:"D",isWhiteKey:!0,basePitch:14},{name:"D♯",isWhiteKey:!1,basePitch:15},{name:"E",isWhiteKey:!0,basePitch:16},{name:"F",isWhiteKey:!0,basePitch:17},{name:"F♯",isWhiteKey:!1,basePitch:18},{name:"G",isWhiteKey:!0,basePitch:19},{name:"G♯",isWhiteKey:!1,basePitch:20},{name:"A",isWhiteKey:!0,basePitch:21},{name:"A♯",isWhiteKey:!1,basePitch:22},{name:"B",isWhiteKey:!0,basePitch:23}]),t.blackKeyNameParents=[-1,1,-1,1,-1,1,-1,-1,1,-1,1,-1],t.tempoMin=1,t.tempoMax=750,t.echoDelayRange=24,t.echoDelayStepTicks=4,t.echoSustainRange=8,t.echoShelfHz=4e3,t.echoShelfGain=Math.pow(2,-.5),t.reverbShelfHz=8e3,t.reverbShelfGain=Math.pow(2,-1.5),t.reverbRange=32,t.reverbDelayBufferSize=16384,t.reverbDelayBufferMask=t.reverbDelayBufferSize-1,t.beatsPerBarMin=1,t.beatsPerBarMax=32,t.barCountMin=1,t.barCountMax=512,t.instrumentCountMin=1,t.layeredInstrumentCountMax=4,t.patternInstrumentCountMax=10,t.partsPerBeat=24,t.ticksPerPart=2,t.ticksPerArpeggio=3,t.normalArpeggioPatterns=[[0],[0,1],[0,1,2],[0,1,2,3],[0,1,2,3,4],[0,1,2,3,4,5],[0,1,2,3,4,5,6],[0,1,2,3,4,5,6,7],[0,1,2,3,4,5,6,7,8]],t.legacyArpeggioPatterns=[[0],[0,1],[0,1,2,1],[0,1,2,3],[0,1,2,3,4],[0,1,2,3,4,5],[0,1,2,3,4,5,6],[0,1,2,3,4,5,6,7],[0,1,2,3,4,5,6,7,8]],t.scrambleArpeggioPatterns=[[0],[0,1],[0,1,0,2],[0,1,0,2,3],[0,1,0,2,3,2,4,2],[0,1,0,2,3,4,3,5],[0,1,0,2,3,4,6,5],[0,1,0,2,3,2,4,2,6,5,7,5],[0,1,0,2,3,4,3,5,6,7,6,8]],t.oscillateArpeggioPatterns=[[0],[0,1],[0,1,0,2],[0,1,0,2,0,3],[0,1,0,2,0,3,0,4],[0,1,0,2,0,3,0,4,0,5],[0,1,0,2,0,3,0,4,0,5,0,6],[0,1,0,2,0,3,0,4,0,5,0,6,0,7],[0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8]],t.escalateArpeggioPatterns=[[0],[0,1],[0,1,0,2],[0,1,0,2,1,3],[0,1,0,2,1,3,2,4],[0,1,0,2,1,3,2,4,3,5],[0,1,0,2,1,3,2,4,3,5,4,6],[0,1,0,2,1,3,2,4,3,5,4,6,5,7],[0,1,0,2,1,3,2,4,3,5,4,6,5,7,6,8]],t.shiftArpeggioPatterns=[[0],[0,1],[0,2,1],[0,3,1,2],[0,4,1,3,2],[0,5,1,4,2,3],[0,6,1,5,2,4,3],[0,7,1,6,2,5,3,4],[0,8,1,7,2,6,3,5,4]],t.normalBounceArpeggioPatterns=[[0],[0,1],[0,1,2,1],[0,1,2,3,2,1],[0,1,2,3,4,3,2,1],[0,1,2,3,4,5,4,3,2,1],[0,1,2,3,4,5,6,5,4,3,2,1],[0,1,2,3,4,5,6,7,6,5,4,3,2,1],[0,1,2,3,4,5,6,7,8,7,6,5,4,3,2,1]],t.scrambleBounceArpeggioPatterns=[[0],[0,1],[0,1,0,2,1],[0,1,0,2,3,1],[0,1,0,2,3,2,4,2,3,1],[0,1,0,2,3,4,3,5,4,2],[0,1,0,2,3,4,6,5,3,1],[0,1,0,2,3,2,4,2,6,5,7,5,4,3,2,1],[0,1,0,2,3,4,3,5,6,7,6,8,0,1,0,2]],t.oscillateBounceArpeggioPatterns=[[0],[0,1],[0,1,0,2],[0,1,0,2,0,3,0,2],[0,1,0,2,0,3,0,4,0,3,0,2],[0,1,0,2,0,3,0,4,0,5,0,4,0,3,0,2],[0,1,0,2,0,3,0,4,0,5,0,6,0,5,0,4,0,3,0,2],[0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,6,0,5,0,4,0,3,0,2],[0,1,0,2,0,3,0,4,0,5,0,6,0,7,0,8,0,7,0,6,0,5,0,4,0,3,0,2]],t.escalateBounceArpeggioPatterns=[[0],[0,1],[0,1,0,2,1,0,1],[0,1,0,2,1,3,2,0,2,3,1,2],[0,1,0,2,1,3,2,4,3,0,3,4,2,3,1,2],[0,1,0,2,1,3,2,4,3,5,4,0,4,5,3,4,2,3,1,2],[0,1,0,2,1,3,2,4,3,5,4,6,5,0,5,6,4,5,3,4,2,3,1,2],[0,1,0,2,1,3,2,4,3,5,4,6,5,7,6,0,6,7,5,6,4,5,3,4,2,3,1,2],[0,1,0,2,1,3,2,4,3,5,4,6,5,7,6,8,7,0,7,8,6,7,5,6,4,5,3,4,2,3,1,2]],t.shiftBounceArpeggioPatterns=[[0],[0,1],[0,2,1,2],[0,3,1,2,1,3],[0,4,1,3,2,3,1,4],[0,5,1,4,2,3,2,4,1,5],[0,6,1,5,2,4,3,4,2,5,1,6],[0,7,1,6,2,5,3,4,3,5,2,6,1,7],[0,8,1,7,2,6,3,5,4,5,3,6,2,7,1,8]],t.rhythms=u([{name:"÷3 (triplets)",stepsPerBeat:3,roundUpThresholds:[5,12,18]},{name:"÷4 (standard)",stepsPerBeat:4,roundUpThresholds:[3,9,17,21]},{name:"÷6",stepsPerBeat:6,roundUpThresholds:null},{name:"÷8",stepsPerBeat:8,roundUpThresholds:null},{name:"freehand",stepsPerBeat:24,roundUpThresholds:null}]),t.instrumentTypeNames=["chip","FM","noise","spectrum","drumset","harmonics","PWM","Picked String","custom chip","mod"],t.instrumentTypeHasSpecialInterval=[!0,!0,!1,!1,!1,!0,!1,!1,!1],t.chipBaseExpression=.03375,t.fmBaseExpression=.03,t.noiseBaseExpression=.19,t.spectrumBaseExpression=.3,t.drumsetBaseExpression=.45,t.harmonicsBaseExpression=.025,t.pwmBaseExpression=.04725,t.pickedStringBaseExpression=.025,t.distortionBaseVolume=.011,t.bitcrusherBaseVolume=.01,t.rawChipWaves=u([{name:"rounded",expression:.94,samples:i([0,.2,.4,.5,.6,.7,.8,.85,.9,.95,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,.95,.9,.85,.8,.7,.6,.5,.4,.2,0,-.2,-.4,-.5,-.6,-.7,-.8,-.85,-.9,-.95,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-.95,-.9,-.85,-.8,-.7,-.6,-.5,-.4,-.2])},{name:"triangle",expression:1,samples:i([1/15,.2,5/15,7/15,.6,11/15,13/15,1,1,13/15,11/15,.6,7/15,5/15,.2,1/15,-1/15,-.2,-5/15,-7/15,-.6,-11/15,-13/15,-1,-1,-13/15,-11/15,-.6,-7/15,-5/15,-.2,-1/15])},{name:"square",expression:.5,samples:i([1,-1])},{name:"1/4 pulse",expression:.5,samples:i([1,-1,-1,-1])},{name:"1/6 pulse",expression:.55,samples:i([1,-1,-1,-1,-1,-1])},{name:"1/8 pulse",expression:.5,samples:i([1,-1,-1,-1,-1,-1,-1,-1])},{name:"1/12 pulse",expression:.55,samples:i([1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])},{name:"1/16 pulse",expression:.575,samples:i([1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1])},{name:"heavy saw",expression:.5,samples:i([1,-1,2,-1,0,3,1,-1,2,-1,0,0])},{name:"bass-y",expression:.5,samples:i([1,-5,4,-3,7,-2,3,-3,6])},{name:"strange",expression:.5,samples:i([1,11,1,-11,-1,-11,4,-6,9,-1,-7,11,2,-5,9,9,-10])},{name:"sawtooth",expression:.65,samples:i([1/31,3/31,5/31,7/31,9/31,11/31,13/31,15/31,17/31,19/31,21/31,23/31,25/31,27/31,29/31,1,-1,-29/31,-27/31,-25/31,-23/31,-21/31,-19/31,-17/31,-15/31,-13/31,-11/31,-9/31,-7/31,-5/31,-3/31,-1/31])},{name:"double saw",expression:.5,samples:i([0,-.2,-.4,-.6,-.8,-1,1,-.8,-.6,-.4,-.2,1,.8,.6,.4,.2])},{name:"double pulse",expression:.4,samples:i([1,1,1,1,1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1])},{name:"spiky",expression:.4,samples:i([1,-1,1,-1,1,0])},{name:"sine",expression:.88,samples:n([8,9,11,12,13,14,15,15,15,15,14,14,13,11,10,9,7,6,4,3,2,1,0,0,0,0,1,1,2,4,5,6])},{name:"flute",expression:.8,samples:n([3,4,6,8,10,11,13,14,15,15,14,13,11,8,5,3])},{name:"harp",expression:.8,samples:n([0,3,3,3,4,5,5,6,7,8,9,11,11,13,13,15,15,14,12,11,10,9,8,7,7,5,4,3,2,1,0,0])},{name:"sharp clarinet",expression:.38,samples:n([0,0,0,1,1,8,8,9,9,9,8,8,8,8,8,9,9,7,9,9,10,4,0,0,0,0,0,0,0,0,0,0])},{name:"soft clarinet",expression:.45,samples:n([0,1,5,8,9,9,9,9,9,9,9,11,11,12,13,12,10,9,7,6,4,3,3,3,1,1,1,1,1,1,1,1])},{name:"alto sax",expression:.3,samples:n([5,5,6,4,3,6,8,7,2,1,5,6,5,4,5,7,9,11,13,14,14,14,14,13,10,8,7,7,4,3,4,2])},{name:"bassoon",expression:.35,samples:n([9,9,7,6,5,4,4,4,4,5,7,8,9,10,11,13,13,11,10,9,7,6,4,2,1,1,1,2,2,5,11,14])},{name:"trumpet",expression:.22,samples:n([10,11,8,6,5,5,5,6,7,7,7,7,6,6,7,7,7,7,7,6,6,6,6,6,6,6,6,7,8,9,11,14])},{name:"electric guitar",expression:.2,samples:n([11,12,12,10,6,6,8,0,2,4,8,10,9,10,1,7,11,3,6,6,8,13,14,2,0,12,8,4,13,11,10,13])},{name:"organ",expression:.2,samples:n([11,10,12,11,14,7,5,5,12,10,10,9,12,6,4,5,13,12,12,10,12,5,2,2,8,6,6,5,8,3,2,1])},{name:"pan flute",expression:.35,samples:n([1,4,7,6,7,9,7,7,11,12,13,15,13,11,11,12,13,10,7,5,3,6,10,7,3,3,1,0,1,0,1,0])},{name:"glitch",expression:.5,samples:i([1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1,-1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,-1,-1])}]),t.chipWaves=function(e){const t=new Array(e.length),i={};for(let n=0;n<t.length;n++){t[n]=Object.assign([],e[n]);const s=t[n];s.index=n,i[s.name]=s}for(let e in i)i[e].samples=s(i[e].samples);const n=t;return n.dictionary=i,n}(t.rawChipWaves),t.chipNoises=u([{name:"retro",expression:.25,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"white",expression:1,basePitch:69,pitchFilterMult:8,isSoft:!0,samples:null},{name:"clang",expression:.4,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"buzz",expression:.3,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"hollow",expression:1.5,basePitch:96,pitchFilterMult:1,isSoft:!0,samples:null},{name:"shine",expression:1,basePitch:69,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"deep",expression:1.5,basePitch:120,pitchFilterMult:1024,isSoft:!0,samples:null},{name:"cutter",expression:.005,basePitch:96,pitchFilterMult:1024,isSoft:!1,samples:null},{name:"metallic",expression:1,basePitch:96,pitchFilterMult:1024,isSoft:!1,samples:null}]),t.filterFreqStep=1/4,t.filterFreqRange=34,t.filterFreqReferenceSetting=28,t.filterFreqReferenceHz=8e3,t.filterFreqMaxHz=t.filterFreqReferenceHz*Math.pow(2,t.filterFreqStep*(t.filterFreqRange-1-t.filterFreqReferenceSetting)),t.filterFreqMinHz=8,t.filterGainRange=15,t.filterGainCenter=7,t.filterGainStep=.5,t.filterMaxPoints=8,t.filterTypeNames=["low-pass","high-pass","peak"],t.filterMorphCount=10,t.filterSimpleCutRange=11,t.filterSimplePeakRange=8,t.fadeInRange=10,t.fadeOutTicks=[-24,-12,-6,-3,-1,6,12,24,48,72,96],t.fadeOutNeutral=4,t.drumsetFadeOutTicks=48,t.transitions=u([{name:"normal",isSeamless:!1,continues:!1,slides:!1,slideTicks:3,includeAdjacentPatterns:!1},{name:"interrupt",isSeamless:!0,continues:!1,slides:!1,slideTicks:3,includeAdjacentPatterns:!0},{name:"continue",isSeamless:!0,continues:!0,slides:!1,slideTicks:3,includeAdjacentPatterns:!0},{name:"slide",isSeamless:!0,continues:!1,slides:!0,slideTicks:3,includeAdjacentPatterns:!0}]),t.vibratos=u([{name:"none",amplitude:0,type:0,delayTicks:0},{name:"light",amplitude:.15,type:0,delayTicks:0},{name:"delayed",amplitude:.3,type:0,delayTicks:37},{name:"heavy",amplitude:.45,type:0,delayTicks:0},{name:"shaky",amplitude:.1,type:1,delayTicks:0}]),t.vibratoTypes=u([{name:"normal",periodsSeconds:[.14],period:.14},{name:"shaky",periodsSeconds:[.11,.17798,.33],period:266.97}]),t.arpSpeedScale=[0,.0625,.125,.2,.25,1/3,.4,.5,2/3,.75,.8,.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2,2.1,2.2,2.3,2.4,2.5,2.6,2.7,2.8,2.9,3,3.1,3.2,3.3,3.4,3.5,3.6,3.7,3.8,3.9,4,4.15,4.3,4.5,4.8,5,5.5,6,8],t.strumSpeedScale=[24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],t.slideSpeedScale=[24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1],t.unisons=u([{name:"none",voices:1,spread:0,offset:0,expression:1.4,sign:1},{name:"shimmer",voices:2,spread:.018,offset:0,expression:.8,sign:1},{name:"hum",voices:2,spread:.045,offset:0,expression:1,sign:1},{name:"honky tonk",voices:2,spread:.09,offset:0,expression:1,sign:1},{name:"dissonant",voices:2,spread:.25,offset:0,expression:.9,sign:1},{name:"fifth",voices:2,spread:3.5,offset:3.5,expression:.9,sign:1},{name:"octave",voices:2,spread:6,offset:6,expression:.8,sign:1},{name:"bowed",voices:2,spread:.02,offset:0,expression:1,sign:-1},{name:"piano",voices:2,spread:.01,offset:0,expression:1,sign:.7},{name:"warbled",voices:2,spread:.25,offset:.05,expression:.9,sign:-.8},{name:"hyper",voices:2,spread:.03,offset:-.02,expression:.85,sign:.7},{name:"peak",voices:2,spread:12.038,offset:12.01,expression:.85,sign:.9},{name:"deep shift",voices:2,spread:12.03,offset:-17.01,expression:.85,sign:1.2},{name:"broke",voices:2,spread:211e-6,offset:-.3,expression:.8,sign:1},{name:"vary",voices:2,spread:.0018,offset:0,expression:.85,sign:1.6},{name:"energetic",voices:2,spread:6.15,offset:6.435,expression:.85,sign:.9},{name:"lone fifth",voices:1,spread:0,offset:7,expression:1.4,sign:1},{name:"alternate fifth",voices:2,spread:2.5,offset:-2.5,expression:.9,sign:1},{name:"offtune",voices:2,spread:.4,offset:.4,expression:.9,sign:1},{name:"hold",voices:2,spread:.003,offset:0,expression:.8,sign:-2.5},{name:"buried",voices:2,spread:.03575,offset:-36,expression:1.4,sign:1},{name:"corrupt",voices:2,spread:18,offset:48,expression:.7,sign:.7},{name:"weird octave",voices:2,spread:5.85,offset:5.85,expression:.75,sign:1}]),t.effectNames=["reverb","chorus","panning","distortion","bitcrusher","note filter","echo","pitch shift","detune","vibrato","transition type","chord type"],t.effectOrder=[2,10,11,7,8,9,5,3,4,1,6,0],t.noteSizeMax=6,t.volumeRange=50,t.volumeLogScale=.1428,t.panCenter=50,t.panMax=2*t.panCenter,t.panDelaySecondsMax=.001,t.chorusRange=8,t.chorusPeriodSeconds=2,t.chorusDelayRange=.0034,t.chorusDelayOffsets=[[1.51,2.1,3.35],[1.47,2.15,3.25]],t.chorusPhaseOffsets=[[0,2.1,4.2],[3.2,5.3,1]],t.chorusMaxDelay=t.chorusDelayRange*(1+t.chorusDelayOffsets[0].concat(t.chorusDelayOffsets[1]).reduce(((e,t)=>Math.max(e,t)))),t.chords=u([{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}]),t.maxChordSize=9,t.operatorCount=4,t.maxPitchOrOperatorCount=Math.max(t.maxChordSize,t.operatorCount),t.algorithms=u([{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:[[],[],[],[]]}]),t.operatorCarrierInterval=[0,.04,-.073,.091],t.operatorAmplitudeMax=15,t.operatorFrequencies=u([{name:"0.125×",mult:.125,hzOffset:0,amplitudeSign:1},{name:"0.25×",mult:.25,hzOffset:0,amplitudeSign:1},{name:"0.50×",mult:.5,hzOffset:0,amplitudeSign:1},{name:"~0.50×",mult:.5,hzOffset:2.3,amplitudeSign:-1},{name:"0.75×",mult:.75,hzOffset:0,amplitudeSign:1},{name:"~0.75×",mult:.75,hzOffset:1.9,amplitudeSign:-1},{name:"1×",mult:1,hzOffset:0,amplitudeSign:1},{name:"~1×",mult:1,hzOffset:1.5,amplitudeSign:-1},{name:"1.50×",mult:1.5,hzOffset:0,amplitudeSign:1},{name:"2×",mult:2,hzOffset:0,amplitudeSign:1},{name:"~2×",mult:2,hzOffset:-1.3,amplitudeSign:-1},{name:"2.50×",mult:2.5,hzOffset:0,amplitudeSign:1},{name:"3×",mult:3,hzOffset:0,amplitudeSign:1},{name:"4×",mult:4,hzOffset:0,amplitudeSign:1},{name:"~4×",mult:4,hzOffset:-2.1,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:"~8×",mult:8,hzOffset:-4.2,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:"~16×",mult:16,hzOffset:-6.3,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:"24×",mult:24,hzOffset:0,amplitudeSign:1},{name:"32×",mult:32,hzOffset:0,amplitudeSign:1},{name:"~32×",mult:32,hzOffset:-8.4,amplitudeSign:-1}]),t.envelopes=u([{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:32},{name:"flare 2",type:3,speed:8},{name:"flare 3",type:3,speed:2},{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:32},{name:"swell 2",type:5,speed:8},{name:"swell 3",type:5,speed:2},{name:"slow swell",type:5,speed:.5},{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:10},{name:"decay 2",type:8,speed:7},{name:"decay 3",type:8,speed:4},{name:"modbox trill",type:10,speed:40},{name:"modbox blip",type:9,speed:4},{name:"modbox click",type:11,speed:5},{name:"modbox bow",type:12,speed:90},{name:"decelerate 0",type:13,speed:1},{name:"decelerate 1",type:13,speed:2},{name:"decelerate 2",type:13,speed:4},{name:"decelerate 3",type:13,speed:8}]),t.feedbacks=u([{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]]}]),t.chipNoiseLength=32768,t.spectrumNoiseLength=32768,t.spectrumBasePitch=24,t.spectrumControlPoints=30,t.spectrumControlPointsPerOctave=7,t.spectrumControlPointBits=3,t.spectrumMax=(1<<t.spectrumControlPointBits)-1,t.harmonicsControlPoints=28,t.harmonicsRendered=64,t.harmonicsRenderedForPickedString=256,t.harmonicsControlPointBits=3,t.harmonicsMax=(1<<t.harmonicsControlPointBits)-1,t.harmonicsWavelength=2048,t.pulseWidthRange=50,t.pulseWidthStepPower=.5,t.pitchChannelCountMin=1,t.pitchChannelCountMax=40,t.noiseChannelCountMin=0,t.noiseChannelCountMax=16,t.modChannelCountMin=0,t.modChannelCountMax=12,t.noiseInterval=6,t.pitchesPerOctave=12,t.drumCount=12,t.pitchOctaves=8,t.modCount=6,t.maxPitch=t.pitchOctaves*t.pitchesPerOctave,t.maximumTonesPerChannel=2*t.maxChordSize,t.justIntonationSemitones=[.5,8/15,9/16,.6,5/8,2/3,32/45,3/4,.8,5/6,8/9,15/16,1,16/15,9/8,1.2,5/4,4/3,45/32,1.5,1.6,5/3,16/9,15/8,2].map((e=>Math.log2(e)*t.pitchesPerOctave)),t.pitchShiftRange=t.justIntonationSemitones.length,t.pitchShiftCenter=t.pitchShiftRange>>1,t.detuneCenter=600,t.detuneMax=1200,t.detuneMin=0,t.songDetuneMin=0,t.songDetuneMax=500,t.sineWaveLength=256,t.sineWaveMask=t.sineWaveLength-1,t.sineWave=function(){const e=new Float32Array(t.sineWaveLength+1);for(let i=0;i<t.sineWaveLength+1;i++)e[i]=Math.sin(i*Math.PI*2/t.sineWaveLength);return e}(),t.pickedStringDispersionCenterFreq=6e3,t.pickedStringDispersionFreqScale=.3,t.pickedStringDispersionFreqMult=4,t.pickedStringShelfHz=4e3,t.distortionRange=8,t.stringSustainRange=15,t.stringDecayRate=.12,t.bitcrusherFreqRange=14,t.bitcrusherOctaveStep=.5,t.bitcrusherQuantizationRange=8,t.maxEnvelopeCount=12,t.defaultAutomationRange=13,t.instrumentAutomationTargets=u([{name:"none",computeIndex:null,displayName:"none",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:null},{name:"noteVolume",computeIndex:0,displayName:"note volume",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:null},{name:"pulseWidth",computeIndex:2,displayName:"pulse width",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[6]},{name:"stringSustain",computeIndex:3,displayName:"sustain",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[7]},{name:"unison",computeIndex:4,displayName:"unison",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[0,5,7,8,3,6]},{name:"operatorFrequency",computeIndex:5,displayName:"fm# freq",interleave:!0,isFilter:!1,maxCount:t.operatorCount,effect:null,compatibleInstruments:[1]},{name:"operatorAmplitude",computeIndex:9,displayName:"fm# volume",interleave:!1,isFilter:!1,maxCount:t.operatorCount,effect:null,compatibleInstruments:[1]},{name:"feedbackAmplitude",computeIndex:13,displayName:"fm feedback",interleave:!1,isFilter:!1,maxCount:1,effect:null,compatibleInstruments:[1]},{name:"pitchShift",computeIndex:14,displayName:"pitch shift",interleave:!1,isFilter:!1,maxCount:1,effect:7,compatibleInstruments:null},{name:"detune",computeIndex:15,displayName:"detune",interleave:!1,isFilter:!1,maxCount:1,effect:8,compatibleInstruments:null},{name:"vibratoDepth",computeIndex:16,displayName:"vibrato range",interleave:!1,isFilter:!1,maxCount:1,effect:9,compatibleInstruments:null},{name:"noteFilterAllFreqs",computeIndex:1,displayName:"n. filter freqs",interleave:!1,isFilter:!0,maxCount:1,effect:5,compatibleInstruments:null},{name:"noteFilterFreq",computeIndex:17,displayName:"n. filter # freq",interleave:!1,isFilter:!0,maxCount:t.filterMaxPoints,effect:5,compatibleInstruments:null}]),t.operatorWaves=u([{name:"sine",samples:t.sineWave},{name:"triangle",samples:function(){const e=new Float32Array(t.sineWaveLength+1);for(let i=0;i<t.sineWaveLength+1;i++)e[i]=Math.asin(Math.sin(i*Math.PI*2/t.sineWaveLength))/(Math.PI/2);return e}()},{name:"sawtooth",samples:l()},{name:"pulse width",samples:o()},{name:"ramp",samples:l(!0)},{name:"trapezoid",samples:function(e=2){const i=new Float32Array(t.sineWaveLength+1);for(let n=0;n<t.sineWaveLength+1;n++)i[n]=Math.max(-1,Math.min(1,Math.asin(Math.sin(n*Math.PI*2/t.sineWaveLength))*e));return i}(2)},{name:"clang",samples:function(){let e=1;const i=new Float32Array(t.sineWaveLength+1);for(let t=0;t<257;t++){for(let n=0;n<1;n++)i[1*t+n]=2*(1&e)-1;let n=e>>1;1==(e+n&1)&&(n+=32768),e=n}return i}()},{name:"metal",samples:function(){const e=new Float32Array(t.sineWaveLength+1);for(let i=0;i<t.sineWaveLength+1;i++){let i=1;for(let n=0;n<t.sineWaveLength;n++){e[n]=(1&i)/2-1;let t=i>>1;1==(i+t&1)&&(t-=40),i=t}}return e}()},{name:"rounded",samples:function(){const e=new Float32Array(t.sineWaveLength+1);for(let i=0;i<t.sineWaveLength+1;i++)e[i]=Math.round(Math.sin(i*Math.PI*2/t.sineWaveLength));return e}()},{name:"secant",samples:function(){const e=new Float32Array(t.sineWaveLength+1);for(let i=0;i<t.sineWaveLength+1;i++)e[i]=1-(Math.sin(i/t.sineWaveLength*Math.PI*2)%2+2)%2;return e}()},{name:"double sine",samples:function(){const e=new Float32Array(t.sineWaveLength+1);for(let i=0;i<t.sineWaveLength+1;i++)e[i]=2*Math.abs(Math.sin(i*Math.PI*2/t.sineWaveLength))-1;return e}()}]),t.pwmOperatorWaves=u([{name:"1%",samples:o(.01)},{name:"5%",samples:o(.05)},{name:"12.5%",samples:o(.125)},{name:"25%",samples:o(.25)},{name:"33%",samples:o(1/3)},{name:"50%",samples:o(.5)},{name:"66%",samples:o(2/3)},{name:"75%",samples:o(.75)},{name:"87.5%",samples:o(.875)},{name:"95%",samples:o(.95)},{name:"99%",samples:o(.99)}]),t.barEditorHeight=10,t.modulators=u([{name:"none",pianoName:"None",maxRawVol:6,newNoteVol:6,forSong:!0,convertRealFactor:0,associatedEffect:12,promptName:"No Mod Setting",promptDesc:["No setting has been chosen yet, so this modulator will have no effect. Try choosing a setting with the dropdown, then click this '?' again for more info.","[$LO - $HI]"]},{name:"song volume",pianoName:"Volume",maxRawVol:100,newNoteVol:100,forSong:!0,convertRealFactor:0,associatedEffect:12,promptName:"Song Volume",promptDesc:["This setting affects the overall volume of the song, just like the main volume slider.","At $HI, the volume will be unchanged from default, and it will get gradually quieter down to $LO.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"tempo",pianoName:"Tempo",maxRawVol:t.tempoMax-t.tempoMin,newNoteVol:Math.ceil((t.tempoMax-t.tempoMin)/2),forSong:!0,convertRealFactor:t.tempoMin,associatedEffect:12,promptName:"Song Tempo",promptDesc:["This setting controls the speed your song plays at, just like the tempo slider.","When you first make a note for this setting, it will default to your current tempo. Raising it speeds up the song, up to $HI BPM, and lowering it slows it down, to a minimum of $LO BPM.","Note that you can make a 'swing' effect by rapidly changing between two tempo values.","[OVERWRITING] [$LO - $HI] [BPM]"]},{name:"song reverb",pianoName:"Reverb",maxRawVol:2*t.reverbRange,newNoteVol:t.reverbRange,forSong:!0,convertRealFactor:-t.reverbRange,associatedEffect:12,promptName:"Song Reverb",promptDesc:["This setting affects the overall reverb of your song. It works by multiplying existing reverb for instruments, so those with no reverb set will be unaffected.","At $MID, all instruments' reverb will be unchanged from default. This increases up to double the reverb value at $HI, or down to no reverb at $LO.","[MULTIPLICATIVE] [$LO - $HI]"]},{name:"next bar",pianoName:"Next Bar",maxRawVol:1,newNoteVol:1,forSong:!0,convertRealFactor:0,associatedEffect:12,promptName:"Go To Next Bar",promptDesc:["This setting functions a little different from most. Wherever a note is placed, the song will jump immediately to the next bar when it is encountered.","This jump happens at the very start of the note, so the length of a next-bar note is irrelevant. Also, the note can be value 0 or 1, but the value is also irrelevant - wherever you place a note, the song will jump.","You can make mixed-meter songs or intro sections by cutting off unneeded beats with a next-bar modulator.","[$LO - $HI]"]},{name:"note volume",pianoName:"Note Vol.",maxRawVol:t.volumeRange,newNoteVol:Math.ceil(t.volumeRange/2),forSong:!1,convertRealFactor:Math.ceil(-t.volumeRange/2),associatedEffect:12,promptName:"Note Volume",promptDesc:["This setting affects the volume of your instrument as if its note size had been scaled.","At $MID, an instrument's volume will be unchanged from default. This means you can still use the volume sliders to mix the base volume of instruments. The volume gradually increases up to $HI, or decreases down to mute at $LO.","This setting was the default for volume modulation in JummBox for a long time. Due to some new effects like distortion and bitcrush, note volume doesn't always allow fine volume control. Also, this modulator affects the value of FM modulator waves instead of just carriers. This can distort the sound which may be useful, but also may be undesirable. In those cases, use the 'mix volume' modulator instead, which will always just scale the volume with no added effects.","For display purposes, this mod will show up on the instrument volume slider, as long as there is not also an active 'mix volume' modulator anyhow. However, as mentioned, it works more like changing note volume.","[MULTIPLICATIVE] [$LO - $HI]"]},{name:"pan",pianoName:"Pan",maxRawVol:t.panMax,newNoteVol:Math.ceil(t.panMax/2),forSong:!1,convertRealFactor:0,associatedEffect:2,promptName:"Instrument Panning",promptDesc:["This setting controls the panning of your instrument, just like the panning slider.","At $LO, your instrument will sound like it is coming fully from the left-ear side. At $MID it will be right in the middle, and at $HI, it will sound like it's on the right.","[OVERWRITING] [$LO - $HI] [L-R]"]},{name:"reverb",pianoName:"Reverb",maxRawVol:t.reverbRange,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:0,promptName:"Instrument Reverb",promptDesc:["This setting controls the reverb of your insturment, just like the reverb slider.","At $LO, your instrument will have no reverb. At $HI, it will be at maximum.","[OVERWRITING] [$LO - $HI]"]},{name:"distortion",pianoName:"Distortion",maxRawVol:t.distortionRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:3,promptName:"Instrument Distortion",promptDesc:["This setting controls the amount of distortion for your instrument, just like the distortion slider.","At $LO, your instrument will have no distortion. At $HI, it will be at maximum.","[OVERWRITING] [$LO - $HI]"]},{name:"fm slider 1",pianoName:"FM 1",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 1",promptDesc:["This setting affects the strength of the first FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 2",pianoName:"FM 2",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 2",promptDesc:["This setting affects the strength of the second FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 3",pianoName:"FM 3",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 3",promptDesc:["This setting affects the strength of the third FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm slider 4",pianoName:"FM 4",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Slider 4",promptDesc:["This setting affects the strength of the fourth FM slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"fm feedback",pianoName:"FM Feedback",maxRawVol:15,newNoteVol:15,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"FM Feedback",promptDesc:["This setting affects the strength of the FM feedback slider, just like the corresponding slider on your instrument.","It works in a multiplicative way, so at $HI your slider will sound the same is its default value, and at $LO it will sound like it has been moved all the way to the left.","For the full range of control with this mod, move your underlying slider all the way to the right.","[MULTIPLICATIVE] [$LO - $HI] [%]"]},{name:"pulse width",pianoName:"Pulse Width",maxRawVol:t.pulseWidthRange,newNoteVol:t.pulseWidthRange,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Pulse Width",promptDesc:["This setting controls the width of this instrument's pulse wave, just like the pulse width slider.","At $HI, your instrument will sound like a pure square wave (on 50% of the time). It will gradually sound narrower down to $LO, where it will be inaudible (as it is on 0% of the time).","Changing pulse width randomly between a few values is a common strategy in chiptune music to lend some personality to a lead instrument.","[OVERWRITING] [$LO - $HI] [%Duty]"]},{name:"detune",pianoName:"Detune",maxRawVol:t.detuneMax-t.detuneMin,newNoteVol:t.detuneCenter,forSong:!1,convertRealFactor:-t.detuneCenter,associatedEffect:8,promptName:"Instrument Detune",promptDesc:["This setting controls the detune for this instrument, just like the detune slider.","At $MID, your instrument will have no detune applied. Each tick corresponds to one cent, or one-hundredth of a pitch. Thus, each change of 100 ticks corresponds to one half-step of detune, up to six half-steps up at $HI, or six half-steps down at $LO.","[OVERWRITING] [$LO - $HI] [cents]"]},{name:"vibrato depth",pianoName:"Vibrato Depth",maxRawVol:50,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:9,promptName:"Vibrato Depth",promptDesc:["This setting controls the amount that your pitch moves up and down by during vibrato, just like the vibrato depth slider.","At $LO, your instrument will have no vibrato depth so its vibrato would be inaudible. This increases up to $HI, where an extreme pitch change will be noticeable.","[OVERWRITING] [$LO - $HI] [pitch ÷25]"]},{name:"song detune",pianoName:"Detune",maxRawVol:t.songDetuneMax-t.songDetuneMin,newNoteVol:Math.ceil((t.songDetuneMax-t.songDetuneMin)/2),forSong:!0,convertRealFactor:-250,associatedEffect:12,promptName:"Song Detune",promptDesc:["This setting controls the overall detune of the entire song. There is no associated slider.","At $MID, your song will have no extra detune applied and sound unchanged from default. Each tick corresponds to four cents, or four hundredths of a pitch. Thus, each change of 25 ticks corresponds to one half-step of detune, up to 10 half-steps up at $HI, or 10 half-steps down at $LO.","[MULTIPLICATIVE] [$LO - $HI] [cents x4]"]},{name:"vibrato speed",pianoName:"Vibrato Speed",maxRawVol:30,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:9,promptName:"Vibrato Speed",promptDesc:["This setting controls the speed your instrument will vibrato at, just like the slider.","A setting of $LO means there will be no oscillation, and vibrato will be disabled. Higher settings will increase the speed, up to a dramatic trill at the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"vibrato delay",pianoName:"Vibrato Delay",maxRawVol:50,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:9,promptName:"Vibrato Delay",promptDesc:["This setting controls the amount of time vibrato will be held off for before triggering for every new note, just like the slider.","A setting of $LO means there will be no delay. A setting of 24 corresponds to one full beat of delay. As a sole exception to this scale, setting delay to $HI will completely disable vibrato (as if it had infinite delay).","[OVERWRITING] [$LO - $HI] [beats ÷24]"]},{name:"arp speed",pianoName:"Arp Speed",maxRawVol:50,newNoteVol:10,forSong:!1,convertRealFactor:0,associatedEffect:11,promptName:"Arpeggio Speed",promptDesc:["This setting controls the speed at which your instrument's chords arpeggiate, just like the arpeggio speed slider.","Each setting corresponds to a different speed, from the slowest to the fastest. The speeds are listed below.","[0-4]: x0, x1/16, x⅛, x⅕, x¼,","[5-9]: x⅓, x⅖, x½, x⅔, x¾,","[10-14]: x⅘, x0.9, x1, x1.1, x1.2,","[15-19]: x1.3, x1.4, x1.5, x1.6, x1.7,","[20-24]: x1.8, x1.9, x2, x2.1, x2.2,","[25-29]: x2.3, x2.4, x2.5, x2.6, x2.7,","[30-34]: x2.8, x2.9, x3, x3.1, x3.2,","[35-39]: x3.3, x3.4, x3.5, x3.6, x3.7,","[40-44]: x3.8, x3.9, x4, x4.15, x4.3,","[45-50]: x4.5, x4.8, x5, x5.5, x6, x8","[OVERWRITING] [$LO - $HI]"]},{name:"pan delay",pianoName:"Pan Delay",maxRawVol:20,newNoteVol:10,forSong:!1,convertRealFactor:0,associatedEffect:2,promptName:"Panning Delay",promptDesc:["This setting controls the delay applied to panning for your instrument, just like the pan delay slider.","With more delay, the panning effect will generally be more pronounced. $MID is the default value, whereas $LO will remove any delay at all. No delay can be desirable for chiptune songs.","[OVERWRITING] [$LO - $HI]"]},{name:"reset arp",pianoName:"Reset Arp",maxRawVol:1,newNoteVol:1,forSong:!1,convertRealFactor:0,associatedEffect:11,promptName:"Reset Arpeggio",promptDesc:["This setting functions a little different from most. Wherever a note is placed, the arpeggio of this instrument will reset at the very start of that note. This is most noticeable with lower arpeggio speeds. The lengths and values of notes for this setting don't matter, just the note start times.","This mod can be used to sync up your apreggios so that they always sound the same, even if you are using an odd-ratio arpeggio speed or modulating arpeggio speed.","[$LO - $HI]"]},{name:"eq filter",pianoName:"EQFlt",maxRawVol:10,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"EQ Filter",promptDesc:["This setting controls a few separate things for your instrument's EQ filter.","When the option 'morph' is selected, your modulator values will indicate a sub-filter index of your EQ filter to 'morph' to over time. For example, a change from 0 to 1 means your main filter (default) will morph to sub-filter 1 over the specified duration. You can shape the main filter and sub-filters in the large filter editor ('+' button). If your two filters' number, type, and order of filter dots all match up, the morph will happen smoothly and you'll be able to hear them changing. If they do not match up, the filters will simply jump between each other.","Note that filters will morph based on endpoints in the pattern editor. So, if you specify a morph from sub-filter 1 to 4 but do not specifically drag in new endpoints for 2 and 3, it will morph directly between 1 and 4 without going through the others.","If you target Dot X or Dot Y, you can finely tune the coordinates of a single dot for your filter. The number of available dots to choose is dependent on your main filter's dot count.","[OVERWRITING] [$LO - $HI]"]},{name:"note filter",pianoName:"N.Flt",maxRawVol:10,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:5,promptName:"Note Filter",promptDesc:["This setting controls a few separate things for your instrument's note filter.","When the option 'morph' is selected, your modulator values will indicate a sub-filter index of your note filter to 'morph' to over time. For example, a change from 0 to 1 means your main filter (default) will morph to sub-filter 1 over the specified duration. You can shape the main filter and sub-filters in the large filter editor ('+' button). If your two filters' number, type, and order of filter dots all match up, the morph will happen smoothly and you'll be able to hear them changing. If they do not match up, the filters will simply jump between each other.","Note that filters will morph based on endpoints in the pattern editor. So, if you specify a morph from sub-filter 1 to 4 but do not specifically drag in new endpoints for 2 and 3, it will morph directly between 1 and 4 without going through the others.","If you target Dot X or Dot Y, you can finely tune the coordinates of a single dot for your filter. The number of available dots to choose is dependent on your main filter's dot count.","[OVERWRITING] [$LO - $HI]"]},{name:"bit crush",pianoName:"Bitcrush",maxRawVol:t.bitcrusherQuantizationRange-1,newNoteVol:Math.round(t.bitcrusherQuantizationRange/2),forSong:!1,convertRealFactor:0,associatedEffect:4,promptName:"Instrument Bit Crush",promptDesc:["This setting controls the bit crush of your instrument, just like the bit crush slider.","At a value of $LO, no bit crush will be applied. This increases and the bit crush effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"freq crush",pianoName:"Freq Crush",maxRawVol:t.bitcrusherFreqRange-1,newNoteVol:Math.round(t.bitcrusherFreqRange/2),forSong:!1,convertRealFactor:0,associatedEffect:4,promptName:"Instrument Frequency Crush",promptDesc:["This setting controls the frequency crush of your instrument, just like the freq crush slider.","At a value of $LO, no frequency crush will be applied. This increases and the frequency crush effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"echo",pianoName:"Echo",maxRawVol:t.echoSustainRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:6,promptName:"Instrument Echo Sustain",promptDesc:["This setting controls the echo sustain (echo loudness) of your instrument, just like the echo slider.","At $LO, your instrument will have no echo sustain and echo will not be audible. Echo sustain increases and the echo effect gets more noticeable up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"echo delay",pianoName:"Echo Delay",maxRawVol:t.echoDelayRange,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Instrument Echo Delay",promptDesc:["This setting controls the echo delay of your instrument, just like the echo delay slider.","At $LO, your instrument will have very little echo delay, and this increases up to 2 beats of delay at $HI.","[OVERWRITING] [$LO - $HI] [~beats ÷12]"]},{name:"chorus",pianoName:"Chorus",maxRawVol:t.chorusRange,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:1,promptName:"Instrument Chorus",promptDesc:["This setting controls the chorus strength of your instrument, just like the chorus slider.","At $LO, the chorus effect will be disabled. The strength of the chorus effect increases up to the max value, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"eq filt cut",pianoName:"EQFlt Cut",maxRawVol:t.filterSimpleCutRange-1,newNoteVol:t.filterSimpleCutRange-1,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"EQ Filter Cutoff Frequency",promptDesc:["This setting controls the filter cut position of your instrument, just like the filter cut slider.","This setting is roughly analagous to the horizontal position of a single low-pass dot on the advanced filter editor. At lower values, a wider range of frequencies is cut off.","[OVERWRITING] [$LO - $HI]"]},{name:"eq filt peak",pianoName:"EQFlt Peak",maxRawVol:t.filterSimplePeakRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"EQ Filter Peak Gain",promptDesc:["This setting controls the filter peak position of your instrument, just like the filter peak slider.","This setting is roughly analagous to the vertical position of a single low-pass dot on the advanced filter editor. At lower values, the cutoff frequency will not be emphasized, and at higher values you will hear emphasis on the cutoff frequency.","[OVERWRITING] [$LO - $HI]"]},{name:"note filt cut",pianoName:"N.Flt Cut",maxRawVol:t.filterSimpleCutRange-1,newNoteVol:t.filterSimpleCutRange-1,forSong:!1,convertRealFactor:0,associatedEffect:5,promptName:"Note Filter Cutoff Frequency",promptDesc:["This setting controls the filter cut position of your instrument, just like the filter cut slider.","This setting is roughly analagous to the horizontal position of a single low-pass dot on the advanced filter editor. At lower values, a wider range of frequencies is cut off.","[OVERWRITING] [$LO - $HI]"]},{name:"note filt peak",pianoName:"N.Flt Peak",maxRawVol:t.filterSimplePeakRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:5,promptName:"Note Filter Peak Gain",promptDesc:["This setting controls the filter peak position of your instrument, just like the filter peak slider.","This setting is roughly analagous to the vertical position of a single low-pass dot on the advanced filter editor. At lower values, the cutoff frequency will not be emphasized, and at higher values you will hear emphasis on the cutoff frequency.","[OVERWRITING] [$LO - $HI]"]},{name:"pitch shift",pianoName:"Pitch Shift",maxRawVol:t.pitchShiftRange-1,newNoteVol:t.pitchShiftCenter,forSong:!1,convertRealFactor:-t.pitchShiftCenter,associatedEffect:7,promptName:"Pitch Shift",promptDesc:["This setting controls the pitch offset of your instrument, just like the pitch shift slider.","At $MID your instrument will have no pitch shift. This increases as you decrease toward $LO pitches (half-steps) at the low end, or increases towards +$HI pitches at the high end.","[OVERWRITING] [$LO - $HI] [pitch]"]},{name:"sustain",pianoName:"Sustain",maxRawVol:t.stringSustainRange-1,newNoteVol:0,forSong:!1,convertRealFactor:0,associatedEffect:12,promptName:"Picked String Sustain",promptDesc:["This setting controls the sustain of your picked string instrument, just like the sustain slider.","At $LO, your instrument will have minimum sustain and sound 'plucky'. This increases to a more held sound as your modulator approaches the maximum, $HI.","[OVERWRITING] [$LO - $HI]"]},{name:"mix volume",pianoName:"Mix Vol.",maxRawVol:t.volumeRange,newNoteVol:Math.ceil(t.volumeRange/2),forSong:!1,convertRealFactor:Math.ceil(-t.volumeRange/2),associatedEffect:12,promptName:"Mix Volume",promptDesc:["This setting affects the volume of your instrument as if its volume slider had been moved.","At $MID, an instrument's volume will be unchanged from default. This means you can still use the volume sliders to mix the base volume of instruments, since this setting and the default value work multiplicatively. The volume gradually increases up to $HI, or decreases down to mute at $LO.","Unlike the 'note volume' setting, mix volume is very straightforward and simply affects the resultant instrument volume after all effects are applied.","[MULTIPLICATIVE] [$LO - $HI]"]}]);/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|android|ipad|playbook|silk/i.test(navigator.userAgent);class M{static valueToPreset(e){const t=e>>6,i=63&e;return M.presetCategories[t].presets[i]}static midiProgramToPresetValue(e){for(let t=0;t<M.presetCategories.length;t++){const i=M.presetCategories[t];for(let n=0;n<i.presets.length;n++){const s=i.presets[n];if(s.generalMidi&&s.midiProgram==e)return(t<<6)+n}}return null}static nameToPresetValue(e){for(let t=0;t<M.presetCategories.length;t++){const i=M.presetCategories[t];for(let n=0;n<i.presets.length;n++){if(i.presets[n].name==e)return(t<<6)+n}}return null}}function F(e,t){for(let i=0;i<e.length;i++)e[i]*=t}function q(e){if(!function(e){return!(!e||e&e-1)}(e))throw new Error("FFT array length must be a power of 2.");return Math.round(Math.log(e)/Math.log(2))}function T(e,t){const i=q(t);if(t<4)throw new Error("FFT array length must be at least 4.");for(let n=i-1;n>=2;n--){const i=1<<n,s=i>>1,a=i<<1,r=2*Math.PI/a,o=Math.cos(r),l=Math.sin(r),h=2*o;for(let n=0;n<t;n+=a){const t=n,a=t+s,r=t+i,u=r+s,c=r+i,p=e[t],f=e[r];e[t]=p+f,e[a]*=2,e[r]=p-f,e[u]*=2;let m=o,d=-l,y=1,v=0;for(let i=1;i<s;i++){const n=t+i,s=r-i,a=r+i,o=c-i,l=e[n],u=e[s],p=e[a],f=e[o],g=l-u,b=p+f;e[n]=l+u,e[s]=f-p,e[a]=g*m-b*d,e[o]=b*m+g*d;const S=h*m-y,w=h*d-v;y=m,v=d,m=S,d=w}}}for(let i=0;i<t;i+=4){const t=i+1,n=i+2,s=i+3,a=e[i],r=2*e[t],o=e[n],l=2*e[s],h=a+o,u=a-o;e[i]=h+r,e[t]=h-r,e[n]=u+l,e[s]=u-l}!function(e,t){const i=q(t);if(i>16)throw new Error("FFT array length must not be greater than 2^16.");const n=16-i;for(let i=0;i<t;i++){let t;if(t=(43690&i)>>1|(21845&i)<<1,t=(52428&t)>>2|(13107&t)<<2,t=(61680&t)>>4|(3855&t)<<4,t=(t>>8|(255&t)<<8)>>n,t>i){let n=e[i];e[i]=e[t],e[t]=n}}}(e,t)}M.version="V2",M.versionDisplayName="Midbox TESTING "+M.version,M.releaseNotesURL="https://jummbus.bitbucket.io/patch_notes/"+M.version+".html",M.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),M.ctrlSymbol=M.isOnMac?"⌘":"Ctrl+",M.ctrlName=M.isOnMac?"command":"control",M.presetCategories=u([{name:"Custom Instruments",presets:u([{name:"chip wave",customType:0},{name:"FM (expert)",customType:1},{name:"basic noise",customType:2},{name:"spectrum",customType:3},{name:"drumset",customType:4},{name:"harmonics",customType:5},{name:"pulse width",customType:6},{name:"picked string",customType:7},{name:"custom chip",customType:8}])},{name:"Midbox Misc Presets",presets:u([{name:"broken music box",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"high-pass",cutoffHz:210.22,linearGain:.5},{type:"low-pass",cutoffHz:6727.17,linearGain:.0884},{type:"peak",cutoffHz:500,linearGain:1.4142}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:210.22,linearGain:.5},{type:"low-pass",cutoffHz:6727.17,linearGain:.0884},{type:"peak",cutoffHz:500,linearGain:1.4142}],effects:["transition type","chord type","vibrato","note filter","bitcrusher","chorus","echo","reverb"],transition:"normal",clicklessTransition:!1,chord:"strum",fastTwoNoteArp:!1,arpeggioSpeed:12,vibrato:"custom",vibratoDepth:.72,vibratoDelay:19,vibratoSpeed:30,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.0884}],noteSubFilters0:[{type:"low-pass",cutoffHz:4756.83,linearGain:.0884}],bitcrusherOctave:3,bitcrusherQuantization:29,panDelay:10,chorus:29,echoSustain:43,echoDelayBeats:1,reverb:23,fadeInSeconds:0,fadeOutTicks:12,wave:"rounded",unison:"hyper",envelopes:[{target:"noteFilterFreq",envelope:"twang 1",index:0}]}},{name:"enhanced synth kick",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"peak",cutoffHz:594.6,linearGain:.0884},{type:"peak",cutoffHz:19027.31,linearGain:4},{type:"high-pass",cutoffHz:62.5,linearGain:2.8284},{type:"peak",cutoffHz:1681.79,linearGain:.25}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"peak",cutoffHz:594.6,linearGain:.0884},{type:"peak",cutoffHz:19027.31,linearGain:4},{type:"high-pass",cutoffHz:62.5,linearGain:2.8284},{type:"peak",cutoffHz:1681.79,linearGain:.25}],effects:["pitch shift","vibrato","note filter","distortion","bitcrusher","chorus"],pitchShiftSemitones:24,vibrato:"custom",vibratoDepth:2,vibratoDelay:0,vibratoSpeed:30,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"peak",cutoffHz:148.65,linearGain:11.3137}],noteSubFilters0:[{type:"peak",cutoffHz:148.65,linearGain:11.3137}],distortion:71,aliases:!1,bitcrusherOctave:4,bitcrusherQuantization:57,panDelay:10,chorus:29,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1 2←(3 4)",feedbackType:"1⟲",feedbackAmplitude:13,operators:[{frequency:"20×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"16×",amplitude:8,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorFrequency",envelope:"twang 1",index:0},{target:"noteVolume",envelope:"twang 3"},{target:"feedbackAmplitude",envelope:"twang 1"},{target:"noteFilterFreq",envelope:"twang 1",index:0},{target:"noteVolume",envelope:"modbox blip"},{target:"operatorFrequency",envelope:"modbox blip",index:1},{target:"operatorAmplitude",envelope:"twang 1",index:1},{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 2"}]}},{name:"scratch string",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:3363.59,linearGain:.1768},{type:"high-pass",cutoffHz:176.78,linearGain:.25}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","vibrato","note filter","distortion","echo","reverb"],transition:"normal",clicklessTransition:!1,vibrato:"light",vibratoDepth:.15,vibratoDelay:0,vibratoSpeed:10,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:1189.21,linearGain:.3536}],distortion:100,aliases:!1,panDelay:10,echoSustain:29,echoDelayBeats:.75,reverb:29,fadeInSeconds:0,fadeOutTicks:12,algorithm:"1←2←(3 4)",feedbackType:"1→4",feedbackAmplitude:3,operators:[{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"~2×",amplitude:8,waveform:"triangle",pulseWidth:6},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"~2×",amplitude:3,waveform:"sawtooth",pulseWidth:1}],envelopes:[{target:"operatorAmplitude",envelope:"swell 1",index:3},{target:"operatorAmplitude",envelope:"tremolo1",index:1}]}},{name:"xylophone saw",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"high-pass",cutoffHz:210.22,linearGain:1},{type:"low-pass",cutoffHz:6727.17,linearGain:.1768}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["chord type","pitch shift","vibrato","bitcrusher","chorus","echo"],chord:"medium strum",fastTwoNoteArp:!0,arpeggioSpeed:12,pitchShiftSemitones:24,vibrato:"light",vibratoDepth:.15,vibratoDelay:0,vibratoSpeed:10,vibratoType:0,bitcrusherOctave:5.5,bitcrusherQuantization:14,panDelay:10,chorus:29,echoSustain:43,echoDelayBeats:.75,fadeInSeconds:0,fadeOutTicks:12,wave:"heavy saw",unison:"broke",envelopes:[{target:"noteVolume",envelope:"twang 2"}]}},{name:"bow bass",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"high-pass",cutoffHz:210.22,linearGain:1},{type:"low-pass",cutoffHz:11313.71,linearGain:.5},{type:"peak",cutoffHz:1414.21,linearGain:.1768}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["chord type","pitch shift","vibrato","note filter","bitcrusher","chorus","echo"],chord:"medium strum",fastTwoNoteArp:!0,arpeggioSpeed:12,pitchShiftSemitones:24,vibrato:"custom",vibratoDepth:.36,vibratoDelay:0,vibratoSpeed:30,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.3536},{type:"peak",cutoffHz:707.11,linearGain:2.8284}],bitcrusherOctave:6,bitcrusherQuantization:29,panDelay:10,chorus:29,echoSustain:43,echoDelayBeats:.75,fadeInSeconds:0,fadeOutTicks:6,wave:"1/12 pulse",unison:"deep shift",envelopes:[{target:"noteFilterFreq",envelope:"twang 2",index:0},{target:"noteFilterFreq",envelope:"twang 2",index:1}]}},{name:"depths",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:1681.79,linearGain:.25},{type:"peak",cutoffHz:4e3,linearGain:.7071},{type:"peak",cutoffHz:840.9,linearGain:.3536},{type:"high-pass",cutoffHz:62.5,linearGain:2}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","chord type","pitch shift","detune","vibrato","note filter","bitcrusher","chorus","reverb"],transition:"continue in pattern",clicklessTransition:!1,chord:"build up",fastTwoNoteArp:!1,arpeggioSpeed:12,pitchShiftSemitones:0,detuneCents:-52,vibrato:"custom",vibratoDepth:.56,vibratoDelay:0,vibratoSpeed:1,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.0884}],bitcrusherOctave:3,bitcrusherQuantization:29,panDelay:10,chorus:100,reverb:71,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←2←3←4",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:15,waveform:"pulse width",pulseWidth:5},{frequency:"1×",amplitude:8,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:3,waveform:"ramp",pulseWidth:5}],envelopes:[{target:"noteFilterFreq",envelope:"tremolo4",index:0}]}},{name:"disco vocal lead",midiProgram:80,settings:{type:"Picked String",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","pitch shift","note filter","distortion","chorus","echo","reverb"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"high-pass",cutoffHz:125,linearGain:.0884},{type:"low-pass",cutoffHz:5656.85,linearGain:4}],distortion:100,aliases:!1,panDelay:10,chorus:100,echoSustain:29,echoDelayBeats:1,reverb:19,fadeInSeconds:0,fadeOutTicks:6,harmonics:[43,71,100,0,0,100,0,57,0,0,0,86,29,0,0,0,0,14,0,14,14,0,0,0,0,43,0,0],unison:"piano",stringSustain:93,envelopes:[]}},{name:"blessed piano",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"peak",cutoffHz:707.11,linearGain:4}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"peak",cutoffHz:707.11,linearGain:4}],effects:["chord type","vibrato","note filter","distortion","bitcrusher","chorus"],chord:"medium strum",fastTwoNoteArp:!1,arpeggioSpeed:12,vibrato:"custom",vibratoDepth:.48,vibratoDelay:11,vibratoSpeed:16,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:5656.85,linearGain:.0884}],distortion:14,aliases:!1,bitcrusherOctave:4,bitcrusherQuantization:29,panDelay:10,chorus:86,fadeInSeconds:0,fadeOutTicks:24,wave:"triangle",unison:"energetic",envelopes:[{target:"noteFilterFreq",envelope:"twang 1",index:0}]}},{name:"sawtooth pluck",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:16e3,linearGain:.25}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","chord type","pitch shift","vibrato","note filter"],transition:"normal",clicklessTransition:!1,chord:"1/3 strum",fastTwoNoteArp:!0,arpeggioSpeed:9,pitchShiftSemitones:24,vibrato:"light",vibratoDepth:.15,vibratoDelay:0,vibratoSpeed:10,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:11313.71,linearGain:.1768},{type:"peak",cutoffHz:4e3,linearGain:11.3137},{type:"peak",cutoffHz:8e3,linearGain:4}],panDelay:10,fadeInSeconds:0,fadeOutTicks:12,wave:"sawtooth",unison:"broke",envelopes:[{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"},{target:"noteFilterFreq",envelope:"twang 1",index:1},{target:"noteFilterFreq",envelope:"twang 1",index:0},{target:"noteFilterFreq",envelope:"swell 1",index:2}]}},{name:"desolated piano",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:11313.71,linearGain:.5}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["pitch shift","vibrato","bitcrusher","chorus","reverb"],pitchShiftSemitones:24,vibrato:"custom",vibratoDepth:.6,vibratoDelay:1,vibratoSpeed:18,vibratoType:0,bitcrusherOctave:3.5,bitcrusherQuantization:0,panDelay:10,chorus:29,reverb:26,fadeInSeconds:0,fadeOutTicks:48,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:7,operators:[{frequency:"~1×",amplitude:15,waveform:"triangle",pulseWidth:5},{frequency:"3×",amplitude:3,waveform:"trapezoid",pulseWidth:5},{frequency:"8×",amplitude:4,waveform:"triangle",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"vibratoDepth",envelope:"twang 2"},{target:"feedbackAmplitude",envelope:"twang 2"},{target:"operatorAmplitude",envelope:"decay 1",index:1},{target:"operatorAmplitude",envelope:"twang 1",index:2},{target:"operatorAmplitude",envelope:"twang 1",index:2}]}},{name:"distorted guitar 1",midiProgram:80,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.5}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:4e3,linearGain:.5}],effects:["note filter","distortion","chorus","echo","reverb"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"high-pass",cutoffHz:297.3,linearGain:2},{type:"low-pass",cutoffHz:3363.59,linearGain:2},{type:"peak",cutoffHz:840.9,linearGain:11.3137},{type:"peak",cutoffHz:1681.79,linearGain:.1768}],noteSubFilters0:[{type:"high-pass",cutoffHz:297.3,linearGain:2},{type:"low-pass",cutoffHz:3363.59,linearGain:2},{type:"peak",cutoffHz:840.9,linearGain:11.3137},{type:"peak",cutoffHz:1681.79,linearGain:.1768}],distortion:71,aliases:!1,panDelay:10,chorus:14,echoSustain:43,echoDelayBeats:1,reverb:39,fadeInSeconds:0,fadeOutTicks:6,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:"distorted guitar 2",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"high-pass",cutoffHz:353.55,linearGain:1},{type:"peak",cutoffHz:1189.21,linearGain:.125},{type:"peak",cutoffHz:3363.59,linearGain:.5}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:353.55,linearGain:1},{type:"peak",cutoffHz:1189.21,linearGain:.125},{type:"peak",cutoffHz:3363.59,linearGain:.5}],effects:["note filter","bitcrusher","chorus","reverb"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"peak",cutoffHz:210.22,linearGain:4},{type:"high-pass",cutoffHz:125,linearGain:1.4142},{type:"peak",cutoffHz:420.45,linearGain:11.3137},{type:"low-pass",cutoffHz:2e3,linearGain:2.8284}],noteSubFilters0:[{type:"peak",cutoffHz:210.22,linearGain:4},{type:"high-pass",cutoffHz:125,linearGain:1.4142},{type:"peak",cutoffHz:420.45,linearGain:11.3137},{type:"low-pass",cutoffHz:2e3,linearGain:2.8284}],bitcrusherOctave:6.5,bitcrusherQuantization:71,panDelay:10,chorus:43,reverb:52,fadeInSeconds:0,fadeOutTicks:24,algorithm:"(1 2 3)←4",feedbackType:"1⟲",feedbackAmplitude:2,operators:[{frequency:"2×",amplitude:14,waveform:"trapezoid",pulseWidth:5},{frequency:"~2×",amplitude:13,waveform:"sine",pulseWidth:5},{frequency:"4×",amplitude:10,waveform:"pulse width",pulseWidth:5},{frequency:"8×",amplitude:3,waveform:"triangle",pulseWidth:5}],envelopes:[]}},{name:"distorted guitar 3",midiProgram:80,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:13454.34,linearGain:.5},{type:"high-pass",cutoffHz:125,linearGain:.5},{type:"peak",cutoffHz:707.11,linearGain:2.8284},{type:"peak",cutoffHz:500,linearGain:4}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:13454.34,linearGain:.5},{type:"high-pass",cutoffHz:125,linearGain:.5},{type:"peak",cutoffHz:707.11,linearGain:2.8284},{type:"peak",cutoffHz:500,linearGain:4}],effects:["pitch shift","note filter","distortion","chorus","reverb"],pitchShiftSemitones:24,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:840.9,linearGain:.7071},{type:"high-pass",cutoffHz:176.78,linearGain:.3536}],noteSubFilters0:[{type:"low-pass",cutoffHz:840.9,linearGain:.7071},{type:"high-pass",cutoffHz:176.78,linearGain:.3536}],distortion:100,aliases:!1,panDelay:10,chorus:14,reverb:6,fadeInSeconds:0,fadeOutTicks:24,harmonics:[100,0,86,0,43,0,100,43,0,29,0,100,0,0,0,71,43,0,0,0,14,0,0,0,0,0,0,29],unison:"none",stringSustain:0,envelopes:[{target:"noteVolume",envelope:"twang 1"}]}},{name:"high pad",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:8e3,linearGain:1},{type:"high-pass",cutoffHz:88.39,linearGain:8}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:8e3,linearGain:1},{type:"high-pass",cutoffHz:88.39,linearGain:8}],effects:["pitch shift","vibrato","note filter","chorus"],pitchShiftSemitones:12,vibrato:"custom",vibratoDepth:.28,vibratoDelay:19,vibratoSpeed:30,vibratoType:0,noteFilterType:!0,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.7071}],noteSubFilters1:[{type:"low-pass",cutoffHz:19027.31,linearGain:.7071}],panDelay:10,chorus:86,fadeInSeconds:.0125,fadeOutTicks:24,algorithm:"1←3 2←4",feedbackType:"1⟲ 2⟲ 3⟲",feedbackAmplitude:11,operators:[{frequency:"4×",amplitude:13,waveform:"pulse width",pulseWidth:3},{frequency:"0.12×",amplitude:13,waveform:"sine",pulseWidth:5},{frequency:"3×",amplitude:1,waveform:"sine",pulseWidth:5},{frequency:"4×",amplitude:8,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteFilterAllFreqs",envelope:"swell 1"},{target:"noteFilterAllFreqs",envelope:"swell 1"},{target:"operatorAmplitude",envelope:"modbox blip",index:2},{target:"feedbackAmplitude",envelope:"twang 1"},{target:"feedbackAmplitude",envelope:"twang 1"},{target:"feedbackAmplitude",envelope:"twang 1"},{target:"operatorAmplitude",envelope:"twang 1",index:1},{target:"noteFilterAllFreqs",envelope:"swell 1"}]}},{name:"magical pulse",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:4e3,linearGain:.0884}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","pitch shift","vibrato","chorus"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:24,vibrato:"custom",vibratoDepth:.56,vibratoDelay:27,vibratoSpeed:14,vibratoType:0,panDelay:10,chorus:57,fadeInSeconds:0,fadeOutTicks:6,wave:"sawtooth",unison:"hyper",envelopes:[{target:"noteVolume",envelope:"swell 3"}]}},{name:"distorted lead",midiProgram:80,settings:{type:"FM",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","distortion","bitcrusher","chorus"],transition:"normal",clicklessTransition:!1,distortion:29,aliases:!1,bitcrusherOctave:2,bitcrusherQuantization:0,panDelay:10,chorus:100,fadeInSeconds:0,fadeOutTicks:6,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"1×",amplitude:11,waveform:"trapezoid",pulseWidth:5},{frequency:"1×",amplitude:7,waveform:"pulse width",pulseWidth:7},{frequency:"1×",amplitude:8,waveform:"ramp",pulseWidth:5},{frequency:"1×",amplitude:5,waveform:"triangle",pulseWidth:5}],envelopes:[]}},{name:"FM punch bass",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"low-pass",cutoffHz:1414.21,linearGain:2.8284}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:1414.21,linearGain:2.8284}],effects:["note filter"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:1414.21,linearGain:2.8284}],noteSubFilters0:[{type:"low-pass",cutoffHz:1414.21,linearGain:2.8284}],panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:4,operators:[{frequency:"1×",amplitude:7,waveform:"pulse width",pulseWidth:5},{frequency:"1×",amplitude:4,waveform:"sine",pulseWidth:7},{frequency:"1×",amplitude:0,waveform:"ramp",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"triangle",pulseWidth:5}],envelopes:[{target:"noteFilterFreq",envelope:"twang 1",index:0},{target:"feedbackAmplitude",envelope:"punch"},{target:"noteVolume",envelope:"twang 2"}]}},{name:"rough glistening piano",midiProgram:80,settings:{type:"harmonics",eqFilter:[{type:"peak",cutoffHz:210.22,linearGain:1.4142},{type:"high-pass",cutoffHz:125,linearGain:.1768}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"peak",cutoffHz:210.22,linearGain:1.4142},{type:"high-pass",cutoffHz:125,linearGain:.1768}],effects:["chord type","note filter","chorus","echo","reverb"],chord:"strum",fastTwoNoteArp:!1,arpeggioSpeed:12,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:5656.85,linearGain:.5}],noteSubFilters0:[{type:"low-pass",cutoffHz:5656.85,linearGain:.5}],panDelay:10,chorus:29,echoSustain:43,echoDelayBeats:1,reverb:23,fadeInSeconds:0,fadeOutTicks:48,harmonics:[100,71,43,29,29,14,14,43,0,43,0,57,71,0,71,43,0,0,57,0,57,0,71,0,71,0,57,0],unison:"honky tonk",envelopes:[{target:"noteFilterFreq",envelope:"twang 2",index:0}]}},{name:"soft glistening piano",midiProgram:80,settings:{type:"harmonics",eqFilter:[{type:"high-pass",cutoffHz:210.22,linearGain:.3536},{type:"peak",cutoffHz:707.11,linearGain:.3536},{type:"peak",cutoffHz:2e3,linearGain:.3536}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:210.22,linearGain:.3536},{type:"peak",cutoffHz:707.11,linearGain:.3536},{type:"peak",cutoffHz:2e3,linearGain:.3536}],effects:["chord type","detune","note filter","chorus","reverb"],chord:"medium strum",fastTwoNoteArp:!1,arpeggioSpeed:12,detuneCents:-20,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:5656.85,linearGain:.5}],noteSubFilters0:[{type:"low-pass",cutoffHz:5656.85,linearGain:.5}],panDelay:10,chorus:29,reverb:97,fadeInSeconds:.135,fadeOutTicks:48,harmonics:[100,0,0,29,29,14,14,0,0,0,0,0,0,0,0,0,0,0,0,29,0,0,43,14,0,0,0,0],unison:"honky tonk",envelopes:[{target:"noteFilterFreq",envelope:"twang 2",index:0}]}},{name:"jingle bells",midiProgram:80,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.3536},{type:"high-pass",cutoffHz:707.11,linearGain:2}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:9513.66,linearGain:.3536},{type:"high-pass",cutoffHz:707.11,linearGain:2}],effects:["chord type","pitch shift","detune","note filter","bitcrusher","chorus","echo","reverb"],chord:"1/3 strum",fastTwoNoteArp:!1,arpeggioSpeed:12,pitchShiftSemitones:24,detuneCents:8,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:16e3,linearGain:2},{type:"high-pass",cutoffHz:176.78,linearGain:.5},{type:"peak",cutoffHz:2378.41,linearGain:.7071},{type:"peak",cutoffHz:1414.21,linearGain:2.8284}],noteSubFilters0:[{type:"low-pass",cutoffHz:16e3,linearGain:2},{type:"high-pass",cutoffHz:176.78,linearGain:.5},{type:"peak",cutoffHz:2378.41,linearGain:.7071},{type:"peak",cutoffHz:1414.21,linearGain:2.8284}],bitcrusherOctave:5,bitcrusherQuantization:0,panDelay:10,chorus:29,echoSustain:57,echoDelayBeats:1.667,reverb:77,fadeInSeconds:0,fadeOutTicks:12,harmonics:[100,29,57,71,0,0,0,0,0,0,0,14,43,14,0,0,0,0,0,0,14,0,14,14,0,0,0,0],unison:"none",envelopes:[{target:"noteVolume",envelope:"twang 2"}]}},{name:"odd snare",midiProgram:80,settings:{type:"FM",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[],effects:["pitch shift","detune","note filter","distortion","bitcrusher","chorus","echo","reverb"],pitchShiftSemitones:24,detuneCents:600,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:.0884},{type:"peak",cutoffHz:176.78,linearGain:2.8284}],noteSubFilters0:[{type:"low-pass",cutoffHz:6727.17,linearGain:.0884},{type:"peak",cutoffHz:176.78,linearGain:2.8284}],distortion:29,aliases:!1,bitcrusherOctave:4.5,bitcrusherQuantization:43,panDelay:10,chorus:29,echoSustain:43,echoDelayBeats:.083,reverb:3,fadeInSeconds:0,fadeOutTicks:12,algorithm:"(1 2)←3←4",feedbackType:"2⟲ 3⟲ 4⟲",feedbackAmplitude:15,operators:[{frequency:"16×",amplitude:15,waveform:"pulse width",pulseWidth:5},{frequency:"32×",amplitude:12,waveform:"sine",pulseWidth:9},{frequency:"2×",amplitude:11,waveform:"sine",pulseWidth:5},{frequency:"13×",amplitude:6,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorAmplitude",envelope:"twang 3",index:0},{target:"noteFilterFreq",envelope:"twang 1",index:0},{target:"operatorFrequency",envelope:"modbox click",index:2},{target:"pitchShift",envelope:"twang 3"},{target:"operatorFrequency",envelope:"twang 1",index:0},{target:"noteFilterFreq",envelope:"swell 1",index:1},{target:"operatorFrequency",envelope:"twang 1",index:0},{target:"operatorFrequency",envelope:"twang 1",index:0}]}},{name:"otherworldly kick",midiProgram:80,settings:{type:"FM",eqFilter:[],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[],effects:["pitch shift","vibrato","distortion","bitcrusher","chorus"],pitchShiftSemitones:12,vibrato:"custom",vibratoDepth:.92,vibratoDelay:18,vibratoSpeed:30,vibratoType:0,distortion:29,aliases:!1,bitcrusherOctave:6,bitcrusherQuantization:57,panDelay:10,chorus:14,fadeInSeconds:0,fadeOutTicks:24,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:0,operators:[{frequency:"20×",amplitude:15,waveform:"triangle",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorFrequency",envelope:"twang 1",index:0},{target:"noteVolume",envelope:"twang 3"},{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"},{target:"operatorFrequency",envelope:"twang 1",index:0}]}},{name:"bit-crushed piano",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"high-pass",cutoffHz:594.6,linearGain:1.4142},{type:"low-pass",cutoffHz:6727.17,linearGain:.0884},{type:"peak",cutoffHz:500,linearGain:1.4142}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:594.6,linearGain:1.4142},{type:"low-pass",cutoffHz:6727.17,linearGain:.0884},{type:"peak",cutoffHz:500,linearGain:1.4142}],effects:["transition type","chord type","pitch shift","vibrato","note filter","bitcrusher","chorus","echo","reverb"],transition:"normal",clicklessTransition:!1,chord:"strum",fastTwoNoteArp:!1,arpeggioSpeed:12,pitchShiftSemitones:24,vibrato:"custom",vibratoDepth:.72,vibratoDelay:19,vibratoSpeed:30,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:4756.83,linearGain:.0884}],noteSubFilters0:[{type:"low-pass",cutoffHz:4756.83,linearGain:.0884}],bitcrusherOctave:3,bitcrusherQuantization:29,panDelay:10,chorus:29,echoSustain:29,echoDelayBeats:.75,reverb:23,fadeInSeconds:0,fadeOutTicks:12,wave:"triangle",unison:"broke",envelopes:[{target:"noteFilterFreq",envelope:"twang 1",index:0}]}},{name:"boop pad",midiProgram:80,settings:{type:"custom chip",eqFilter:[{type:"low-pass",cutoffHz:11313.71,linearGain:.1768}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:11313.71,linearGain:.1768}],effects:["transition type","note filter","reverb"],transition:"interrupt",clicklessTransition:!1,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:16e3,linearGain:.0884}],noteSubFilters0:[{type:"low-pass",cutoffHz:16e3,linearGain:.0884}],panDelay:10,reverb:48,fadeInSeconds:0,fadeOutTicks:96,wave:"square",unison:"broke",customChipWave:{0:-1,1:1,2:-1,3:-4,4:-6,5:-8,6:-11,7:-12,8:-15,9:-16,10:-18,11:-19,12:-21,13:-22,14:-24,15:-24,16:-24,17:-24,18:-23,19:-22,20:-21,21:-19,22:-17,23:-16,24:-14,25:-13,26:-10,27:-8,28:-6,29:-4,30:-2,31:-1,32:2,33:3,34:5,35:7,36:10,37:12,38:14,39:16,40:18,41:19,42:20,43:21,44:23,45:23,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:23,59:22,60:21,61:19,62:16,63:14},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:[{target:"noteVolume",envelope:"twang 2"},{target:"noteFilterFreq",envelope:"twang 2",index:0}]}},{name:"spectrum pad",midiProgram:80,settings:{type:"spectrum",eqFilter:[{type:"low-pass",cutoffHz:2196.8,linearGain:1}],eqFilterType:!0,eqSimpleCut:6,eqSimplePeak:2,eqSubFilters1:[],effects:["vibrato","distortion","bitcrusher","reverb"],vibrato:"delayed",vibratoDepth:.3,vibratoDelay:18.5,vibratoSpeed:10,vibratoType:0,distortion:29,aliases:!1,bitcrusherOctave:4.5,bitcrusherQuantization:43,panDelay:10,reverb:26,fadeInSeconds:0,fadeOutTicks:-1,spectrum:[100,0,0,0,0,0,0,71,0,0,0,57,0,0,57,0,43,0,43,0,0,29,0,29,0,14,14,14,0,0],envelopes:[]}},{name:"3, 2, 1, GO! pulse",midiProgram:80,settings:{type:"PWM",eqFilter:[{type:"peak",cutoffHz:2828.43,linearGain:2}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","pitch shift","detune","chorus","echo","reverb"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:16,detuneCents:196,panDelay:10,chorus:14,echoSustain:29,echoDelayBeats:.5,reverb:13,fadeInSeconds:0,fadeOutTicks:48,pulseWidth:42,envelopes:[{target:"pitchShift",envelope:"twang 1"},{target:"pitchShift",envelope:"twang 1"}]}},{name:"ambient pulse 1",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"high-pass",cutoffHz:250,linearGain:2.8284},{type:"peak",cutoffHz:1414.21,linearGain:.3536},{type:"peak",cutoffHz:353.55,linearGain:.1768},{type:"peak",cutoffHz:2e3,linearGain:.3536},{type:"low-pass",cutoffHz:6727.17,linearGain:.25}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:250,linearGain:2.8284},{type:"peak",cutoffHz:1414.21,linearGain:.3536},{type:"peak",cutoffHz:353.55,linearGain:.1768},{type:"peak",cutoffHz:2e3,linearGain:.3536},{type:"low-pass",cutoffHz:6727.17,linearGain:.25}],effects:["note filter","echo","reverb"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:2378.41,linearGain:2.8284}],noteSubFilters0:[{type:"low-pass",cutoffHz:2378.41,linearGain:2.8284}],panDelay:10,echoSustain:29,echoDelayBeats:1.333,reverb:35,fadeInSeconds:0,fadeOutTicks:96,algorithm:"(1 2)←(3 4)",feedbackType:"4⟲",feedbackAmplitude:9,operators:[{frequency:"1×",amplitude:13,waveform:"triangle",pulseWidth:5},{frequency:"1×",amplitude:13,waveform:"pulse width",pulseWidth:6},{frequency:"3×",amplitude:0,waveform:"triangle",pulseWidth:5},{frequency:"~2×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorAmplitude",envelope:"flare 1",index:2}]}},{name:"saturn pad",midiProgram:80,settings:{type:"Picked String",eqFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:1},{type:"peak",cutoffHz:707.11,linearGain:1.4142}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:2828.43,linearGain:1},{type:"peak",cutoffHz:707.11,linearGain:1.4142}],effects:["note filter","reverb"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:2828.43,linearGain:.5}],noteSubFilters0:[{type:"low-pass",cutoffHz:2828.43,linearGain:.5}],panDelay:10,reverb:26,fadeInSeconds:0,fadeOutTicks:24,harmonics:[0,100,100,100,0,0,0,0,43,43,0,86,0,100,0,29,0,0,0,0,71,57,0,0,86,0,0,43],unison:"shimmer",stringSustain:93,envelopes:[{target:"noteFilterAllFreqs",envelope:"tremolo3"},{target:"noteFilterAllFreqs",envelope:"twang 3"}]}},{name:"build-up pad",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"high-pass",cutoffHz:250,linearGain:2.8284},{type:"peak",cutoffHz:1414.21,linearGain:.3536},{type:"peak",cutoffHz:353.55,linearGain:.1768},{type:"peak",cutoffHz:2e3,linearGain:.3536}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:250,linearGain:2.8284},{type:"peak",cutoffHz:1414.21,linearGain:.3536},{type:"peak",cutoffHz:353.55,linearGain:.1768},{type:"peak",cutoffHz:2e3,linearGain:.3536}],effects:["note filter","reverb"],noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:16e3,linearGain:.3536}],noteSubFilters0:[{type:"low-pass",cutoffHz:16e3,linearGain:.3536}],panDelay:10,reverb:32,fadeInSeconds:0,fadeOutTicks:96,algorithm:"(1 2)←(3 4)",feedbackType:"4⟲",feedbackAmplitude:9,operators:[{frequency:"1×",amplitude:13,waveform:"triangle",pulseWidth:5},{frequency:"1×",amplitude:13,waveform:"pulse width",pulseWidth:6},{frequency:"3×",amplitude:0,waveform:"triangle",pulseWidth:5},{frequency:"~2×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"operatorAmplitude",envelope:"flare 1",index:2},{target:"noteFilterFreq",envelope:"slow swell",index:0}]}},{name:"ambient pulse 2",midiProgram:80,settings:{type:"harmonics",eqFilter:[{type:"low-pass",cutoffHz:1189.21,linearGain:.7071},{type:"high-pass",cutoffHz:594.6,linearGain:1.4142},{type:"peak",cutoffHz:420.45,linearGain:8}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:1189.21,linearGain:.7071},{type:"high-pass",cutoffHz:594.6,linearGain:1.4142},{type:"peak",cutoffHz:420.45,linearGain:8}],effects:["chord type","note filter","reverb"],chord:"medium strum",fastTwoNoteArp:!1,arpeggioSpeed:12,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:1681.79,linearGain:1}],noteSubFilters0:[{type:"low-pass",cutoffHz:1681.79,linearGain:1}],panDelay:10,reverb:32,fadeInSeconds:0,fadeOutTicks:72,harmonics:[57,57,71,57,43,43,43,71,43,43,43,57,71,86,100,86,57,57,43,43,43,57,43,29,43,57,57,43],unison:"vary",envelopes:[{target:"noteFilterAllFreqs",envelope:"tremolo5"}]}},{name:"hyper synth saw",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"peak",cutoffHz:19027.31,linearGain:11.3137},{type:"peak",cutoffHz:1681.79,linearGain:1.4142}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"peak",cutoffHz:19027.31,linearGain:11.3137},{type:"peak",cutoffHz:1681.79,linearGain:1.4142}],effects:["chord type","detune","vibrato","distortion","chorus","echo","reverb"],chord:"medium strum",fastTwoNoteArp:!1,arpeggioSpeed:12,detuneCents:16,vibrato:"delayed",vibratoDepth:.3,vibratoDelay:18.5,vibratoSpeed:10,vibratoType:0,distortion:14,aliases:!1,panDelay:10,chorus:86,echoSustain:43,echoDelayBeats:1,reverb:58,fadeInSeconds:0,fadeOutTicks:96,wave:"sawtooth",unison:"hyper",envelopes:[]}},{name:"mechanical blip",midiProgram:80,settings:{type:"chip",eqFilter:[{type:"low-pass",cutoffHz:19027.31,linearGain:.3536},{type:"peak",cutoffHz:2e3,linearGain:.25},{type:"peak",cutoffHz:1414.21,linearGain:.3536},{type:"high-pass",cutoffHz:125,linearGain:.3536}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:19027.31,linearGain:.3536},{type:"peak",cutoffHz:2e3,linearGain:.25},{type:"peak",cutoffHz:1414.21,linearGain:.3536},{type:"high-pass",cutoffHz:125,linearGain:.3536}],effects:["transition type","detune","note filter","bitcrusher","chorus","echo","reverb"],transition:"continue in pattern",clicklessTransition:!1,detuneCents:16,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:500,linearGain:4},{type:"high-pass",cutoffHz:176.78,linearGain:11.3137}],noteSubFilters0:[{type:"low-pass",cutoffHz:500,linearGain:4},{type:"high-pass",cutoffHz:176.78,linearGain:11.3137}],noteSubFilters1:[{type:"low-pass",cutoffHz:19027.31,linearGain:.7071}],bitcrusherOctave:4.5,bitcrusherQuantization:43,panDelay:10,chorus:43,echoSustain:57,echoDelayBeats:1.5,reverb:23,fadeInSeconds:0,fadeOutTicks:-1,wave:"rounded",unison:"none",envelopes:[]}},{name:"another piano",midiProgram:80,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:11313.71,linearGain:.0884},{type:"peak",cutoffHz:9513.66,linearGain:.3536},{type:"peak",cutoffHz:2378.41,linearGain:2},{type:"peak",cutoffHz:3363.59,linearGain:1.4142},{type:"high-pass",cutoffHz:88.39,linearGain:1}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:11313.71,linearGain:.0884},{type:"peak",cutoffHz:9513.66,linearGain:.3536},{type:"peak",cutoffHz:2378.41,linearGain:2},{type:"peak",cutoffHz:3363.59,linearGain:1.4142},{type:"high-pass",cutoffHz:88.39,linearGain:1}],effects:["detune","note filter","reverb"],detuneCents:16,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:6727.17,linearGain:.125}],noteSubFilters0:[{type:"low-pass",cutoffHz:6727.17,linearGain:.125}],panDelay:10,reverb:26,fadeInSeconds:0,fadeOutTicks:24,pulseWidth:44,envelopes:[{target:"noteFilterAllFreqs",envelope:"punch"},{target:"noteVolume",envelope:"twang 2"},{target:"unison",envelope:"twang 1"},{target:"unison",envelope:"twang 1"},{target:"unison",envelope:"twang 1"},{target:"unison",envelope:"twang 1"},{target:"unison",envelope:"twang 1"}]}}])},{name:"Midbox Dubstep Presets",presets:u([{name:"dubstep bwayyyy",midiProgram:80,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.1768},{type:"peak",cutoffHz:297.3,linearGain:1},{type:"peak",cutoffHz:594.6,linearGain:.7071},{type:"peak",cutoffHz:420.45,linearGain:.5}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","vibrato","note filter","distortion","chorus","reverb"],transition:"continue",clicklessTransition:!1,vibrato:"custom",vibratoDepth:.45,vibratoDelay:23,vibratoSpeed:26,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:2e3,linearGain:11.3137}],distortion:100,aliases:!1,panDelay:10,chorus:71,reverb:32,fadeInSeconds:0,fadeOutTicks:12,pulseWidth:30,envelopes:[{target:"noteFilterFreq",envelope:"swell 3",index:0},{target:"noteFilterFreq",envelope:"swell 2",index:0}]}},{name:"dubstep bass hum",midiProgram:80,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.1768},{type:"peak",cutoffHz:297.3,linearGain:1},{type:"peak",cutoffHz:1189.21,linearGain:2},{type:"peak",cutoffHz:420.45,linearGain:.5},{type:"high-pass",cutoffHz:105.11,linearGain:.5},{type:"peak",cutoffHz:16e3,linearGain:2}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","pitch shift","vibrato","note filter","distortion","bitcrusher","chorus","reverb"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:0,vibrato:"custom",vibratoDepth:.45,vibratoDelay:23,vibratoSpeed:26,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:1414.21,linearGain:11.3137}],distortion:29,aliases:!1,bitcrusherOctave:2,bitcrusherQuantization:14,panDelay:10,chorus:43,reverb:32,fadeInSeconds:0,fadeOutTicks:24,pulseWidth:10,envelopes:[{target:"noteFilterFreq",envelope:"flare 1",index:0},{target:"noteFilterFreq",envelope:"flare 3",index:0}]}},{name:"dubstep yaa",midiProgram:80,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.0884},{type:"peak",cutoffHz:297.3,linearGain:1},{type:"peak",cutoffHz:1189.21,linearGain:.3536},{type:"peak",cutoffHz:594.6,linearGain:.3536},{type:"high-pass",cutoffHz:105.11,linearGain:.3536}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,effects:["transition type","pitch shift","vibrato","note filter","bitcrusher","chorus","reverb"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:0,vibrato:"custom",vibratoDepth:.45,vibratoDelay:23,vibratoSpeed:26,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:1414.21,linearGain:11.3137}],bitcrusherOctave:2.5,bitcrusherQuantization:29,panDelay:10,chorus:86,reverb:10,fadeInSeconds:0,fadeOutTicks:24,pulseWidth:8,envelopes:[{target:"noteFilterFreq",envelope:"swell 1",index:0}]}},{name:"dubstep yeoww",midiProgram:80,settings:{type:"PWM",eqFilter:[{type:"low-pass",cutoffHz:9513.66,linearGain:.0884},{type:"peak",cutoffHz:297.3,linearGain:1},{type:"peak",cutoffHz:1189.21,linearGain:.3536},{type:"peak",cutoffHz:594.6,linearGain:.3536},{type:"high-pass",cutoffHz:105.11,linearGain:.3536}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"low-pass",cutoffHz:9513.66,linearGain:.0884},{type:"peak",cutoffHz:297.3,linearGain:1},{type:"peak",cutoffHz:1189.21,linearGain:.3536},{type:"peak",cutoffHz:594.6,linearGain:.3536},{type:"high-pass",cutoffHz:105.11,linearGain:.3536}],effects:["transition type","chord type","vibrato","note filter","distortion","bitcrusher","chorus","reverb"],transition:"continue in pattern",clicklessTransition:!1,chord:"slow strum",fastTwoNoteArp:!1,arpeggioSpeed:12,vibrato:"custom",vibratoDepth:.44,vibratoDelay:23,vibratoSpeed:26,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:3363.59,linearGain:11.3137}],noteSubFilters0:[{type:"low-pass",cutoffHz:3363.59,linearGain:11.3137}],distortion:100,aliases:!1,bitcrusherOctave:4,bitcrusherQuantization:0,panDelay:10,chorus:86,reverb:35,fadeInSeconds:0,fadeOutTicks:24,pulseWidth:40,envelopes:[{target:"noteFilterFreq",envelope:"twang 3",index:0},{target:"pulseWidth",envelope:"tremolo6"}]}},{name:"dubstep lead",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"peak",cutoffHz:1189.21,linearGain:.0884}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"peak",cutoffHz:1189.21,linearGain:.0884}],effects:["transition type","pitch shift","note filter","distortion","bitcrusher"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"peak",cutoffHz:594.6,linearGain:5.6569},{type:"low-pass",cutoffHz:1e3,linearGain:2}],noteSubFilters0:[{type:"peak",cutoffHz:594.6,linearGain:5.6569},{type:"low-pass",cutoffHz:1e3,linearGain:2}],distortion:29,aliases:!1,bitcrusherOctave:6.5,bitcrusherQuantization:86,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:15,operators:[{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteFilterFreq",envelope:"note size",index:0},{target:"noteFilterFreq",envelope:"note size",index:1}]}},{name:"dubstep dyaii",midiProgram:80,settings:{type:"Picked String",eqFilter:[{type:"high-pass",cutoffHz:125,linearGain:.5},{type:"low-pass",cutoffHz:3363.59,linearGain:.5},{type:"peak",cutoffHz:11313.71,linearGain:2.8284},{type:"peak",cutoffHz:1e3,linearGain:.0884}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"high-pass",cutoffHz:125,linearGain:.5},{type:"low-pass",cutoffHz:3363.59,linearGain:.5},{type:"peak",cutoffHz:11313.71,linearGain:2.8284},{type:"peak",cutoffHz:1e3,linearGain:.0884}],effects:["transition type","vibrato","note filter","distortion","bitcrusher","chorus","reverb"],transition:"slide",clicklessTransition:!1,vibrato:"custom",vibratoDepth:.44,vibratoDelay:23,vibratoSpeed:26,vibratoType:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"low-pass",cutoffHz:707.11,linearGain:8},{type:"peak",cutoffHz:1414.21,linearGain:11.3137}],noteSubFilters0:[{type:"low-pass",cutoffHz:707.11,linearGain:8},{type:"peak",cutoffHz:1414.21,linearGain:11.3137}],distortion:29,aliases:!1,bitcrusherOctave:3,bitcrusherQuantization:71,panDelay:10,chorus:71,reverb:32,fadeInSeconds:0,fadeOutTicks:12,harmonics:[100,0,71,86,0,0,100,86,86,71,57,57,29,14,57,71,0,0,0,0,0,0,0,0,0,0,0,0],unison:"none",stringSustain:100,envelopes:[{target:"noteFilterAllFreqs",envelope:"note size"},{target:"noteFilterAllFreqs",envelope:"twang 3"}]}},{name:"dubstep alarm",midiProgram:80,settings:{type:"FM",eqFilter:[{type:"peak",cutoffHz:2e3,linearGain:.0884},{type:"peak",cutoffHz:1414.21,linearGain:.5}],eqFilterType:!1,eqSimpleCut:10,eqSimplePeak:0,eqSubFilters0:[{type:"peak",cutoffHz:2e3,linearGain:.0884},{type:"peak",cutoffHz:1414.21,linearGain:.5}],effects:["transition type","pitch shift","note filter","distortion","bitcrusher"],transition:"normal",clicklessTransition:!1,pitchShiftSemitones:0,noteFilterType:!1,noteSimpleCut:10,noteSimplePeak:0,noteFilter:[{type:"high-pass",cutoffHz:1414.21,linearGain:11.3137}],noteSubFilters0:[{type:"high-pass",cutoffHz:1414.21,linearGain:11.3137}],distortion:29,aliases:!1,bitcrusherOctave:6.5,bitcrusherQuantization:100,panDelay:10,fadeInSeconds:0,fadeOutTicks:-1,algorithm:"1←(2 3 4)",feedbackType:"1⟲",feedbackAmplitude:6,operators:[{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:15,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5},{frequency:"1×",amplitude:0,waveform:"sine",pulseWidth:5}],envelopes:[{target:"noteFilterFreq",envelope:"note size",index:0}]}}])},{name:"Midbox Noise Presets",presets:u([{name:"hollow retro riser",midiProgram:80,isNoise:!0,settings:{type:"noise",eqFilter:[{type:"low-pass",cutoffHz:16e3,linearGain:.3536}],eqFilterType:!0,eqSimpleCut:8,eqSimplePeak:0,eqSubFilters1:[],effects:["bitcrusher","chorus","echo","reverb"],bitcrusherOctave:4,bitcrusherQuantization:43,panDelay:10,chorus:29,echoSustain:57,echoDelayBeats:.5,reverb:29,fadeInSeconds:0,fadeOutTicks:-3,wave:"hollow",envelopes:[]}}])},{name:"Retro Presets",presets:u([{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:"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:"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:u([{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:"Idiophone Presets",presets:u([{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:u([{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:u([{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:u([{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:u([{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:u([{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:u([{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:"Vocal Presets",presets:u([{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:u([{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:u([{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:u([{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:u([{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:"Drum Presets",presets:u([{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:u([{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"}]}}])}]);class P{constructor(){this.t=1,this.i=[void 0],this.o=0,this.l=0,this.h=0}pushFront(e){this.h>=this.t&&this.u(),this.l=this.l-1&this.o,this.i[this.l]=e,this.h++}pushBack(e){this.h>=this.t&&this.u(),this.i[this.l+this.h&this.o]=e,this.h++}popFront(){if(this.h<=0)throw new Error("No elements left to pop.");const e=this.i[this.l];return this.i[this.l]=void 0,this.l=this.l+1&this.o,this.h--,e}popBack(){if(this.h<=0)throw new Error("No elements left to pop.");this.h--;const e=this.l+this.h&this.o,t=this.i[e];return this.i[e]=void 0,t}peakFront(){if(this.h<=0)throw new Error("No elements left to pop.");return this.i[this.l]}peakBack(){if(this.h<=0)throw new Error("No elements left to pop.");return this.i[this.l+this.h-1&this.o]}count(){return this.h}set(e,t){if(e<0||e>=this.h)throw new Error("Invalid index");this.i[this.l+e&this.o]=t}get(e){if(e<0||e>=this.h)throw new Error("Invalid index");return this.i[this.l+e&this.o]}remove(e){if(e<0||e>=this.h)throw new Error("Invalid index");if(e<=this.h>>1){for(;e>0;)this.set(e,this.get(e-1)),e--;this.popFront()}else{for(e++;e<this.h;)this.set(e-1,this.get(e)),e++;this.popBack()}}u(){if(this.t>=1073741824)throw new Error("Capacity too big.");this.t=this.t<<1;const e=this.i,t=new Array(this.t),i=0|this.h,n=0|this.l;for(let s=0;s<i;s++)t[s]=e[n+s&this.o];for(let e=i;e<this.t;e++)t[e]=void 0;this.l=0,this.i=t,this.o=this.t-1}}class I{constructor(){this.a=[1],this.b=[1],this.order=0}linearGain0thOrder(e){this.b[0]=e,this.order=0}lowPass1stOrderButterworth(e){const t=1/Math.tan(.5*e),i=1+t;this.a[1]=(1-t)/i,this.b[1]=this.b[0]=1/i,this.order=1}lowPass1stOrderSimplified(e){const t=2*Math.sin(.5*e);this.a[1]=t-1,this.b[0]=t,this.b[1]=0,this.order=1}highPass1stOrderButterworth(e){const t=1/Math.tan(.5*e),i=1+t;this.a[1]=(1-t)/i,this.b[0]=t/i,this.b[1]=-t/i,this.order=1}highShelf1stOrder(e,t){const i=Math.tan(.5*e),n=Math.sqrt(t),s=(i*n-1)/(i*n+1);this.a[1]=s/1,this.b[0]=(1+s+t*(1-s))/2,this.b[1]=(1+s-t*(1-s))/2,this.order=1}allPass1stOrderInvertPhaseAbove(e){const t=(Math.sin(e)-1)/Math.cos(e);this.a[1]=t,this.b[0]=t,this.b[1]=1,this.order=1}allPass1stOrderFractionalDelay(e){const t=(1-e)/(1+e);this.a[1]=t,this.b[0]=t,this.b[1]=1,this.order=1}lowPass2ndOrderButterworth(e,t){const i=Math.sin(e)/(2*t),n=Math.cos(e),s=1+i;this.a[1]=-2*n/s,this.a[2]=(1-i)/s,this.b[2]=this.b[0]=(1-n)/(2*s),this.b[1]=(1-n)/s,this.order=2}lowPass2ndOrderSimplified(e,t){const i=2*Math.sin(e/2),n=1-1/(2*t),s=n+n/(1-i);this.a[1]=2*i+(i-1)*i*s-2,this.a[2]=(i-1)*(i-i*s-1),this.b[0]=i*i,this.b[1]=0,this.b[2]=0,this.order=2}highPass2ndOrderButterworth(e,t){const i=Math.sin(e)/(2*t),n=Math.cos(e),s=1+i;this.a[1]=-2*n/s,this.a[2]=(1-i)/s,this.b[2]=this.b[0]=(1+n)/(2*s),this.b[1]=-(1+n)/s,this.order=2}peak2ndOrder(e,t,i){const n=Math.sqrt(t),s=i*e/(n>=1?n:1/n),a=Math.tan(.5*s),r=1+a/n;this.b[0]=(1+a*n)/r,this.b[1]=this.a[1]=-2*Math.cos(e)/r,this.b[2]=(1-a*n)/r,this.a[2]=(1-a/n)/r,this.order=2}}class z{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,i){const n=e.a,s=e.b,a=t,r=-i;let o=s[0]+s[1]*a,l=s[1]*r,h=1+n[1]*a,u=n[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+=s[t]*c,l+=s[t]*p,h+=n[t]*c,u+=n[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 H{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,i,n){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])*i,this.a2Delta=(t.a[2]-e.a[2])*i,n?(this.b0Delta=Math.pow(t.b[0]/e.b[0],i),this.b1Delta=Math.pow(t.b[1]/e.b[1],i),this.b2Delta=Math.pow(t.b[2]/e.b[2],i)):(this.b0Delta=(t.b[0]-e.b[0])*i,this.b1Delta=(t.b[1]-e.b[1])*i,this.b2Delta=(t.b[2]-e.b[2])*i),this.useMultiplicativeInputCoefficients=n}}const x=new class{constructor(){this.activeEvents=[],this.listeners={},this.activeEvents=[],this.listeners={}}raise(e,t,i,n){if(null!=this.listeners[e]){this.activeEvents.push(e);for(let s=0;s<this.listeners[e].length;s++)this.listeners[e][s](t,i,n);this.activeEvents.pop()}}listen(e,t){null==this.listeners[e]&&(this.listeners[e]=[]),this.listeners[e].push(t)}unlisten(e,t){if(null==this.listeners[e])return;const i=this.listeners[e].indexOf(t);-1!=i&&this.listeners[e].splice(i,1)}unlistenAll(e){null!=this.listeners[e]&&(this.listeners[e]=[])}},D=1e-24;function O(e,t,i){return i<=(t-=1)?i>=e?i:e:t}function G(e,t,i){if(e<=i&&i<=t)return i;throw new Error(`Value ${i} not in range [${e}, ${t}]`)}const A=[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],R=[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 C{constructor(e,t,i){this.p=[],this.m=0;for(let n=t;n<i;n++){const t=R[e.charCodeAt(n)];this.p.push(t>>5&1),this.p.push(t>>4&1),this.p.push(t>>3&1),this.p.push(t>>2&1),this.p.push(t>>1&1),this.p.push(1&t)}}read(e){let t=0;for(;e>0;)t<<=1,t+=this.p[this.m++],e--;return t}readLongTail(e,t){let i=e,n=t;for(;this.p[this.m++];)i+=1<<n,n++;for(;n>0;)n--,this.p[this.m++]&&(i+=1<<n);return i}readPartDuration(){return this.readLongTail(1,3)}readLegacyPartDuration(){return this.readLongTail(1,2)}readPinCount(){return this.readLongTail(1,0)}readPitchInterval(){return this.read(1)?-this.readLongTail(1,3):this.readLongTail(1,3)}}class E{constructor(){this.v=0,this.p=[]}clear(){this.v=0}write(e,t){for(e--;e>=0;)this.p[this.v++]=t>>>e&1,e--}writeLongTail(e,t,i){if(i<e)throw new Error("value out of bounds");i-=e;let n=t;for(;i>=1<<n;)this.p[this.v++]=1,i-=1<<n,n++;for(this.p[this.v++]=0;n>0;)n--,this.p[this.v++]=i>>>n&1}writePartDuration(e){this.writeLongTail(1,3,e)}writePinCount(e){this.writeLongTail(1,0,e)}writePitchInterval(e){e<0?(this.write(1,1),this.writeLongTail(1,3,-e)):(this.write(1,0),this.writeLongTail(1,3,e))}concat(e){for(let t=0;t<e.v;t++)this.p[this.v++]=e.p[t]}encodeBase64(e){for(let t=0;t<this.v;t+=6){const i=this.p[t]<<5|this.p[t+1]<<4|this.p[t+2]<<3|this.p[t+3]<<2|this.p[t+4]<<1|this.p[t+5];e.push(A[i])}return e}lengthBase64(){return Math.ceil(this.v/6)}}function L(e,t,i){return{interval:e,time:t,size:i}}class N{constructor(e,t,i,n,s=!1){this.pitches=[e],this.pins=[L(0,0,n),L(0,i-t,s?0:n)],this.start=t,this.end=i,this.continuesLastPattern=!1}pickMainInterval(){let e=0,t=0;for(let i=1;i<this.pins.length;i++){const n=this.pins[i-1],s=this.pins[i];if(n.interval==s.interval){const i=s.time-n.time;e<i&&(e=i,t=n.interval)}}if(0==e){let e=0;for(let i=0;i<this.pins.length;i++){const n=this.pins[i];e<n.size&&(e=n.size,t=n.interval)}}return t}clone(){const e=new N(-1,this.start,this.end,3);e.pitches=this.pitches.concat(),e.pins=[];for(const t of this.pins)e.pins.push(L(t.interval,t.time,t.size));return e.continuesLastPattern=this.continuesLastPattern,e}getEndPinIndex(e){let t;for(t=1;t<this.pins.length-1&&!(this.pins[t].time+this.start>e);t++);return t}}class V{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,i,n){const s=[];for(const a of this.notes){let r=i.instruments[this.instruments[0]],o=Math.max(0,t.modCount-a.pitches[0]-1),l=e.getVolumeCapForSetting(n,r.modulators[o],r.modFilterTypes[o]);const h=[];for(const i of a.pins){let s=n?Math.round(i.size):Math.round(100*i.size/l);h.push({tick:(i.time+a.start)*t.rhythms[e.rhythm].stepsPerBeat/t.partsPerBeat,pitchBend:i.interval,volume:s,forMod:n})}const u={pitches:a.pitches,points:h};0==a.start&&(u.continuesLastPattern=a.continuesLastPattern),s.push(u)}const a={notes:s};return e.patternInstruments&&(a.instruments=this.instruments.map((e=>e+1))),a}fromJsonObject(e,i,n,s,a,r){if(i.patternInstruments)if(Array.isArray(e.instruments)){const s=e.instruments,a=O(t.instrumentCountMin,i.getMaxInstrumentsPerPatternForChannel(n)+1,s.length);for(let e=0;e<a;e++)this.instruments[e]=O(0,n.instruments.length,(0|s[e])-1);this.instruments.length=a}else this.instruments[0]=O(0,n.instruments.length,(0|e.instrument)-1),this.instruments.length=1;if(e.notes&&e.notes.length>0){const o=Math.min(i.beatsPerBar*t.partsPerBeat*(r?t.modCount:1),e.notes.length>>>0);for(let l=0;l<e.notes.length&&!(l>=o);l++){const o=e.notes[l];if(!(o&&o.pitches&&o.pitches.length>=1&&o.points&&o.points.length>=2))continue;const h=new N(0,0,0,0);h.pitches=[],h.pins=[];for(let e=0;e<o.pitches.length;e++){const i=0|o.pitches[e];if(-1==h.pitches.indexOf(i)&&(h.pitches.push(i),h.pitches.length>=t.maxChordSize))break}if(h.pitches.length<1)continue;let u=0;for(let e=0;e<o.points.length;e++){const a=o.points[e];if(null==a||null==a.tick)continue;const l=null==a.pitchBend?0:0|a.pitchBend,c=Math.round(+a.tick*t.partsPerBeat/s);let p,f=n.instruments[this.instruments[0]],m=Math.max(0,t.modCount-h.pitches[0]-1),d=i.getVolumeCapForSetting(r,f.modulators[m],f.modFilterTypes[m]);p=null==a.volume?d:null==a.forMod?Math.max(0,Math.min(d,Math.round((0|a.volume)*d/100))):(0|a.forMod)>0?Math.round(0|a.volume):Math.max(0,Math.min(d,Math.round((0|a.volume)*d/100))),c>i.beatsPerBar*t.partsPerBeat||(0==h.pins.length&&(h.start=c,u=l),h.pins.push(L(l-u,c-h.start,p)))}if(h.pins.length<2)continue;h.end=h.pins[h.pins.length-1].time+h.start;const c=a?t.drumCount-1:t.maxPitch;let p=c,f=0;for(let e=0;e<h.pitches.length;e++)h.pitches[e]+=u,(h.pitches[e]<0||h.pitches[e]>c)&&(h.pitches.splice(e,1),e--),h.pitches[e]<p&&(p=h.pitches[e]),h.pitches[e]>f&&(f=h.pitches[e]);if(!(h.pitches.length<1)){for(let e=0;e<h.pins.length;e++){const t=h.pins[e];t.interval+p<0&&(t.interval=-p),t.interval+f>c&&(t.interval=c-f),e>=2&&t.interval==h.pins[e-1].interval&&t.interval==h.pins[e-2].interval&&t.size==h.pins[e-1].size&&t.size==h.pins[e-2].size&&(h.pins.splice(e-1,1),e--)}0==h.start?h.continuesLastPattern=!0===o.continuesLastPattern:h.continuesLastPattern=!1,this.notes.push(h)}}}}}class W{constructor(e){this.frequency=6,this.amplitude=0,this.waveform=0,this.pulseWidth=.5,this.reset(e)}reset(e){this.frequency=6,this.amplitude=e<=1?t.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 B{constructor(e){this.spectrum=[],this.hash=-1,this.reset(e)}reset(e){for(let i=0;i<t.spectrumControlPoints;i++)if(e)this.spectrum[i]=Math.round(t.spectrumMax*(1/Math.sqrt(1+i/3)));else{const e=0==i||7==i||11==i||14==i||16==i||18==i||21==i||23==i||i>=25;this.spectrum[i]=e?Math.max(0,Math.round(t.spectrumMax*(1-i/30))):0}this.markCustomWaveDirty()}markCustomWaveDirty(){const e=se.fittingPowerOfTwo(t.spectrumMax+2)-1;let i=0;for(const t of this.spectrum)i=i*e+t>>>0;this.hash=i}}class ${constructor(){this.wave=null,this.g=-1}getCustomWave(e,i){if(this.g==e.hash)return this.wave;this.g=e.hash;const n=t.spectrumNoiseLength;null!=this.wave&&this.wave.length==n+1||(this.wave=new Float32Array(n+1));const s=this.wave;for(let e=0;e<n;e++)s[e]=0;const a=[0,1/7,Math.log2(5/4),3/7,Math.log2(1.5),5/7,6/7];function o(e){return i+Math.floor(e/t.spectrumControlPointsPerOctave)+a[(e+t.spectrumControlPointsPerOctave)%t.spectrumControlPointsPerOctave]}let l=1;for(let i=0;i<t.spectrumControlPoints+1;i++){const a=i<=0?0:e.spectrum[i-1],h=i>=t.spectrumControlPoints?e.spectrum[t.spectrumControlPoints-1]:e.spectrum[i],u=o(i-1);let c=o(i);i>=t.spectrumControlPoints&&(c=14+.25*(c-14)),0==a&&0==h||(l+=.02*r(s,n,u,c,a/t.spectrumMax,h/t.spectrumMax,-.5))}return e.spectrum[t.spectrumControlPoints-1]>0&&(l+=.02*r(s,n,14+.25*(o(t.spectrumControlPoints)-14),14,e.spectrum[t.spectrumControlPoints-1]/t.spectrumMax,0,-.5)),T(s,n),F(s,5/(Math.sqrt(n)*Math.pow(l,.75))),s[n]=s[0],s}}class j{constructor(){this.harmonics=[],this.hash=-1,this.reset()}reset(){for(let e=0;e<t.harmonicsControlPoints;e++)this.harmonics[e]=0;this.harmonics[0]=t.harmonicsMax,this.harmonics[3]=t.harmonicsMax,this.harmonics[6]=t.harmonicsMax,this.markCustomWaveDirty()}markCustomWaveDirty(){const e=se.fittingPowerOfTwo(t.harmonicsMax+2)-1;let i=0;for(const t of this.harmonics)i=i*e+t>>>0;this.hash=i}}class U{constructor(){this.wave=null,this.g=-1}getCustomWave(e,i){if(this.g==e.hash&&this.S==i)return this.wave;this.g=e.hash,this.S=i;const n=7==i?t.harmonicsRenderedForPickedString:t.harmonicsRendered,s=t.harmonicsWavelength,r=a(0,null,null);null!=this.wave&&this.wave.length==s+1||(this.wave=new Float32Array(s+1));const o=this.wave;for(let e=0;e<s;e++)o[e]=0;let l=1;for(let i=0;i<n;i++){const a=i+1;let h=i<t.harmonicsControlPoints?e.harmonics[i]:e.harmonics[t.harmonicsControlPoints-1];i>=t.harmonicsControlPoints&&(h*=1-(i-t.harmonicsControlPoints)/(n-t.harmonicsControlPoints));const u=h/t.harmonicsMax;let c=Math.pow(2,h-t.harmonicsMax+1)*Math.sqrt(u);i<t.harmonicsControlPoints&&(l+=c),c*=Math.pow(a,-.25),c*=r[i+589],o[s-a]=c}T(o,s);const h=1/Math.pow(l,.7);for(let e=0;e<o.length;e++)o[e]*=h;return function(e){let t=0;for(let i=0;i<e.length;i++){const n=e[i];e[i]=t,t+=n}}(o),o[s]=o[0],o}}class Q{constructor(){this.freq=0,this.gain=t.filterGainCenter,this.type=2}set(e,t){this.freq=e,this.gain=t}getHz(){return Q.getHzFromSettingValue(this.freq)}static getHzFromSettingValue(e){return t.filterFreqReferenceHz*Math.pow(2,(e-t.filterFreqReferenceSetting)*t.filterFreqStep)}static getSettingValueFromHz(e){return Math.log2(e/t.filterFreqReferenceHz)/t.filterFreqStep+t.filterFreqReferenceSetting}static getRoundedSettingValueFromHz(e){return Math.max(0,Math.min(t.filterFreqRange-1,Math.round(Q.getSettingValueFromHz(e))))}getLinearGain(e=1){const i=(this.gain-t.filterGainCenter)*t.filterGainStep,n=2==this.type?0:-.5,s=n+(i-n)*e;return Math.pow(2,s)}static getRoundedSettingValueFromLinearGain(e){return Math.max(0,Math.min(t.filterGainRange-1,Math.round(Math.log2(e)/t.filterGainStep+t.filterGainCenter)))}toCoefficients(e,i,n=1,s=1){const a=2*Math.PI*Math.max(t.filterFreqMinHz,Math.min(t.filterFreqMaxHz,n*this.getHz()))/i,r=this.getLinearGain(s);switch(this.type){case 0:e.lowPass2ndOrderButterworth(a,r);break;case 1:e.highPass2ndOrderButterworth(a,r);break;case 2:e.peak2ndOrder(a,r,1);break;default:throw new Error}}getVolumeCompensationMult(){const e=(this.freq-t.filterFreqReferenceSetting)*t.filterFreqStep,i=(this.gain-t.filterGainCenter)*t.filterGainStep;switch(this.type){case 0:const n=Math.pow(2,e)*t.filterFreqReferenceHz/8e3,s=(Math.sqrt(1+4*n)-1)/2,a=Math.log2(s);return Math.pow(.5,.2*Math.max(0,i+1)+Math.min(0,Math.max(-3,.595*a+.35*Math.min(0,i+1))));case 1:return Math.pow(.5,.125*Math.max(0,i+1)+Math.min(0,.3*(-e-Math.log2(t.filterFreqReferenceHz/125))+.2*Math.min(0,i+1)));case 2:const r=e+Math.log2(t.filterFreqReferenceHz/2e3),o=Math.pow(1/(1+Math.pow(r/3,2)),2);return Math.pow(.5,.125*Math.max(0,i)+.1*o*Math.min(0,i));default:throw new Error}}}class K{constructor(){this.controlPoints=[],this.controlPointCount=0,this.reset()}reset(){this.controlPointCount=0}addPoint(e,t,i){let n;this.controlPoints.length<=this.controlPointCount?(n=new Q,this.controlPoints[this.controlPointCount]=n):n=this.controlPoints[this.controlPointCount],this.controlPointCount++,n.type=e,n.set(t,i)}toJsonObject(){const e=[];for(let i=0;i<this.controlPointCount;i++){const n=this.controlPoints[i];e.push({type:t.filterTypeNames[n.type],cutoffHz:Math.round(100*n.getHz())/100,linearGain:Math.round(1e4*n.getLinearGain())/1e4})}return e}fromJsonObject(e){if(this.controlPoints.length=0,e)for(const i of e){const e=new Q;e.type=t.filterTypeNames.indexOf(i.type),-1==e.type&&(e.type=2),null!=i.cutoffHz?e.freq=Q.getRoundedSettingValueFromHz(i.cutoffHz):e.freq=0,null!=i.linearGain?e.gain=Q.getRoundedSettingValueFromLinearGain(i.linearGain):e.gain=t.filterGainCenter,this.controlPoints.push(e)}this.controlPointCount=this.controlPoints.length}static filtersCanMorph(e,t){if(e.controlPointCount!=t.controlPointCount)return!1;for(let i=0;i<e.controlPointCount;i++)if(e.controlPoints[i].type!=t.controlPoints[i].type)return!1;return!0}static lerpFilters(e,t,i){let n=new K;if(null==e)return e;if(null==t)return t;if(i=Math.max(0,Math.min(1,i)),this.filtersCanMorph(e,t)){for(let s=0;s<e.controlPointCount;s++)n.controlPoints[s]=new Q,n.controlPoints[s].type=e.controlPoints[s].type,n.controlPoints[s].freq=e.controlPoints[s].freq+(t.controlPoints[s].freq-e.controlPoints[s].freq)*i,n.controlPoints[s].gain=e.controlPoints[s].gain+(t.controlPoints[s].gain-e.controlPoints[s].gain)*i;return n.controlPointCount=e.controlPointCount,n}return i>=1?t:e}convertLegacySettings(e,t,i){this.reset();const n=2*Math.asin(.475),s=t>1,a=0==t,r=10==e,o=3==i.type||4==i.type||8==i.type||0==i.type,l=48e3,h=8e3*Math.pow(2,.5*(e-10)),u=Math.min(n,2*Math.PI*h/l);if(1==i.type&&!s&&r);else if(a){const e=3.5,t=u*Math.pow(2,e),i=l*(t/(1+t/Math.PI))/(2*Math.PI),n=Q.getRoundedSettingValueFromHz(i),s=Q.getHzFromSettingValue(n),a=2*Math.PI*s/l,r=new I;r.lowPass1stOrderSimplified(u);const h=new z;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=Q.getRoundedSettingValueFromLinearGain(f);this.addPoint(0,n,m)}else{const e=.5/(1-.95*Math.sqrt(Math.max(0,t-1)/6)),i=.5/e,n=u+(u*(u/(2*Math.PI*8e3/l)*Math.pow(i,.9)+1)-u)*i;let a;a=o?l*Math.min(n,u*Math.pow(2,.25))/(2*Math.PI):l*n/(2*Math.PI);const r=Q.getRoundedSettingValueFromHz(a);let h;if(o)h=e;else{const t=new I;t.lowPass2ndOrderSimplified(u,e);const i=new z;i.analyze(t,n),h=i.magnitude()}s||(h=Math.min(h,Math.sqrt(.5)));const c=Q.getRoundedSettingValueFromLinearGain(h);this.addPoint(0,r,c)}this.controlPoints.length=this.controlPointCount}convertLegacySettingsForSynth(e,t,i=!1){this.reset();const n=2*Math.asin(.475),s=0==t&&i,a=48e3,r=8e3*Math.pow(2,.5*(e-10)),o=Math.min(n,2*Math.PI*r/a);if(s){const e=3.5,t=o*Math.pow(2,e),i=a*(t/(1+t/Math.PI))/(2*Math.PI),n=Q.getRoundedSettingValueFromHz(i),s=Q.getHzFromSettingValue(n),r=2*Math.PI*s/a,l=new I;l.lowPass1stOrderSimplified(o);const h=new z;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=Q.getRoundedSettingValueFromLinearGain(p);this.addPoint(0,n,f)}else{const e=.5/(1-.95*Math.sqrt(Math.max(0,t-1)/6)),i=.5/e,n=o+(o*(o/(2*Math.PI*8e3/a)*Math.pow(i,.9)+1)-o)*i;let s;s=a*n/(2*Math.PI);const r=Q.getSettingValueFromHz(s);let l;const h=new I;h.lowPass2ndOrderSimplified(o,e);const u=new z;u.analyze(h,n),l=u.magnitude();const c=Q.getRoundedSettingValueFromLinearGain(l);this.addPoint(0,r,c)}}}class J{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:t.instrumentAutomationTargets[this.target].name,envelope:t.envelopes[this.envelope].name};return t.instrumentAutomationTargets[this.target].maxCount>1&&(e.index=this.index),e}fromJsonObject(e){this.reset();let i=t.instrumentAutomationTargets.dictionary[e.target];null==i&&(i=t.instrumentAutomationTargets.dictionary.noteVolume),this.target=i.index;let n=t.envelopes.dictionary[e.envelope];null==n&&(n=t.envelopes.dictionary.none),this.envelope=n.index,null!=e.index?this.index=O(0,t.instrumentAutomationTargets[this.target].maxCount,0|e.index):this.index=0}}class _{constructor(e,i){if(this.type=0,this.preset=0,this.chipWave=2,this.chipNoise=1,this.eqFilter=new K,this.eqFilterType=!1,this.eqFilterSimpleCut=t.filterSimpleCutRange-1,this.eqFilterSimplePeak=0,this.noteFilter=new K,this.noteFilterType=!1,this.noteFilterSimpleCut=t.filterSimpleCutRange-1,this.noteFilterSimplePeak=0,this.eqSubFilters=[],this.noteSubFilters=[],this.envelopes=[],this.fadeIn=0,this.fadeOut=t.fadeOutNeutral,this.envelopeCount=0,this.transition=t.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.unison=0,this.effects=0,this.chord=1,this.volume=0,this.pan=t.panCenter,this.panDelay=10,this.fastTwoNoteArp=!1,this.arpeggioSpeed=12,this.arpeggioPattern=0,this.strumSpeed=23,this.slideSpeed=21,this.legacyTieOver=!1,this.clicklessTransition=!1,this.continueThruPattern=!1,this.aliases=!1,this.pulseWidth=t.pulseWidthRange,this.stringSustain=10,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.feedbackAmplitude=0,this.LFOtime=0,this.nextLFOtime=0,this.arpTime=0,this.customChipWave=new Float32Array(64),this.customChipWaveIntegral=new Float32Array(65),this.operators=[],this.harmonicsWave=new j,this.drumsetEnvelopes=[],this.drumsetSpectrumWaves=[],this.modChannels=[],this.modInstruments=[],this.modulators=[],this.modFilterTypes=[],this.invalidModulators=[],i)for(let e=0;e<t.modCount;e++)this.modChannels.push(0),this.modInstruments.push(0),this.modulators.push(t.modulators.dictionary.none.index);this.spectrumWave=new B(e);for(let e=0;e<t.operatorCount;e++)this.operators[e]=new W(e);for(let e=0;e<t.drumCount;e++)this.drumsetEnvelopes[e]=t.envelopes.dictionary["twang 2"].index,this.drumsetSpectrumWaves[e]=new B(!0);for(let e=0;e<64;e++)this.customChipWave[e]=24-Math.floor(.75*e);let n=0;for(let e=0;e<this.customChipWave.length;e++)n+=this.customChipWave[e];const s=n/this.customChipWave.length;let a=0,r=0;for(let e=0;e<this.customChipWave.length;e++)a+=r,r=this.customChipWave[e]-s,this.customChipWaveIntegral[e]=a;this.customChipWaveIntegral[64]=0}setTypeAndReset(e,i,n){n&&(e=9),this.type=e,this.preset=e,this.volume=0,this.effects=4,this.chorus=t.chorusRange-1,this.reverb=0,this.echoSustain=Math.floor(.5*(t.echoSustainRange-1)),this.echoDelay=Math.floor(.5*(t.echoDelayRange-1)),this.eqFilter.reset(),this.eqFilterType=!1,this.eqFilterSimpleCut=t.filterSimpleCutRange-1,this.eqFilterSimplePeak=0;for(let e=0;e<t.filterMorphCount;e++)this.eqSubFilters[e]=null,this.noteSubFilters[e]=null;switch(this.noteFilter.reset(),this.noteFilterType=!1,this.noteFilterSimpleCut=t.filterSimpleCutRange-1,this.noteFilterSimplePeak=0,this.distortion=Math.floor(.75*(t.distortionRange-1)),this.bitcrusherFreq=Math.floor(.5*(t.bitcrusherFreqRange-1)),this.bitcrusherQuantization=Math.floor(.5*(t.bitcrusherQuantizationRange-1)),this.pan=t.panCenter,this.panDelay=10,this.pitchShift=t.pitchShiftCenter,this.detune=t.detuneCenter,this.vibrato=0,this.unison=0,this.stringSustain=10,this.clicklessTransition=!1,this.continueThruPattern=!1,this.arpeggioSpeed=12,this.arpeggioPattern=0,this.strumSpeed=23,this.slideSpeed=21,this.legacyTieOver=!1,this.aliases=!1,this.fadeIn=0,this.fadeOut=t.fadeOutNeutral,this.transition=t.transitions.dictionary.normal.index,this.envelopeCount=0,e){case 0:this.chipWave=2,this.chord=t.chords.dictionary.arpeggio.index;break;case 8:this.chipWave=2,this.chord=t.chords.dictionary.arpeggio.index;for(let e=0;e<64;e++)this.customChipWave[e]=24-Math.floor(.75*e);let n=0;for(let e=0;e<this.customChipWave.length;e++)n+=this.customChipWave[e];const s=n/this.customChipWave.length;let a=0,r=0;for(let e=0;e<this.customChipWave.length;e++)a+=r,r=this.customChipWave[e]-s,this.customChipWaveIntegral[e]=a;this.customChipWaveIntegral[64]=0;break;case 1:this.chord=t.chords.dictionary["custom interval"].index,this.algorithm=0,this.feedbackType=0,this.feedbackAmplitude=0;for(let e=0;e<this.operators.length;e++)this.operators[e].reset(e);break;case 2:this.chipNoise=1,this.chord=t.chords.dictionary.arpeggio.index;break;case 3:this.chord=t.chords.dictionary.simultaneous.index,this.spectrumWave.reset(i);break;case 4:this.chord=t.chords.dictionary.simultaneous.index;for(let e=0;e<t.drumCount;e++)this.drumsetEnvelopes[e]=t.envelopes.dictionary["twang 2"].index,null==this.drumsetSpectrumWaves[e]&&(this.drumsetSpectrumWaves[e]=new B(!0)),this.drumsetSpectrumWaves[e].reset(i);break;case 5:this.chord=t.chords.dictionary.simultaneous.index,this.harmonicsWave.reset();break;case 6:this.chord=t.chords.dictionary.arpeggio.index,this.pulseWidth=t.pulseWidthRange;break;case 7:this.chord=t.chords.dictionary.strum.index,this.harmonicsWave.reset();break;case 9:this.transition=0,this.vibrato=0,this.interval=0,this.effects=0,this.chord=0,this.modChannels=[],this.modInstruments=[],this.modulators=[];for(let e=0;e<t.modCount;e++)this.modChannels.push(-2),this.modInstruments.push(0),this.modulators.push(t.modulators.dictionary.none.index),this.invalidModulators[e]=!1,this.modFilterTypes[e]=0;break;default:throw new Error("Unrecognized instrument type: "+e)}this.chord!=t.chords.dictionary.simultaneous.index&&(this.effects=2048|this.effects)}convertLegacySettings(e,i){let n=e.filterCutoff,s=e.filterResonance,a=e.filterEnvelope,r=e.pulseEnvelope,o=e.operatorEnvelopes,l=e.feedbackEnvelope;null==n&&(n=0==this.type?6:10),null==s&&(s=0),null==a&&(a=t.envelopes.dictionary.none),null==r&&(r=t.envelopes.dictionary[6==this.type?"twang 2":"none"]),null==o&&(o=[t.envelopes.dictionary[1==this.type?"note size":"none"],t.envelopes.dictionary.none,t.envelopes.dictionary.none,t.envelopes.dictionary.none]),null==l&&(l=t.envelopes.dictionary.none);10==n&&2==a.type&&(a=t.envelopes.dictionary.none);const h=t.algorithms[this.algorithm].carrierCount;let u=!0,c=!0,p=0==a.type||0==r.type;if(1==this.type){p=p||0==l.type;for(let e=0;e<o.length;e++)e<h?0!=o[e].type?c=!1:u=!1:p=p||0==o[e].type}this.envelopeCount=0,1==this.type&&(c&&p?this.addEnvelope(t.instrumentAutomationTargets.dictionary.noteVolume.index,0,t.envelopes.dictionary["note size"].index):u&&!p&&this.addEnvelope(t.instrumentAutomationTargets.dictionary.none.index,0,t.envelopes.dictionary["note size"].index)),1==a.type?(this.noteFilter.reset(),this.noteFilterType=!1,this.eqFilter.convertLegacySettings(n,s,a),this.effects&=-33,(i||this.eqFilterType)&&(this.eqFilterType=!0,this.eqFilterSimpleCut=n,this.eqFilterSimplePeak=s)):(this.eqFilter.reset(),this.eqFilterType=!1,this.noteFilterType=!1,this.noteFilter.convertLegacySettings(n,s,a),this.effects|=32,this.addEnvelope(t.instrumentAutomationTargets.dictionary.noteFilterAllFreqs.index,0,a.index),(i||this.noteFilterType)&&(this.noteFilterType=!0,this.noteFilterSimpleCut=n,this.noteFilterSimplePeak=s)),1!=r.type&&this.addEnvelope(t.instrumentAutomationTargets.dictionary.pulseWidth.index,0,r.index);for(let e=0;e<o.length;e++)e<h&&c||1!=o[e].type&&this.addEnvelope(t.instrumentAutomationTargets.dictionary.operatorAmplitude.index,e,o[e].index);1!=l.type&&this.addEnvelope(t.instrumentAutomationTargets.dictionary.feedbackAmplitude.index,0,l.index)}toJsonObject(){const e={type:t.instrumentTypeNames[this.type],volume:this.volume,eqFilter:this.eqFilter.toJsonObject(),eqFilterType:this.eqFilterType,eqSimpleCut:this.eqFilterSimpleCut,eqSimplePeak:this.eqFilterSimplePeak};this.preset!=this.type&&(e.preset=this.preset);for(let i=0;i<t.filterMorphCount;i++)null!=this.eqSubFilters[i]&&(e["eqSubFilters"+i]=this.eqSubFilters[i].toJsonObject());const i=[];for(const e of t.effectOrder)this.effects&1<<e&&i.push(t.effectNames[e]);if(e.effects=i,c(this.effects)&&(e.transition=t.transitions[this.transition].name,e.slideSpeed=this.slideSpeed,e.clicklessTransition=this.clicklessTransition,e.continueThruPattern=this.continueThruPattern),p(this.effects)&&(e.chord=this.getChord().name,e.fastTwoNoteArp=this.fastTwoNoteArp,e.arpeggioSpeed=this.arpeggioSpeed,e.arpeggioPattern=this.arpeggioPattern,e.strumSpeed=this.strumSpeed),f(this.effects)&&(e.pitchShiftSemitones=this.pitchShift),m(this.effects)&&(e.detuneCents=se.detuneToCents(this.detune)),d(this.effects)&&(-1==this.vibrato&&(this.vibrato=5),5!=this.vibrato?e.vibrato=t.vibratos[this.vibrato].name:e.vibrato="custom",e.vibratoDepth=this.vibratoDepth,e.vibratoDelay=this.vibratoDelay,e.vibratoSpeed=this.vibratoSpeed,e.vibratoType=this.vibratoType),y(this.effects)){e.noteFilterType=this.noteFilterType,e.noteSimpleCut=this.noteFilterSimpleCut,e.noteSimplePeak=this.noteFilterSimplePeak,e.noteFilter=this.noteFilter.toJsonObject();for(let i=0;i<t.filterMorphCount;i++)null!=this.noteSubFilters[i]&&(e["noteSubFilters"+i]=this.noteSubFilters[i].toJsonObject())}if(v(this.effects)&&(e.distortion=Math.round(100*this.distortion/(t.distortionRange-1)),e.aliases=this.aliases),g(this.effects)&&(e.bitcrusherOctave=(t.bitcrusherFreqRange-1-this.bitcrusherFreq)*t.bitcrusherOctaveStep,e.bitcrusherQuantization=Math.round(100*this.bitcrusherQuantization/(t.bitcrusherQuantizationRange-1))),b(this.effects)&&(e.pan=Math.round(100*(this.pan-t.panCenter)/t.panCenter),e.panDelay=this.panDelay),S(this.effects)&&(e.chorus=Math.round(100*this.chorus/(t.chorusRange-1))),w(this.effects)&&(e.echoSustain=Math.round(100*this.echoSustain/(t.echoSustainRange-1)),e.echoDelayBeats=Math.round(1e3*(this.echoDelay+1)*t.echoDelayStepTicks/(t.ticksPerPart*t.partsPerBeat))/1e3),k(this.effects)&&(e.reverb=Math.round(100*this.reverb/(t.reverbRange-1))),4!=this.type&&(e.fadeInSeconds=Math.round(1e4*se.fadeInSettingToSeconds(this.fadeIn))/1e4,e.fadeOutTicks=se.fadeOutSettingToTicks(this.fadeOut)),5==this.type||7==this.type){e.harmonics=[];for(let i=0;i<t.harmonicsControlPoints;i++)e.harmonics[i]=Math.round(100*this.harmonicsWave.harmonics[i]/t.harmonicsMax)}if(2==this.type)e.wave=t.chipNoises[this.chipNoise].name;else if(3==this.type){e.spectrum=[];for(let i=0;i<t.spectrumControlPoints;i++)e.spectrum[i]=Math.round(100*this.spectrumWave.spectrum[i]/t.spectrumMax)}else if(4==this.type){e.drums=[];for(let i=0;i<t.drumCount;i++){const n=[];for(let e=0;e<t.spectrumControlPoints;e++)n[e]=Math.round(100*this.drumsetSpectrumWaves[i].spectrum[e]/t.spectrumMax);e.drums[i]={filterEnvelope:this.getDrumsetEnvelope(i).name,spectrum:n}}}else if(0==this.type)e.wave=t.chipWaves[this.chipWave].name,e.unison=t.unisons[this.unison].name;else if(6==this.type)e.pulseWidth=this.pulseWidth;else if(7==this.type)e.unison=t.unisons[this.unison].name,e.stringSustain=Math.round(100*this.stringSustain/(t.stringSustainRange-1));else if(5==this.type)e.unison=t.unisons[this.unison].name;else if(1==this.type){const i=[];for(const e of this.operators)i.push({frequency:t.operatorFrequencies[e.frequency].name,amplitude:e.amplitude,waveform:t.operatorWaves[e.waveform].name,pulseWidth:e.pulseWidth});e.algorithm=t.algorithms[this.algorithm].name,e.feedbackType=t.feedbacks[this.feedbackType].name,e.feedbackAmplitude=this.feedbackAmplitude,e.operators=i}else if(8==this.type){e.wave=t.chipWaves[this.chipWave].name,e.unison=t.unisons[this.unison].name,e.customChipWave=new Float64Array(64),e.customChipWaveIntegral=new Float64Array(65);for(let t=0;t<this.customChipWave.length;t++)e.customChipWave[t]=this.customChipWave[t]}else{if(9!=this.type)throw new Error("Unrecognized instrument type");e.modChannels=[],e.modInstruments=[],e.modSettings=[],e.modStatuses=[];for(let i=0;i<t.modCount;i++)e.modChannels[i]=this.modChannels[i],e.modInstruments[i]=this.modInstruments[i],e.modSettings[i]=this.modulators[i]}const n=[];for(let e=0;e<this.envelopeCount;e++)n.push(this.envelopes[e].toJsonObject());return e.envelopes=n,e}fromJsonObject(e,i,n,s,a,r=0){null==e&&(e={});let o=t.instrumentTypeNames.indexOf(e.type);if(-1==o&&(o=n?9:i?2:0),this.setTypeAndReset(o,i,n),null!=e.preset&&(this.preset=e.preset>>>0),null!=e.volume?this.volume=O(-t.volumeRange/2,t.volumeRange/2+1,0|e.volume):this.volume=0,Array.isArray(e.effects)){let i=0;for(let n=0;n<e.effects.length;n++)i|=1<<t.effectNames.indexOf(e.effects[n]);this.effects=4095&i}else{const t=["none","reverb","chorus","chorus & reverb"];this.effects=t.indexOf(e.effects),-1==this.effects&&(this.effects=2==this.type?0:1)}this.transition=t.transitions.dictionary.normal.index;const l=e.transition||e.envelope;if(null!=l){let i=t.transitions.dictionary[l];if(null==e.fadeInSeconds||null==e.fadeOutTicks){const e={binary:{transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1},seamless:{transition:"interrupt",fadeInSeconds:0,fadeOutTicks:-1},sudden:{transition:"normal",fadeInSeconds:0,fadeOutTicks:-3},hard:{transition:"normal",fadeInSeconds:0,fadeOutTicks:-3},smooth:{transition:"normal",fadeInSeconds:.025,fadeOutTicks:-3},soft:{transition:"normal",fadeInSeconds:.025,fadeOutTicks:-3},slide:{transition:"slide in pattern",fadeInSeconds:.025,fadeOutTicks:-3},"cross fade":{transition:"normal",fadeInSeconds:.04,fadeOutTicks:6},"hard fade":{transition:"normal",fadeInSeconds:0,fadeOutTicks:48},"medium fade":{transition:"normal",fadeInSeconds:.0125,fadeOutTicks:72},"soft fade":{transition:"normal",fadeInSeconds:.06,fadeOutTicks:96}}[l];null!=e&&(i=t.transitions.dictionary[e.transition],this.fadeIn=se.secondsToFadeInSetting(e.fadeInSeconds),this.fadeOut=se.ticksToFadeOutSetting(e.fadeOutTicks))}null!=i&&(this.transition=i.index),this.transition!=t.transitions.dictionary.normal.index&&(this.effects=1024|this.effects)}null!=e.fadeInSeconds&&(this.fadeIn=se.secondsToFadeInSetting(+e.fadeInSeconds)),null!=e.fadeOutTicks&&(this.fadeOut=se.ticksToFadeOutSetting(+e.fadeOutTicks));{const i=e.chord,n={harmony:"simultaneous"},s=t.chords.dictionary[n[i]]||t.chords.dictionary[i];null!=s?this.chord=s.index:2==this.type?this.chord=t.chords.dictionary.arpeggio.index:7==this.type?this.chord=t.chords.dictionary.strum.index:0==this.type?this.chord=t.chords.dictionary.arpeggio.index:1==this.type?this.chord=t.chords.dictionary["custom interval"].index:this.chord=t.chords.dictionary.simultaneous.index}this.unison=t.unisons.dictionary.none.index;const h=e.unison||e.interval||e.chorus;if(null!=h){const e={union:"none",fifths:"fifth",octaves:"octave"},i=t.unisons.dictionary[e[h]]||t.unisons.dictionary[h];null!=i&&(this.unison=i.index)}"custom harmony"==e.chorus&&(this.unison=t.unisons.dictionary.hum.index,this.chord=t.chords.dictionary["custom interval"].index),this.chord==t.chords.dictionary.simultaneous.index||Array.isArray(e.effects)||(this.effects=2048|this.effects),null!=e.pitchShiftSemitones&&(this.pitchShift=O(0,t.pitchShiftRange,Math.round(+e.pitchShiftSemitones))),null!=e.detuneCents&&(this.detune=O(t.detuneMin,t.detuneMax+1,Math.round(se.centsToDetune(+e.detuneCents)))),this.vibrato=t.vibratos.dictionary.none.index;const u=e.vibrato||e.effect;if(null!=u){const i={"vibrato light":"light","vibrato delayed":"delayed","vibrato heavy":"heavy"},n=t.vibratos.dictionary[i[h]]||t.vibratos.dictionary[u];null!=n?this.vibrato=n.index:"custom"==u&&(this.vibrato=t.vibratos.length),this.vibrato==t.vibratos.length?(this.vibratoDepth=e.vibratoDepth,this.vibratoSpeed=e.vibratoSpeed,this.vibratoDelay=e.vibratoDelay,this.vibratoType=e.vibratoType):(this.vibratoDepth=t.vibratos[this.vibrato].amplitude,this.vibratoDelay=t.vibratos[this.vibrato].delayTicks/2,this.vibratoSpeed=10,this.vibratoType=t.vibratos[this.vibrato].type),n!=t.vibratos.dictionary.none&&(this.effects=512|this.effects)}if(null!=e.pan?(this.pan=O(0,t.panMax+1,Math.round(t.panCenter+(0|e.pan)*t.panCenter/100)),this.pan!=t.panCenter&&(this.effects=4|this.effects)):(this.pan=t.panCenter,this.effects=4|this.effects),null!=e.panDelay?this.panDelay=0|e.panDelay:this.panDelay=10,null!=e.detune?this.detune=O(t.detuneMin,t.detuneMax+1,0|e.detune):null==e.detuneCents&&(this.detune=t.detuneCenter),null!=e.distortion&&(this.distortion=O(0,t.distortionRange,Math.round((t.distortionRange-1)*(0|e.distortion)/100))),null!=e.bitcrusherOctave&&(this.bitcrusherFreq=t.bitcrusherFreqRange-1-+e.bitcrusherOctave/t.bitcrusherOctaveStep),null!=e.bitcrusherQuantization&&(this.bitcrusherQuantization=O(0,t.bitcrusherQuantizationRange,Math.round((t.bitcrusherQuantizationRange-1)*(0|e.bitcrusherQuantization)/100))),null!=e.echoSustain&&(this.echoSustain=O(0,t.echoSustainRange,Math.round((t.echoSustainRange-1)*(0|e.echoSustain)/100))),null!=e.echoDelayBeats&&(this.echoDelay=O(0,t.echoDelayRange,Math.round(+e.echoDelayBeats*(t.ticksPerPart*t.partsPerBeat)/t.echoDelayStepTicks-1))),isNaN(e.chorus)||(this.chorus=O(0,t.chorusRange,Math.round((t.chorusRange-1)*(0|e.chorus)/100))),null!=e.reverb?this.reverb=O(0,t.reverbRange,Math.round((t.reverbRange-1)*(0|e.reverb)/100)):this.reverb=r,null!=e.pulseWidth?this.pulseWidth=O(1,t.pulseWidthRange+1,Math.round(e.pulseWidth)):this.pulseWidth=t.pulseWidthRange,null!=e.harmonics){for(let i=0;i<t.harmonicsControlPoints;i++)this.harmonicsWave.harmonics[i]=Math.max(0,Math.min(t.harmonicsMax,Math.round(t.harmonicsMax*+e.harmonics[i]/100)));this.harmonicsWave.markCustomWaveDirty()}else this.harmonicsWave.reset();if(null!=e.spectrum)for(let i=0;i<t.spectrumControlPoints;i++)this.spectrumWave.spectrum[i]=Math.max(0,Math.min(t.spectrumMax,Math.round(t.spectrumMax*+e.spectrum[i]/100)));else this.spectrumWave.reset(i);null!=e.stringSustain?this.stringSustain=O(0,t.stringSustainRange,Math.round((t.stringSustainRange-1)*(0|e.stringSustain)/100)):this.stringSustain=10,2==this.type&&(this.chipNoise=t.chipNoises.findIndex((t=>t.name==e.wave)),-1==this.chipNoise&&(this.chipNoise=1));const c={custom:"note size",steady:"none","pluck 1":"twang 1","pluck 2":"twang 2","pluck 3":"twang 3"},p=e=>null!=c[e]?t.envelopes.dictionary[c[e]]:t.envelopes.dictionary[e];if(4==this.type&&null!=e.drums)for(let i=0;i<t.drumCount;i++){const n=e.drums[i];if(null!=n){if(this.drumsetEnvelopes[i]=t.envelopes.dictionary["twang 2"].index,null!=n.filterEnvelope){const e=p(n.filterEnvelope);null!=e&&(this.drumsetEnvelopes[i]=e.index)}if(null!=n.spectrum)for(let e=0;e<t.spectrumControlPoints;e++)this.drumsetSpectrumWaves[i].spectrum[e]=Math.max(0,Math.min(t.spectrumMax,Math.round(t.spectrumMax*+n.spectrum[e]/100)))}}if(0==this.type){const i={triangle:1,square:2,"pulse wide":3,"pulse narrow":5,sawtooth:11,"double saw":12,"double pulse":13,spiky:14,plateau:0};this.chipWave=null!=i[e.wave]?i[e.wave]:t.chipWaves.findIndex((t=>t.name==e.wave)),-1==this.chipWave&&(this.chipWave=1)}if(1==this.type){this.algorithm=t.algorithms.findIndex((t=>t.name==e.algorithm)),-1==this.algorithm&&(this.algorithm=0),this.feedbackType=t.feedbacks.findIndex((t=>t.name==e.feedbackType)),-1==this.feedbackType&&(this.feedbackType=0),null!=e.feedbackAmplitude?this.feedbackAmplitude=O(0,t.operatorAmplitudeMax+1,0|e.feedbackAmplitude):this.feedbackAmplitude=0;for(let i=0;i<t.operatorCount;i++){const n=this.operators[i];let s;null!=e.operators&&(s=e.operators[i]),null==s&&(s={}),n.frequency=t.operatorFrequencies.findIndex((e=>e.name==s.frequency)),-1==n.frequency&&(n.frequency=0),null!=s.amplitude?n.amplitude=O(0,t.operatorAmplitudeMax+1,0|s.amplitude):n.amplitude=0,null!=s.waveform?(n.waveform=t.operatorWaves.findIndex((e=>e.name==s.waveform)),-1==n.waveform&&("square"==s.waveform?(n.waveform=t.operatorWaves.dictionary["pulse width"].index,n.pulseWidth=5):n.waveform=0)):n.waveform=0,null!=s.pulseWidth?n.pulseWidth=0|s.pulseWidth:n.pulseWidth=5}}else if(8==this.type){if(e.customChipWave){for(let t=0;t<64;t++)this.customChipWave[t]=e.customChipWave[t];let t=0;for(let e=0;e<this.customChipWave.length;e++)t+=this.customChipWave[e];const i=t/this.customChipWave.length;let n=0,s=0;for(let e=0;e<this.customChipWave.length;e++)n+=s,s=this.customChipWave[e]-i,this.customChipWaveIntegral[e]=n;this.customChipWaveIntegral[64]=0}}else if(9==this.type&&null!=e.modChannels)for(let i=0;i<t.modCount;i++)this.modChannels[i]=e.modChannels[i],this.modInstruments[i]=e.modInstruments[i],this.modulators[i]=e.modSettings[i];if(9!=this.type){this.chord==t.chords.dictionary.arpeggio.index&&null!=e.arpeggioSpeed?this.arpeggioSpeed=e.arpeggioSpeed:this.arpeggioSpeed=s?9:12,null!=e.fastTwoNoteArp?this.fastTwoNoteArp=e.fastTwoNoteArp:this.fastTwoNoteArp=a,this.chord==t.chords.dictionary.arpeggio.index&&null!=e.arpeggioPattern?this.arpeggioPattern=e.arpeggioPattern:this.arpeggioPattern=1,null!=e.strumSpeed?this.strumSpeed=e.strumSpeed:this.strumSpeed=23,null!=e.slideSpeed?this.slideSpeed=e.slideSpeed:this.slideSpeed=21,null!=e.clicklessTransition?this.clicklessTransition=e.clicklessTransition:this.clicklessTransition=!1,null!=e.continueThruPattern?this.continueThruPattern=e.continueThruPattern:this.continueThruPattern=!1,null!=e.aliases?this.aliases=e.aliases:this.aliases=!1,null!=e.noteFilterType&&(this.noteFilterType=e.noteFilterType),null!=e.noteSimpleCut&&(this.noteFilterSimpleCut=e.noteSimpleCut),null!=e.noteSimplePeak&&(this.noteFilterSimplePeak=e.noteSimplePeak),null!=e.noteFilter?this.noteFilter.fromJsonObject(e.noteFilter):this.noteFilter.reset();for(let i=0;i<t.filterMorphCount;i++)Array.isArray(e["noteSubFilters"+i])&&(this.noteSubFilters[i]=new K,this.noteSubFilters[i].fromJsonObject(e["noteSubFilters"+i]));if(null!=e.eqFilterType&&(this.eqFilterType=e.eqFilterType),null!=e.eqSimpleCut&&(this.eqFilterSimpleCut=e.eqSimpleCut),null!=e.eqSimplePeak&&(this.eqFilterSimplePeak=e.eqSimplePeak),Array.isArray(e.eqFilter))this.eqFilter.fromJsonObject(e.eqFilter);else{this.eqFilter.reset();const i={},n=8e3,s=11,a=8;if(null!=e.filterCutoffHz?i.filterCutoff=O(0,s,Math.round(s-1+2*Math.log((0|e.filterCutoffHz)/n)/Math.LN2)):i.filterCutoff=0==this.type?6:10,null!=e.filterResonance?i.filterResonance=O(0,a,Math.round((a-1)*(0|e.filterResonance)/100)):i.filterResonance=0,i.filterEnvelope=p(e.filterEnvelope),i.pulseEnvelope=p(e.pulseEnvelope),i.feedbackEnvelope=p(e.feedbackEnvelope),Array.isArray(e.operators)){i.operatorEnvelopes=[];for(let n=0;n<t.operatorCount;n++){let s;null!=e.operators[n]&&(s=p(e.operators[n].envelope)),i.operatorEnvelopes[n]=null!=s?s:t.envelopes.dictionary.none}}if(null!=e.filter){const t=[10,6,3,0,8,5,2],n=["none","none","none","none","decay 1","decay 2","decay 3"],s=["none","bright","medium","soft","decay bright","decay medium","decay soft"],a={"sustain sharp":1,"sustain medium":2,"sustain soft":3,"decay sharp":4};let r=null!=a[e.filter]?a[e.filter]:s.indexOf(e.filter);-1==r&&(r=0),i.filterCutoff=t[r],i.filterEnvelope=p(n[r]),i.filterResonance=0}this.convertLegacySettings(i,!0)}for(let i=0;i<t.filterMorphCount;i++)Array.isArray(e["eqSubFilters"+i])&&(this.eqSubFilters[i]=new K,this.eqSubFilters[i].fromJsonObject(e["eqSubFilters"+i]));if(Array.isArray(e.envelopes)){const i=e.envelopes;for(let e=0;e<i.length&&!(this.envelopeCount>=t.maxEnvelopeCount);e++){const t=new J;t.fromJsonObject(i[e]),this.addEnvelope(t.target,t.index,t.envelope)}}}}static frequencyFromPitch(e){return 440*Math.pow(2,(e-69)/12)}addEnvelope(e,i,n){let s=!1;if(this.supportsEnvelopeTarget(e,i)||(s=!0),this.envelopeCount>=t.maxEnvelopeCount)throw new Error;for(;this.envelopes.length<=this.envelopeCount;)this.envelopes[this.envelopes.length]=new J;const a=this.envelopes[this.envelopeCount];a.target=s?t.instrumentAutomationTargets.dictionary.none.index:e,a.index=s?0:i,a.envelope=n,this.envelopeCount++}supportsEnvelopeTarget(e,i){const n=t.instrumentAutomationTargets[e];if(i>=n.maxCount)return!1;if(null!=n.compatibleInstruments&&-1==n.compatibleInstruments.indexOf(this.type))return!1;if(null!=n.effect&&0==(this.effects&1<<n.effect))return!1;if(n.isFilter){let e=this.noteFilter.controlPointCount;if(this.noteFilterType&&(e=1),i>=e)return!1}return!0}clearInvalidEnvelopeTargets(){for(let e=0;e<this.envelopeCount;e++){const i=this.envelopes[e].target,n=this.envelopes[e].index;this.supportsEnvelopeTarget(i,n)||(this.envelopes[e].target=t.instrumentAutomationTargets.dictionary.none.index,this.envelopes[e].index=0)}}getTransition(){return c(this.effects)?t.transitions[this.transition]:9==this.type?t.transitions.dictionary.interrupt:t.transitions.dictionary.normal}getFadeInSeconds(){return 4==this.type?0:se.fadeInSettingToSeconds(this.fadeIn)}getFadeOutTicks(){return 4==this.type?t.drumsetFadeOutTicks:se.fadeOutSettingToTicks(this.fadeOut)}getChord(){return p(this.effects)?t.chords[this.chord]:t.chords.dictionary.simultaneous}getDrumsetEnvelope(e){if(4!=this.type)throw new Error("Can't getDrumsetEnvelope() for non-drumset.");return t.envelopes[this.drumsetEnvelopes[e]]}}class Y{constructor(){this.octave=0,this.instruments=[],this.patterns=[],this.bars=[],this.muted=!1,this.name=""}}class X{constructor(e){this.channels=[],this.limitDecay=4,this.limitRise=4e3,this.compressionThreshold=1,this.limitThreshold=1,this.compressionRatio=1,this.limitRatio=1,this.masterGain=1,this.inVolumeCap=0,this.outVolumeCap=0,this.getNewNoteVolume=(e,i,n,s)=>{if(e&&null!=i&&null!=n&&null!=s){s=t.modCount-s-1;let e=t.modulators[this.channels[i].instruments[n].modulators[s]].newNoteVol,a=t.modulators.dictionary.tempo.index;return this.channels[i].instruments[n].modulators[s]==a&&(e=this.tempo-t.modulators[a].convertRealFactor),null!=e?e:6}return 6},this.getVolumeCap=(e,i,n,s)=>{if(e&&null!=i&&null!=n&&null!=s){s=t.modCount-s-1;let e=this.channels[i].instruments[n],a=t.modulators[e.modulators[s]],r=a.maxRawVol;return null!=r?("eq filter"!=a.name&&"note filter"!=a.name||(r=t.filterMorphCount-1,e.modFilterTypes[s]>0&&e.modFilterTypes[s]%2?r=t.filterFreqRange:e.modFilterTypes[s]>0&&(r=t.filterGainRange)),r):6}return 6},this.getVolumeCapForSetting=(e,i,n)=>{if(e){let e=t.modulators[i].maxRawVol;return null!=e?(null==n||"eq filter"!=t.modulators[i].name&&"note filter"!=t.modulators[i].name||(e=t.filterMorphCount-1,n>0&&n%2?e=t.filterFreqRange:n>0&&(e=t.filterGainRange)),e):t.noteSizeMax}return t.noteSizeMax},null!=e?this.fromBase64String(e):this.initToDefault(!0)}getChannelCount(){return this.pitchChannelCount+this.noiseChannelCount+this.modChannelCount}getMaxInstrumentsPerChannel(){return Math.max(this.layeredInstruments?t.layeredInstrumentCountMax:t.instrumentCountMin,this.patternInstruments?t.patternInstrumentCountMax:t.instrumentCountMin)}getMaxInstrumentsPerPattern(e){return this.getMaxInstrumentsPerPatternForChannel(this.channels[e])}getMaxInstrumentsPerPatternForChannel(e){return this.layeredInstruments?Math.min(t.layeredInstrumentCountMax,e.instruments.length):1}getChannelIsNoise(e){return e>=this.pitchChannelCount&&e<this.pitchChannelCount+this.noiseChannelCount}getChannelIsMod(e){return e>=this.pitchChannelCount+this.noiseChannelCount}initToDefault(e=!0){if(this.scale=0,this.key=0,this.loopStart=0,this.loopLength=8,this.tempo=150,this.reverb=0,this.beatsPerBar=8,this.barCount=16,this.patternsPerChannel=32,this.rhythm=3,this.layeredInstruments=!1,this.patternInstruments=!1,this.title="Warning! Songs made in",this.subtitle="this fork may be corrupted!",document.title=M.versionDisplayName,e){this.pitchChannelCount=4,this.noiseChannelCount=2,this.modChannelCount=1;for(let e=0;e<this.getChannelCount();e++){const i=e>=this.pitchChannelCount&&e<this.pitchChannelCount+this.noiseChannelCount,n=e>=this.pitchChannelCount+this.noiseChannelCount;this.channels.length<=e&&(this.channels[e]=new Y);const s=this.channels[e];s.octave=Math.max(3-e,0);for(let e=0;e<this.patternsPerChannel;e++)s.patterns.length<=e?s.patterns[e]=new V:s.patterns[e].reset();s.patterns.length=this.patternsPerChannel;for(let e=0;e<t.instrumentCountMin;e++)s.instruments.length<=e&&(s.instruments[e]=new _(i,n)),s.instruments[e].setTypeAndReset(n?9:i?2:0,i,n);s.instruments.length=t.instrumentCountMin;for(let e=0;e<this.barCount;e++)s.bars[e]=e<4?1:0;s.bars.length=this.barCount}this.channels.length=this.getChannelCount()}}toBase64String(){let e,i=[];i.push(X.k),i.push(A[X.M]),i.push(78);var n=encodeURIComponent(this.title);i.push(A[n.length>>6],A[63&n.length]);for(let e=0;e<n.length;e++)i.push(n.charCodeAt(e));i.push(75);var s=encodeURIComponent(this.subtitle);i.push(A[s.length>>6],A[63&s.length]);for(let e=0;e<s.length;e++)i.push(s.charCodeAt(e));i.push(110,A[this.pitchChannelCount],A[this.noiseChannelCount],A[this.modChannelCount]),i.push(115,A[this.scale]),i.push(107,A[this.key]),i.push(108,A[this.loopStart>>6],A[63&this.loopStart]),i.push(101,A[this.loopLength-1>>6],A[this.loopLength-1&63]),i.push(116,A[this.tempo>>6],A[63&this.tempo]),i.push(97,A[this.beatsPerBar-1]),i.push(103,A[this.barCount-1>>6],A[this.barCount-1&63]),i.push(106,A[this.patternsPerChannel-1>>6],A[this.patternsPerChannel-1&63]),i.push(114,A[this.rhythm]),i.push(79),1!=this.compressionRatio||1!=this.limitRatio||4e3!=this.limitRise||4!=this.limitDecay||1!=this.limitThreshold||1!=this.compressionThreshold||1!=this.masterGain?(i.push(A[Math.round(this.compressionRatio<1?10*this.compressionRatio:10+60*(this.compressionRatio-1))]),i.push(A[Math.round(this.limitRatio<1?10*this.limitRatio:9+this.limitRatio)]),i.push(A[this.limitDecay]),i.push(A[Math.round((this.limitRise-2e3)/250)]),i.push(A[Math.round(20*this.compressionThreshold)]),i.push(A[Math.round(20*this.limitThreshold)]),i.push(A[Math.round(50*this.masterGain)>>6],A[63&Math.round(50*this.masterGain)])):i.push(A[63]),i.push(85);for(let e=0;e<this.getChannelCount();e++){var a=encodeURIComponent(this.channels[e].name);i.push(A[a.length>>6],A[63&a.length]);for(let e=0;e<a.length;e++)i.push(a.charCodeAt(e))}if(i.push(105,A[this.layeredInstruments<<1|this.patternInstruments]),this.layeredInstruments||this.patternInstruments)for(let e=0;e<this.getChannelCount();e++)i.push(A[this.channels[e].instruments.length-t.instrumentCountMin]);i.push(111);for(let e=0;e<this.pitchChannelCount;e++)i.push(A[this.channels[e].octave]);for(let e=0;e<this.getChannelCount();e++)for(let n=0;n<this.channels[e].instruments.length;n++){const s=this.channels[e].instruments[n];if(i.push(84,A[s.type]),i.push(118,A[s.volume+t.volumeRange/2>>6],A[s.volume+t.volumeRange/2&63]),i.push(117,A[s.preset>>6],A[63&s.preset]),i.push(102),i.push(A[+s.eqFilterType]),s.eqFilterType)i.push(A[s.eqFilterSimpleCut]),i.push(A[s.eqFilterSimplePeak]);else{if(null==s.eqFilter)i.push(A[0]),console.log("Null EQ filter settings detected in toBase64String for channelIndex "+e+", instrumentIndex "+n);else{i.push(A[s.eqFilter.controlPointCount]);for(let e=0;e<s.eqFilter.controlPointCount;e++){const t=s.eqFilter.controlPoints[e];i.push(A[t.type],A[Math.round(t.freq)],A[Math.round(t.gain)])}}let a=0;for(let e=0;e<t.filterMorphCount-1;e++)a|=+(null!=s.eqSubFilters[e+1])<<e;i.push(A[a>>6],A[63&a]);for(let e=0;e<t.filterMorphCount-1;e++)if(a&1<<e){i.push(A[s.eqSubFilters[e+1].controlPointCount]);for(let t=0;t<s.eqSubFilters[e+1].controlPointCount;t++){const n=s.eqSubFilters[e+1].controlPoints[t];i.push(A[n.type],A[Math.round(n.freq)],A[Math.round(n.gain)])}}}if(i.push(113,A[s.effects>>6],A[63&s.effects]),y(s.effects))if(i.push(A[+s.noteFilterType]),s.noteFilterType)i.push(A[s.noteFilterSimpleCut]),i.push(A[s.noteFilterSimplePeak]);else{if(null==s.noteFilter)i.push(A[0]),console.log("Null note filter settings detected in toBase64String for channelIndex "+e+", instrumentIndex "+n);else{i.push(A[s.noteFilter.controlPointCount]);for(let e=0;e<s.noteFilter.controlPointCount;e++){const t=s.noteFilter.controlPoints[e];i.push(A[t.type],A[Math.round(t.freq)],A[Math.round(t.gain)])}}let a=0;for(let e=0;e<t.filterMorphCount-1;e++)a|=+(null!=s.noteSubFilters[e+1])<<e;i.push(A[a>>6],A[63&a]);for(let e=0;e<t.filterMorphCount-1;e++)if(a&1<<e){i.push(A[s.noteSubFilters[e+1].controlPointCount]);for(let t=0;t<s.noteSubFilters[e+1].controlPointCount;t++){const n=s.noteSubFilters[e+1].controlPoints[t];i.push(A[n.type],A[Math.round(n.freq)],A[Math.round(n.gain)])}}}if(c(s.effects)&&(i.push(A[s.transition]),t.transitions[s.transition].slides&&i.push(A[s.slideSpeed])),p(s.effects)&&(i.push(A[s.chord]),s.chord==t.chords.dictionary.arpeggio.index?(i.push(A[s.arpeggioSpeed]),i.push(A[+s.fastTwoNoteArp]),i.push(A[+s.arpeggioPattern])):t.chords[s.chord].strumParts>0&&i.push(A[s.strumSpeed])),f(s.effects)&&i.push(A[s.pitchShift]),m(s.effects)&&i.push(A[s.detune-t.detuneMin>>6],A[s.detune-t.detuneMin&63]),d(s.effects)&&(i.push(A[s.vibrato]),s.vibrato==t.vibratos.length&&(i.push(A[Math.round(25*s.vibratoDepth)]),i.push(A[s.vibratoSpeed]),i.push(A[Math.round(s.vibratoDelay)]),i.push(A[s.vibratoType]))),v(s.effects)&&(i.push(A[s.distortion]),i.push(A[+s.aliases])),g(s.effects)&&i.push(A[s.bitcrusherFreq],A[s.bitcrusherQuantization]),b(s.effects)&&(i.push(A[s.pan>>6],A[63&s.pan]),i.push(A[s.panDelay])),S(s.effects)&&i.push(A[s.chorus]),w(s.effects)&&i.push(A[s.echoSustain],A[s.echoDelay]),k(s.effects)&&i.push(A[s.reverb]),4!=s.type&&(i.push(100,A[s.fadeIn],A[s.fadeOut]),i.push(A[+s.clicklessTransition]),i.push(A[+s.continueThruPattern])),5==s.type||7==s.type){i.push(72);const e=new E;for(let i=0;i<t.harmonicsControlPoints;i++)e.write(t.harmonicsControlPointBits,s.harmonicsWave.harmonics[i]);e.encodeBase64(i)}if(0==s.type)i.push(119,A[s.chipWave]),i.push(104,A[s.unison]);else if(1==s.type){i.push(65,A[s.algorithm]),i.push(70,A[s.feedbackType]),i.push(66,A[s.feedbackAmplitude]),i.push(81);for(let e=0;e<t.operatorCount;e++)i.push(A[s.operators[e].frequency]);i.push(80);for(let e=0;e<t.operatorCount;e++)i.push(A[s.operators[e].amplitude]);i.push(82);for(let e=0;e<t.operatorCount;e++)i.push(A[s.operators[e].waveform]),3==s.operators[e].waveform&&i.push(A[s.operators[e].pulseWidth])}else if(8==s.type){i.push(119,A[s.chipWave]),i.push(104,A[s.unison]),i.push(77);for(let e=0;e<64;e++)i.push(A[s.customChipWave[e]+24])}else if(2==s.type)i.push(119,A[s.chipNoise]);else if(3==s.type){i.push(83);const e=new E;for(let i=0;i<t.spectrumControlPoints;i++)e.write(t.spectrumControlPointBits,s.spectrumWave.spectrum[i]);e.encodeBase64(i)}else if(4==s.type){i.push(122);for(let e=0;e<t.drumCount;e++)i.push(A[s.drumsetEnvelopes[e]]);i.push(83);const e=new E;for(let i=0;i<t.drumCount;i++)for(let n=0;n<t.spectrumControlPoints;n++)e.write(t.spectrumControlPointBits,s.drumsetSpectrumWaves[i].spectrum[n]);e.encodeBase64(i)}else if(5==s.type)i.push(104,A[s.unison]);else if(6==s.type)i.push(87,A[s.pulseWidth]);else if(7==s.type)i.push(104,A[s.unison]),i.push(73,A[s.stringSustain]);else if(9!=s.type)throw new Error("Unknown instrument type.");i.push(69,A[s.envelopeCount]);for(let e=0;e<s.envelopeCount;e++)i.push(A[s.envelopes[e].target]),t.instrumentAutomationTargets[s.envelopes[e].target].maxCount>1&&i.push(A[s.envelopes[e].index]),i.push(A[s.envelopes[e].envelope])}i.push(98),e=new E;let r=0;for(;1<<r<this.patternsPerChannel+1;)r++;for(let t=0;t<this.getChannelCount();t++)for(let i=0;i<this.barCount;i++)e.write(r,this.channels[t].bars[i]);e.encodeBase64(i),i.push(112),e=new E;const o=new E,l=X.getNeededBits(t.noteSizeMax);for(let i=0;i<this.getChannelCount();i++){const n=this.channels[i],s=this.getMaxInstrumentsPerPattern(i),a=this.getChannelIsNoise(i),r=this.getChannelIsMod(i),h=X.getNeededBits(s-t.instrumentCountMin),u=X.getNeededBits(n.instruments.length-1);if(r){const s=X.getNeededBits(this.getMaxInstrumentsPerChannel()+2);for(let a=0;a<n.instruments.length;a++){let n=this.channels[i].instruments[a];for(let i=0;i<t.modCount;i++){const a=n.modChannels[i],r=n.modInstruments[i],o=n.modulators[i],l=n.modFilterTypes[i];let h=t.modulators[o].forSong?2:0;o==t.modulators.dictionary.none.index&&(h=3),e.write(2,h),0!=h&&1!=h||(e.write(8,a),e.write(s,r)),3!=h&&e.write(6,o),"eq filter"!=t.modulators[n.modulators[i]].name&&"note filter"!=t.modulators[n.modulators[i]].name||e.write(6,l)}}}const c=a||r?0:n.octave*t.pitchesPerOctave;let p=a?4:c;const f=r?[0,1,2,3,4,5]:a?[4,6,7,2,3,8,0,10]:[0,7,12,19,24,-5,-12],m=[];for(let e=0;e<f.length;e++)f[e]+=c;for(const i of n.patterns){if(this.patternInstruments){const n=G(t.instrumentCountMin,s,i.instruments.length);e.write(h,n-t.instrumentCountMin);for(let t=0;t<n;t++)e.write(u,i.instruments[t])}if(i.notes.length>0){e.write(1,1);let n=0;for(const t of i.notes){t.start<n&&r&&(e.write(2,0),e.write(1,1),e.writePartDuration(n-t.start)),t.start>n&&(e.write(2,0),r&&e.write(1,0),e.writePartDuration(t.start-n)),o.clear(),1==t.pitches.length?o.write(1,0):(o.write(1,1),o.write(3,t.pitches.length-2)),o.writePinCount(t.pins.length-1),r?o.write(9,t.pins[0].size):o.write(l,t.pins[0].size);let i=0,s=t.pitches[0],a=s;const h=[];for(let e=1;e<t.pins.length;e++){const n=t.pins[e],u=s+n.interval;a!=u?(o.write(1,1),h.push(u),a=u):o.write(1,0),o.writePartDuration(n.time-i),i=n.time,r?o.write(9,n.size):o.write(l,n.size)}const u=String.fromCharCode.apply(null,o.encodeBase64([])),c=m.indexOf(u);-1==c?(e.write(2,1),e.concat(o)):(e.write(1,1),e.writeLongTail(0,0,c),m.splice(c,1)),m.unshift(u),m.length>10&&m.pop();const d=t.pitches.concat(h);for(let i=0;i<d.length;i++){const n=d[i],s=f.indexOf(n);if(-1==s){let t=0,i=p;if(i<n)for(;i!=n;)i++,-1==f.indexOf(i)&&t++;else for(;i!=n;)i--,-1==f.indexOf(i)&&t--;e.write(1,0),e.writePitchInterval(t)}else e.write(1,1),e.write(4,s),f.splice(s,1);f.unshift(n),f.length>16&&f.pop(),p=i==t.pitches.length-1?t.pitches[0]:n}0==t.start&&e.write(1,t.continuesLastPattern?1:0),n=t.end}n<this.beatsPerBar*t.partsPerBeat+ +r&&(e.write(2,0),r&&e.write(1,0),e.writePartDuration(this.beatsPerBar*t.partsPerBeat+ +r-n))}else e.write(1,0)}}let h=e.lengthBase64(),u=[];for(;h>0;)u.unshift(A[63&h]),h>>=6;i.push(A[u.length]),Array.prototype.push.apply(i,u),e.encodeBase64(i);const M=64e3;if(i.length<M)return String.fromCharCode.apply(null,i);{let e="";for(let t=0;t<i.length;t+=M)e+=String.fromCharCode.apply(null,i.slice(t,t+M));return e}}static q(e){return 0==e?e=1:1==e&&(e=0),t.envelopes[O(0,t.envelopes.length,e)]}fromBase64String(e){if(null==e||""==e)return void this.initToDefault(!0);let i=0;for(;e.charCodeAt(i)<=32;)i++;if(35==e.charCodeAt(i)&&i++,123==e.charCodeAt(i))return void this.fromJsonObject(JSON.parse(0==i?e:e.substring(i)));let n,s;106==e.charCodeAt(i)?(n=!1,s=!0,i++):(n=!0,s=!1);const a=R[e.charCodeAt(i++)];if(n&&(-1==a||a>X.T||a<X.P))return;if(s&&(-1==a||a>X.M||a<X.I))return;const r=a<2,o=a<3,l=a<4,h=a<5,u=a<6,F=a<7,q=a<8,T=a<9;this.initToDefault(n&&T||s&&h);const P=n&&T||s&&h;if(o&&n){for(const e of this.channels)e.instruments[0].transition=t.transitions.dictionary.interrupt.index,e.instruments[0].effects|=1024;this.channels[3].instruments[0].chipNoise=0}let I=null;if(n&&T||s&&h){I=[];for(let e=I.length;e<this.getChannelCount();e++){I[e]=[];for(let i=0;i<t.instrumentCountMin;i++)I[e][i]={}}}let z,H=0,x=0,D=-1,A=!1,E=!1;for(;i<e.length;)switch(z=e.charCodeAt(i++)){case 78:var W=(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)];this.title=decodeURIComponent(e.substring(i,i+W)),document.title=this.title+" - "+M.versionDisplayName,i+=W;break;case 75:W=(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)];this.subtitle=decodeURIComponent(e.substring(i,i+W)),i+=W;break;case 110:this.pitchChannelCount=R[e.charCodeAt(i++)],this.noiseChannelCount=R[e.charCodeAt(i++)],this.modChannelCount=n||r?0:R[e.charCodeAt(i++)],this.pitchChannelCount=G(t.pitchChannelCountMin,t.pitchChannelCountMax,this.pitchChannelCount),this.noiseChannelCount=G(t.noiseChannelCountMin,t.noiseChannelCountMax,this.noiseChannelCount),this.modChannelCount=G(t.modChannelCountMin,t.modChannelCountMax,this.modChannelCount);for(let e=this.channels.length;e<this.getChannelCount();e++)this.channels[e]=new Y;if(this.channels.length=this.getChannelCount(),n&&T||s&&h)for(let e=I.length;e<this.getChannelCount();e++){I[e]=[];for(let i=0;i<t.instrumentCountMin;i++)I[e][i]={}}break;case 115:this.scale=R[e.charCodeAt(i++)],n&&(this.scale=0);break;case 107:this.key=O(0,t.keys.length,F&&n?11-R[e.charCodeAt(i++)]:R[e.charCodeAt(i++)]);break;case 108:this.loopStart=h&&n?R[e.charCodeAt(i++)]:(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)];break;case 101:this.loopLength=h&&n?R[e.charCodeAt(i++)]:(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)]+1;break;case 116:this.tempo=l&&n?[95,120,151,190][R[e.charCodeAt(i++)]]:F&&n?[88,95,103,111,120,130,140,151,163,176,190,206,222,240,259][R[e.charCodeAt(i++)]]:R[e.charCodeAt(i++)]<<6|R[e.charCodeAt(i++)],this.tempo=O(t.tempoMin,t.tempoMax+1,this.tempo);break;case 109:T&&n?(H=12*R[e.charCodeAt(i++)],H=O(0,t.reverbRange,H)):h&&s&&(H=R[e.charCodeAt(i++)],H=O(0,t.reverbRange,H));break;case 97:this.beatsPerBar=o&&n?[6,7,8,9,10][R[e.charCodeAt(i++)]]:R[e.charCodeAt(i++)]+1,this.beatsPerBar=Math.max(t.beatsPerBarMin,Math.min(t.beatsPerBarMax,this.beatsPerBar));break;case 103:{const n=(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)]+1;this.barCount=G(t.barCountMin,t.barCountMax,n);for(let e=0;e<this.getChannelCount();e++){for(let t=this.channels[e].bars.length;t<this.barCount;t++)this.channels[e].bars[t]=t<4?1:0;this.channels[e].bars.length=this.barCount}}break;case 106:{let s;s=q&&n?R[e.charCodeAt(i++)]+1:(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)]+1,this.patternsPerChannel=G(1,t.barCountMax,s);const a=this.getChannelCount();for(let e=0;e<a;e++){const t=this.channels[e].patterns;for(let e=t.length;e<this.patternsPerChannel;e++)t[e]=new V;t.length=this.patternsPerChannel}}break;case 105:if(T&&n||h&&s){const s=G(t.instrumentCountMin,t.patternInstrumentCountMax,R[e.charCodeAt(i++)]+t.instrumentCountMin);this.layeredInstruments=!1,this.patternInstruments=s>1;for(let e=0;e<this.getChannelCount();e++){const t=e>=this.pitchChannelCount&&e<this.pitchChannelCount+this.noiseChannelCount,i=e>=this.pitchChannelCount+this.noiseChannelCount;for(let n=this.channels[e].instruments.length;n<s;n++)this.channels[e].instruments[n]=new _(t,i);if(this.channels[e].instruments.length=s,u&&n)for(let n=0;n<s;n++)this.channels[e].instruments[n].setTypeAndReset(t?2:0,t,i);for(let t=I[e].length;t<s;t++)I[e][t]={}}}else{const n=R[e.charCodeAt(i++)];this.layeredInstruments=0!=(2&n),this.patternInstruments=0!=(1&n);for(let n=0;n<this.getChannelCount();n++){let s=1;(this.layeredInstruments||this.patternInstruments)&&(s=G(t.instrumentCountMin,this.getMaxInstrumentsPerChannel(),R[e.charCodeAt(i++)]+t.instrumentCountMin));const a=this.channels[n],r=this.getChannelIsNoise(n),o=this.getChannelIsMod(n);for(let e=a.instruments.length;e<s;e++)a.instruments[e]=new _(r,o);a.instruments.length=s}}break;case 114:this.rhythm=R[e.charCodeAt(i++)],(s&&o||n)&&(this.rhythm!=t.rhythms.dictionary["÷3 (triplets)"].index&&this.rhythm!=t.rhythms.dictionary["÷6"].index||(A=!0),this.rhythm>=t.rhythms.dictionary["÷6"].index&&(E=!0));break;case 111:if(o&&n){const n=R[e.charCodeAt(i++)];this.channels[n].octave=O(0,t.pitchOctaves,R[e.charCodeAt(i++)]+1),n>=this.pitchChannelCount&&(this.channels[n].octave=0)}else if(T&&n||h&&s)for(let n=0;n<this.getChannelCount();n++)this.channels[n].octave=O(0,t.pitchOctaves,R[e.charCodeAt(i++)]+1),n>=this.pitchChannelCount&&(this.channels[n].octave=0);else{for(let n=0;n<this.pitchChannelCount;n++)this.channels[n].octave=O(0,t.pitchOctaves,R[e.charCodeAt(i++)]);for(let e=this.pitchChannelCount;e<this.getChannelCount();e++)this.channels[e].octave=0}break;case 84:{D++,D>=this.channels[x].instruments.length&&(x++,D=0),G(0,this.channels.length-1,x);const a=this.channels[x].instruments[D];let o=G(0,9,R[e.charCodeAt(i++)]);s&&h&&(7==o?o=8:8==o&&(o=9)),a.setTypeAndReset(o,x>=this.pitchChannelCount&&x<this.pitchChannelCount+this.noiseChannelCount,x>=this.pitchChannelCount+this.noiseChannelCount),!(F&&n||r&&s)||0!=o&&8!=o&&6!=o||(a.aliases=!0,a.distortion=0,a.effects|=8),A&&(a.arpeggioSpeed=9),E&&(a.fastTwoNoteArp=!0),F&&n&&(a.effects=0,a.chord!=t.chords.dictionary.simultaneous.index&&(a.effects|=2048))}break;case 117:{const t=R[e.charCodeAt(i++)]<<6|R[e.charCodeAt(i++)];this.channels[x].instruments[D].preset=t,s&&h&&7==this.channels[x].instruments[D].preset&&(this.channels[x].instruments[D].preset=8)}break;case 119:if(o&&n){const n=[1,2,3,4,5,6,7,8,0],s=R[e.charCodeAt(i++)],a=this.channels[s].instruments[0];a.chipWave=O(0,t.chipWaves.length,0|n[R[e.charCodeAt(i++)]]),a.convertLegacySettings(I[s][0],P)}else if(u&&n){const n=[1,2,3,4,5,6,7,8,0];for(let s=0;s<this.getChannelCount();s++)for(const a of this.channels[s].instruments)s>=this.pitchChannelCount?a.chipNoise=O(0,t.chipNoises.length,R[e.charCodeAt(i++)]):a.chipWave=O(0,t.chipWaves.length,0|n[R[e.charCodeAt(i++)]])}else if(F&&n){const n=[1,2,3,4,5,6,7,8,0];x>=this.pitchChannelCount?this.channels[x].instruments[D].chipNoise=O(0,t.chipNoises.length,R[e.charCodeAt(i++)]):this.channels[x].instruments[D].chipWave=O(0,t.chipWaves.length,0|n[R[e.charCodeAt(i++)]])}else x>=this.pitchChannelCount?this.channels[x].instruments[D].chipNoise=O(0,t.chipNoises.length,R[e.charCodeAt(i++)]):this.channels[x].instruments[D].chipWave=O(0,t.chipWaves.length,R[e.charCodeAt(i++)]);break;case 102:if(T&&n||h&&s)if(F&&n){const s=[10,6,3,0,8,5,2],a=["none","none","none","none","decay 1","decay 2","decay 3"];if(o&&n){const n=R[e.charCodeAt(i++)],r=this.channels[n].instruments[0],o=I[n][0],l=[1,3,4,5][O(0,s.length,R[e.charCodeAt(i++)])];o.filterCutoff=s[l],o.filterResonance=0,o.filterEnvelope=t.envelopes.dictionary[a[l]],r.convertLegacySettings(o,P)}else if(u&&n)for(let n=0;n<this.getChannelCount();n++)for(let r=0;r<this.channels[n].instruments.length;r++){const o=this.channels[n].instruments[r],l=I[n][r],h=O(0,s.length,R[e.charCodeAt(i++)]+1);n<this.pitchChannelCount?(l.filterCutoff=s[h],l.filterResonance=0,l.filterEnvelope=t.envelopes.dictionary[a[h]]):(l.filterCutoff=10,l.filterResonance=0,l.filterEnvelope=t.envelopes.dictionary.none),o.convertLegacySettings(l,P)}else{const n=O(0,s.length,R[e.charCodeAt(i++)]),r=this.channels[x].instruments[D],o=I[x][D];o.filterCutoff=s[n],o.filterResonance=0,o.filterEnvelope=t.envelopes.dictionary[a[n]],r.convertLegacySettings(o,P)}}else{const t=11,n=this.channels[x].instruments[D],s=I[x][D];s.filterCutoff=O(0,t,R[e.charCodeAt(i++)]),n.convertLegacySettings(s,P)}else{const a=this.channels[x].instruments[D];let r=R[e.charCodeAt(i++)];if(n||0==r){a.eqFilterType=!1,s&&(r=R[e.charCodeAt(i++)]);const n=r;a.eqFilter.controlPointCount=O(0,t.filterMaxPoints+1,n);for(let e=a.eqFilter.controlPoints.length;e<a.eqFilter.controlPointCount;e++)a.eqFilter.controlPoints[e]=new Q;for(let n=0;n<a.eqFilter.controlPointCount;n++){const s=a.eqFilter.controlPoints[n];s.type=O(0,3,R[e.charCodeAt(i++)]),s.freq=O(0,t.filterFreqRange,R[e.charCodeAt(i++)]),s.gain=O(0,t.filterGainRange,R[e.charCodeAt(i++)])}for(let e=a.eqFilter.controlPointCount;e<n;e++)i+=3;if(a.eqSubFilters[0]=a.eqFilter,s&&!h){let n=R[e.charCodeAt(i++)]<<6|R[e.charCodeAt(i++)];for(let s=0;s<t.filterMorphCount-1;s++)if(n&1<<s){const n=R[e.charCodeAt(i++)];null==a.eqSubFilters[s+1]&&(a.eqSubFilters[s+1]=new K),a.eqSubFilters[s+1].controlPointCount=O(0,t.filterMaxPoints+1,n);for(let e=a.eqSubFilters[s+1].controlPoints.length;e<a.eqSubFilters[s+1].controlPointCount;e++)a.eqSubFilters[s+1].controlPoints[e]=new Q;for(let n=0;n<a.eqSubFilters[s+1].controlPointCount;n++){const r=a.eqSubFilters[s+1].controlPoints[n];r.type=O(0,3,R[e.charCodeAt(i++)]),r.freq=O(0,t.filterFreqRange,R[e.charCodeAt(i++)]),r.gain=O(0,t.filterGainRange,R[e.charCodeAt(i++)])}for(let e=a.eqSubFilters[s+1].controlPointCount;e<n;e++)i+=3}}}else a.eqFilterType=!0,a.eqFilterSimpleCut=O(0,t.filterSimpleCutRange,R[e.charCodeAt(i++)]),a.eqFilterSimplePeak=O(0,t.filterSimplePeakRange,R[e.charCodeAt(i++)])}break;case 121:if(T&&n||h&&s){const t=8,n=this.channels[x].instruments[D],s=I[x][D];s.filterResonance=O(0,t,R[e.charCodeAt(i++)]),n.convertLegacySettings(s,P)}break;case 122:{const a=this.channels[x].instruments[D];if(T&&n||h&&s)if(4==a.type)for(let n=0;n<t.drumCount;n++)a.drumsetEnvelopes[n]=X.q(R[e.charCodeAt(i++)]).index;else{const t=I[x][D];t.filterEnvelope=X.q(R[e.charCodeAt(i++)]),a.convertLegacySettings(t,P)}else for(let n=0;n<t.drumCount;n++)a.drumsetEnvelopes[n]=O(0,t.envelopes.length,R[e.charCodeAt(i++)])}break;case 87:{const a=this.channels[x].instruments[D];if(a.pulseWidth=O(0,t.pulseWidthRange+ +s,R[e.charCodeAt(i++)]),n&&(a.pulseWidth=Math.round(Math.pow(.5,(7-a.pulseWidth)*t.pulseWidthStepPower)*t.pulseWidthRange)),T&&n||h&&s){const t=I[x][D];t.pulseEnvelope=X.q(R[e.charCodeAt(i++)]),a.convertLegacySettings(t,P)}}break;case 73:this.channels[x].instruments[D].stringSustain=O(0,t.stringSustainRange,R[e.charCodeAt(i++)]);break;case 100:if(T&&n||h&&s){const s=[{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}];if(o&&n){const n=R[e.charCodeAt(i++)],a=s[O(0,s.length,R[e.charCodeAt(i++)])],r=this.channels[n].instruments[0];r.fadeIn=se.secondsToFadeInSetting(a.fadeInSeconds),r.fadeOut=se.ticksToFadeOutSetting(a.fadeOutTicks),r.transition=t.transitions.dictionary[a.transition].index,r.transition!=t.transitions.dictionary.normal.index&&(r.effects|=1024)}else if(u&&n)for(let n=0;n<this.getChannelCount();n++)for(const a of this.channels[n].instruments){const n=s[O(0,s.length,R[e.charCodeAt(i++)])];a.fadeIn=se.secondsToFadeInSetting(n.fadeInSeconds),a.fadeOut=se.ticksToFadeOutSetting(n.fadeOutTicks),a.transition=t.transitions.dictionary[n.transition].index,a.transition!=t.transitions.dictionary.normal.index&&(a.effects|=1024)}else if(l||n){const n=s[O(0,s.length,R[e.charCodeAt(i++)])],a=this.channels[x].instruments[D];a.fadeIn=se.secondsToFadeInSetting(n.fadeInSeconds),a.fadeOut=se.ticksToFadeOutSetting(n.fadeOutTicks),a.transition=t.transitions.dictionary[n.transition].index,a.transition!=t.transitions.dictionary.normal.index&&(a.effects|=1024)}else{const n=s[O(0,s.length,R[e.charCodeAt(i++)])],a=this.channels[x].instruments[D];a.fadeIn=se.secondsToFadeInSetting(n.fadeInSeconds),a.fadeOut=se.ticksToFadeOutSetting(n.fadeOutTicks),a.transition=t.transitions.dictionary[n.transition].index,R[e.charCodeAt(i++)]>0&&(a.legacyTieOver=!0),a.clicklessTransition=!!R[e.charCodeAt(i++)],(a.transition!=t.transitions.dictionary.normal.index||a.clicklessTransition)&&(a.effects|=1024)}}else{const n=this.channels[x].instruments[D];n.fadeIn=O(0,t.fadeInRange,R[e.charCodeAt(i++)]),n.fadeOut=O(0,t.fadeOutTicks.length,R[e.charCodeAt(i++)]),s&&(n.clicklessTransition=!!R[e.charCodeAt(i++)],n.continueThruPattern=!!R[e.charCodeAt(i++)])}break;case 99:if(T&&n||h&&s)if(F&&n)if(o&&n){const n=[0,3,2,0],s=["none","none","none","tremolo2"],a=R[e.charCodeAt(i++)],r=O(0,n.length,R[e.charCodeAt(i++)]),o=this.channels[a].instruments[0],l=I[a][0];o.vibrato=n[r],null!=l.filterEnvelope&&1!=l.filterEnvelope.type||(l.filterEnvelope=t.envelopes.dictionary[s[r]],o.convertLegacySettings(l,P)),o.vibrato!=t.vibratos.dictionary.none.index&&(o.effects|=512)}else if(u&&n){const n=[0,1,2,3,0,0],a=["none","none","none","none","tremolo5","tremolo2"];for(let r=0;r<this.getChannelCount();r++)for(let o=0;o<this.channels[r].instruments.length;o++){const l=O(0,n.length,R[e.charCodeAt(i++)]),u=this.channels[r].instruments[o],c=I[r][o];u.vibrato=n[l],null!=c.filterEnvelope&&1!=c.filterEnvelope.type||(c.filterEnvelope=t.envelopes.dictionary[a[l]],u.convertLegacySettings(c,P)),u.vibrato!=t.vibratos.dictionary.none.index&&(u.effects|=512),(0!=H||s&&h)&&!this.getChannelIsNoise(r)&&(u.effects|=1,u.reverb=H)}}else{const n=[0,1,2,3,0,0],a=["none","none","none","none","tremolo5","tremolo2"],r=O(0,n.length,R[e.charCodeAt(i++)]),o=this.channels[x].instruments[D],l=I[x][D];o.vibrato=n[r],null!=l.filterEnvelope&&1!=l.filterEnvelope.type||(l.filterEnvelope=t.envelopes.dictionary[a[r]],o.convertLegacySettings(l,P)),o.vibrato!=t.vibratos.dictionary.none.index&&(o.effects|=512),(0!=H||s&&h)&&(o.effects|=1,o.reverb=H)}else{const n=this.channels[x].instruments[D],s=O(0,t.vibratos.length+1,R[e.charCodeAt(i++)]);n.vibrato=s,n.vibrato!=t.vibratos.dictionary.none.index&&(n.effects|=512),s==t.vibratos.length?(n.vibratoDepth=O(0,t.modulators.dictionary["vibrato depth"].maxRawVol+1,R[e.charCodeAt(i++)])/50,n.vibratoSpeed=O(0,t.modulators.dictionary["vibrato speed"].maxRawVol+1,R[e.charCodeAt(i++)]),n.vibratoDelay=O(0,t.modulators.dictionary["vibrato delay"].maxRawVol+1,R[e.charCodeAt(i++)])/2,n.vibratoType=O(0,t.vibratoTypes.length,R[e.charCodeAt(i++)]),n.effects|=512):(n.vibratoDepth=t.vibratos[n.vibrato].amplitude,n.vibratoSpeed=10,n.vibratoDelay=t.vibratos[n.vibrato].delayTicks/2,n.vibratoType=t.vibratos[n.vibrato].type)}break;case 71:if(s&&h){const n=this.channels[x].instruments[D];n.arpeggioSpeed=O(0,t.modulators.dictionary["arp speed"].maxRawVol+1,R[e.charCodeAt(i++)]),n.fastTwoNoteArp=!!R[e.charCodeAt(i++)],n.arpeggioPattern=O(0,10,R[e.charCodeAt(i++)])}break;case 104:if(o&&n){const n=R[e.charCodeAt(i++)];this.channels[n].instruments[0].unison=O(0,t.unisons.length,R[e.charCodeAt(i++)])}else if(u&&n)for(let n=0;n<this.getChannelCount();n++)for(const s of this.channels[n].instruments){const n=R[e.charCodeAt(i++)];let a=O(0,t.unisons.length,n);8==n&&(a=2,s.chord=3),s.unison=a}else if(F&&n){const n=R[e.charCodeAt(i++)];let s=O(0,t.unisons.length,n);8==n&&(s=2,this.channels[x].instruments[D].chord=3),this.channels[x].instruments[D].unison=s}else this.channels[x].instruments[D].unison=O(0,t.unisons.length,R[e.charCodeAt(i++)]);break;case 67:if(T&&n||h&&s){const n=this.channels[x].instruments[D];n.chord=O(0,t.chords.length,R[e.charCodeAt(i++)]),n.chord!=t.chords.dictionary.simultaneous.index&&(n.effects|=2048)}break;case 113:{const a=this.channels[x].instruments[D];if(T&&n||h&&s){a.effects=4095&R[e.charCodeAt(i++)],0!=H||s&&h?k(a.effects)&&(a.reverb=H):a.effects&=-2,a.effects|=4,a.vibrato!=t.vibratos.dictionary.none.index&&(a.effects|=512),a.detune!=t.detuneCenter&&(a.effects|=256),a.aliases?a.effects|=8:a.effects&=-9;const n=I[x][D];a.convertLegacySettings(n,P)}else{if(a.effects=R[e.charCodeAt(i++)]<<6|R[e.charCodeAt(i++)],y(a.effects)){let r=R[e.charCodeAt(i++)];if(n||0==r){a.noteFilterType=!1,s&&(r=R[e.charCodeAt(i++)]),a.noteFilter.controlPointCount=O(0,t.filterMaxPoints+1,r);for(let e=a.noteFilter.controlPoints.length;e<a.noteFilter.controlPointCount;e++)a.noteFilter.controlPoints[e]=new Q;for(let n=0;n<a.noteFilter.controlPointCount;n++){const s=a.noteFilter.controlPoints[n];s.type=O(0,3,R[e.charCodeAt(i++)]),s.freq=O(0,t.filterFreqRange,R[e.charCodeAt(i++)]),s.gain=O(0,t.filterGainRange,R[e.charCodeAt(i++)])}for(let e=a.noteFilter.controlPointCount;e<r;e++)i+=3;if(a.noteSubFilters[0]=a.noteFilter,s&&!h){let n=R[e.charCodeAt(i++)]<<6|R[e.charCodeAt(i++)];for(let s=0;s<t.filterMorphCount-1;s++)if(n&1<<s){const n=R[e.charCodeAt(i++)];null==a.noteSubFilters[s+1]&&(a.noteSubFilters[s+1]=new K),a.noteSubFilters[s+1].controlPointCount=O(0,t.filterMaxPoints+1,n);for(let e=a.noteSubFilters[s+1].controlPoints.length;e<a.noteSubFilters[s+1].controlPointCount;e++)a.noteSubFilters[s+1].controlPoints[e]=new Q;for(let n=0;n<a.noteSubFilters[s+1].controlPointCount;n++){const r=a.noteSubFilters[s+1].controlPoints[n];r.type=O(0,3,R[e.charCodeAt(i++)]),r.freq=O(0,t.filterFreqRange,R[e.charCodeAt(i++)]),r.gain=O(0,t.filterGainRange,R[e.charCodeAt(i++)])}for(let e=a.noteSubFilters[s+1].controlPointCount;e<n;e++)i+=3}}}else a.noteFilterType=!0,a.noteFilter.reset(),a.noteFilterSimpleCut=O(0,t.filterSimpleCutRange,R[e.charCodeAt(i++)]),a.noteFilterSimplePeak=O(0,t.filterSimplePeakRange,R[e.charCodeAt(i++)])}c(a.effects)&&(a.transition=O(0,t.transitions.length,R[e.charCodeAt(i++)]),t.transitions[a.transition].slides&&(a.slideSpeed=R[e.charCodeAt(i++)])),p(a.effects)&&(a.chord=O(0,t.chords.length,R[e.charCodeAt(i++)]),a.chord==t.chords.dictionary.arpeggio.index&&s?(a.arpeggioSpeed=R[e.charCodeAt(i++)],a.fastTwoNoteArp=!!R[e.charCodeAt(i++)],a.arpeggioPattern=R[e.charCodeAt(i++)]):t.chords[a.chord].strumParts>0&&(a.strumSpeed=R[e.charCodeAt(i++)])),f(a.effects)&&(a.pitchShift=O(0,t.pitchShiftRange,R[e.charCodeAt(i++)])),m(a.effects)&&(n?(a.detune=O(t.detuneMin,t.detuneMax+1,R[e.charCodeAt(i++)]),a.detune=Math.round((a.detune-9)*(Math.abs(a.detune-9)+1)/2+t.detuneCenter)):a.detune=O(t.detuneMin,t.detuneMax+1,(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)])),d(a.effects)&&(a.vibrato=O(0,t.vibratos.length+1,R[e.charCodeAt(i++)]),a.vibrato==t.vibratos.length&&s?(a.vibratoDepth=O(0,t.modulators.dictionary["vibrato depth"].maxRawVol+1,R[e.charCodeAt(i++)])/25,a.vibratoSpeed=O(0,t.modulators.dictionary["vibrato speed"].maxRawVol+1,R[e.charCodeAt(i++)]),a.vibratoDelay=O(0,t.modulators.dictionary["vibrato delay"].maxRawVol+1,R[e.charCodeAt(i++)]),a.vibratoType=O(0,t.vibratoTypes.length,R[e.charCodeAt(i++)])):(a.vibratoDepth=t.vibratos[a.vibrato].amplitude,a.vibratoSpeed=10,a.vibratoDelay=t.vibratos[a.vibrato].delayTicks/2,a.vibratoType=t.vibratos[a.vibrato].type)),v(a.effects)&&(a.distortion=O(0,t.distortionRange,R[e.charCodeAt(i++)]),s&&!h&&(a.aliases=!!R[e.charCodeAt(i++)])),g(a.effects)&&(a.bitcrusherFreq=O(0,t.bitcrusherFreqRange,R[e.charCodeAt(i++)]),a.bitcrusherQuantization=O(0,t.bitcrusherQuantizationRange,R[e.charCodeAt(i++)])),b(a.effects)&&(a.pan=O(0,t.panMax+1,n?Math.round(R[e.charCodeAt(i++)]*(t.panMax/8)):(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)]),s&&!r&&(a.panDelay=R[e.charCodeAt(i++)])),S(a.effects)&&(a.chorus=n?2*O(0,t.chorusRange/2+1,R[e.charCodeAt(i++)]):O(0,t.chorusRange,R[e.charCodeAt(i++)])),w(a.effects)&&(a.echoSustain=O(0,t.echoSustainRange,R[e.charCodeAt(i++)]),a.echoDelay=O(0,t.echoDelayRange,R[e.charCodeAt(i++)])),k(a.effects)&&(a.reverb=O(0,t.reverbRange,n?Math.round(R[e.charCodeAt(i++)]*t.reverbRange/3):R[e.charCodeAt(i++)]))}a.effects&=4095}break;case 118:if(o&&n){const n=R[e.charCodeAt(i++)];this.channels[n].instruments[0].volume=Math.round(O(-t.volumeRange/2,1,5*-R[e.charCodeAt(i++)]))}else if(u&&n)for(let n=0;n<this.getChannelCount();n++)for(const s of this.channels[n].instruments)s.volume=Math.round(O(-t.volumeRange/2,1,5*-R[e.charCodeAt(i++)]));else if(F&&n){this.channels[x].instruments[D].volume=Math.round(O(-t.volumeRange/2,1,5*-R[e.charCodeAt(i++)]))}else if(n){this.channels[x].instruments[D].volume=Math.round(O(-t.volumeRange/2,1,25*-R[e.charCodeAt(i++)]/7))}else{this.channels[x].instruments[D].volume=Math.round(O(-t.volumeRange/2,t.volumeRange/2+1,(R[e.charCodeAt(i++)]<<6|R[e.charCodeAt(i++)])-t.volumeRange/2))}break;case 76:if(T&&n){this.channels[x].instruments[D].pan=O(0,t.panMax+1,R[e.charCodeAt(i++)]*(t.panMax/8))}else if(h&&s){const n=this.channels[x].instruments[D];n.pan=O(0,t.panMax+1,(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)]),s&&!o&&(n.panDelay=R[e.charCodeAt(i++)])}break;case 68:{const n=this.channels[x].instruments[D];s&&h&&(n.detune=O(t.detuneMin,t.detuneMax+1,4*((R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)])),n.effects|=256)}break;case 77:{let t=this.channels[x].instruments[D];for(let n=0;n<64;n++)t.customChipWave[n]=O(-24,25,R[e.charCodeAt(i++)]-24);let n=0;for(let e=0;e<t.customChipWave.length;e++)n+=t.customChipWave[e];const s=n/t.customChipWave.length;let a=0,r=0;for(let e=0;e<t.customChipWave.length;e++)a+=r,r=t.customChipWave[e]-s,t.customChipWaveIntegral[e]=a;t.customChipWaveIntegral[64]=0}break;case 79:{let t=R[e.charCodeAt(i++)];63==t?this.restoreLimiterDefaults():(this.compressionRatio=t<10?t/10:1+(t-10)/60,t=R[e.charCodeAt(i++)],this.limitRatio=t<10?t/10:t-9,this.limitDecay=R[e.charCodeAt(i++)],this.limitRise=250*R[e.charCodeAt(i++)]+2e3,this.compressionThreshold=R[e.charCodeAt(i++)]/20,this.limitThreshold=R[e.charCodeAt(i++)]/20,this.masterGain=((R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)])/50)}break;case 85:for(let t=0;t<this.getChannelCount();t++){var B;B=l?R[e.charCodeAt(i++)]:(R[e.charCodeAt(i++)]<<6)+R[e.charCodeAt(i++)],this.channels[t].name=decodeURIComponent(e.substring(i,i+B)),i+=B}break;case 65:{const a=this.channels[x].instruments[D];if(a.algorithm=O(0,t.algorithms.length,R[e.charCodeAt(i++)]),T&&n||h&&s){const e=I[x][D];a.convertLegacySettings(e,P)}}break;case 70:this.channels[x].instruments[D].feedbackType=O(0,t.feedbacks.length,R[e.charCodeAt(i++)]);break;case 66:this.channels[x].instruments[D].feedbackAmplitude=O(0,t.operatorAmplitudeMax+1,R[e.charCodeAt(i++)]);break;case 86:if(T&&n||h&&s){const t=this.channels[x].instruments[D],n=I[x][D];n.feedbackEnvelope=X.q(R[e.charCodeAt(i++)]),t.convertLegacySettings(n,P)}break;case 81:for(let n=0;n<t.operatorCount;n++)this.channels[x].instruments[D].operators[n].frequency=O(0,t.operatorFrequencies.length,R[e.charCodeAt(i++)]);break;case 80:for(let n=0;n<t.operatorCount;n++)this.channels[x].instruments[D].operators[n].amplitude=O(0,t.operatorAmplitudeMax+1,R[e.charCodeAt(i++)]);break;case 69:{const a=this.channels[x].instruments[D];if(T&&n||h&&s){const n=I[x][D];n.operatorEnvelopes=[];for(let s=0;s<t.operatorCount;s++)n.operatorEnvelopes[s]=X.q(R[e.charCodeAt(i++)]);a.convertLegacySettings(n,P)}else{const n=O(0,t.maxEnvelopeCount+1,R[e.charCodeAt(i++)]);for(let s=0;s<n;s++){const n=O(0,t.instrumentAutomationTargets.length,R[e.charCodeAt(i++)]);let s=0;const r=t.instrumentAutomationTargets[n].maxCount;r>1&&(s=O(0,r,R[e.charCodeAt(i++)]));const o=O(0,t.envelopes.length,R[e.charCodeAt(i++)]);a.addEnvelope(n,s,o)}}}break;case 82:{const n=this.channels[x].instruments[D];for(let s=0;s<t.operatorCount;s++)n.operators[s].waveform=O(0,t.operatorWaves.length,R[e.charCodeAt(i++)]),3==n.operators[s].waveform&&(n.operators[s].pulseWidth=O(0,t.pwmOperatorWaves.length,R[e.charCodeAt(i++)]))}break;case 83:{const n=this.channels[x].instruments[D];if(3==n.type){const s=Math.ceil(t.spectrumControlPoints*t.spectrumControlPointBits/6),a=new C(e,i,i+s);for(let e=0;e<t.spectrumControlPoints;e++)n.spectrumWave.spectrum[e]=a.read(t.spectrumControlPointBits);n.spectrumWave.markCustomWaveDirty(),i+=s}else{if(4!=n.type)throw new Error("Unhandled instrument type for spectrum song tag code.");{const s=Math.ceil(t.drumCount*t.spectrumControlPoints*t.spectrumControlPointBits/6),a=new C(e,i,i+s);for(let e=0;e<t.drumCount;e++){for(let i=0;i<t.spectrumControlPoints;i++)n.drumsetSpectrumWaves[e].spectrum[i]=a.read(t.spectrumControlPointBits);n.drumsetSpectrumWaves[e].markCustomWaveDirty()}i+=s}}}break;case 72:{const n=this.channels[x].instruments[D],s=Math.ceil(t.harmonicsControlPoints*t.harmonicsControlPointBits/6),a=new C(e,i,i+s);for(let e=0;e<t.harmonicsControlPoints;e++)n.harmonicsWave.harmonics[e]=a.read(t.harmonicsControlPointBits);n.harmonicsWave.markCustomWaveDirty(),i+=s}break;case 88:if(s&&h){const t=this.channels[x].instruments[D];t.aliases=!!R[e.charCodeAt(i++)],t.aliases&&(t.distortion=0,t.effects|=8)}break;case 98:{let t;if(o&&n){const n=R[e.charCodeAt(i++)],s=R[e.charCodeAt(i++)];t=Math.ceil(.5*s);const a=new C(e,i,i+t);for(let e=0;e<s;e++)this.channels[n].bars[e]=a.read(3)+1}else if(h&&n){let n=0;for(;1<<n<this.patternsPerChannel;)n++;t=Math.ceil(this.getChannelCount()*this.barCount*n/6);const s=new C(e,i,i+t);for(let e=0;e<this.getChannelCount();e++)for(let t=0;t<this.barCount;t++)this.channels[e].bars[t]=s.read(n)+1}else{let n=0;for(;1<<n<this.patternsPerChannel+1;)n++;t=Math.ceil(this.getChannelCount()*this.barCount*n/6);const s=new C(e,i,i+t);for(let e=0;e<this.getChannelCount();e++)for(let t=0;t<this.barCount;t++)this.channels[e].bars[t]=s.read(n)}i+=t}break;case 112:{let a,r=0,u=!(l&&s||n),c=u?4:3,p=u?16:8;if(o&&n)a=R[e.charCodeAt(i++)],i++,r=R[e.charCodeAt(i++)],r<<=6,r+=R[e.charCodeAt(i++)];else{a=0;let t=G(1,4,R[e.charCodeAt(i++)]);for(;t>0;)r<<=6,r+=R[e.charCodeAt(i++)],t--}const f=new C(e,i,i+r);i+=r;const m=X.getNeededBits(t.noteSizeMax);let d=-1,v=-1,g=-1;for(;;){const e=this.channels[a],i=this.getChannelIsNoise(a),r=this.getChannelIsMod(a),b=this.getMaxInstrumentsPerPattern(a),S=X.getNeededBits(b-t.instrumentCountMin),w=X.getNeededBits(e.instruments.length-1);if(r){const i=h?w:X.getNeededBits(this.getMaxInstrumentsPerChannel()+2);for(let n=0;n<e.instruments.length;n++){let s=e.instruments[n];for(let e=0;e<t.modCount;e++){let r=f.read(2);switch(r){case 0:s.modChannels[e]=O(0,this.pitchChannelCount+this.noiseChannelCount+1,f.read(8)),s.modInstruments[e]=O(0,this.channels[s.modChannels[e]].instruments.length+2,f.read(i));break;case 1:s.modChannels[e]=this.pitchChannelCount+O(0,this.noiseChannelCount+1,f.read(8)),s.modInstruments[e]=O(0,this.channels[s.modChannels[e]].instruments.length+2,f.read(w));break;case 2:s.modChannels[e]=-1;break;case 3:s.modChannels[e]=-2}if(3!=r&&(s.modulators[e]=f.read(6)),h||"eq filter"!=t.modulators[s.modulators[e]].name&&"note filter"!=t.modulators[s.modulators[e]].name||(s.modFilterTypes[e]=f.read(6)),h&&s.modChannels[e]>=0){let i=y(this.channels[s.modChannels[e]].instruments[s.modInstruments[e]].effects);7==s.modulators[e]?(s.modulators[e]=i?t.modulators.dictionary["note filt cut"].index:t.modulators.dictionary["eq filt cut"].index,s.modFilterTypes[e]=1):8==s.modulators[e]&&(s.modulators[e]=i?t.modulators.dictionary["note filt peak"].index:t.modulators.dictionary["eq filt peak"].index,s.modFilterTypes[e]=2)}else h&&s.modulators[e]==t.modulators.dictionary["song reverb"].index&&(d=a,v=n,g=e);h&&12!=t.modulators[s.modulators[e]].associatedEffect&&(this.channels[s.modChannels[e]].instruments[s.modInstruments[e]].effects|=1<<t.modulators[s.modulators[e]].associatedEffect)}}}const k=[];for(let i=0;i<e.instruments.length;i++){k[i]=[];for(let n=0;n<t.modCount;n++)k[i][t.modCount-1-n]=1+3*+(h&&s&&r&&e.instruments[i].modulators[n]==t.modulators.dictionary.detune.index)}const M=i||r?0:12*e.octave;let q=i||r?4:M;const P=r?[0,1,2,3,4,5]:i?[4,6,7,2,3,8,0,10]:[0,7,12,19,24,-5,-12],I=[];for(let e=0;e<P.length;e++)P[e]+=M;for(let i=0;i<this.patternsPerChannel;i++){const a=e.patterns[i];if(T&&n||h&&s)a.instruments[0]=G(0,e.instruments.length-1,f.read(w)),a.instruments.length=1;else if(this.patternInstruments){const i=G(t.instrumentCountMin,b,f.read(S)+t.instrumentCountMin);for(let t=0;t<i;t++)a.instruments[t]=G(0,e.instruments.length-1+2*+r,f.read(w));a.instruments.length=i}else a.instruments[0]=0,a.instruments.length=t.instrumentCountMin;if(!(n&&o||0!=f.read(1))){a.notes.length=0;continue}let d=0;const y=a.notes;let v=0;for(;d<this.beatsPerBar*t.partsPerBeat+ +r;){const i=1==f.read(1);let o=!1,g=0;if(i?g=G(0,I.length-1,f.readLongTail(0,0)):o=1==f.read(1),i||o){let o,b,S;if(i)o=I[g],I.splice(g,1);else{if(o={},u)1==f.read(1)?o.pitchCount=f.read(3)+2:o.pitchCount=1;else for(o.pitchCount=1;o.pitchCount<4&&1==f.read(1);)o.pitchCount++;o.pinCount=f.readPinCount(),o.initialSize=n?2*f.read(2):r?f.read(9):f.read(m),o.pins=[],o.length=0,o.bendCount=0;for(let e=0;e<o.pinCount;e++){let e={};e.pitchBend=1==f.read(1),e.pitchBend&&o.bendCount++,o.length+=F&&n?f.readLegacyPartDuration()*t.partsPerBeat/t.rhythms[this.rhythm].stepsPerBeat:f.readPartDuration(),e.time=o.length,e.size=n?2*f.read(2):r?f.read(9):f.read(m),o.pins.push(e)}}I.unshift(o),I.length>10&&I.pop(),y.length<=v?(b=new N(0,d,d+o.length,o.initialSize),y[v++]=b):(b=y[v++],b.start=d,b.end=d+o.length,b.pins[0].size=o.initialSize);let w=0;const M=[];for(let e=0;e<o.pitchCount+o.bendCount;e++){if(1==f.read(1)){const e=G(0,P.length-1,f.read(c));S=P[e],P.splice(e,1)}else{S=q;let e=f.readPitchInterval();for(;e>0;){for(S++;-1!=P.indexOf(S);)S++;e--}for(;e<0;){for(S--;-1!=P.indexOf(S);)S--;e++}}P.unshift(S),P.length>p&&P.pop(),e<o.pitchCount?b.pitches[w++]=S:M.push(S),q=e==o.pitchCount-1?b.pitches[0]:S}b.pitches.length=w,M.unshift(b.pitches[0]),r&&(b.pins[0].size*=k[a.instruments[0]][b.pitches[0]]);let z=1;for(const e of o.pins){e.pitchBend&&M.shift();const t=M[0]-b.pitches[0];if(b.pins.length<=z)b.pins[z++]=L(t,e.time,r?e.size*k[a.instruments[0]][b.pitches[0]]:e.size);else{const i=b.pins[z++];i.interval=t,i.time=e.time,i.size=r?e.size*k[a.instruments[0]][b.pitches[0]]:e.size}}b.pins.length=z,0==b.start&&(b.continuesLastPattern=T&&n||h&&s?!l&&!n&&e.instruments[a.instruments[0]].legacyTieOver:1==f.read(1)),d=G(0,this.beatsPerBar*t.partsPerBeat,b.end)}else if(r){const e=1==f.read(1),t=f.readPartDuration();e?d-=t:d+=t}else{d+=F&&n?f.readLegacyPartDuration()*t.partsPerBeat/t.rhythms[this.rhythm].stepsPerBeat:f.readPartDuration()}}y.length=v}if(o&&n)break;if(a++,a>=this.getChannelCount())break}if(s&&h&&g>=0)for(let e=0;e<this.channels.length;e++)for(let i=0;i<this.channels[e].instruments.length;i++){const n=this.channels[e].instruments[i];if(k(n.effects)&&(n.reverb=t.reverbRange-1),d==e&&v==i){const i=this.channels[e].bars[0];if(i>0){const n=this.channels[e].patterns[i-1];let s=6;for(const e of n.notes)e.pitches[0]==t.modCount-1-g&&(s=Math.min(s,e.start));s>0&&n.notes.push(new N(t.modCount-1-g,0,s,H))}else if(this.channels[e].patterns.length<t.barCountMax){const i=new V;if(this.channels[e].patterns.push(i),this.channels[e].bars[0]=this.channels[e].patterns.length,this.channels[e].patterns.length>this.patternsPerChannel){for(let e=0;e<this.channels.length;e++)this.channels[e].patterns.length<=this.patternsPerChannel&&this.channels[e].patterns.push(new V);this.patternsPerChannel++}i.instruments.length=1,i.instruments[0]=v,i.notes.length=0,i.notes.push(new N(t.modCount-1-g,0,6,H))}}}}break;default:throw new Error("Unrecognized song tag code "+String.fromCharCode(z)+" at index "+(i-1))}}toJsonObject(e=!0,i=1,n=!0){const s=[];for(let t=0;t<this.getChannelCount();t++){const a=this.channels[t],r=[],o=this.getChannelIsNoise(t),l=this.getChannelIsMod(t);for(const e of a.instruments)r.push(e.toJsonObject());const h=[];for(const e of a.patterns)h.push(e.toJsonObject(this,a,l));const u=[];if(e)for(let e=0;e<this.loopStart;e++)u.push(a.bars[e]);for(let e=0;e<i;e++)for(let e=this.loopStart;e<this.loopStart+this.loopLength;e++)u.push(a.bars[e]);if(n)for(let e=this.loopStart+this.loopLength;e<this.barCount;e++)u.push(a.bars[e]);const c={type:l?"mod":o?"drum":"pitch",name:a.name,instruments:r,patterns:h,sequence:u};o||(c.octaveScrollBar=a.octave-1),s.push(c)}return{name:this.title,subname:this.subtitle,format:X.H,version:X.M,scale:t.scales[this.scale].name,key:t.keys[this.key].name,introBars:this.loopStart,loopBars:this.loopLength,beatsPerBar:this.beatsPerBar,ticksPerBeat:t.rhythms[this.rhythm].stepsPerBeat,beatsPerMinute:this.tempo,reverb:this.reverb,masterGain:this.masterGain,compressionThreshold:this.compressionThreshold,limitThreshold:this.limitThreshold,limitDecay:this.limitDecay,limitRise:this.limitRise,limitRatio:this.limitRatio,compressionRatio:this.compressionRatio,layeredInstruments:this.layeredInstruments,patternInstruments:this.patternInstruments,channels:s}}fromJsonObject(e){if(this.initToDefault(!0),!e)return;if(null!=e.name&&(this.title=e.name),null!=e.subname&&(this.subtitle=e.subname),this.scale=0,null!=e.scale){const i={"romani :)":"dbl harmonic :)","romani :(":"dbl harmonic :(",enigma:"strange"},n=null!=i[e.scale]?i[e.scale]:e.scale,s=t.scales.findIndex((e=>e.name==n));-1!=s&&(this.scale=s)}if(null!=e.key)if("number"==typeof e.key)this.key=(e.key+1200>>>0)%t.keys.length;else if("string"==typeof e.key){const t=e.key,i=t.charAt(0).toUpperCase(),n=t.charAt(1).toLowerCase();let s={C:0,D:2,E:4,F:5,G:7,A:9,B:11}[i];const a={"#":1,"♯":1,b:-1,"♭":-1}[n];null!=s&&(null!=a&&(s+=a),s<0&&(s+=12),s%=12,this.key=s)}null!=e.beatsPerMinute&&(this.tempo=O(t.tempoMin,t.tempoMax+1,0|e.beatsPerMinute));let i=0;null!=e.reverb&&(i=O(0,32,0|e.reverb)),null!=e.beatsPerBar&&(this.beatsPerBar=Math.max(t.beatsPerBarMin,Math.min(t.beatsPerBarMax,0|e.beatsPerBar)));let n=4;null!=e.ticksPerBeat&&(n=0|e.ticksPerBeat||4,this.rhythm=t.rhythms.findIndex((e=>e.stepsPerBeat==n)),-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 s=1,a=1,r=1;if(null!=e.channels)for(const t of e.channels)t.instruments&&(s=Math.max(s,0|t.instruments.length)),t.patterns&&(a=Math.max(a,0|t.patterns.length)),t.sequence&&(r=Math.max(r,0|t.sequence.length));null!=e.layeredInstruments?this.layeredInstruments=!!e.layeredInstruments:this.layeredInstruments=!1,null!=e.patternInstruments?this.patternInstruments=!!e.patternInstruments:this.patternInstruments=s>1,this.patternsPerChannel=Math.min(a,t.barCountMax),this.barCount=Math.min(r,t.barCountMax),null!=e.introBars&&(this.loopStart=O(0,this.barCount,0|e.introBars)),null!=e.loopBars&&(this.loopLength=O(1,this.barCount-this.loopStart+1,0|e.loopBars));const o=[],l=[],h=[];if(null!=e.channels)for(let s=0;s<e.channels.length;s++){let a=e.channels[s];const r=new Y;let u=!1,c=!1;if(null!=a.type?(u="drum"==a.type,c="mod"==a.type):u=s>=3,u?l.push(r):c?h.push(r):o.push(r),null!=a.octaveScrollBar&&(r.octave=O(0,t.pitchOctaves,1+(0|a.octaveScrollBar)),u&&(r.octave=0)),null!=a.name?r.name=a.name:r.name="",Array.isArray(a.instruments)){const e=a.instruments;for(let t=0;t<e.length&&!(t>=this.getMaxInstrumentsPerChannel());t++){const n=new _(u,c);r.instruments[t]=n,n.fromJsonObject(e[t],u,c,!1,!1,i)}}for(let e=0;e<this.patternsPerChannel;e++){const t=new V;let i;r.patterns[e]=t,a.patterns&&(i=a.patterns[e]),null!=i&&t.fromJsonObject(i,this,r,n,u,c)}r.patterns.length=this.patternsPerChannel;for(let e=0;e<this.barCount;e++)r.bars[e]=null!=a.sequence?Math.min(this.patternsPerChannel,a.sequence[e]>>>0):0;r.bars.length=this.barCount}o.length>t.pitchChannelCountMax&&(o.length=t.pitchChannelCountMax),l.length>t.noiseChannelCountMax&&(l.length=t.noiseChannelCountMax),h.length>t.modChannelCountMax&&(h.length=t.modChannelCountMax),this.pitchChannelCount=o.length,this.noiseChannelCount=l.length,this.modChannelCount=h.length,this.channels.length=0,Array.prototype.push.apply(this.channels,o),Array.prototype.push.apply(this.channels,l),Array.prototype.push.apply(this.channels,h)}getPattern(e,t){if(t<0||t>=this.barCount)return null;const i=this.channels[e].bars[t];return 0==i?null:this.channels[e].patterns[i-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}}X.H="BeepBox",X.P=2,X.T=9,X.I=1,X.M=5,X.k=106;class Z{constructor(){this.delayLine=null,this.allPassG=0,this.allPassGDelta=0,this.shelfA1=0,this.shelfA1Delta=0,this.shelfB0=0,this.shelfB0Delta=0,this.shelfB1=0,this.shelfB1Delta=0,this.reset()}reset(){this.delayIndex=-1,this.allPassSample=0,this.allPassPrevInput=0,this.shelfSample=0,this.shelfPrevInput=0,this.fractionalDelaySample=0,this.prevDelayLength=-1,this.delayResetOffset=0}update(e,i,n,s,a,r,o){const l=2*Math.PI*t.pickedStringDispersionCenterFreq/e.samplesPerSecond,h=2*Math.PI*t.pickedStringShelfHz/e.samplesPerSecond,u=(Math.pow(100,r)-1)/99,c=(Math.pow(100,o)-1)/99,p=this.prevDelayLength,f=n.phaseDeltas[s],m=n.phaseDeltaScales[s],d=f*Math.pow(m,a),y=2*Math.PI*f,v=2*Math.PI*d,g=2*y,b=2*v,S=Math.min(Math.PI,y*t.pickedStringDispersionFreqMult*Math.pow(l/y,t.pickedStringDispersionFreqScale)),w=Math.min(Math.PI,v*t.pickedStringDispersionFreqMult*Math.pow(l/v,t.pickedStringDispersionFreqScale)),k=Math.pow(.5,u*h/y),M=Math.pow(.5,c*h/v),F=Math.pow(k,t.stringDecayRate),q=Math.pow(M,t.stringDecayRate),T=Math.pow(k,.002),P=Math.pow(M,.002);se.tempFilterStartCoefficients.allPass1stOrderInvertPhaseAbove(S),e.tempFrequencyResponse.analyze(se.tempFilterStartCoefficients,g);const I=se.tempFilterStartCoefficients.b[0],z=-e.tempFrequencyResponse.angle()/g;se.tempFilterEndCoefficients.allPass1stOrderInvertPhaseAbove(w),e.tempFrequencyResponse.analyze(se.tempFilterEndCoefficients,b);const H=se.tempFilterEndCoefficients.b[0],x=-e.tempFrequencyResponse.angle()/b;se.tempFilterStartCoefficients.highShelf1stOrder(h,F),e.tempFrequencyResponse.analyze(se.tempFilterStartCoefficients,g);const D=se.tempFilterStartCoefficients.a[1],O=se.tempFilterStartCoefficients.b[0]*T,G=se.tempFilterStartCoefficients.b[1]*T,A=-e.tempFrequencyResponse.angle()/g;se.tempFilterEndCoefficients.highShelf1stOrder(h,q),e.tempFrequencyResponse.analyze(se.tempFilterEndCoefficients,b);const R=se.tempFilterEndCoefficients.a[1],C=se.tempFilterEndCoefficients.b[0]*P,E=se.tempFilterEndCoefficients.b[1]*P,L=-e.tempFrequencyResponse.angle()/b,N=1/f,V=1/d,W=Math.ceil(2*Math.max(N,V)),B=N-z-A,$=V-x-L;this.prevDelayLength=B,this.delayLengthDelta=($-B)/a,this.allPassG=I,this.shelfA1=D,this.shelfB0=O,this.shelfB1=G,this.allPassGDelta=(H-I)/a,this.shelfA1Delta=(R-D)/a,this.shelfB0Delta=(C-O)/a,this.shelfB1Delta=(E-G)/a;const j=Math.abs(Math.log2(B/p))>.01,U=-1==this.delayIndex||j;if(null==this.delayLine||this.delayLine.length<=W){const t=Math.ceil(2*e.samplesPerSecond/_.frequencyFromPitch(12)),i=new Float32Array(se.fittingPowerOfTwo(Math.max(t,W)));if(!U&&null!=this.delayLine){const e=this.delayLine.length-1>>0,t=this.delayIndex+this.delayResetOffset;this.delayIndex=this.delayLine.length-this.delayResetOffset;for(let n=0;n<this.delayLine.length;n++)i[n]=this.delayLine[t+n&e]}this.delayLine=i}const Q=this.delayLine,K=Q.length-1>>0;if(U){this.delayIndex=0,this.allPassSample=0,this.allPassPrevInput=0,this.shelfSample=0,this.shelfPrevInput=0,this.fractionalDelaySample=0;const t=-B,n=Math.floor(t-N/2),s=Math.ceil(n+2*N);this.delayResetOffset=s;for(let e=n;e<=s;e++)Q[e&K]=0;const a=i.wave,r=a.length-1,o=r/N,l=Math.min(.2*N,.003*e.samplesPerSecond),h=Math.ceil(t),u=t+N+l,c=u;let p=(h-t)*o,f=0;for(let e=h;e<=c;e++){const i=0|p,n=i%r;let s=a[n];const h=p-i;s+=(a[n+1]-s)*h;const c=(s-f)/o,m=Math.min(1,(e-t)/l)*Math.min(1,(u-e)/l),d=m*m*(3-2*m);Q[e&K]+=c*d,f=s,p+=o}}}}class ee{constructor(){this.noteSecondsStart=0,this.noteSecondsEnd=0,this.noteTicksStart=0,this.noteTicksEnd=0,this.noteSizeStart=t.noteSizeMax,this.noteSizeEnd=t.noteSizeMax,this.prevNoteSize=t.noteSizeMax,this.nextNoteSize=t.noteSizeMax,this.O=t.noteSizeMax,this.prevNoteSecondsStart=0,this.prevNoteSecondsEnd=0,this.prevNoteTicksStart=0,this.prevNoteTicksEnd=0,this.R=t.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.L=[],this.N=0,this.lowpassCutoffDecayVolumeCompensation=1;for(let e=0;e<33;e++)this.envelopeStarts[e]=1,this.envelopeEnds[e]=1;this.reset()}reset(){this.noteSecondsEnd=0,this.noteTicksEnd=0,this.O=t.noteSizeMax,this.prevNoteSecondsEnd=0,this.prevNoteTicksEnd=0,this.R=t.noteSizeMax,this.N=0}computeEnvelopes(e,i,n,s,a){const r=e.getTransition();null==a||!a.atNoteStart||r.continues||a.forceContinueAtStart||(this.prevNoteSecondsEnd=this.noteSecondsEnd,this.prevNoteTicksEnd=this.noteTicksEnd,this.R=this.O,this.noteSecondsEnd=0,this.noteTicksEnd=0),null!=a&&(null!=a.note?this.O=a.note.pins[a.note.pins.length-1].size:this.O=t.noteSizeMax);const o=n+1,l=this.noteSecondsEnd,h=l+s,u=this.noteTicksEnd,c=u+1,p=this.prevNoteSecondsEnd,f=p+s,m=this.prevNoteTicksEnd,d=m+1,y=1/(t.ticksPerPart*t.partsPerBeat),v=y*n,g=y*o;let b=this.O,S=this.O,w=this.R,k=0,M=!1,F=!1,q=!1,T=!1,P=0,I=0,z=0,H=0;if(null!=a&&null!=a.note&&!a.passedEndOfNote){const s=a.note.getEndPinIndex(i),l=a.note.pins[s-1],h=a.note.pins[s],u=(a.note.start+l.time)*t.ticksPerPart,c=(a.note.start+h.time)*t.ticksPerPart,p=(n-u)/(c-u),f=(o-u)/(c-u);if(b=l.size+(h.size-l.size)*p,S=l.size+(h.size-l.size)*f,r.slides){const i=a.noteStartPart*t.ticksPerPart,s=a.noteEndPart*t.ticksPerPart,l=.5*(s-i);let h=Math.min(l,r.slideTicks);!!t.transitions[e.transition].slides&&(h+=t.slideSpeedScale[e.slideSpeed]),null==a.prevNote||a.forceContinueAtStart||(n-i<h&&(M=!0,P=.5*(1-(n-i)/h)),o-i<h&&(F=!0,I=.5*(1-(o-i)/h))),null==a.nextNote||a.forceContinueAtEnd||(k=a.nextNote.pins[0].size,s-n<h&&(q=!0,z=.5*(1-(s-n)/h)),s-o<h&&(T=!0,H=.5*(1-(s-o)/h)))}}let x=1,D=!1;for(let i=0;i<=e.envelopeCount;i++){let n,s,a;if(i==e.envelopeCount){if(D)break;n=t.instrumentAutomationTargets.dictionary.noteVolume,s=0,a=t.envelopes.dictionary["note size"]}else{let r=e.envelopes[i];n=t.instrumentAutomationTargets[r.target],s=r.index,a=t.envelopes[r.envelope],0==a.type&&(D=!0)}if(null!=n.computeIndex){const t=n.computeIndex+s;let i=ee.computeEnvelope(a,l,v,b),r=ee.computeEnvelope(a,h,g,S);if(M){i+=(ee.computeEnvelope(a,p,v,w)-i)*P}if(F){r+=(ee.computeEnvelope(a,f,g,w)-r)*I}if(q){i+=(ee.computeEnvelope(a,0,v,k)-i)*z}if(T){r+=(ee.computeEnvelope(a,0,g,k)-r)*H}if(this.envelopeStarts[t]*=i,this.envelopeEnds[t]*=r,this.L[this.N++]=t,n.isFilter){const t=null!=e.tmpNoteFilterStart?e.tmpNoteFilterStart:e.noteFilter;t.controlPointCount>s&&0==t.controlPoints[s].type&&(x=Math.max(x,ee.getLowpassCutoffDecayVolumeCompensation(a)))}}}this.noteSecondsStart=l,this.noteSecondsEnd=h,this.noteTicksStart=u,this.noteTicksEnd=c,this.prevNoteSecondsStart=p,this.prevNoteSecondsEnd=f,this.prevNoteTicksStart=m,this.prevNoteTicksEnd=d,this.prevNoteSize=w,this.nextNoteSize=k,this.noteSizeStart=b,this.noteSizeEnd=S,this.prevSlideStart=M,this.prevSlideEnd=F,this.nextSlideStart=q,this.nextSlideEnd=T,this.prevSlideRatioStart=P,this.prevSlideRatioEnd=I,this.nextSlideRatioStart=z,this.nextSlideRatioEnd=H,this.lowpassCutoffDecayVolumeCompensation=x}clearEnvelopes(){for(let e=0;e<this.N;e++){const t=this.L[e];this.envelopeStarts[t]=1,this.envelopeEnds[t]=1}this.N=0}static computeEnvelope(e,t,i,n){switch(e.type){case 0:return se.noteSizeToVolumeMult(n);case 1:return 1;case 4:return 1/(1+t*e.speed);case 5:return 1-1/(1+t*e.speed);case 6:return.5-.5*Math.cos(2*i*Math.PI*e.speed);case 7:return.75-.25*Math.cos(2*i*Math.PI*e.speed);case 2:return Math.max(1,2-10*t);case 3:const s=.25/Math.sqrt(e.speed);return t<s?t/s:1/(1+(t-s)*e.speed);case 8:return Math.pow(2,-e.speed*t);case 10:const a=.25/Math.sqrt(e.speed);return t<a?(a-t)/a:1;case 9:{const i=.25/Math.sqrt(e.speed),n=.7/Math.sqrt(e.speed),s=2,a=.9;return t<i?(a-s)/i*t+s:t<n?(1-a)/(n-i)*(t-i)+a:1}case 11:{const i=.25/e.speed,n=9.5;return t<i?(t*(1-n)-i*-n)/i:1}case 12:{const i=.25/Math.sqrt(e.speed),n=-.4;return t<i?(t*(1-n)-i*-n)/i:1}case 13:return.5-.5*Math.sin(Math.pow((t+3)/8,-1.3)*(400/e.speed));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 te{constructor(){this.pitches=Array(t.maxChordSize).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.stringSustainStart=0,this.stringSustainEnd=0,this.phases=[],this.operatorWaves=[],this.phaseDeltas=[],this.phaseDeltaScales=[],this.expression=0,this.expressionDelta=0,this.operatorExpressions=[],this.operatorExpressionDeltas=[],this.prevPitchExpressions=Array(t.maxPitchOrOperatorCount).fill(null),this.prevVibrato=null,this.prevStringDecay=null,this.pulseWidth=0,this.pulseWidthDelta=0,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 ee,this.reset()}reset(){this.noiseSample=0;for(let e=0;e<t.maxPitchOrOperatorCount;e++)this.phases[e]=0,this.operatorWaves[e]=t.operatorWaves[0],this.feedbackOutputs[e]=0,this.prevPitchExpressions[e]=null;for(let e=0;e<this.noteFilterCount;e++)this.noteFilters[e].resetOutput();this.noteFilterCount=0,this.initialNoteFilterInput1=0,this.initialNoteFilterInput2=0,this.liveInputSamplesHeld=0;for(const e of this.pickedStrings)e.reset();this.envelopeComputer.reset(),this.prevVibrato=null,this.prevStringDecay=null,this.drumsetPitch=null}}class ie{constructor(){this.awake=!1,this.computed=!1,this.tonesAddedInThisTick=!1,this.flushingDelayLines=!1,this.deactivateAfterThisTick=!1,this.attentuationProgress=0,this.flushedSamples=0,this.activeTones=new P,this.activeModTones=new P,this.releasedTones=new P,this.liveInputTones=new P,this.type=0,this.synthesizer=null,this.wave=null,this.noisePitchFilterMult=1,this.unison=null,this.chord=null,this.effects=0,this.volumeScale=0,this.aliases=!1,this.eqFilterVolume=1,this.eqFilterVolumeDelta=0,this.mixVolume=1,this.mixVolumeDelta=0,this.delayInputMult=0,this.delayInputMultDelta=0,this.distortion=0,this.distortionDelta=0,this.distortionDrive=0,this.distortionDriveDelta=0,this.distortionFractionalInput1=0,this.distortionFractionalInput2=0,this.distortionFractionalInput3=0,this.distortionPrevInput=0,this.distortionNextOutput=0,this.bitcrusherPrevInput=0,this.bitcrusherCurrentOutput=0,this.bitcrusherPhase=1,this.bitcrusherPhaseDelta=0,this.bitcrusherPhaseDeltaScale=1,this.bitcrusherScale=1,this.bitcrusherScaleScale=1,this.bitcrusherFoldLevel=1,this.bitcrusherFoldLevelScale=1,this.eqFilters=[],this.eqFilterCount=0,this.initialEqFilterInput1=0,this.initialEqFilterInput2=0,this.panningDelayLine=null,this.panningDelayPos=0,this.panningVolumeL=0,this.panningVolumeR=0,this.panningVolumeDeltaL=0,this.panningVolumeDeltaR=0,this.panningOffsetL=0,this.panningOffsetR=0,this.panningOffsetDeltaL=0,this.panningOffsetDeltaR=0,this.chorusDelayLineL=null,this.chorusDelayLineR=null,this.chorusDelayLineDirty=!1,this.chorusDelayPos=0,this.chorusPhase=0,this.chorusVoiceMult=0,this.chorusVoiceMultDelta=0,this.chorusCombinedMult=0,this.chorusCombinedMultDelta=0,this.echoDelayLineL=null,this.echoDelayLineR=null,this.echoDelayLineDirty=!1,this.echoDelayPos=0,this.echoDelayOffsetStart=0,this.echoDelayOffsetEnd=null,this.echoDelayOffsetRatio=0,this.echoDelayOffsetRatioDelta=0,this.echoMult=0,this.echoMultDelta=0,this.echoShelfA1=0,this.echoShelfB0=0,this.echoShelfB1=0,this.echoShelfSampleL=0,this.echoShelfSampleR=0,this.echoShelfPrevInputL=0,this.echoShelfPrevInputR=0,this.reverbDelayLine=null,this.reverbDelayLineDirty=!1,this.reverbDelayPos=0,this.reverbMult=0,this.reverbMultDelta=0,this.reverbShelfA1=0,this.reverbShelfB0=0,this.reverbShelfB1=0,this.reverbShelfSample0=0,this.reverbShelfSample1=0,this.reverbShelfSample2=0,this.reverbShelfSample3=0,this.reverbShelfPrevInput0=0,this.reverbShelfPrevInput1=0,this.reverbShelfPrevInput2=0,this.reverbShelfPrevInput3=0,this.spectrumWave=new $,this.harmonicsWave=new U,this.drumsetSpectrumWaves=[];for(let e=0;e<t.drumCount;e++)this.drumsetSpectrumWaves[e]=new $}allocateNecessaryBuffers(e,i,n){if(b(i.effects)&&(null==this.panningDelayLine||this.panningDelayLine.length<e.panningDelayBufferSize)&&(this.panningDelayLine=new Float32Array(e.panningDelayBufferSize)),S(i.effects)&&((null==this.chorusDelayLineL||this.chorusDelayLineL.length<e.chorusDelayBufferSize)&&(this.chorusDelayLineL=new Float32Array(e.chorusDelayBufferSize)),(null==this.chorusDelayLineR||this.chorusDelayLineR.length<e.chorusDelayBufferSize)&&(this.chorusDelayLineR=new Float32Array(e.chorusDelayBufferSize))),w(i.effects)){const e=Math.max(t.echoDelayRange>>1,i.echoDelay+1),s=2*se.fittingPowerOfTwo(e*t.echoDelayStepTicks*n);if(null==this.echoDelayLineL||null==this.echoDelayLineR)this.echoDelayLineL=new Float32Array(s),this.echoDelayLineR=new Float32Array(s);else if(this.echoDelayLineL.length<s||this.echoDelayLineR.length<s){const e=new Float32Array(s),t=new Float32Array(s),i=this.echoDelayLineL.length-1;for(let n=0;n<this.echoDelayLineL.length;n++)e[n]=this.echoDelayLineL[this.echoDelayPos+n&i],t[n]=this.echoDelayLineL[this.echoDelayPos+n&i];this.echoDelayPos=this.echoDelayLineL.length,this.echoDelayLineL=e,this.echoDelayLineR=t}}k(i.effects)&&null==this.reverbDelayLine&&(this.reverbDelayLine=new Float32Array(t.reverbDelayBufferSize))}deactivate(){this.bitcrusherPrevInput=0,this.bitcrusherCurrentOutput=0,this.bitcrusherPhase=1;for(let e=0;e<this.eqFilterCount;e++)this.eqFilters[e].resetOutput();if(this.eqFilterCount=0,this.initialEqFilterInput1=0,this.initialEqFilterInput2=0,this.distortionFractionalInput1=0,this.distortionFractionalInput2=0,this.distortionFractionalInput3=0,this.distortionPrevInput=0,this.distortionNextOutput=0,this.panningDelayPos=0,null!=this.panningDelayLine)for(let e=0;e<this.panningDelayLine.length;e++)this.panningDelayLine[e]=0;this.echoDelayOffsetEnd=null,this.echoShelfSampleL=0,this.echoShelfSampleR=0,this.echoShelfPrevInputL=0,this.echoShelfPrevInputR=0,this.reverbShelfSample0=0,this.reverbShelfSample1=0,this.reverbShelfSample2=0,this.reverbShelfSample3=0,this.reverbShelfPrevInput0=0,this.reverbShelfPrevInput1=0,this.reverbShelfPrevInput2=0,this.reverbShelfPrevInput3=0,this.volumeScale=1,this.aliases=!1,this.awake=!1,this.flushingDelayLines=!1,this.deactivateAfterThisTick=!1,this.attentuationProgress=0,this.flushedSamples=0}resetAllEffects(){if(this.deactivate(),this.chorusDelayLineDirty){for(let e=0;e<this.chorusDelayLineL.length;e++)this.chorusDelayLineL[e]=0;for(let e=0;e<this.chorusDelayLineR.length;e++)this.chorusDelayLineR[e]=0}if(this.echoDelayLineDirty){for(let e=0;e<this.echoDelayLineL.length;e++)this.echoDelayLineL[e]=0;for(let e=0;e<this.echoDelayLineR.length;e++)this.echoDelayLineR[e]=0}if(this.reverbDelayLineDirty)for(let e=0;e<this.reverbDelayLine.length;e++)this.reverbDelayLine[e]=0;this.chorusPhase=0}compute(e,i,n,s,a,r,o){this.computed=!0,this.type=i.type,this.synthesizer=se.getInstrumentSynthFunction(i),this.unison=t.unisons[i.unison],this.chord=i.getChord(),this.noisePitchFilterMult=t.chipNoises[i.chipNoise].pitchFilterMult,this.effects=i.effects,this.aliases=i.aliases,this.volumeScale=1,this.allocateNecessaryBuffers(e,i,n);const l=e.samplesPerSecond;this.updateWaves(i,l);const h=v(this.effects),u=g(this.effects),c=b(this.effects),p=S(this.effects),f=w(this.effects),m=k(this.effects);if(h){let n=i.distortion,a=i.distortion;e.isModActive(t.modulators.dictionary.distortion.index,r,o)&&(n=e.getModValue(t.modulators.dictionary.distortion.index,r,o,!1),a=e.getModValue(t.modulators.dictionary.distortion.index,r,o,!0));const l=Math.min(1,n/(t.distortionRange-1)),h=Math.min(1,a/(t.distortionRange-1)),u=Math.pow(1-.895*(Math.pow(20,l)-1)/19,2),c=Math.pow(1-.895*(Math.pow(20,h)-1)/19,2),p=(1+2*l)/t.distortionBaseVolume,f=(1+2*h)/t.distortionBaseVolume;this.distortion=u,this.distortionDelta=(c-u)/s,this.distortionDrive=p,this.distortionDriveDelta=(f-p)/s}if(u){let n=i.bitcrusherFreq,a=i.bitcrusherFreq;e.isModActive(t.modulators.dictionary["freq crush"].index,r,o)&&(n=e.getModValue(t.modulators.dictionary["freq crush"].index,r,o,!1),a=e.getModValue(t.modulators.dictionary["freq crush"].index,r,o,!0));let h=i.bitcrusherQuantization,u=i.bitcrusherQuantization;e.isModActive(t.modulators.dictionary["bit crush"].index,r,o)&&(h=e.getModValue(t.modulators.dictionary["bit crush"].index,r,o,!1),u=e.getModValue(t.modulators.dictionary["bit crush"].index,r,o,!0));const c=t.keys[e.song.key].basePitch,p=_.frequencyFromPitch(c+60)*Math.pow(2,(t.bitcrusherFreqRange-1-n)*t.bitcrusherOctaveStep),f=_.frequencyFromPitch(c+60)*Math.pow(2,(t.bitcrusherFreqRange-1-a)*t.bitcrusherOctaveStep),m=Math.min(1,p/l),d=Math.min(1,f/l);this.bitcrusherPhaseDelta=m,this.bitcrusherPhaseDeltaScale=Math.pow(d/m,1/s);const y=2*t.bitcrusherBaseVolume*Math.pow(2,1-Math.pow(2,.5*(t.bitcrusherQuantizationRange-1-h))),v=2*t.bitcrusherBaseVolume*Math.pow(2,1-Math.pow(2,.5*(t.bitcrusherQuantizationRange-1-u)));this.bitcrusherScale=y,this.bitcrusherScaleScale=Math.pow(v/y,1/s);const g=2*t.bitcrusherBaseVolume*Math.pow(1.5,t.bitcrusherQuantizationRange-1-h),b=2*t.bitcrusherBaseVolume*Math.pow(1.5,t.bitcrusherQuantizationRange-1-u);this.bitcrusherFoldLevel=g,this.bitcrusherFoldLevelScale=Math.pow(b/g,1/s)}let d=1;if(i.eqFilterType){const n=i.eqFilter;null==i.eqSubFilters[1]&&(i.eqSubFilters[1]=new K);const a=i.eqSubFilters[1];let h,u=i.eqFilterSimpleCut,c=i.eqFilterSimplePeak,p=i.eqFilterSimpleCut,f=i.eqFilterSimplePeak,m=!1;if(e.isModActive(t.modulators.dictionary["eq filt cut"].index,r,o)&&(u=e.getModValue(t.modulators.dictionary["eq filt cut"].index,r,o,!1),p=e.getModValue(t.modulators.dictionary["eq filt cut"].index,r,o,!0),m=!0),e.isModActive(t.modulators.dictionary["eq filt peak"].index,r,o)&&(c=e.getModValue(t.modulators.dictionary["eq filt peak"].index,r,o,!1),f=e.getModValue(t.modulators.dictionary["eq filt peak"].index,r,o,!0),m=!0),m){n.convertLegacySettingsForSynth(u,c),a.convertLegacySettingsForSynth(p,f),h=n.controlPoints[0];let e=a.controlPoints[0];h.toCoefficients(se.tempFilterStartCoefficients,l,1,1),e.toCoefficients(se.tempFilterEndCoefficients,l,1,1),this.eqFilters.length<1&&(this.eqFilters[0]=new H),this.eqFilters[0].loadCoefficientsWithGradient(se.tempFilterStartCoefficients,se.tempFilterEndCoefficients,1/s,0==h.type)}else n.convertLegacySettingsForSynth(u,c,!0),h=n.controlPoints[0],h.toCoefficients(se.tempFilterStartCoefficients,l,1,1),this.eqFilters.length<1&&(this.eqFilters[0]=new H),this.eqFilters[0].loadCoefficientsWithGradient(se.tempFilterStartCoefficients,se.tempFilterStartCoefficients,1/s,0==h.type);d*=h.getVolumeCompensationMult(),this.eqFilterCount=1,d=Math.min(3,d)}else{const e=null!=i.tmpEqFilterStart?i.tmpEqFilterStart:i.eqFilter;for(let t=0;t<e.controlPointCount;t++){let n=e.controlPoints[t],a=null!=i.tmpEqFilterEnd&&null!=i.tmpEqFilterEnd.controlPoints[t]?i.tmpEqFilterEnd.controlPoints[t]:e.controlPoints[t];n.type!=a.type&&(n=a),n.toCoefficients(se.tempFilterStartCoefficients,l,1,1),a.toCoefficients(se.tempFilterEndCoefficients,l,1,1),this.eqFilters.length<=t&&(this.eqFilters[t]=new H),this.eqFilters[t].loadCoefficientsWithGradient(se.tempFilterStartCoefficients,se.tempFilterEndCoefficients,1/s,0==n.type),d*=n.getVolumeCompensationMult()}this.eqFilterCount=e.controlPointCount,d=Math.min(3,d)}const y=se.instrumentVolumeToVolumeMult(i.volume);this.mixVolume=y;let M=y;if(e.isModActive(t.modulators.dictionary["mix volume"].index,r,o)){const i=e.getModValue(t.modulators.dictionary["mix volume"].index,r,o,!1),n=e.getModValue(t.modulators.dictionary["mix volume"].index,r,o,!0);this.mixVolume*=i<=0?(i+t.volumeRange/2)/(t.volumeRange/2):se.instrumentVolumeToVolumeMult(i),M*=n<=0?(n+t.volumeRange/2)/(t.volumeRange/2):se.instrumentVolumeToVolumeMult(n)}e.isModActive(t.modulators.dictionary["song volume"].index)&&(this.mixVolume*=e.getModValue(t.modulators.dictionary["song volume"].index,void 0,void 0,!1)/100,M*=e.getModValue(t.modulators.dictionary["song volume"].index,void 0,void 0,!0)/100),this.mixVolumeDelta=(M-this.mixVolume)/s;let F=d,q=d,T=1,P=1;if(c){let n=i.pan,a=i.pan;e.isModActive(t.modulators.dictionary.pan.index,r,o)&&(n=e.getModValue(t.modulators.dictionary.pan.index,r,o,!1),a=e.getModValue(t.modulators.dictionary.pan.index,r,o,!0));let h=Math.max(-1,Math.min(1,(n-t.panCenter)/t.panCenter)),u=Math.max(-1,Math.min(1,(a-t.panCenter)/t.panCenter));const c=1.414*Math.cos((1+h)*Math.PI*.25),p=1.414*Math.cos((1-h)*Math.PI*.25),f=1.414*Math.cos((1+u)*Math.PI*.25),m=1.414*Math.cos((1-u)*Math.PI*.25),d=l*t.panDelaySecondsMax;let y=i.panDelay,v=i.panDelay;e.isModActive(t.modulators.dictionary["pan delay"].index,r,o)&&(y=e.getModValue(t.modulators.dictionary["pan delay"].index,r,o,!1),v=e.getModValue(t.modulators.dictionary["pan delay"].index,r,o,!0));const g=h*y*d/10,b=u*v*d/10,S=Math.max(0,g),w=Math.max(0,-g),k=Math.max(0,b),M=Math.max(0,-b);this.panningVolumeL=c,this.panningVolumeR=p,this.panningVolumeDeltaL=(f-c)/s,this.panningVolumeDeltaR=(m-p)/s,this.panningOffsetL=this.panningDelayPos-S+e.panningDelayBufferSize,this.panningOffsetR=this.panningDelayPos-w+e.panningDelayBufferSize,this.panningOffsetDeltaL=(k-S)/s,this.panningOffsetDeltaR=(M-w)/s}if(p){let n=i.chorus,a=i.chorus;e.isModActive(t.modulators.dictionary.chorus.index,r,o)&&(n=e.getModValue(t.modulators.dictionary.chorus.index,r,o,!1),a=e.getModValue(t.modulators.dictionary.chorus.index,r,o,!0));let l=Math.min(1,n/(t.chorusRange-1)),h=Math.min(1,a/(t.chorusRange-1));l=.6*l+.4*Math.pow(l,6),h=.6*h+.4*Math.pow(h,6);const u=1/Math.sqrt(3*l*l+1),c=1/Math.sqrt(3*h*h+1);this.chorusVoiceMult=l,this.chorusVoiceMultDelta=(h-l)/s,this.chorusCombinedMult=u,this.chorusCombinedMultDelta=(c-u)/s}let I=0,z=0;if(f){let a=i.echoSustain,h=i.echoSustain;e.isModActive(t.modulators.dictionary.echo.index,r,o)&&(a=Math.max(0,e.getModValue(t.modulators.dictionary.echo.index,r,o,!1)),h=Math.max(0,e.getModValue(t.modulators.dictionary.echo.index,r,o,!0)));const u=.9*Math.min(1,Math.pow(a/t.echoSustainRange,1.1)),c=.9*Math.min(1,Math.pow(h/t.echoSustainRange,1.1));this.echoMult=u,this.echoMultDelta=Math.max(0,(c-u)/s),I=Math.max(u,c);let p=i.echoDelay,f=i.echoDelay,m=!1;e.isModActive(t.modulators.dictionary["echo delay"].index,r,o)&&(p=e.getModValue(t.modulators.dictionary["echo delay"].index,r,o,!1),f=e.getModValue(t.modulators.dictionary["echo delay"].index,r,o,!0),m=!0);const d=Math.round((p+1)*t.echoDelayStepTicks*n),y=Math.round((f+1)*t.echoDelayStepTicks*n);null==this.echoDelayOffsetEnd||m?this.echoDelayOffsetStart=d:this.echoDelayOffsetStart=this.echoDelayOffsetEnd,this.echoDelayOffsetEnd=y,z=.5*(this.echoDelayOffsetStart+this.echoDelayOffsetEnd)/l,this.echoDelayOffsetRatio=0,this.echoDelayOffsetRatioDelta=1/s;const v=2*Math.PI*t.echoShelfHz/e.samplesPerSecond;se.tempFilterStartCoefficients.highShelf1stOrder(v,t.echoShelfGain),this.echoShelfA1=se.tempFilterStartCoefficients.a[1],this.echoShelfB0=se.tempFilterStartCoefficients.b[0],this.echoShelfB1=se.tempFilterStartCoefficients.b[1]}let x=0;if(m){let n=i.reverb,a=i.reverb;e.isModActive(t.modulators.dictionary.reverb.index,r,o)&&(n=e.getModValue(t.modulators.dictionary.reverb.index,r,o,!1),a=e.getModValue(t.modulators.dictionary.reverb.index,r,o,!0)),e.isModActive(t.modulators.dictionary["song reverb"].index,r,o)&&(n*=(e.getModValue(t.modulators.dictionary["song reverb"].index,void 0,void 0,!1)-t.modulators.dictionary["song reverb"].convertRealFactor)/t.reverbRange,a*=(e.getModValue(t.modulators.dictionary["song reverb"].index,void 0,void 0,!0)-t.modulators.dictionary["song reverb"].convertRealFactor)/t.reverbRange);const l=.425*Math.min(1,Math.pow(n/t.reverbRange,.667)),h=.425*Math.min(1,Math.pow(a/t.reverbRange,.667));this.reverbMult=l,this.reverbMultDelta=(h-l)/s,x=Math.max(l,h);const u=2*Math.PI*t.reverbShelfHz/e.samplesPerSecond;se.tempFilterStartCoefficients.highShelf1stOrder(u,t.reverbShelfGain),this.reverbShelfA1=se.tempFilterStartCoefficients.a[1],this.reverbShelfB0=se.tempFilterStartCoefficients.b[0],this.reverbShelfB1=se.tempFilterStartCoefficients.b[1]}if(this.tonesAddedInThisTick)this.attentuationProgress=0,this.flushedSamples=0,this.flushingDelayLines=!1;else if(this.flushingDelayLines){F=0,q=0,T=0,P=0;let i=0;p&&(i+=e.chorusDelayBufferSize),f&&(i+=this.echoDelayLineL.length),m&&(i+=t.reverbDelayBufferSize),this.flushedSamples+=s,this.flushedSamples>=i&&(this.deactivateAfterThisTick=!0)}else{0==this.attentuationProgress||(F=0),q=0;const e=1/256,i=-Math.log2(e);let s=0;if(p&&(s+=t.chorusMaxDelay),f){const e=Math.pow(I,1/z);s+=-1/Math.log2(e)*i}if(m){const e=2*x,n=t.reverbDelayBufferSize/4/l,a=Math.pow(e,1/n);s+=-1/Math.log2(a)*i}const a=n/l/s,r=this.attentuationProgress+a;r>=1&&(P=0),this.attentuationProgress=r,this.attentuationProgress>=1&&(this.flushingDelayLines=!0)}this.eqFilterVolume=F,this.eqFilterVolumeDelta=(q-F)/s,this.delayInputMult=T,this.delayInputMultDelta=(P-T)/s}updateWaves(e,i){if(this.volumeScale=1,0==e.type)this.wave=this.aliases?t.rawChipWaves[e.chipWave].samples:t.chipWaves[e.chipWave].samples;else if(8==e.type)this.wave=this.aliases?e.customChipWave:e.customChipWaveIntegral,this.volumeScale=.05;else if(2==e.type)this.wave=a(e.chipNoise,T,F);else if(5==e.type)this.wave=this.harmonicsWave.getCustomWave(e.harmonicsWave,e.type);else if(7==e.type)this.wave=this.harmonicsWave.getCustomWave(e.harmonicsWave,e.type);else if(3==e.type)this.wave=this.spectrumWave.getCustomWave(e.spectrumWave,8);else if(4==e.type){for(let i=0;i<t.drumCount;i++)this.drumsetSpectrumWaves[i].getCustomWave(e.drumsetSpectrumWaves[i],ie.V(i));this.wave=null}else this.wave=null}getDrumsetWave(e){if(4==this.type)return this.drumsetSpectrumWaves[e].wave;throw new Error("Unhandled instrument type in getDrumsetWave")}static drumsetIndexReferenceDelta(e){return _.frequencyFromPitch(t.spectrumBasePitch+6*e)/44100}static V(e){return 15+Math.log2(ie.drumsetIndexReferenceDelta(e))}}class ne{constructor(){this.instruments=[],this.muted=!1,this.singleSeamlessInstrument=null}}class se{constructor(e=null){this.samplesPerSecond=44100,this.song=null,this.preferLowerLatency=!1,this.anticipatePoorPerformance=!1,this.liveInputDuration=0,this.liveInputStarted=!1,this.liveInputPitches=[],this.liveInputChannel=0,this.liveInputInstruments=[],this.loopRepeatCount=-1,this.volume=1,this.oscRefreshEventTimer=0,this.oscEnabled=!0,this.oscilloscopeScale=1,this.enableMetronome=!1,this.countInMetronome=!1,this.renderingSong=!1,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 Q,this.tempFrequencyResponse=new z,this.channels=[],this.tonePool=new P,this.tempMatchedPitchTones=Array(t.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,i=t.getChannelData(0),n=t.getChannelData(1);if(!this.browserAutomaticallyClearsAudioBuffer||0==i[0]&&0==n[0]&&0==i[t.length-1]&&0==n[t.length-1]||(this.browserAutomaticallyClearsAudioBuffer=!1),!this.browserAutomaticallyClearsAudioBuffer){const e=t.length;for(let t=0;t<e;t++)i[t]=0,n[t]=0}!this.isPlayingSong&&performance.now()>=this.liveInputEndTime?this.deactivateAudio():(this.synthesize(i,n,t.length,this.isPlayingSong),this.oscEnabled&&(this.oscRefreshEventTimer<=0?(x.raise("oscilloscopeUpdate",this.oscilloscopeScale,i,n),this.oscRefreshEventTimer=2):this.oscRefreshEventTimer--))},this.computeDelayBufferSizes(),null!=e&&this.setSong(e)}syncSongState(){const e=this.song.getChannelCount();for(let t=this.channels.length;t<e;t++)this.channels[t]=new ne;this.channels.length=e;for(let t=0;t<e;t++){const e=this.song.channels[t],i=this.channels[t];for(let t=i.instruments.length;t<e.instruments.length;t++)i.instruments[t]=new ie;if(i.instruments.length=e.instruments.length,i.muted!=e.muted&&(i.muted=e.muted,i.muted))for(const e of i.instruments)e.resetAllEffects()}}warmUpSynthesizer(e){if(null!=e){this.syncSongState();const t=this.getSamplesPerTick();for(let i=0;i<e.getChannelCount();i++)for(let n=0;n<e.channels[i].instruments.length;n++){const s=e.channels[i].instruments[n],a=this.channels[i].instruments[n];se.getInstrumentSynthFunction(s),s.LFOtime=0,s.nextLFOtime=0,s.arpTime=0,s.tmpEqFilterStart=s.eqFilter,s.tmpEqFilterEnd=null,s.tmpNoteFilterStart=s.noteFilter,s.tmpNoteFilterEnd=null,a.updateWaves(s,this.samplesPerSecond),a.allocateNecessaryBuffers(this,s,t)}}var t=new Float32Array(1);this.isPlayingSong=!0,this.synthesize(t,t,1,!0),this.isPlayingSong=!1}computeLatestModValues(){if(null!=this.song&&this.song.modChannelCount>0){let e=[],i=[];this.modValues=[],this.nextModValues=[],this.modInsValues=[],this.nextModInsValues=[];for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++){i[e]=[],this.modInsValues[e]=[],this.nextModInsValues[e]=[];for(let t=0;t<this.song.channels[e].instruments.length;t++)this.modInsValues[e][t]=[],this.nextModInsValues[e][t]=[],i[e][t]=[]}let n=this.beat*t.partsPerBeat+this.part;for(let s=this.song.pitchChannelCount+this.song.noiseChannelCount;s<this.song.getChannelCount();s++)if(!this.song.channels[s].muted){let a;for(let r=this.bar;r>=0;r--)if(a=this.song.getPattern(s,r),null!=a){let o=a.instruments[0],l=this.song.channels[s].instruments[o],h=[],u=[],c=r==this.bar?n:this.findPartsInBar(r);for(const e of a.notes)if(e.start<c&&(null==h[t.modCount-1-e.pitches[0]]||e.end>h[t.modCount-1-e.pitches[0]]))if(e.end<=c)h[t.modCount-1-e.pitches[0]]=e.end,u[t.modCount-1-e.pitches[0]]=e.pins[e.pins.length-1].size;else{h[t.modCount-1-e.pitches[0]]=c;for(let i=0;i<e.pins.length;i++)if(e.pins[i].time+e.start>c){const n=e.pins[i].time-e.pins[i-1].time,s=c-e.start-e.pins[i-1].time,a=e.pins[i].size-e.pins[i-1].size;u[t.modCount-1-e.pitches[0]]=Math.round(e.pins[i-1].size+a*s/n),i=e.pins.length}}for(let n=0;n<t.modCount;n++)if(null!=h[n])if(t.modulators[l.modulators[n]].forSong)(null==e[l.modulators[n]]||r*t.partsPerBeat*this.song.beatsPerBar+h[n]>e[l.modulators[n]])&&(this.setModValue(u[n],u[n],n,l.modChannels[n],l.modInstruments[n],l.modulators[n]),e[l.modulators[n]]=r*t.partsPerBeat*this.song.beatsPerBar+h[n]);else{let e=[];if(l.modInstruments[n]==this.song.channels[l.modChannels[n]].instruments.length)for(let t=0;t<this.song.channels[l.modChannels[n]].instruments.length;t++)e.push(t);else if(l.modInstruments[n]>this.song.channels[l.modChannels[n]].instruments.length){const t=this.song.getPattern(l.modChannels[n],r);null!=t&&(e=t.instruments)}else e.push(l.modInstruments[n]);for(let s=0;s<e.length;s++){const a=l.modulators[n]==t.modulators.dictionary["eq filter"].index,o=l.modulators[n]==t.modulators.dictionary["note filter"].index;let c=l.modulators[n];if(a?c=t.modulators.length+l.modFilterTypes[n]:o&&(c=t.modulators.length+1+2*t.filterMaxPoints+l.modFilterTypes[n]),null==i[l.modChannels[n]][e[s]][c]||r*t.partsPerBeat*this.song.beatsPerBar+h[n]>i[l.modChannels[n]][e[s]][c]){if(a){let i=this.song.channels[l.modChannels[n]].instruments[e[s]];if(0==l.modFilterTypes[n])i.tmpEqFilterStart=i.eqSubFilters[u[n]];else{for(let e=0;e<t.filterMorphCount;e++)i.tmpEqFilterStart==i.eqSubFilters[e]&&(i.tmpEqFilterStart=new K,i.tmpEqFilterStart.fromJsonObject(i.eqSubFilters[e].toJsonObject()),e=t.filterMorphCount);Math.floor((l.modFilterTypes[n]-1)/2)<i.tmpEqFilterStart.controlPointCount&&(l.modFilterTypes[n]%2?i.tmpEqFilterStart.controlPoints[Math.floor((l.modFilterTypes[n]-1)/2)].freq=u[n]:i.tmpEqFilterStart.controlPoints[Math.floor((l.modFilterTypes[n]-1)/2)].gain=u[n])}i.tmpEqFilterEnd=i.tmpEqFilterStart}else if(o){let i=this.song.channels[l.modChannels[n]].instruments[e[s]];if(0==l.modFilterTypes[n])i.tmpNoteFilterStart=i.noteSubFilters[u[n]];else{for(let e=0;e<t.filterMorphCount;e++)i.tmpNoteFilterStart==i.noteSubFilters[e]&&(i.tmpNoteFilterStart=new K,i.tmpNoteFilterStart.fromJsonObject(i.noteSubFilters[e].toJsonObject()),e=t.filterMorphCount);Math.floor((l.modFilterTypes[n]-1)/2)<i.tmpNoteFilterStart.controlPointCount&&(l.modFilterTypes[n]%2?i.tmpNoteFilterStart.controlPoints[Math.floor((l.modFilterTypes[n]-1)/2)].freq=u[n]:i.tmpNoteFilterStart.controlPoints[Math.floor((l.modFilterTypes[n]-1)/2)].gain=u[n])}i.tmpNoteFilterEnd=i.tmpNoteFilterStart}else this.setModValue(u[n],u[n],n,l.modChannels[n],e[s],c);i[l.modChannels[n]][e[s]][c]=r*t.partsPerBeat*this.song.beatsPerBar+h[n]}}}}}}}determineInvalidModulators(e){if(null!=this.song)for(let i=0;i<t.modCount;i++){if(e.invalidModulators[i]=!0,-1==e.modChannels[i]){0!=e.modulators[i]&&(e.invalidModulators[i]=!1);continue}const n=this.song.channels[e.modChannels[i]];if(null==n)continue;let s=[];s=e.modInstruments[i]>=n.instruments.length?n.instruments:[n.instruments[e.modInstruments[i]]];for(let n=0;n<s.length;n++){const a=s[n];if(null==a)continue;const r=t.modulators[e.modulators[i]].name;12!=t.modulators[e.modulators[i]].associatedEffect&&!(a.effects&1<<t.modulators[e.modulators[i]].associatedEffect)||1!=a.type&&("fm slider 1"==r||"fm slider 2"==r||"fm slider 3"==r||"fm slider 4"==r||"fm feedback"==r)||6!=a.type&&"pulse width"==r||!a.getChord().arpeggiates&&("arp speed"==r||"reset arp"==r)||a.eqFilterType&&"eq filter"==r||!a.eqFilterType&&("eq filt cut"==r||"eq filt peak"==r)||"eq filter"==r&&Math.floor((e.modFilterTypes[i]+1)/2)>a.eqFilter.controlPointCount||a.noteFilterType&&"note filter"==r||!a.noteFilterType&&("note filt cut"==r||"note filt peak"==r)||"note filter"==r&&Math.floor((e.modFilterTypes[i]+1)/2)>a.noteFilter.controlPointCount||(e.invalidModulators[i]=!1,n=s.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 i=this.playheadInternal;this.bar=Math.floor(i),i=this.song.beatsPerBar*(i-this.bar),this.beat=Math.floor(i),i=t.partsPerBeat*(i-this.beat),this.part=Math.floor(i),i=t.ticksPerPart*(i-this.part),this.tick=Math.floor(i),this.tickSampleCountdown=0,this.isAtStartOfTick=!0,this.prevBar=null}}getSamplesPerBar(){if(null==this.song)throw new Error;return this.getSamplesPerTick()*t.ticksPerPart*t.partsPerBeat*this.song.beatsPerBar}getTicksIntoBar(){return(this.beat*t.partsPerBeat+this.part)*t.ticksPerPart+this.tick}getCurrentPart(){return this.beat*t.partsPerBeat+this.part}findPartsInBar(e){if(null==this.song)return 0;let i=t.partsPerBeat*this.song.beatsPerBar;for(let n=this.song.pitchChannelCount+this.song.noiseChannelCount;n<this.song.getChannelCount();n++){let s=this.song.getPattern(n,e);if(null!=s){let e=this.song.channels[n].instruments[s.instruments[0]];for(let n=0;n<t.modCount;n++)if(e.modulators[n]==t.modulators.dictionary["next bar"].index)for(const e of s.notes)e.pitches[0]==t.modCount-1-n&&i>e.start&&(i=e.start)}}return i}getTotalSamples(e,i,n){if(null==this.song)return-1;let s=e?0:this.song.loopStart,a=i?this.song.barCount:this.song.loopStart+this.song.loopLength,r=!1,o=!1,l=this.song.tempo;for(let e=this.song.pitchChannelCount+this.song.noiseChannelCount;e<this.song.getChannelCount();e++)for(let i=s;i<a;i++){let n=this.song.getPattern(e,i);if(null!=n){let i=this.song.channels[e].instruments[n.instruments[0]];for(let e=0;e<t.modCount;e++)i.modulators[e]==t.modulators.dictionary.tempo.index&&(r=!0),i.modulators[e]==t.modulators.dictionary["next bar"].index&&(o=!0)}}if(s>0){let e=null,i=0;for(let n=s-1;n>=0;n--){for(let s=this.song.pitchChannelCount+this.song.noiseChannelCount;s<this.song.getChannelCount();s++){let a=this.song.getPattern(s,n);if(null!=a){let r=a.instruments[0],o=this.song.channels[s].instruments[r],l=this.findPartsInBar(n);for(const n of a.notes)if(o.modulators[t.modCount-1-n.pitches[0]]==t.modulators.dictionary.tempo.index&&n.start<l&&(null==e||n.end>e))if(n.end<=l)e=n.end,i=n.pins[n.pins.length-1].size;else{e=l;for(let e=0;e<n.pins.length;e++)if(n.pins[e].time+n.start>l){const t=n.pins[e].time-n.pins[e-1].time,s=l-n.start-n.pins[e-1].time,a=n.pins[e].size-n.pins[e-1].size;i=Math.round(n.pins[e-1].size+a*s/t),e=n.pins.length}}}}null!=e&&(l=i+t.modulators.dictionary.tempo.convertRealFactor,n=-1)}}if(r||o){let e=s,i=!1,h=0;for(;!i;){let s=t.partsPerBeat*this.song.beatsPerBar,u=0;if(o&&(s=this.findPartsInBar(e)),r){let i=!1;for(let n=this.song.pitchChannelCount+this.song.noiseChannelCount;n<this.song.getChannelCount();n++)if(0==i){let a=this.song.getPattern(n,e);if(null!=a){let e=this.song.channels[n].instruments[a.instruments[0]];for(let n=0;n<t.modCount;n++)if(0==i&&e.modulators[n]==t.modulators.dictionary.tempo.index&&a.notes.find((e=>e.pitches[0]==t.modCount-1-n))){i=!0,a.notes.sort((function(e,t){return e.start==t.start?e.pitches[0]-t.pitches[0]:e.start-t.start}));for(const e of a.notes)if(e.pitches[0]==t.modCount-1-n&&(h+=Math.min(s-u,e.start-u)*t.ticksPerPart*this.getSamplesPerTickSpecificBPM(l),e.start<s))for(let i=1;i<e.pins.length;i++){if(e.pins[i-1].time+e.start<=s){const n=t.ticksPerPart*Math.min(s-(e.start+e.pins[i-1].time),e.pins[i].time-e.pins[i-1].time),a=e.pins[i-1].size+t.modulators.dictionary.tempo.convertRealFactor;let r=e.pins[i].size+t.modulators.dictionary.tempo.convertRealFactor;e.pins[i].time+e.start>s&&(r=e.pins[i-1].size+(e.pins[i].size-e.pins[i-1].size)*(s-(e.start+e.pins[i-1].time))/(e.pins[i].time-e.pins[i-1].time)+t.modulators.dictionary.tempo.convertRealFactor);let o=t.partsPerBeat*t.ticksPerPart/60;h+=r!=a?-this.samplesPerSecond*n*(Math.log(o*r*n)-Math.log(o*a*n))/(o*(a-r)):n*this.getSamplesPerTickSpecificBPM(r),l=r}u=Math.min(e.start+e.pins[i].time,s)}}}}}h+=(s-u)*t.ticksPerPart*this.getSamplesPerTickSpecificBPM(l),e++,0!=n&&e==this.song.loopStart+this.song.loopLength&&(e=this.song.loopStart,n>0&&n--),e>=a&&(i=!0)}return Math.ceil(h)}return this.getSamplesPerBar()*this.getTotalBars(e,i,n)}getTotalBars(e,t,i=this.loopRepeatCount){if(null==this.song)throw new Error;let n=this.song.loopLength*(i+1);return e&&(n+=this.song.loopStart),t&&(n+=this.song.barCount-(this.song.loopStart+this.song.loopLength)),n}setSong(e){"string"==typeof e?this.song=new X(e):e instanceof X&&(this.song=e),this.prevBar=null}computeDelayBufferSizes(){this.panningDelayBufferSize=se.fittingPowerOfTwo(this.samplesPerSecond*t.panDelaySecondsMax),this.panningDelayBufferMask=this.panningDelayBufferSize-1,this.chorusDelayBufferSize=se.fittingPowerOfTwo(this.samplesPerSecond*t.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.computeLatestModValues(),this.warmUpSynthesizer(this.song),this.isPlayingSong=!0,this.activateAudio())}pause(){if(this.isPlayingSong&&(this.isPlayingSong=!1,this.isRecording=!1,this.modValues=[],this.nextModValues=[],null!=this.song)){this.song.inVolumeCap=0,this.song.outVolumeCap=0;for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)this.modInsValues[e]=[],this.nextModInsValues[e]=[]}}startRecording(){this.preferLowerLatency=!0,this.isRecording=!0,this.play()}resetEffects(){if(this.limit=0,this.freeAllTones(),null!=this.song)for(const e of this.channels)for(const t of e.instruments)t.resetAllEffects()}setModValue(e,i,n,s,a,r){let o=e+t.modulators[r].convertRealFactor,l=i+t.modulators[r].convertRealFactor;return t.modulators[r].forSong?null!=this.modValues[r]&&this.modValues[r]==o&&this.nextModValues[r]==l||(this.modValues[r]=o,this.nextModValues[r]=l):null!=this.modInsValues[s][a][r]&&this.modInsValues[s][a][r]==o&&this.nextModInsValues[s][a][r]==l||(this.modInsValues[s][a][r]=o,this.nextModInsValues[s][a][r]=l),o}getModValue(e,i,n,s){if(t.modulators[e].forSong){if(null!=this.modValues[e]&&null!=this.nextModValues[e])return s?this.nextModValues[e]:this.modValues[e]}else if(null!=i&&null!=n&&null!=this.modInsValues[i][n][e]&&null!=this.nextModInsValues[i][n][e])return s?this.nextModInsValues[i][n][e]:this.modInsValues[i][n][e];return-1}isAnyModActive(e,i){for(let n=0;n<t.modulators.length;n++)if(null!=this.modValues&&null!=this.modValues[n]||null!=this.modInsValues&&null!=this.modInsValues[e]&&null!=this.modInsValues[e][i]&&null!=this.modInsValues[e][i][n])return!0;return!1}unsetMod(e,t,i){(this.isModActive(e)||null!=t&&null!=i&&this.isModActive(e,t,i))&&(this.modValues[e]=null,this.nextModValues[e]=null,null!=t&&null!=i&&(this.modInsValues[t][i][e]=null,this.nextModInsValues[t][i][e]=null))}isFilterModActive(e,t,i){const n=this.song.channels[t].instruments[i];if(e){if(n.noteFilterType)return!1;if(null!=n.tmpNoteFilterEnd)return!0}else{if(n.eqFilterType)return!1;if(null!=n.tmpEqFilterEnd)return!0}return!1}isModActive(e,i,n){return t.modulators[e].forSong?null!=this.modValues&&null!=this.modValues[e]:null!=i&&null!=n&&null!=this.modInsValues&&null!=this.modInsValues[i]&&null!=this.modInsValues[i][n]&&null!=this.modInsValues[i][n][e]}snapToStart(){this.bar=0,this.resetEffects(),this.snapToBar()}goToBar(e){this.bar=e,this.resetEffects(),this.playheadInternal=this.bar}snapToBar(){this.playheadInternal=this.bar,this.beat=0,this.part=0,this.tick=0,this.tickSampleCountdown=0}jumpIntoLoop(){if(this.song&&(this.bar<this.song.loopStart||this.bar>=this.song.loopStart+this.song.loopLength)){const e=this.bar;this.bar=this.song.loopStart,this.playheadInternal+=this.bar-e,this.playing&&this.computeLatestModValues()}}goToNextBar(){if(!this.song)return;this.prevBar=this.bar;const e=this.bar;this.bar++,this.bar>=this.song.barCount&&(this.bar=0),this.playheadInternal+=this.bar-e,this.playing&&this.computeLatestModValues()}goToPrevBar(){if(!this.song)return;this.prevBar=null;const e=this.bar;this.bar--,(this.bar<0||this.bar>=this.song.barCount)&&(this.bar=this.song.barCount-1),this.playheadInternal+=this.bar-e,this.playing&&this.computeLatestModValues()}getNextBar(){let e=this.bar+1;return this.isRecording?e>=this.song.barCount&&(e=this.song.barCount-1):0!=this.loopRepeatCount&&e==this.song.loopStart+this.song.loopLength&&(e=this.song.loopStart),e}skipBar(){if(!this.song)return;const e=this.getSamplesPerTick();this.bar++,this.beat=0,this.part=0,this.tick=0,this.tickSampleCountdown=e,this.isAtStartOfTick=!0,0!=this.loopRepeatCount&&this.bar==this.song.loopStart+this.song.loopLength&&(this.bar=this.song.loopStart,this.loopRepeatCount>0&&this.loopRepeatCount--)}synthesize(e,i,n,s=!0){if(null==this.song){for(let t=0;t<n;t++)e[t]=0,i[t]=0;return void this.deactivateAudio()}const a=this.song;this.song.inVolumeCap=0,this.song.outVolumeCap=0;let r=this.getSamplesPerTick(),o=!1;(this.tickSampleCountdown<=0||this.tickSampleCountdown>r)&&(this.tickSampleCountdown=r,this.isAtStartOfTick=!0),s&&(this.beat>=a.beatsPerBar&&(this.beat=0,this.part=0,this.tick=0,this.tickSampleCountdown=r,this.isAtStartOfTick=!0,this.prevBar=this.bar,this.bar=this.getNextBar(),this.bar<=this.prevBar&&this.loopRepeatCount>0&&this.loopRepeatCount--),this.bar>=a.barCount&&(this.bar=0,-1!=this.loopRepeatCount&&(o=!0,this.pause()))),this.syncSongState(),(null==this.tempMonoInstrumentSampleBuffer||this.tempMonoInstrumentSampleBuffer.length<n)&&(this.tempMonoInstrumentSampleBuffer=new Float32Array(n));const l=+this.volume,h=1-Math.pow(.5,4/this.samplesPerSecond),u=1-Math.pow(.5,4e3/this.samplesPerSecond);let c=+this.limit,p=[],f=-1,m=0;for(;m<n&&!o;){this.nextBar=this.getNextBar(),this.nextBar>=a.barCount&&(this.nextBar=null);const d=n-m,y=Math.ceil(this.tickSampleCountdown),v=Math.min(y,d),g=m+v;if(this.isPlayingSong||this.renderingSong)for(let e=a.pitchChannelCount+a.noiseChannelCount;e<a.getChannelCount();e++){const t=a.channels[e],i=this.channels[e];this.determineCurrentActiveTones(a,e,r,s);for(let n=0;n<t.instruments.length;n++){const t=i.instruments[n];for(let i=0;i<t.activeModTones.count();i++){const n=t.activeModTones.get(i);this.playModTone(a,e,r,m,v,n,!1,!1)}}}if(this.wantToSkip){let e=p.includes(this.bar);if(e&&m==f)return;-1==f&&(f=m),e||p.push(this.bar),this.wantToSkip=!1,this.skipBar()}else{for(let n=0;n<a.pitchChannelCount+a.noiseChannelCount;n++){const o=a.channels[n],l=this.channels[n];this.isAtStartOfTick&&(this.determineCurrentActiveTones(a,n,r,s&&!this.countInMetronome),this.determineLiveInputTones(a,n,r));for(let s=0;s<o.instruments.length;s++){const h=o.instruments[s],u=l.instruments[s];if(this.isAtStartOfTick){let e=u.activeTones.count()+u.liveInputTones.count();for(let i=0;i<u.releasedTones.count();i++){const s=u.releasedTones.get(i);if(s.ticksSinceReleased>=Math.abs(h.getFadeOutTicks())){this.freeReleasedTone(u,i),i--;continue}const o=e>=t.maximumTonesPerChannel;this.computeTone(a,n,r,s,!0,o),e++}u.awake&&(u.computed||u.compute(this,h,r,Math.ceil(r),null,n,s),u.computed=!1)}for(let e=0;e<u.activeTones.count();e++){const t=u.activeTones.get(e);this.playTone(n,m,v,t)}for(let e=0;e<u.liveInputTones.count();e++){const t=u.liveInputTones.get(e);this.playTone(n,m,v,t)}for(let e=0;e<u.releasedTones.count();e++){const t=u.releasedTones.get(e);this.playTone(n,m,v,t)}u.awake&&se.effectsSynth(this,e,i,m,v,u);const c=this.tickSampleCountdown,p=1-c/r,f=1-(c-v)/r,d=(this.beat*t.partsPerBeat+this.part)*t.ticksPerPart+this.tick,y=d/t.ticksPerPart,g=(d+1)/t.ticksPerPart,b=y+(g-y)*p,S=y+(g-y)*f;let w=h.vibratoSpeed;h.LFOtime=h.nextLFOtime,this.isModActive(t.modulators.dictionary["vibrato speed"].index,n,s)&&(w=this.getModValue(t.modulators.dictionary["vibrato speed"].index,n,s)),0==w?(h.LFOtime=0,h.nextLFOtime=0):h.nextLFOtime+=.1*w*(S-b)}}if(this.enableMetronome||this.countInMetronome)if(0==this.part){if(!this.startedMetronome){const e=a.beatsPerBar>4&&a.beatsPerBar%2==0&&this.beat==a.beatsPerBar/2,t=0==this.beat?8:e?6:4,i=0==this.beat?1600:e?1200:800,n=0==this.beat?.06:e?.05:.04,s=this.samplesPerSecond/i,r=2*Math.PI/s;this.metronomeSamplesRemaining=Math.floor(s*t),this.metronomeFilter=2*Math.cos(r),this.metronomeAmplitude=n*Math.sin(r),this.metronomePrevAmplitude=0,this.startedMetronome=!0}if(this.metronomeSamplesRemaining>0){const t=Math.min(g,m+this.metronomeSamplesRemaining);this.metronomeSamplesRemaining-=t-m;for(let n=m;n<t;n++){e[n]+=this.metronomeAmplitude,i[n]+=this.metronomeAmplitude;const t=this.metronomeFilter*this.metronomeAmplitude-this.metronomePrevAmplitude;this.metronomePrevAmplitude=this.metronomeAmplitude,this.metronomeAmplitude=t}}}else this.startedMetronome=!1;for(let t=m;t<g;t++){const n=e[t]*a.masterGain*a.masterGain,s=i[t]*a.masterGain*a.masterGain,r=n<0?-n:n,o=s<0?-s:s,p=r>o?r:o;this.song.inVolumeCap=this.song.inVolumeCap>p?this.song.inVolumeCap:p;const f=+(p>a.compressionThreshold)+ +(p>a.limitThreshold),m=+(0==f)*((.8*(p+1-a.compressionThreshold)+.25)*a.compressionRatio+1.05*(1-a.compressionRatio))+1.05*+(1==f)+ +(2==f)*(1.05*((p+1-a.limitThreshold)*a.limitRatio+(1-a.limitThreshold)));c+=(m-c)*(c<m?u:h);const d=l/(c>=1?1.05*c:.8*c+.25);e[t]=n*d,i[t]=s*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;e<t.releasedTones.count();e++){const i=t.releasedTones.get(e);i.isOnLastTick?(this.freeReleasedTone(t,e),e--):i.ticksSinceReleased++}t.deactivateAfterThisTick&&t.deactivate(),t.tonesAddedInThisTick=!1}for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)for(let i=0;i<this.song.channels[e].instruments.length;i++){let n=this.song.channels[e].instruments[i],s=n.arpeggioSpeed;this.isModActive(t.modulators.dictionary["arp speed"].index,e,i)?(s=this.getModValue(t.modulators.dictionary["arp speed"].index,e,i,!1),Number.isInteger(s)?n.arpTime+=t.arpSpeedScale[s]:n.arpTime+=(1-s%1)*t.arpSpeedScale[Math.floor(s)]+s%1*t.arpSpeedScale[Math.ceil(s)]):n.arpTime+=t.arpSpeedScale[s]}for(let e=0;e<this.song.pitchChannelCount+this.song.noiseChannelCount;e++)for(let t=0;t<this.song.channels[e].instruments.length;t++){let i=this.song.channels[e].instruments[t];null!=i.tmpEqFilterEnd?i.tmpEqFilterStart=i.tmpEqFilterEnd:i.tmpEqFilterStart=i.eqFilter,null!=i.tmpNoteFilterEnd?i.tmpNoteFilterStart=i.tmpNoteFilterEnd:i.tmpNoteFilterStart=i.noteFilter}this.tick++,this.tickSampleCountdown+=r,this.tick==t.ticksPerPart&&(this.tick=0,this.part++,this.liveInputDuration--,this.part==t.partsPerBeat&&(this.part=0,s&&(this.beat++,this.beat==a.beatsPerBar&&(this.beat=0,this.countInMetronome?this.countInMetronome=!1:(this.prevBar=this.bar,this.bar=this.getNextBar(),this.bar<=this.prevBar&&this.loopRepeatCount>0&&this.loopRepeatCount--,this.bar>=a.barCount&&(this.bar=0,-1!=this.loopRepeatCount&&(o=!0,this.resetEffects(),this.pause())))))))}for(let e=0;e<t.modulators.length;e++)null!=this.nextModValues&&null!=this.nextModValues[e]&&(this.modValues[e]=this.nextModValues[e]);this.isModActive(t.modulators.dictionary.tempo.index)&&(r=this.getSamplesPerTick(),this.tickSampleCountdown=Math.min(this.tickSampleCountdown,r));for(let e=0;e<this.song.pitchChannelCount;e++)for(let i of this.song.channels[e].instruments)i.nextLFOtime=i.nextLFOtime%(t.vibratoTypes[i.vibratoType].period/(t.ticksPerPart*r/this.samplesPerSecond)),i.arpTime=i.arpTime%(2520*t.ticksPerArpeggio);for(let e=0;e<t.modulators.length;e++)for(let t=0;t<this.song.pitchChannelCount+this.song.noiseChannelCount;t++)for(let i=0;i<this.song.getMaxInstrumentsPerChannel();i++)null!=this.nextModInsValues&&null!=this.nextModInsValues[t]&&null!=this.nextModInsValues[t][i]&&null!=this.nextModInsValues[t][i][e]&&(this.modInsValues[t][i][e]=this.nextModInsValues[t][i][e])}}(!Number.isFinite(c)||Math.abs(c)<D)&&(c=0),this.limit=c,s&&!this.countInMetronome&&(this.playheadInternal=(((this.tick+1-this.tickSampleCountdown/r)/2+this.part)/t.partsPerBeat+this.beat)/a.beatsPerBar+this.bar)}freeTone(e){this.tonePool.pushBack(e)}newTone(){if(this.tonePool.count()>0){const e=this.tonePool.popBack();return e.freshlyAllocated=!0,e}return new te}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,i){const n=e.channels[t],s=this.channels[t],a=this.liveInputPitches;for(let r=0;r<n.instruments.length;r++){const o=s.instruments[r],l=o.liveInputTones;let h=0;if(this.liveInputDuration>0&&t==this.liveInputChannel&&a.length>0&&-1!=this.liveInputInstruments.indexOf(r)){const s=n.instruments[r];if(s.getChord().singleTone){let n;l.count()<=h?(n=this.newTone(),l.pushBack(n)):!s.getTransition().isSeamless&&this.liveInputStarted?(this.releaseTone(o,l.get(h)),n=this.newTone(),l.set(h,n)):n=l.get(h),h++;for(let e=0;e<a.length;e++)n.pitches[e]=a[e];n.pitchCount=a.length,n.chordSize=1,n.instrumentIndex=r,n.note=n.prevNote=n.nextNote=null,n.atNoteStart=this.liveInputStarted,n.forceContinueAtStart=!1,n.forceContinueAtEnd=!1,this.computeTone(e,t,i,n,!1,!1)}else{this.moveTonesIntoOrderedTempMatchedList(l,a);for(let n=0;n<a.length;n++){let s;null!=this.tempMatchedPitchTones[h]?(s=this.tempMatchedPitchTones[h],this.tempMatchedPitchTones[h]=null,1==s.pitchCount&&s.pitches[0]==a[n]||(this.releaseTone(o,s),s=this.newTone()),l.pushBack(s)):(s=this.newTone(),l.pushBack(s)),h++,s.pitches[0]=a[n],s.pitchCount=1,s.chordSize=a.length,s.instrumentIndex=r,s.note=s.prevNote=s.nextNote=null,s.atNoteStart=this.liveInputStarted,s.forceContinueAtStart=!1,s.forceContinueAtEnd=!1,this.computeTone(e,t,i,s,!1,!1)}}}for(;l.count()>h;)this.releaseTone(o,l.popBack());this.clearTempMatchedPitchTones(h,o)}this.liveInputStarted=!1}adjacentPatternHasCompatibleInstrumentTransition(e,t,i,n,s,a,r,o,l,h,u){if(e.patternInstruments&&-1==n.instruments.indexOf(s)){if(i.instruments.length>1||n.instruments.length>1)return null;const e=t.instruments[n.instruments[0]];if(h)return e.getChord();const s=e.getTransition();return!u.continueThruPattern&&a.includeAdjacentPatterns&&s.includeAdjacentPatterns&&s.slides==a.slides?e.getChord():null}return h||!u.continueThruPattern&&a.includeAdjacentPatterns?r:null}static adjacentNotesHaveMatchingPitches(e,t){if(e.pitches.length!=t.pitches.length)return!1;const i=e.pins[e.pins.length-1].interval;for(const n of e.pitches)if(-1==t.pitches.indexOf(n+i))return!1;return!0}moveTonesIntoOrderedTempMatchedList(e,t){for(let i=0;i<e.count();i++){const n=e.get(i),s=n.pitches[0]+n.lastInterval;for(let a=0;a<t.length;a++)if(t[a]==s){this.tempMatchedPitchTones[a]=n,e.remove(i),i--;break}}for(;e.count()>0;){const t=e.popFront();for(let e=0;e<this.tempMatchedPitchTones.length;e++)if(null==this.tempMatchedPitchTones[e]){this.tempMatchedPitchTones[e]=t;break}}}determineCurrentActiveTones(e,i,n,s){const a=e.channels[i],r=this.channels[i],o=e.getPattern(i,this.bar),l=this.getCurrentPart(),h=this.tick+t.ticksPerPart*l;if(s&&e.getChannelIsMod(i)){let n=[],s=[],u=[],c=t.modCount;for(;c--;)n.push(null),s.push(null),u.push(null);if(null!=o&&!a.muted)for(let e=0;e<o.notes.length;e++)o.notes[e].end<=l?(null==s[o.notes[e].pitches[0]]||o.notes[e].end>s[o.notes[e].pitches[0]].start)&&(s[o.notes[e].pitches[0]]=o.notes[e]):o.notes[e].start<=l&&o.notes[e].end>l?n[o.notes[e].pitches[0]]=o.notes[e]:o.notes[e].start>l&&(null==u[o.notes[e].pitches[0]]||o.notes[e].start<u[o.notes[e].pitches[0]].start)&&(u[o.notes[e].pitches[0]]=o.notes[e]);let p=0;const f=e.patternInstruments&&null!=o?o.instruments[0]:0,m=r.instruments[f],d=m.activeModTones;for(let e=0;e<t.modCount;e++){if(null!=n[e]&&(null!=s[e]&&s[e].end!=n[e].start&&(s[e]=null),null!=u[e]&&u[e].start!=n[e].end&&(u[e]=null)),null!=r.singleSeamlessInstrument&&r.singleSeamlessInstrument!=f&&r.singleSeamlessInstrument<r.instruments.length){const e=r.instruments[r.singleSeamlessInstrument],t=r.instruments[f];for(;e.activeModTones.count()>0;)t.activeModTones.pushFront(e.activeModTones.popBack())}if(r.singleSeamlessInstrument=f,null!=n[e]){let i=s[e],a=u[e],r=!1,o=!1;const l=t.ticksPerPart*n[e].start==h&&this.isAtStartOfTick;let c;if(d.count()<=p)c=this.newTone(),d.pushBack(c);else if(l&&null==i){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;t<n[e].pitches.length;t++)c.pitches[t]=n[e].pitches[t];c.pitchCount=n[e].pitches.length,c.chordSize=1,c.instrumentIndex=f,c.note=n[e],c.noteStartPart=n[e].start,c.noteEndPart=n[e].end,c.prevNote=i,c.nextNote=a,c.prevNotePitchIndex=0,c.nextNotePitchIndex=0,c.atNoteStart=l,c.passedEndOfNote=!1,c.forceContinueAtStart=r,c.forceContinueAtEnd=o}}for(;d.count()>p;){const t=d.popBack(),n=e.channels[i];if(t.instrumentIndex<n.instruments.length&&!t.isOnLastTick){const e=this.channels[i].instruments[t.instrumentIndex];this.releaseTone(e,t)}else this.freeTone(t)}}else if(!e.getChannelIsMod(i)){let u=null,c=null,p=null;if(s&&null!=o&&!a.muted&&(!this.isRecording||this.liveInputChannel!=i)){for(let e=0;e<o.notes.length;e++)if(o.notes[e].end<=l)c=o.notes[e];else if(o.notes[e].start<=l&&o.notes[e].end>l)u=o.notes[e];else if(o.notes[e].start>l){p=o.notes[e];break}null!=u&&(null!=c&&c.end!=u.start&&(c=null),null!=p&&p.start!=u.end&&(p=null))}if(null!=o&&(!e.layeredInstruments||1==a.instruments.length||e.patternInstruments&&1==o.instruments.length)){const t=e.patternInstruments?o.instruments[0]:0;if(null!=r.singleSeamlessInstrument&&r.singleSeamlessInstrument!=t&&r.singleSeamlessInstrument<r.instruments.length){const e=r.instruments[r.singleSeamlessInstrument],i=r.instruments[t];for(;e.activeTones.count()>0;)i.activeTones.pushFront(e.activeTones.popBack())}r.singleSeamlessInstrument=t}else r.singleSeamlessInstrument=null;for(let s=0;s<a.instruments.length;s++){const f=r.instruments[s],m=f.activeTones;let d=0;if(null!=u&&(!e.patternInstruments||-1!=o.instruments.indexOf(s))){const r=a.instruments[s];let y=c,v=p;const g=t.partsPerBeat*e.beatsPerBar,b=r.getTransition(),S=r.getChord(),w=S.strumParts>0;let k=!1,M=!1,F=0,q=0;if(0==u.start){let t=null==this.prevBar?null:e.getPattern(i,this.prevBar);if(null!=t){const i=t.notes.length<=0?null:t.notes[t.notes.length-1];if(null!=i&&i.end==g){const n=u.continuesLastPattern&&se.adjacentNotesHaveMatchingPitches(i,u),l=this.adjacentPatternHasCompatibleInstrumentTransition(e,a,o,t,s,b,S,u,i,n,r);null!=l&&(y=i,F=l.singleTone?1:y.pitches.length,k=n)}}}else null!=y&&(F=S.singleTone?1:y.pitches.length);if(u.end==g){let t=null==this.nextBar?null:e.getPattern(i,this.nextBar);if(null!=t){const i=t.notes.length<=0?null:t.notes[0];if(null!=i&&0==i.start){const n=i.continuesLastPattern&&se.adjacentNotesHaveMatchingPitches(u,i),l=this.adjacentPatternHasCompatibleInstrumentTransition(e,a,o,t,s,b,S,u,i,n,r);null!=l&&(v=i,q=l.singleTone?1:v.pitches.length,M=n)}}}else null!=v&&(q=S.singleTone?1:v.pitches.length);if(S.singleTone){const a=t.ticksPerPart*u.start==h;let o;if(m.count()<=d)o=this.newTone(),m.pushBack(o);else if(!a||(b.isSeamless||r.clicklessTransition||k)&&null!=y)o=m.get(d);else{const e=m.get(d);e.isOnLastTick?this.freeTone(e):this.releaseTone(f,e),o=this.newTone(),m.set(d,o)}d++;for(let e=0;e<u.pitches.length;e++)o.pitches[e]=u.pitches[e];o.pitchCount=u.pitches.length,o.chordSize=1,o.instrumentIndex=s,o.note=u,o.noteStartPart=u.start,o.noteEndPart=u.end,o.prevNote=y,o.nextNote=v,o.prevNotePitchIndex=0,o.nextNotePitchIndex=0,o.atNoteStart=a,o.passedEndOfNote=!1,o.forceContinueAtStart=k,o.forceContinueAtEnd=M,this.computeTone(e,i,n,o,!1,!1)}else{const a=r.getTransition();(a.isSeamless&&!a.slides&&0==S.strumParts||k)&&t.ticksPerPart*u.start==h&&null!=y&&this.moveTonesIntoOrderedTempMatchedList(m,u.pitches);let o=0;for(let c=0;c<u.pitches.length;c++){let p=F>c?y:null,g=u,b=q>c?v:null,S=g.start+o,T=!1;if(S>l){if(!(m.count()>c&&(a.isSeamless||k)&&null!=p))break;b=g,g=p,p=null,S=g.start+o,T=!0}let P=g.end;(a.isSeamless||k)&&null!=b&&(P=Math.min(t.partsPerBeat*this.song.beatsPerBar,P+o)),(a.continues||k)&&null!=p||w&&(o+=t.strumSpeedScale[r.strumSpeed]);const I=t.ticksPerPart*S==h;let z;if(null!=this.tempMatchedPitchTones[d])z=this.tempMatchedPitchTones[d],this.tempMatchedPitchTones[d]=null,m.pushBack(z);else if(m.count()<=d)z=this.newTone(),m.pushBack(z);else if(!I||(a.isSeamless||k)&&null!=p)z=m.get(d);else{const e=m.get(d);e.isOnLastTick?this.freeTone(e):this.releaseTone(f,e),z=this.newTone(),m.set(d,z)}d++,z.pitches[0]=g.pitches[c],z.pitchCount=1,z.chordSize=g.pitches.length,z.instrumentIndex=s,z.note=g,z.noteStartPart=S,z.noteEndPart=P,z.prevNote=p,z.nextNote=b,z.prevNotePitchIndex=c,z.nextNotePitchIndex=c,z.atNoteStart=I,z.passedEndOfNote=T,z.forceContinueAtStart=k&&null!=p,z.forceContinueAtEnd=M&&null!=b,this.computeTone(e,i,n,z,!1,!1)}}}for(;m.count()>d;){const t=m.popBack(),n=e.channels[i];if(t.instrumentIndex<n.instruments.length&&!t.isOnLastTick){const e=r.instruments[t.instrumentIndex];this.releaseTone(e,t)}else this.freeTone(t)}this.clearTempMatchedPitchTones(d,f)}}}clearTempMatchedPitchTones(e,t){for(let i=e;i<this.tempMatchedPitchTones.length;i++){const e=this.tempMatchedPitchTones[i];null!=e&&(e.isOnLastTick?this.freeTone(e):this.releaseTone(t,e),this.tempMatchedPitchTones[i]=null)}}playTone(e,t,i,n){const s=this.channels[e].instruments[n.instrumentIndex];null!=s.synthesizer&&s.synthesizer(this,t,i,n,s),n.envelopeComputer.clearEnvelopes()}playModTone(e,i,n,s,a,r,o,l){const h=e.channels[i].instruments[r.instrumentIndex];if(null!=r.note){const e=this.getTicksIntoBar(),i=e/t.ticksPerPart,o=(e+1)/t.ticksPerPart,l=this.tickSampleCountdown,u=i+(o-i)*(1-l/n),c=i+(o-i)*(1-(l-a)/n),p=t.ticksPerPart*u,f=t.ticksPerPart*c,m=r.note.getEndPinIndex(this.getCurrentPart()),d=r.note.pins[m-1],y=r.note.pins[m],v=(r.note.start+d.time)*t.ticksPerPart,g=(r.note.start+y.time)*t.ticksPerPart,b=(p-v)/(g-v),S=(f-v)/(g-v);r.expression=d.size+(y.size-d.size)*b,r.expressionDelta=d.size+(y.size-d.size)*S-r.expression,se.modSynth(this,s,a,r,h)}}static computeChordExpression(e){return 1/(.25*(e-1)+1)}computeTone(e,i,n,s,a,r){const o=Math.ceil(n),l=e.channels[i],u=this.channels[i],c=l.instruments[s.instrumentIndex],p=u.instruments[s.instrumentIndex];p.awake=!0,p.tonesAddedInThisTick=!0,p.computed||p.compute(this,c,n,o,s,i,s.instrumentIndex);const v=c.getTransition(),g=c.getChord(),b=g.singleTone?1:se.computeChordExpression(s.chordSize),S=e.getChannelIsNoise(i),w=S?t.noiseInterval:1,k=t.ticksPerPart*n/this.samplesPerSecond,M=1/this.samplesPerSecond,F=1/t.partsPerBeat,q=this.getTicksIntoBar(),T=q/t.ticksPerPart,P=(q+1)/t.ticksPerPart,I=this.getCurrentPart();let z=1;s.specialIntervalExpressionMult=1;let x=r,D=0,O=0,G=1,A=1,R=b,C=b,E=16,L=t.keys[e.key].basePitch,N=1,V=48;if(3==c.type)N=t.spectrumBaseExpression,S&&(L=t.spectrumBasePitch,N*=2),E=t.spectrumBasePitch,V=28;else if(4==c.type)L=t.spectrumBasePitch,N=t.drumsetBaseExpression,E=L;else if(2==c.type)L=t.chipNoises[c.chipNoise].basePitch,N=t.noiseBaseExpression,E=L,V=t.chipNoises[c.chipNoise].isSoft?24:60;else if(1==c.type)N=t.fmBaseExpression;else if(0==c.type||8==c.type)N=t.chipBaseExpression;else if(5==c.type)N=t.harmonicsBaseExpression;else if(6==c.type)N=t.pwmBaseExpression;else if(7==c.type)N=t.pickedStringBaseExpression;else{if(9!=c.type)throw new Error("Unknown instrument type in computeTone.");N=1,E=0,V=1,L=0}(s.atNoteStart&&!v.isSeamless&&!s.forceContinueAtStart||s.freshlyAllocated)&&s.reset(),s.freshlyAllocated=!1;for(let e=0;e<t.maxPitchOrOperatorCount;e++)s.phaseDeltas[e]=0,s.phaseDeltaScales[e]=0,s.operatorExpressions[e]=0,s.operatorExpressionDeltas[e]=0;s.expression=0,s.expressionDelta=0;for(let e=0;e<t.operatorCount;e++)s.operatorWaves[e]=se.getOperatorWave(c.operators[e].waveform,c.operators[e].pulseWidth);if(a){const e=s.ticksSinceReleased,i=s.ticksSinceReleased+1;D=O=s.lastInterval;const n=Math.abs(c.getFadeOutTicks());G=se.noteSizeToVolumeMult((1-e/n)*t.noteSizeMax),A=se.noteSizeToVolumeMult((1-i/n)*t.noteSizeMax),r&&(A=0),s.ticksSinceReleased+1>=n&&(x=!0)}else if(null==s.note)G=A=1,s.lastInterval=0,s.ticksSinceReleased=0,s.liveInputSamplesHeld+=o;else{const e=s.note,i=s.nextNote,n=s.noteStartPart,a=s.noteEndPart,r=e.getEndPinIndex(I),o=e.pins[r-1],l=e.pins[r],h=n*t.ticksPerPart,u=a*t.ticksPerPart,p=(e.start+o.time)*t.ticksPerPart,f=(e.start+l.time)*t.ticksPerPart;s.ticksSinceReleased=0;const m=I*t.ticksPerPart+this.tick,d=m+1,y=m-h,g=d-h,b=Math.min(1,(m-p)/(f-p)),S=Math.min(1,(d-p)/(f-p));if(G=1,A=1,D=o.interval+(l.interval-o.interval)*b,O=o.interval+(l.interval-o.interval)*S,s.lastInterval=O,!v.isSeamless&&!s.forceContinueAtEnd||null==i){const e=-c.getFadeOutTicks();if(e>0){const t=u-h;G*=Math.min(1,(t-y)/e),A*=Math.min(1,(t-g)/e),d>=h+t&&(x=!0)}}}s.isOnLastTick=x;let W,B,$=c.noteFilter;if(c.noteFilterType){const e=c.noteFilter;null==c.noteSubFilters[1]&&(c.noteSubFilters[1]=new K);const n=c.noteSubFilters[1];let a=c.noteFilterSimpleCut,r=c.noteFilterSimplePeak,o=c.noteFilterSimpleCut,l=c.noteFilterSimplePeak,h=!1;this.isModActive(t.modulators.dictionary["note filt cut"].index,i,s.instrumentIndex)&&(a=this.getModValue(t.modulators.dictionary["note filt cut"].index,i,s.instrumentIndex,!1),o=this.getModValue(t.modulators.dictionary["note filt cut"].index,i,s.instrumentIndex,!0),h=!0),this.isModActive(t.modulators.dictionary["note filt peak"].index,i,s.instrumentIndex)&&(r=this.getModValue(t.modulators.dictionary["note filt peak"].index,i,s.instrumentIndex,!1),l=this.getModValue(t.modulators.dictionary["note filt peak"].index,i,s.instrumentIndex,!0),h=!0),e.convertLegacySettingsForSynth(a,r,!h),n.convertLegacySettingsForSynth(o,l,!h),W=e.controlPoints[0],B=n.controlPoints[0],c.noteFilter=e,c.tmpNoteFilterStart=e}const j=s.envelopeComputer;j.computeEnvelopes(c,I,t.ticksPerPart*T,n/this.samplesPerSecond,s);const U=s.envelopeComputer.envelopeStarts,J=s.envelopeComputer.envelopeEnds;if(c.noteFilter=$,null!=s.note&&v.slides){const e=s.prevNote,t=s.nextNote;if(null!=e){const t=e.pitches[s.prevNotePitchIndex]+e.pins[e.pins.length-1].interval-s.pitches[0];if(j.prevSlideStart&&(D+=t*j.prevSlideRatioStart),j.prevSlideEnd&&(O+=t*j.prevSlideRatioEnd),!g.singleTone){const t=e.pitches.length-s.chordSize;j.prevSlideStart&&(R=se.computeChordExpression(s.chordSize+t*j.prevSlideRatioStart)),j.prevSlideEnd&&(C=se.computeChordExpression(s.chordSize+t*j.prevSlideRatioEnd))}}if(null!=t){const e=t.pitches[s.nextNotePitchIndex]-(s.pitches[0]+s.note.pins[s.note.pins.length-1].interval);if(j.nextSlideStart&&(D+=e*j.nextSlideRatioStart),j.nextSlideEnd&&(O+=e*j.nextSlideRatioEnd),!g.singleTone){const e=t.pitches.length-s.chordSize;j.nextSlideStart&&(R=se.computeChordExpression(s.chordSize+e*j.nextSlideRatioStart)),j.nextSlideEnd&&(C=se.computeChordExpression(s.chordSize+e*j.nextSlideRatioEnd))}}}if(f(c.effects)){let e=t.justIntonationSemitones[c.pitchShift]/w,n=1,a=1;this.isModActive(t.modulators.dictionary["pitch shift"].index,i,s.instrumentIndex)&&(e=t.justIntonationSemitones[t.justIntonationSemitones.length-1],n=this.getModValue(t.modulators.dictionary["pitch shift"].index,i,s.instrumentIndex,!1)/t.pitchShiftCenter,a=this.getModValue(t.modulators.dictionary["pitch shift"].index,i,s.instrumentIndex,!0)/t.pitchShiftCenter);D+=e*U[14]*n,O+=e*J[14]*a}if(m(c.effects)||this.isModActive(t.modulators.dictionary["song detune"].index,i,s.instrumentIndex)){const e=U[15],n=J[15];let a=c.detune,r=c.detune;this.isModActive(t.modulators.dictionary.detune.index,i,s.instrumentIndex)&&(a=this.getModValue(t.modulators.dictionary.detune.index,i,s.instrumentIndex,!1)+t.detuneCenter,r=this.getModValue(t.modulators.dictionary.detune.index,i,s.instrumentIndex,!0)+t.detuneCenter),this.isModActive(t.modulators.dictionary["song detune"].index,i,s.instrumentIndex)&&(a+=4*this.getModValue(t.modulators.dictionary["song detune"].index,i,s.instrumentIndex,!1),r+=4*this.getModValue(t.modulators.dictionary["song detune"].index,i,s.instrumentIndex,!0)),D+=se.detuneToCents(a*e)*t.pitchesPerOctave/1200,O+=se.detuneToCents(r*n)*t.pitchesPerOctave/1200}if(d(c.effects)){let e,n,a,r;if(c.vibrato==t.vibratos.length?(e=2*c.vibratoDelay,c.vibratoDelay==t.modulators.dictionary["vibrato delay"].maxRawVol&&(e=Number.POSITIVE_INFINITY),n=c.vibratoDepth,a=n):(e=t.vibratos[c.vibrato].delayTicks,n=t.vibratos[c.vibrato].amplitude,a=n),this.isModActive(t.modulators.dictionary["vibrato delay"].index,i,s.instrumentIndex)&&(e=2*this.getModValue(t.modulators.dictionary["vibrato delay"].index,i,s.instrumentIndex,!1),e==2*t.modulators.dictionary["vibrato delay"].maxRawVol&&(e=Number.POSITIVE_INFINITY)),this.isModActive(t.modulators.dictionary["vibrato depth"].index,i,s.instrumentIndex)&&(n=this.getModValue(t.modulators.dictionary["vibrato depth"].index,i,s.instrumentIndex,!1)/25,a=this.getModValue(t.modulators.dictionary["vibrato depth"].index,i,s.instrumentIndex,!0)/25),null!=s.prevVibrato)r=s.prevVibrato;else{if(r=n*se.getLFOAmplitude(c,k*c.LFOtime)*U[16],e>0){const t=e-j.noteTicksStart;r*=Math.max(0,Math.min(1,1-t/2))}}let o=se.getLFOAmplitude(c,k*c.nextLFOtime);const l=J[16];if(9!=c.type){let t=a*o*l;if(e>0){const i=e-j.noteTicksEnd;t*=Math.max(0,Math.min(1,1-i/2))}s.prevVibrato=t,D+=r,O+=t}}if(!v.isSeamless&&!s.forceContinueAtStart||null==s.prevNote){const e=c.getFadeInSeconds();e>0&&(G*=Math.min(1,j.noteSecondsStart/e),A*=Math.min(1,j.noteSecondsEnd/e))}4==c.type&&null==s.drumsetPitch&&(s.drumsetPitch=s.pitches[0],null!=s.note&&(s.drumsetPitch+=s.note.pickMainInterval()),s.drumsetPitch=Math.max(0,Math.min(t.drumCount-1,s.drumsetPitch)));let Y=j.lowpassCutoffDecayVolumeCompensation;if(y(c.effects)){const e=U[1],t=J[1];if(c.noteFilterType){const i=U[17],n=J[17],a=U[25],r=J[25];W.toCoefficients(se.tempFilterStartCoefficients,this.samplesPerSecond,e*i,a),B.toCoefficients(se.tempFilterEndCoefficients,this.samplesPerSecond,t*n,r),s.noteFilters.length<1&&(s.noteFilters[0]=new H),s.noteFilters[0].loadCoefficientsWithGradient(se.tempFilterStartCoefficients,se.tempFilterEndCoefficients,1/o,0==W.type),Y*=W.getVolumeCompensationMult(),s.noteFilterCount=1}else{const i=null!=c.tmpNoteFilterStart?c.tmpNoteFilterStart:c.noteFilter;for(let n=0;n<i.controlPointCount;n++){const a=U[17+n],r=J[17+n],l=U[25+n],h=J[25+n];let u=i.controlPoints[n];const p=null!=c.tmpNoteFilterEnd&&null!=c.tmpNoteFilterEnd.controlPoints[n]?c.tmpNoteFilterEnd.controlPoints[n]:i.controlPoints[n];u.type!=p.type&&(u=p),u.toCoefficients(se.tempFilterStartCoefficients,this.samplesPerSecond,e*a,l),p.toCoefficients(se.tempFilterEndCoefficients,this.samplesPerSecond,t*r,h),s.noteFilters.length<=n&&(s.noteFilters[n]=new H),s.noteFilters[n].loadCoefficientsWithGradient(se.tempFilterStartCoefficients,se.tempFilterEndCoefficients,1/o,0==u.type),Y*=u.getVolumeCompensationMult()}s.noteFilterCount=i.controlPointCount}}else s.noteFilterCount=0;if(4==c.type){const e=c.getDrumsetEnvelope(s.drumsetPitch);Y*=ee.getLowpassCutoffDecayVolumeCompensation(e);let t=ee.computeEnvelope(e,j.noteSecondsStart,F*T,j.noteSizeStart),i=ee.computeEnvelope(e,j.noteSecondsEnd,F*P,j.noteSizeEnd);if(j.prevSlideStart){t+=(ee.computeEnvelope(e,j.prevNoteSecondsStart,F*T,j.prevNoteSize)-t)*j.prevSlideRatioStart}if(j.prevSlideEnd){i+=(ee.computeEnvelope(e,j.prevNoteSecondsEnd,F*P,j.prevNoteSize)-i)*j.prevSlideRatioEnd}if(j.nextSlideStart){t+=(ee.computeEnvelope(e,0,F*T,j.nextNoteSize)-t)*j.nextSlideRatioStart}if(j.nextSlideEnd){i+=(ee.computeEnvelope(e,0,F*P,j.nextNoteSize)-i)*j.nextSlideRatioEnd}const n=this.tempDrumSetControlPoint;n.type=0,n.gain=Q.getRoundedSettingValueFromLinearGain(.5),n.freq=Q.getRoundedSettingValueFromHz(8e3),n.toCoefficients(se.tempFilterStartCoefficients,this.samplesPerSecond,t*(1+t),1),n.toCoefficients(se.tempFilterEndCoefficients,this.samplesPerSecond,i*(1+i),1),s.noteFilters.length==s.noteFilterCount&&(s.noteFilters[s.noteFilterCount]=new H),s.noteFilters[s.noteFilterCount].loadCoefficientsWithGradient(se.tempFilterStartCoefficients,se.tempFilterEndCoefficients,1/o,!0),s.noteFilterCount++}if(Y=Math.min(3,Y),1==c.type){let e=1,n=0,a=0;const r=g.arpeggiates;if(s.pitchCount>1&&r){const e=Math.floor(c.arpTime/t.ticksPerArpeggio);a=s.pitches[h(s.pitchCount,c.fastTwoNoteArp,c.arpeggioPattern,e)]-s.pitches[0]}const l=t.algorithms[c.algorithm].carrierCount;for(let h=0;h<t.operatorCount;h++){const u=t.algorithms[c.algorithm].associatedCarrier[h]-1,p=s.pitches[r?0:h<s.pitchCount?h:u<s.pitchCount?u:0],f=t.operatorFrequencies[c.operators[h].frequency].mult,m=t.operatorCarrierInterval[u]+a,d=L+(p+D)*w+m,y=L+(p+O)*w+m,v=_.frequencyFromPitch(d),g=_.frequencyFromPitch(y),b=t.operatorFrequencies[c.operators[h].frequency].hzOffset,S=f*v+b,k=f*g+b,F=U[5+h],q=J[5+h];let T,P;1!=F||1!=q?(T=Math.pow(2,Math.log2(S/v)*F)*v,P=Math.pow(2,Math.log2(k/g)*q)*g):(T=S,P=k),s.phaseDeltas[h]=T*M,s.phaseDeltaScales[h]=Math.pow(P/T,1/o);let I=c.operators[h].amplitude,z=c.operators[h].amplitude;this.isModActive(t.modulators.dictionary["fm slider 1"].index+h,i,s.instrumentIndex)&&(I*=this.getModValue(t.modulators.dictionary["fm slider 1"].index+h,i,s.instrumentIndex,!1)/15,z*=this.getModValue(t.modulators.dictionary["fm slider 1"].index+h,i,s.instrumentIndex,!0)/15);const H=se.operatorAmplitudeCurve(I),x=se.operatorAmplitudeCurve(z);let G=H*t.operatorFrequencies[c.operators[h].frequency].amplitudeSign,A=x*t.operatorFrequencies[c.operators[h].frequency].amplitudeSign;if(h<l){let e;e=null!=s.prevPitchExpressions[h]?s.prevPitchExpressions[h]:Math.pow(2,-(d-E)/V);const t=Math.pow(2,-(y-E)/V);s.prevPitchExpressions[h]=t,G*=e,A*=t,n+=x}else G*=1.5*t.sineWaveLength,A*=1.5*t.sineWaveLength,e*=1-Math.min(1,c.operators[h].amplitude/15);if(G*=U[9+h],A*=J[9+h],this.isModActive(t.modulators.dictionary["note volume"].index,i,s.instrumentIndex)){const e=this.getModValue(t.modulators.dictionary["note volume"].index,i,s.instrumentIndex,!1),n=this.getModValue(t.modulators.dictionary["note volume"].index,i,s.instrumentIndex,!0);G*=e<=0?(e+t.volumeRange/2)/(t.volumeRange/2):se.instrumentVolumeToVolumeMult(e),A*=n<=0?(n+t.volumeRange/2)/(t.volumeRange/2):se.instrumentVolumeToVolumeMult(n)}s.operatorExpressions[h]=G,s.operatorExpressionDeltas[h]=(A-G)/o}e*=(Math.pow(2,2-1.4*c.feedbackAmplitude/15)-1)/3,e*=1-Math.min(1,Math.max(0,n-1)/2),e=1+3*e;const u=N*e*Y*G*R*U[0],p=N*e*Y*A*C*J[0];s.expression=u,s.expressionDelta=(p-u)/o;let f=c.feedbackAmplitude,m=c.feedbackAmplitude;this.isModActive(t.modulators.dictionary["fm feedback"].index,i,s.instrumentIndex)&&(f*=this.getModValue(t.modulators.dictionary["fm feedback"].index,i,s.instrumentIndex,!1)/15,m*=this.getModValue(t.modulators.dictionary["fm feedback"].index,i,s.instrumentIndex,!0)/15);let d=.3*t.sineWaveLength*f/15;const y=.3*t.sineWaveLength*m/15;let v=d*U[13],b=y*J[13];s.feedbackMult=v,s.feedbackDelta=(b-v)/o}else{const e=Math.pow(2,(O-D)*w/12/o);let n=s.pitches[0];if(s.pitchCount>1&&(g.arpeggiates||g.customInterval)){const e=Math.floor(c.arpTime/t.ticksPerArpeggio);if(g.customInterval){const t=s.pitches[1+h(s.pitchCount-1,c.fastTwoNoteArp,c.arpeggioPattern,e)]-s.pitches[0];z=Math.pow(2,t/12),s.specialIntervalExpressionMult=Math.pow(2,-t/V)}else n=s.pitches[h(s.pitchCount,c.fastTwoNoteArp,c.arpeggioPattern,e)]}const a=L+(n+D)*w,r=L+(n+O)*w;let l;l=null!=s.prevPitchExpressions[0]?s.prevPitchExpressions[0]:Math.pow(2,-(a-E)/V);const u=Math.pow(2,-(r-E)/V);s.prevPitchExpressions[0]=u;let f=N*Y;if(2==c.type&&(f*=t.chipNoises[c.chipNoise].expression),0==c.type&&(f*=t.chipWaves[c.chipWave].expression),6==c.type){const e=c.pulseWidth/(2*t.pulseWidthRange);let n=e,a=e;this.isModActive(t.modulators.dictionary["pulse width"].index,i,s.instrumentIndex)&&(n=this.getModValue(t.modulators.dictionary["pulse width"].index,i,s.instrumentIndex,!1)/(2*t.pulseWidthRange),a=this.getModValue(t.modulators.dictionary["pulse width"].index,i,s.instrumentIndex,!0)/(2*t.pulseWidthRange));const r=n*U[2],l=a*J[2];s.pulseWidth=r,s.pulseWidthDelta=(l-r)/o}if(7==c.type){let e=c.stringSustain,n=c.stringSustain;this.isModActive(t.modulators.dictionary.sustain.index,i,s.instrumentIndex)&&(e=this.getModValue(t.modulators.dictionary.sustain.index,i,s.instrumentIndex,!1),n=this.getModValue(t.modulators.dictionary.sustain.index,i,s.instrumentIndex,!0)),s.stringSustainStart=e,s.stringSustainEnd=n,f*=Math.pow(2,.7*(1-e/(t.stringSustainRange-1)))}const m=_.frequencyFromPitch(a);if(0==c.type||8==c.type||5==c.type||7==c.type){const i=t.unisons[c.unison],n=7==c.type?1:i.voices/2;f*=i.expression*n;const a=U[4],r=J[4],l=Math.pow(2,(i.offset+i.spread)*a/12),h=Math.pow(2,(i.offset+i.spread)*r/12),u=Math.pow(2,(i.offset-i.spread)*a/12)*z,p=Math.pow(2,(i.offset-i.spread)*r/12)*z;s.phaseDeltas[0]=m*M*l,s.phaseDeltas[1]=m*M*u,s.phaseDeltaScales[0]=e*Math.pow(h/l,1/o),s.phaseDeltaScales[1]=e*Math.pow(p/u,1/o)}else s.phaseDeltas[0]=m*M,s.phaseDeltaScales[0]=e;let d=f*G*R*l*U[0],y=f*A*C*u*J[0];if(this.isModActive(t.modulators.dictionary["note volume"].index,i,s.instrumentIndex)){const e=this.getModValue(t.modulators.dictionary["note volume"].index,i,s.instrumentIndex,!1),n=this.getModValue(t.modulators.dictionary["note volume"].index,i,s.instrumentIndex,!0);d*=e<=0?(e+t.volumeRange/2)/(t.volumeRange/2):se.instrumentVolumeToVolumeMult(e),y*=n<=0?(n+t.volumeRange/2)/(t.volumeRange/2):se.instrumentVolumeToVolumeMult(n)}if(s.expression=d,s.expressionDelta=(y-d)/o,7==c.type){let e;if(null!=s.prevStringDecay)e=s.prevStringDecay;else{const i=s.envelopeComputer.envelopeStarts[3];e=1-Math.min(1,i*s.stringSustainStart/(t.stringSustainRange-1))}const i=s.envelopeComputer.envelopeEnds[3];let n=1-Math.min(1,i*s.stringSustainEnd/(t.stringSustainRange-1));s.prevStringDecay=n;const a=t.unisons[c.unison];for(let e=s.pickedStrings.length;e<a.voices;e++)s.pickedStrings[e]=new Z;if(s.atNoteStart&&!v.continues&&!s.forceContinueAtStart)for(const e of s.pickedStrings)e.delayIndex=-1;for(let t=0;t<a.voices;t++)s.pickedStrings[t].update(this,p,s,t,o,e,n)}}}static getLFOAmplitude(e,i){let n=0;for(const s of t.vibratoTypes[e.vibratoType].periodsSeconds)n+=Math.sin(2*Math.PI*i/s);return n}static getInstrumentSynthFunction(e){if(1==e.type){const i=e.algorithm+"_"+e.feedbackType;if(null==se.fmSynthFunctionCache[i]){const n=[];for(const i of se.fmSourceTemplate)if(-1!=i.indexOf("// CARRIER OUTPUTS")){const s=[];for(let i=0;i<t.algorithms[e.algorithm].carrierCount;i++)s.push("operator"+i+"Scaled");n.push(i.replace("/*operator#Scaled*/",s.join(" + ")))}else if(-1!=i.indexOf("// INSERT OPERATOR COMPUTATION HERE"))for(let i=t.operatorCount-1;i>=0;i--)for(const s of se.operatorSourceTemplate)if(-1!=s.indexOf("/* + operator@Scaled*/")){let a="";for(const n of t.algorithms[e.algorithm].modulatedBy[i])a+=" + operator"+(n-1)+"Scaled";const r=t.feedbacks[e.feedbackType].indices[i];if(r.length>0){a+=" + feedbackMult * (";const e=[];for(const t of r)e.push("operator"+(t-1)+"Output");a+=e.join(" + ")+")"}n.push(s.replace(/\#/g,i+"").replace("/* + operator@Scaled*/",a))}else n.push(s.replace(/\#/g,i+""));else if(-1!=i.indexOf("#"))for(let e=0;e<t.operatorCount;e++)n.push(i.replace(/\#/g,e+""));else n.push(i);se.fmSynthFunctionCache[i]=new Function("synth","bufferIndex","roundedSamplesPerTick","tone","instrumentState",n.join("\n"))}return se.fmSynthFunctionCache[i]}if(0==e.type)return se.chipSynth;if(8==e.type)return se.chipSynth;if(5==e.type)return se.harmonicsSynth;if(6==e.type)return se.pulseWidthSynth;if(7==e.type)return se.pickedStringSynth;if(2==e.type)return se.noiseSynth;if(3==e.type)return se.spectrumSynth;if(4==e.type)return se.drumsetSynth;if(9==e.type)return se.modSynth;throw new Error("Unrecognized instrument type: "+e.type)}static chipSynth(e,t,i,n,s){const a=v(s.effects)&&s.aliases,r=e.tempMonoInstrumentSampleBuffer,o=s.wave,l=s.volumeScale,h=a&&8==s.type?o.length:o.length-1,u=n.specialIntervalExpressionMult*s.unison.sign;1!=s.unison.voices||s.chord.customInterval||(n.phases[1]=n.phases[0]);let c=n.phaseDeltas[0]*h,p=n.phaseDeltas[1]*h;const f=+n.phaseDeltaScales[0],m=+n.phaseDeltaScales[1];let d=+n.expression;const y=+n.expressionDelta;let g=n.phases[0]%1*h,b=n.phases[1]%1*h;const S=n.noteFilters,w=0|n.noteFilterCount;let k=+n.initialNoteFilterInput1,M=+n.initialNoteFilterInput2;const F=se.applyFilters;let q=0,T=0;if(!a){const e=0|g,t=0|b,i=e%h,n=t%h,s=g-e,a=b-t;q=+o[i],T=+o[n],q+=(o[i+1]-q)*s,T+=(o[n+1]-T)*a}const P=t+i;for(let e=t;e<P;e++){let t,i,n;if(g+=c,b+=p,a)t=o[(0|g)%h],i=o[(0|b)%h],n=t+i;else{const e=0|g,s=0|b,a=e%h,r=s%h;let l=o[a],f=o[r];const m=g-e,d=b-s;l+=(o[a+1]-l)*m,f+=(o[r+1]-f)*d,t=(l-q)/c,i=(f-T)/p,q=l,T=f,n=t+i*u}const s=F(n*l,k,M,w,S);M=k,k=n*l,c*=f,p*=m;const v=s*d;d+=y,r[e]+=v}n.phases[0]=g/h,n.phases[1]=b/h,n.phaseDeltas[0]=c/h,n.phaseDeltas[1]=p/h,n.expression=d,e.sanitizeFilters(S),n.initialNoteFilterInput1=k,n.initialNoteFilterInput2=M}static harmonicsSynth(e,t,i,n,s){const a=e.tempMonoInstrumentSampleBuffer,r=s.wave,o=r.length-1,l=n.specialIntervalExpressionMult*s.unison.sign;1!=s.unison.voices||s.chord.customInterval||(n.phases[1]=n.phases[0]);let h=n.phaseDeltas[0]*o,u=n.phaseDeltas[1]*o;const c=+n.phaseDeltaScales[0],p=+n.phaseDeltaScales[1];let f=+n.expression;const m=+n.expressionDelta;let d=n.phases[0]%1*o,y=n.phases[1]%1*o;const v=n.noteFilters,g=0|n.noteFilterCount;let b=+n.initialNoteFilterInput1,S=+n.initialNoteFilterInput2;const w=se.applyFilters,k=0|d,M=0|y,F=k%o,q=M%o,T=d-k,P=y-M;let I=+r[F],z=+r[q];I+=(r[F+1]-I)*T,z+=(r[q+1]-z)*P;const H=t+i;for(let e=t;e<H;e++){d+=h,y+=u;const t=0|d,i=0|y,n=t%o,s=i%o;let k=r[n],M=r[s];const F=d-t,q=y-i;k+=(r[n+1]-k)*F,M+=(r[s+1]-M)*q;const T=(k-I)/h,P=(M-z)/u;I=k,z=M;const H=T+P*l,x=w(H,b,S,g,v);S=b,b=H,h*=c,u*=p;const D=x*f;f+=m,a[e]+=D}n.phases[0]=d/o,n.phases[1]=y/o,n.phaseDeltas[0]=h/o,n.phaseDeltas[1]=u/o,n.expression=f,e.sanitizeFilters(v),n.initialNoteFilterInput1=b,n.initialNoteFilterInput2=S}static pickedStringSynth(e,t,i,n,s){const a=s.unison.voices;let r=se.pickedStringFunctionCache[a];if(null==r){let e="";e+="\n\t\t\t\tconst Config = beepbox.Config;\n\t\t\t\tconst Synth = beepbox.Synth;\n\t\t\t\tconst data = synth.tempMonoInstrumentSampleBuffer;\n\t\t\t\t\n\t\t\t\tlet pickedString# = tone.pickedStrings[#];\n\t\t\t\tlet allPassSample# = +pickedString#.allPassSample;\n\t\t\t\tlet allPassPrevInput# = +pickedString#.allPassPrevInput;\n\t\t\t\tlet shelfSample# = +pickedString#.shelfSample;\n\t\t\t\tlet shelfPrevInput# = +pickedString#.shelfPrevInput;\n\t\t\t\tlet fractionalDelaySample# = +pickedString#.fractionalDelaySample;\n\t\t\t\tconst delayLine# = pickedString#.delayLine;\n\t\t\t\tconst delayBufferMask# = (delayLine#.length - 1) >> 0;\n\t\t\t\tlet delayIndex# = pickedString#.delayIndex|0;\n\t\t\t\tdelayIndex# = (delayIndex# & delayBufferMask#) + delayLine#.length;\n\t\t\t\tlet delayLength# = +pickedString#.prevDelayLength;\n\t\t\t\tconst delayLengthDelta# = +pickedString#.delayLengthDelta;\n\t\t\t\tlet allPassG# = +pickedString#.allPassG;\n\t\t\t\tlet shelfA1# = +pickedString#.shelfA1;\n\t\t\t\tlet shelfB0# = +pickedString#.shelfB0;\n\t\t\t\tlet shelfB1# = +pickedString#.shelfB1;\n\t\t\t\tconst allPassGDelta# = +pickedString#.allPassGDelta;\n\t\t\t\tconst shelfA1Delta# = +pickedString#.shelfA1Delta;\n\t\t\t\tconst shelfB0Delta# = +pickedString#.shelfB0Delta;\n\t\t\t\tconst shelfB1Delta# = +pickedString#.shelfB1Delta;\n\t\t\t\t\n\t\t\t\tlet expression = +tone.expression;\n\t\t\t\tconst expressionDelta = +tone.expressionDelta;\n\t\t\t\t\n\t\t\t\tconst unisonSign = tone.specialIntervalExpressionMult * instrumentState.unison.sign;\n\t\t\t\tconst delayResetOffset# = pickedString#.delayResetOffset|0;\n\t\t\t\t\n\t\t\t\tconst filters = tone.noteFilters;\n\t\t\t\tconst filterCount = tone.noteFilterCount|0;\n\t\t\t\tlet initialFilterInput1 = +tone.initialNoteFilterInput1;\n\t\t\t\tlet initialFilterInput2 = +tone.initialNoteFilterInput2;\n\t\t\t\tconst applyFilters = Synth.applyFilters;\n\t\t\t\t\n\t\t\t\tconst stopIndex = bufferIndex + runLength;\n\t\t\t\tfor (let sampleIndex = bufferIndex; sampleIndex < stopIndex; sampleIndex++) {\n\t\t\t\t\tconst targetSampleTime# = delayIndex# - delayLength#;\n\t\t\t\t\tconst lowerIndex# = (targetSampleTime# + 0.125) | 0; // Offset to improve stability of all-pass filter.\n\t\t\t\t\tconst upperIndex# = lowerIndex# + 1;\n\t\t\t\t\tconst fractionalDelay# = upperIndex# - targetSampleTime#;\n\t\t\t\t\tconst fractionalDelayG# = (1.0 - fractionalDelay#) / (1.0 + fractionalDelay#); // Inlined version of FilterCoefficients.prototype.allPass1stOrderFractionalDelay\n\t\t\t\t\tconst prevInput# = delayLine#[lowerIndex# & delayBufferMask#];\n\t\t\t\t\tconst input# = delayLine#[upperIndex# & delayBufferMask#];\n\t\t\t\t\tfractionalDelaySample# = fractionalDelayG# * input# + prevInput# - fractionalDelayG# * fractionalDelaySample#;\n\t\t\t\t\t\n\t\t\t\t\tallPassSample# = fractionalDelaySample# * allPassG# + allPassPrevInput# - allPassG# * allPassSample#;\n\t\t\t\t\tallPassPrevInput# = fractionalDelaySample#;\n\t\t\t\t\t\n\t\t\t\t\tshelfSample# = shelfB0# * allPassSample# + shelfB1# * shelfPrevInput# - shelfA1# * shelfSample#;\n\t\t\t\t\tshelfPrevInput# = allPassSample#;\n\t\t\t\t\t\n\t\t\t\t\tdelayLine#[delayIndex# & delayBufferMask#] += shelfSample#;\n\t\t\t\t\tdelayLine#[(delayIndex# + delayResetOffset#) & delayBufferMask#] = 0.0;\n\t\t\t\t\tdelayIndex#++;\n\t\t\t\t\t\n\t\t\t\t\tconst inputSample = (";const t=[];for(let e=0;e<a;e++)t.push("fractionalDelaySample"+e+(1==e?" * unisonSign":""));e+=t.join(" + "),e+=") * expression;\n\t\t\t\t\tconst sample = applyFilters(inputSample, initialFilterInput1, initialFilterInput2, filterCount, filters);\n\t\t\t\t\tinitialFilterInput2 = initialFilterInput1;\n\t\t\t\t\tinitialFilterInput1 = inputSample;\n\t\t\t\t\tdata[sampleIndex] += sample;\n\t\t\t\t\t\n\t\t\t\t\texpression += expressionDelta;\n\t\t\t\t\tdelayLength# += delayLengthDelta#;\n\t\t\t\t\tallPassG# += allPassGDelta#;\n\t\t\t\t\tshelfA1# += shelfA1Delta#;\n\t\t\t\t\tshelfB0# += shelfB0Delta#;\n\t\t\t\t\tshelfB1# += shelfB1Delta#;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Avoid persistent denormal or NaN values in the delay buffers and filter history.\n\t\t\t\tconst epsilon = (1.0e-24);\n\t\t\t\tif (!Number.isFinite(allPassSample#) || Math.abs(allPassSample#) < epsilon) allPassSample# = 0.0;\n\t\t\t\tif (!Number.isFinite(allPassPrevInput#) || Math.abs(allPassPrevInput#) < epsilon) allPassPrevInput# = 0.0;\n\t\t\t\tif (!Number.isFinite(shelfSample#) || Math.abs(shelfSample#) < epsilon) shelfSample# = 0.0;\n\t\t\t\tif (!Number.isFinite(shelfPrevInput#) || Math.abs(shelfPrevInput#) < epsilon) shelfPrevInput# = 0.0;\n\t\t\t\tif (!Number.isFinite(fractionalDelaySample#) || Math.abs(fractionalDelaySample#) < epsilon) fractionalDelaySample# = 0.0;\n\t\t\t\tpickedString#.allPassSample = allPassSample#;\n\t\t\t\tpickedString#.allPassPrevInput = allPassPrevInput#;\n\t\t\t\tpickedString#.shelfSample = shelfSample#;\n\t\t\t\tpickedString#.shelfPrevInput = shelfPrevInput#;\n\t\t\t\tpickedString#.fractionalDelaySample = fractionalDelaySample#;\n\t\t\t\tpickedString#.delayIndex = delayIndex#;\n\t\t\t\tpickedString#.prevDelayLength = delayLength#;\n\t\t\t\tpickedString#.allPassG = allPassG#;\n\t\t\t\tpickedString#.shelfA1 = shelfA1#;\n\t\t\t\tpickedString#.shelfB0 = shelfB0#;\n\t\t\t\tpickedString#.shelfB1 = shelfB1#;\n\t\t\t\t\n\t\t\t\ttone.expression = expression;\n\t\t\t\t\n\t\t\t\tsynth.sanitizeFilters(filters);\n\t\t\t\ttone.initialNoteFilterInput1 = initialFilterInput1;\n\t\t\t\ttone.initialNoteFilterInput2 = initialFilterInput2;",e=e.replace(/^.*\#.*$/gm,(e=>{const t=[];for(let i=0;i<a;i++)t.push(e.replace(/\#/g,String(i)));return t.join("\n")})),r=new Function("synth","bufferIndex","runLength","tone","instrumentState",e),se.pickedStringFunctionCache[a]=r}r(e,t,i,n,s)}static effectsSynth(e,t,i,n,s,a){const r=v(a.effects),o=g(a.effects),l=a.eqFilterCount>0,h=b(a.effects),u=S(a.effects),c=w(a.effects),p=k(a.effects);let f=0;r&&(f|=1),f<<=1,o&&(f|=1),f<<=1,l&&(f|=1),f<<=1,h&&(f|=1),f<<=1,u&&(f|=1),f<<=1,c&&(f|=1),f<<=1,p&&(f|=1);let m=se.effectsFunctionCache[f];if(null==m){let e="";const t=u||p||c;e+="\n\t\t\t\tconst Config = beepbox.Config;\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 = beepbox.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;"),u&&(e+="\n\t\t\t\t\n\t\t\t\tconst chorusMask = synth.chorusDelayBufferMask >>> 0;\n\t\t\t\tconst chorusDelayLineL = instrumentState.chorusDelayLineL;\n\t\t\t\tconst chorusDelayLineR = instrumentState.chorusDelayLineR;\n\t\t\t\tinstrumentState.chorusDelayLineDirty = true;\n\t\t\t\tlet chorusDelayPos = instrumentState.chorusDelayPos & chorusMask;\n\t\t\t\t\n\t\t\t\tlet chorusVoiceMult = +instrumentState.chorusVoiceMult;\n\t\t\t\tconst chorusVoiceMultDelta = +instrumentState.chorusVoiceMultDelta;\n\t\t\t\tlet chorusCombinedMult = +instrumentState.chorusCombinedMult;\n\t\t\t\tconst chorusCombinedMultDelta = +instrumentState.chorusCombinedMultDelta;\n\t\t\t\t\n\t\t\t\tconst chorusDuration = +beepbox.Config.chorusPeriodSeconds;\n\t\t\t\tconst chorusAngle = Math.PI * 2.0 / (chorusDuration * synth.samplesPerSecond);\n\t\t\t\tconst chorusRange = synth.samplesPerSecond * beepbox.Config.chorusDelayRange;\n\t\t\t\tconst chorusOffset0 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[0][0] * chorusRange;\n\t\t\t\tconst chorusOffset1 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[0][1] * chorusRange;\n\t\t\t\tconst chorusOffset2 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[0][2] * chorusRange;\n\t\t\t\tconst chorusOffset3 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[1][0] * chorusRange;\n\t\t\t\tconst chorusOffset4 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[1][1] * chorusRange;\n\t\t\t\tconst chorusOffset5 = synth.chorusDelayBufferSize - beepbox.Config.chorusDelayOffsets[1][2] * chorusRange;\n\t\t\t\tlet chorusPhase = instrumentState.chorusPhase % (Math.PI * 2.0);\n\t\t\t\tlet chorusTap0Index = chorusDelayPos + chorusOffset0 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][0]);\n\t\t\t\tlet chorusTap1Index = chorusDelayPos + chorusOffset1 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][1]);\n\t\t\t\tlet chorusTap2Index = chorusDelayPos + chorusOffset2 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][2]);\n\t\t\t\tlet chorusTap3Index = chorusDelayPos + chorusOffset3 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][0]);\n\t\t\t\tlet chorusTap4Index = chorusDelayPos + chorusOffset4 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][1]);\n\t\t\t\tlet chorusTap5Index = chorusDelayPos + chorusOffset5 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][2]);\n\t\t\t\tchorusPhase += chorusAngle * runLength;\n\t\t\t\tconst chorusTap0End = chorusDelayPos + chorusOffset0 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][0]) + runLength;\n\t\t\t\tconst chorusTap1End = chorusDelayPos + chorusOffset1 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][1]) + runLength;\n\t\t\t\tconst chorusTap2End = chorusDelayPos + chorusOffset2 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[0][2]) + runLength;\n\t\t\t\tconst chorusTap3End = chorusDelayPos + chorusOffset3 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][0]) + runLength;\n\t\t\t\tconst chorusTap4End = chorusDelayPos + chorusOffset4 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][1]) + runLength;\n\t\t\t\tconst chorusTap5End = chorusDelayPos + chorusOffset5 - chorusRange * Math.sin(chorusPhase + beepbox.Config.chorusPhaseOffsets[1][2]) + runLength;\n\t\t\t\tconst chorusTap0Delta = (chorusTap0End - chorusTap0Index) / runLength;\n\t\t\t\tconst chorusTap1Delta = (chorusTap1End - chorusTap1Index) / runLength;\n\t\t\t\tconst chorusTap2Delta = (chorusTap2End - chorusTap2Index) / runLength;\n\t\t\t\tconst chorusTap3Delta = (chorusTap3End - chorusTap3Index) / runLength;\n\t\t\t\tconst chorusTap4Delta = (chorusTap4End - chorusTap4Index) / runLength;\n\t\t\t\tconst chorusTap5Delta = (chorusTap5End - chorusTap5Index) / runLength;"),c&&(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;"),p&&(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;",u&&(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;"),c&&(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 "),p&&(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\tbeepbox.Synth.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;"),u&&(e+="\n\t\t\t\t\n\t\t\t\tbeepbox.Synth.sanitizeDelayLine(chorusDelayLineL, chorusDelayPos, chorusMask);\n\t\t\t\tbeepbox.Synth.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;"),c&&(e+="\n\t\t\t\t\n\t\t\t\tbeepbox.Synth.sanitizeDelayLine(echoDelayLineL, echoDelayPos, echoMask);\n\t\t\t\tbeepbox.Synth.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;"),p&&(e+="\n\t\t\t\t\n\t\t\t\tbeepbox.Synth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos , reverbMask);\n\t\t\t\tbeepbox.Synth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos + 3041, reverbMask);\n\t\t\t\tbeepbox.Synth.sanitizeDelayLine(reverbDelayLine, reverbDelayPos + 6426, reverbMask);\n\t\t\t\tbeepbox.Synth.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;"),m=new Function("synth","outputDataL","outputDataR","bufferIndex","runLength","instrumentState",e),se.effectsFunctionCache[f]=m}m(e,t,i,n,s,a)}static pulseWidthSynth(e,t,i,n,s){const a=e.tempMonoInstrumentSampleBuffer;let r=n.phaseDeltas[0];const o=+n.phaseDeltaScales[0];let l=+n.expression;const h=+n.expressionDelta;let u=n.phases[0]%1,c=n.pulseWidth;const p=n.pulseWidthDelta,f=n.noteFilters,m=0|n.noteFilterCount;let d=+n.initialNoteFilterInput1,y=+n.initialNoteFilterInput2;const v=se.applyFilters,g=t+i;for(let e=t;e<g;e++){const t=u%1,i=(u+c)%1;let n=i-t;if(!s.aliases){if(t<r)n+=.5*((b=t/r)+b-b*b-1);else if(t>1-r){n+=.5*((b=(t-1)/r)+b+b*b+1)}if(i<r)n-=.5*((b=i/r)+b-b*b-1);else if(i>1-r){var b;n-=.5*((b=(i-1)/r)+b+b*b+1)}}const g=n,S=v(g,d,y,m,f);y=d,d=g,u+=r,r*=o,c+=p;const w=S*l;l+=h,a[e]+=w}n.phases[0]=u,n.phaseDeltas[0]=r,n.expression=l,n.pulseWidth=c,e.sanitizeFilters(f),n.initialNoteFilterInput1=d,n.initialNoteFilterInput2=y}static noiseSynth(e,i,n,s,a){const r=e.tempMonoInstrumentSampleBuffer,o=a.wave;let l=+s.phaseDeltas[0];const h=+s.phaseDeltaScales[0];let u=+s.expression;const c=+s.expressionDelta;let p=s.phases[0]%1*t.chipNoiseLength;0==s.phases[0]&&(p=Math.random()*t.chipNoiseLength);const f=t.chipNoiseLength-1;let m=+s.noiseSample;const d=s.noteFilters,y=0|s.noteFilterCount;let v=+s.initialNoteFilterInput1,g=+s.initialNoteFilterInput2;const b=se.applyFilters,S=Math.min(1,l*a.noisePitchFilterMult),w=i+n;for(let e=i;e<w;e++){m+=(o[p&f]-m)*S;const t=m,i=b(t,v,g,y,d);g=v,v=t,p+=l,l*=h;const n=i*u;u+=c,r[e]+=n}s.phases[0]=p/t.chipNoiseLength,s.phaseDeltas[0]=l,s.expression=u,s.noiseSample=m,e.sanitizeFilters(d),s.initialNoteFilterInput1=v,s.initialNoteFilterInput2=g}static spectrumSynth(e,i,n,s,a){const r=e.tempMonoInstrumentSampleBuffer,o=a.wave;let l=128*s.phaseDeltas[0];const h=+s.phaseDeltaScales[0];let u=+s.expression;const c=+s.expressionDelta;let p=+s.noiseSample;const f=s.noteFilters,m=0|s.noteFilterCount;let d=+s.initialNoteFilterInput1,y=+s.initialNoteFilterInput2;const v=se.applyFilters;let g=s.phases[0]%1*t.spectrumNoiseLength;0==s.phases[0]&&(g=se.findRandomZeroCrossing(o,t.spectrumNoiseLength)+l);const b=t.spectrumNoiseLength-1,S=Math.min(1,l),w=i+n;for(let e=i;e<w;e++){const t=0|g,i=t&b;let n=o[i];const s=g-t;n+=(o[i+1]-n)*s,p+=(n-p)*S;const a=p,w=v(a,d,y,m,f);y=d,d=a,g+=l,l*=h;const k=w*u;u+=c,r[e]+=k}s.phases[0]=g/t.spectrumNoiseLength,s.phaseDeltas[0]=l/128,s.expression=u,s.noiseSample=p,e.sanitizeFilters(f),s.initialNoteFilterInput1=d,s.initialNoteFilterInput2=y}static drumsetSynth(e,i,n,s,a){const r=e.tempMonoInstrumentSampleBuffer;let o=a.getDrumsetWave(s.drumsetPitch);const l=ie.drumsetIndexReferenceDelta(s.drumsetPitch);let h=s.phaseDeltas[0]/l;const u=+s.phaseDeltaScales[0];let c=+s.expression;const p=+s.expressionDelta,f=s.noteFilters,m=0|s.noteFilterCount;let d=+s.initialNoteFilterInput1,y=+s.initialNoteFilterInput2;const v=se.applyFilters;let g=s.phases[0]%1*t.spectrumNoiseLength;0==s.phases[0]&&(g=se.findRandomZeroCrossing(o,t.spectrumNoiseLength)+h);const b=t.spectrumNoiseLength-1,S=i+n;for(let e=i;e<S;e++){const t=0|g,i=t&b;let n=o[i];const s=g-t;n+=(o[i+1]-n)*s;const a=n,l=v(a,d,y,m,f);y=d,d=a,g+=h,h*=u;const S=l*c;c+=p,r[e]+=S}s.phases[0]=g/t.spectrumNoiseLength,s.phaseDeltas[0]=h*l,s.expression=c,e.sanitizeFilters(f),s.initialNoteFilterInput1=d,s.initialNoteFilterInput2=y}static modSynth(e,i,n,s,a){if(!e.song)return;let r=t.modCount-1-s.pitches[0];if(a.invalidModulators[r])return;let o=a.modulators[r],l=[];if(t.modulators[a.modulators[r]].forSong)l.push(0);else if(a.modInstruments[r]==e.song.channels[a.modChannels[r]].instruments.length)for(let t=0;t<e.song.channels[a.modChannels[r]].instruments.length;t++)l.push(t);else a.modInstruments[r]>e.song.channels[a.modChannels[r]].instruments.length?null!=e.song.getPattern(a.modChannels[r],e.bar)&&(l=e.song.getPattern(a.modChannels[r],e.bar).instruments):l.push(a.modInstruments[r]);for(let i=0;i<l.length;i++)if(e.setModValue(s.expression,s.expression+s.expressionDelta,r,a.modChannels[r],l[i],o),o==t.modulators.dictionary["reset arp"].index&&0==e.tick&&s.noteStartPart==e.beat*t.partsPerBeat+e.part)e.song.channels[a.modChannels[r]].instruments[l[i]].arpTime=0;else if(o==t.modulators.dictionary["next bar"].index)e.wantToSkip=!0;else if(o==t.modulators.dictionary["eq filter"].index){const o=e.song.channels[a.modChannels[r]].instruments[l[i]];if(!o.eqFilterType){let i=0|a.modFilterTypes[r];if(0==i){let i=0;const a=e.getTicksIntoBar()/t.ticksPerPart;for(;s.note.start+s.note.pins[i].time<=a;)i++;let r=(a-s.note.start+n/(e.getSamplesPerTick()*t.ticksPerPart)*t.ticksPerPart-s.note.pins[i-1].time)/(s.note.pins[i].time-s.note.pins[i-1].time);null!=o.eqSubFilters[s.note.pins[i-1].size]||null!=o.eqSubFilters[s.note.pins[i].size]?o.tmpEqFilterEnd=K.lerpFilters(o.eqSubFilters[s.note.pins[i-1].size],o.eqSubFilters[s.note.pins[i].size],r):o.tmpEqFilterEnd=o.eqFilter}else{for(let e=0;e<t.filterMorphCount;e++)o.tmpEqFilterEnd==o.eqSubFilters[e]&&null!=o.tmpEqFilterEnd&&(o.tmpEqFilterEnd=new K,o.tmpEqFilterEnd.fromJsonObject(o.eqSubFilters[e].toJsonObject()));null==o.tmpEqFilterEnd&&(o.tmpEqFilterEnd=new K,o.tmpEqFilterEnd.fromJsonObject(o.eqFilter.toJsonObject())),o.tmpEqFilterEnd.controlPointCount>Math.floor((i-1)/2)&&(i%2?o.tmpEqFilterEnd.controlPoints[Math.floor((i-1)/2)].freq=s.expression+s.expressionDelta:o.tmpEqFilterEnd.controlPoints[Math.floor((i-1)/2)].gain=s.expression+s.expressionDelta)}}}else if(o==t.modulators.dictionary["note filter"].index){const o=e.song.channels[a.modChannels[r]].instruments[l[i]];if(!o.noteFilterType){let i=0|a.modFilterTypes[r];if(0==i){let i=0;const a=e.getTicksIntoBar()/t.ticksPerPart;for(;s.note.start+s.note.pins[i].time<=a;)i++;let r=(a-s.note.start+n/(e.getSamplesPerTick()*t.ticksPerPart)*t.ticksPerPart-s.note.pins[i-1].time)/(s.note.pins[i].time-s.note.pins[i-1].time);null!=o.noteSubFilters[s.note.pins[i-1].size]||null!=o.noteSubFilters[s.note.pins[i].size]?o.tmpNoteFilterEnd=K.lerpFilters(o.noteSubFilters[s.note.pins[i-1].size],o.noteSubFilters[s.note.pins[i].size],r):o.tmpNoteFilterEnd=o.noteFilter}else{for(let e=0;e<t.filterMorphCount;e++)o.tmpNoteFilterEnd==o.noteSubFilters[e]&&null!=o.tmpNoteFilterEnd&&(o.tmpNoteFilterEnd=new K,o.tmpNoteFilterEnd.fromJsonObject(o.noteSubFilters[e].toJsonObject()));null==o.tmpNoteFilterEnd&&(o.tmpNoteFilterEnd=new K,o.tmpNoteFilterEnd.fromJsonObject(o.noteFilter.toJsonObject())),o.tmpNoteFilterEnd.controlPointCount>Math.floor((i-1)/2)&&(i%2?o.tmpNoteFilterEnd.controlPoints[Math.floor((i-1)/2)].freq=s.expression+s.expressionDelta:o.tmpNoteFilterEnd.controlPoints[Math.floor((i-1)/2)].gain=s.expression+s.expressionDelta)}}}}static findRandomZeroCrossing(e,t){let i=Math.random()*t;const n=t-1;let s=i&n,a=e[s];for(let r=128;r>0;r--){const r=s+16&n,o=e[r];if(a*o<=0){for(let r=0;r<16;r++){const r=s+1&n,o=e[r];if(a*o<=0){const e=o-a;i=s,Math.abs(e)>1e-8&&(i+=-a/e),i=Math.max(0,i)%t;break}s=r,a=o}break}s=r,a=o}return i}static instrumentVolumeToVolumeMult(e){return e==-t.volumeRange/2?0:Math.pow(2,t.volumeLogScale*e)}static volumeMultToInstrumentVolume(e){return e<=0?-t.volumeRange/2:Math.min(t.volumeRange,Math.log(e)/Math.LN2/t.volumeLogScale)}static noteSizeToVolumeMult(e){return Math.pow(Math.max(0,e)/t.noteSizeMax,1.5)}static volumeMultToNoteSize(e){return Math.pow(Math.max(0,e),1/1.5)*t.noteSizeMax}static fadeInSettingToSeconds(e){return.0125*(.95*e+.05*e*e)}static secondsToFadeInSetting(e){return O(0,t.fadeInRange,Math.round((-.95+Math.sqrt(.9025+.2*e/.0125))/.1))}static fadeOutSettingToTicks(e){return t.fadeOutTicks[e]}static ticksToFadeOutSetting(e){let i=t.fadeOutTicks[0];if(e<=i)return 0;for(let n=1;n<t.fadeOutTicks.length;n++){let s=t.fadeOutTicks[n];if(e<=s)return e<(i+s)/2?n-1:n;i=s}return t.fadeOutTicks.length-1}static detuneToCents(e){return e-t.detuneCenter}static centsToDetune(e){return e+t.detuneCenter}static getOperatorWave(e,i){return 3!=e?t.operatorWaves[e]:t.pwmOperatorWaves[i]}getSamplesPerTick(){if(null==this.song)return 0;let e=this.song.getBeatsPerMinute();return this.isModActive(t.modulators.dictionary.tempo.index)&&(e=this.getModValue(t.modulators.dictionary.tempo.index)),this.getSamplesPerTickSpecificBPM(e)}getSamplesPerTickSpecificBPM(e){const i=e/60,n=t.partsPerBeat*i,s=t.ticksPerPart*n;return this.samplesPerSecond/s}static fittingPowerOfTwo(e){return 1<<32-Math.clz32(Math.ceil(e)-1)}sanitizeFilters(e){let t=!1;for(const i of e){const e=Math.abs(i.output1),n=Math.abs(i.output2);if(!(e<100&&n<100)){t=!0;break}e<D&&(i.output1=0),n<D&&(i.output2=0)}if(t)for(const t of e)t.output1=0,t.output2=0}static sanitizeDelayLine(e,t,i){for(;;){const n=--t&i,s=Math.abs(e[n]);if(Number.isFinite(s)&&(0==s||s>=D))break;e[n]=0}}static applyFilters(e,t,i,n,s){for(let a=0;a<n;a++){const n=s[a],r=n.output1,o=n.output2,l=n.a1,h=n.a2,u=n.b0,c=n.b1,p=n.b2;e=u*e+c*t+p*i-l*r-h*o,n.a1=l+n.a1Delta,n.a2=h+n.a2Delta,n.useMultiplicativeInputCoefficients?(n.b0=u*n.b0Delta,n.b1=c*n.b1Delta,n.b2=p*n.b2Delta):(n.b0=u+n.b0Delta,n.b1=c+n.b1Delta,n.b2=p+n.b2Delta),n.output2=r,n.output1=e,i=o,t=r}return e}}return se.tempFilterStartCoefficients=new I,se.tempFilterEndCoefficients=new I,se.fmSynthFunctionCache={},se.effectsFunctionCache=Array(128).fill(void 0),se.pickedStringFunctionCache=Array(3).fill(void 0),se.fmSourceTemplate=("\n\t\tconst data = synth.tempMonoInstrumentSampleBuffer;\n\t\tconst sineWave = beepbox.Config.sineWave;\n\t\t\t\n\t\t// I'm adding 1000 to the phase to ensure that it's never negative even when modulated by other waves because negative numbers don't work with the modulus operator very well.\n\t\tlet operator#Phase = +((tone.phases[#] % 1) + 1000) * "+t.sineWaveLength+";\n\t\tlet operator#PhaseDelta = +tone.phaseDeltas[#] * "+t.sineWaveLength+";\n\t\tlet operator#PhaseDeltaScale = +tone.phaseDeltaScales[#];\n\t\tlet operator#OutputMult = +tone.operatorExpressions[#];\n\t\tconst operator#OutputDelta = +tone.operatorExpressionDeltas[#];\n\t\tlet operator#Output = +tone.feedbackOutputs[#];\n const operator#Wave = tone.operatorWaves[#].samples;\n\t\tlet feedbackMult = +tone.feedbackMult;\n\t\tconst feedbackDelta = +tone.feedbackDelta;\n let expression = +tone.expression;\n\t\tconst expressionDelta = +tone.expressionDelta;\n\t\t\n\t\tconst filters = tone.noteFilters;\n\t\tconst filterCount = tone.noteFilterCount|0;\n\t\tlet initialFilterInput1 = +tone.initialNoteFilterInput1;\n\t\tlet initialFilterInput2 = +tone.initialNoteFilterInput2;\n\t\tconst applyFilters = beepbox.Synth.applyFilters;\n\t\t\n\t\tconst stopIndex = bufferIndex + roundedSamplesPerTick;\n\t\tfor (let sampleIndex = bufferIndex; sampleIndex < stopIndex; sampleIndex++) {\n\t\t\t\t// INSERT OPERATOR COMPUTATION HERE\n\t\t\t\tconst fmOutput = (/*operator#Scaled*/); // CARRIER OUTPUTS\n\t\t\t\t\n\t\t\tconst inputSample = fmOutput;\n\t\t\tconst sample = applyFilters(inputSample, initialFilterInput1, initialFilterInput2, filterCount, filters);\n\t\t\tinitialFilterInput2 = initialFilterInput1;\n\t\t\tinitialFilterInput1 = inputSample;\n\t\t\t\t\n\t\t\t\tfeedbackMult += feedbackDelta;\n\t\t\t\toperator#OutputMult += operator#OutputDelta;\n\t\t\t\toperator#Phase += operator#PhaseDelta;\n\t\t\toperator#PhaseDelta *= operator#PhaseDeltaScale;\n\t\t\t\n\t\t\tconst output = sample * expression;\n\t\t\texpression += expressionDelta;\n\n\t\t\tdata[sampleIndex] += output;\n\t\t\t}\n\t\t\t\n\t\t\ttone.phases[#] = operator#Phase / "+t.sineWaveLength+";\n\t\t\ttone.phaseDeltas[#] = operator#PhaseDelta / "+t.sineWaveLength+";\n\t\t\ttone.operatorExpressions[#] = operator#OutputMult;\n\t\t tone.feedbackOutputs[#] = operator#Output;\n\t\t tone.feedbackMult = feedbackMult;\n\t\t tone.expression = expression;\n\t\t\t\n\t\tsynth.sanitizeFilters(filters);\n\t\ttone.initialNoteFilterInput1 = initialFilterInput1;\n\t\ttone.initialNoteFilterInput2 = initialFilterInput2;\n\t\t").split("\n"),se.operatorSourceTemplate=("\n\t\t\t\tconst operator#PhaseMix = operator#Phase/* + operator@Scaled*/;\n\t\t\t\tconst operator#PhaseInt = operator#PhaseMix|0;\n\t\t\t\tconst operator#Index = operator#PhaseInt & "+t.sineWaveMask+";\n const operator#Sample = operator#Wave[operator#Index];\n operator#Output = operator#Sample + (operator#Wave[operator#Index + 1] - operator#Sample) * (operator#PhaseMix - operator#PhaseInt);\n\t\t\t\tconst operator#Scaled = operator#OutputMult * operator#Output;\n\t\t").split("\n"),e.Channel=Y,e.Config=t,e.EnvelopeSettings=J,e.FilterControlPoint=Q,e.FilterSettings=K,e.HarmonicsWave=j,e.Instrument=_,e.Note=N,e.Operator=W,e.Pattern=V,e.Song=X,e.SpectrumWave=B,e.Synth=se,e.clamp=O,e.makeNotePin=L,Object.defineProperty(e,"W",{value:!0}),e}({});
//# sourceMappingURL=beepbox_synth.min.js.map