/*! p5.func.js v0.5 2022-07-03 */ !function(b,a){"function"==typeof define&&define.amd?define("p5.func",["p5"],function(b){a(b)}):"object"==typeof exports?a(require("../p5")):a(b.p5)}(this,function(p5){p5.Gen=function(){this.version=.01},p5.Gen.prototype.harmonics=function(a,c){var b,f=!0;for(var e in Array.isArray(a)||a.constructor===Float32Array||a.constructor===Float64Array||(a=[a],f=!1),Array.isArray(c)||(c=[c]),Array.isArray(a)?b=new Array(a.length):a.constructor===Float32Array?b=new Float32Array(a.length):a.constructor===Float64Array&&(b=new Float64Array(a.length)),a){var d=c.length;for(b[e]=0;d--;)if(0!=c[d]){var g=TWO_PI*a[e]*(d+1);b[e]+=Math.sin(g)*c[d]}}return f?b:b[0]},p5.Gen.prototype.triples=function(a,b){var e=!0;if(Array.isArray(a)||a.constructor===Float32Array||a.constructor===Float64Array||(a=[a],e=!1),b.length<2)return console.log("p5.Gen : we need at least 3 arguments!"),0;for(i in b.length%3!=0&&console.log("p5.Gen : incomplete triplet!"),Array.isArray(a)?d=new Array(a.length):a.constructor===Float32Array?d=new Float32Array(a.length):a.constructor===Float64Array&&(d=new Float64Array(a.length)),a){d[i]=0;for(var d,f,c=b.length-1;c>0;c-=3)0!=b[c-1]&&(f=0==b[c-2]?1:Math.sin(TWO_PI*(a[i]/(1/b[c-2])+b[c]/360)),d[i]+=f*b[c-1])}return e?d:d[0]},p5.Gen.prototype.chebyshev=function(a,c){var b,g=!0;for(var d in Array.isArray(a)||a.constructor===Float32Array||a.constructor===Float64Array||(a=[a],g=!1),Array.isArray(c)||(c=[c]),Array.isArray(a)?b=new Array(a.length):a.constructor===Float32Array?b=new Float32Array(a.length):a.constructor===Float64Array&&(b=new Float64Array(a.length)),a){var h=2*a[d]-1;b[d]=0;for(var i=1,e=h,f=0;f pair!"),0;var j=b[b.length-2],k=b[0];if(j-k<=0)return console.log("p5.Gen : bpf times must be in ascending order!"),0;var l=1/(j-k),e=0,f=0,g=0,h=0;for(i in Array.isArray(a)?d=new Array(a.length):a.constructor===Float32Array?d=new Float32Array(a.length):a.constructor===Float64Array&&(d=new Float64Array(a.length)),a)for(var c=1;c=e&&a[i]<=f){b[c+1],d[i]=map(a[i],e,f,g,h);break}}return i?d:d[0]},p5.Gen.prototype.random=function(a,e){var b,d=!0;for(var c in a?"string"!=typeof a?Array.isArray(arguments[0])||arguments[0].constructor===Float32Array||arguments[0].constructor===Float64Array||(a=[a],d=!1):(e=a,a=[performance.now()],d=!1):(e="linear",a=[performance.now()],d=!1),Array.isArray(a)?b=new Array(a.length):a.constructor===Float32Array?b=new Float32Array(a.length):a.constructor===Float64Array&&(b=new Float64Array(a.length)),-1===a[0]&&randomSeed(1e5*performance.now()),a)switch(-1!=a[c]&&randomSeed(1e5*a[c]),e){case"linear":case"even":default:b[c]=random();break;case"low":b[c]=Math.min(random(),random());break;case"high":b[c]=Math.max(random(),random());break;case"triangle":b[c]=(random()+random())/2;break;case"gaussian":for(var f=12,i=.166666,g=0,h=0;h1)}return d?b:b[0]},p5.Gen.prototype.window=function(a,y,b){var t=!0;switch(Array.isArray(b)||(b=[b]),Array.isArray(a)||a.constructor===Float32Array||a.constructor===Float64Array||(a=[a],t=!1),Array.isArray(a)?s=new Array(a.length):a.constructor===Float32Array?s=new Float32Array(a.length):a.constructor===Float64Array&&(s=new Float64Array(a.length)),y){case 1:case"hamming":var n=.54,z=.46;for(d in a)s[d]=n-z*Math.cos(TWO_PI*a[d]);break;case 2:case"hanning":case"vonhann":case"hann":case"hannsolo":case"hanningvonhannmeister":for(d in a)s[d]=.5*(1-Math.cos(TWO_PI*a[d]));break;case 3:case"bartlett":case"fejer":case"fej\xe9r":case"triangle":for(d in a)s[d]=1-Math.abs((a[d]-.5)/.5);break;case"bartlett-hann":var e=.62,f=.48,g=.38;for(d in a)s[d]=e-f*Math.abs(a[d]-.5)-g*Math.cos(2*PI*a[d]);break;case 4:case"blackman":var e=7938/18608,f=9240/18608,g=1430/18608;for(d in a)s[d]=e-f*Math.cos(2*PI*a[d])+g*Math.cos(4*PI*a[d]);break;case"generalizedblackman":b[0]||(b[0]=.5);var c=b[0],e=(1-c)/2,f=.5,g=c/2;for(d in a){var u=PI*a[d];s[d]=e-f*Math.cos(2*u)+g*Math.cos(4*u)}break;case 5:case"blackman-harris":var e=.35875,f=.48829,g=.14128,i=.01168;for(d in a)s[d]=e-f*Math.cos(2*PI*a[d])+g*Math.cos(4*PI*a[d])+i*Math.cos(6*PI*a[d]);break;case"blackman-nuttal":var e=.3635819,f=.4891775,g=.1365995,i=.0106411;for(d in a)s[d]=e-f*Math.cos(2*PI*a[d])+g*Math.cos(4*PI*a[d])+i*Math.cos(6*PI*a[d]);break;case"nuttal":var e=.355768,f=.487396,g=.144232,i=.012604;for(d in a)s[d]=e-f*Math.cos(2*PI*a[d])+g*Math.cos(4*PI*a[d])+i*Math.cos(6*PI*a[d]);break;case 6:case"gaussian":b[0]||(b[0]=.4);var j=b[0];for(d in a)s[d]=Math.exp(-0.5*((a[d]-.5)/(.5*j))*((a[d]-.5)/(.5*j)));break;case 7:case"kaiser":var n=3;for(d in a){var A=PI*n*Math.sqrt(1-(2*a[d]-1)*(2*a[d]-1)),B=PI*n;s[d]=besselI0(A)/besselI0(B)}break;case 8:case"rectangle":case"boxcar":case"dirichlet":for(d in a)s[d]=1;break;case"cosine":for(d in a)s[d]=Math.sin(PI*a[d]);break;case 9:case"sinc":case"sync":case"lanczos":for(d in a)s[d]=sinc(2*a[d]-1);break;case"flattop":var e=1,f=1.93,g=1.29,i=.388,v=.032;for(d in a)s[d]=e-f*Math.cos(2*PI*a[d])+g*Math.cos(4*PI*a[d])-i*Math.cos(6*PI*a[d])+v*Math.cos(8*PI*a[d]),s[d]/=e+f+g+i+v;break;case"tukey":b[0]||(b[0]=.5);var c=b[0],o=c/2,w=1-o;for(d in a)s[d]=1,a[d]<=o?s[d]=.5*(1+Math.cos(PI*(2*a[d]/c-1))):a[d]>w&&(s[d]=.5*(1+Math.cos(PI*(2*a[d]/c-2/c+1))));break;case"slidinggaussian":b[0]||(b[0]=.5),b[1]||(b[1]=.4);var C=2*(b[0]-.5),j=2*b[1];for(var d in a)s[d]=Math.exp(0-sq(2*a[d]-1-C)/(2*j*j));break;case"adjustablecosine":b[0]||(b[0]=.5);var c=b[0],o=c/2,w=1-o;for(d in a)s[d]=1,a[d]<=c?s[d]=.5*(1+Math.cos(PI*(a[d]/c-1))):s[d]=.5*(1+Math.cos(PI*((a[d]-c)/(1-c))));break;case"elliptic":b[0]||(b[0]=.5);var c=b[0],k=0+Number.EPSILON,l=1-Number.EPSILON;for(d in c=constrain(c,k,l),a)s[d]=0,a[d]<=c?s[d]=1/c*Math.sqrt(sq(c)-sq(a[d]-c)):s[d]=1/(1-c)*Math.sqrt(sq(1-c)-sq(a[d]-c));break;case"hyperelliptic":b[0]||(b[0]=.5),b[1]||(b[1]=3);var c=b[0],p=b[1],k=0+Number.EPSILON,l=1-Number.EPSILON;for(d in c=constrain(c,k,l),a){s[d]=0;var h=2*p;a[d]<=c?s[d]=1/c*Math.pow(Math.pow(c,h)-Math.pow(a[d]-c,h),1/h):s[d]=1/(1-c)*Math.pow(Math.pow(1-c,h)-Math.pow(a[d]-c,h),1/h)}break;case"squircular":b[0]||(b[0]=.5),b[1]||(b[1]=3);var c=b[0],p=b[1],k=0+Number.EPSILON,l=1-Number.EPSILON;for(d in c=constrain(c,k,l),a){s[d]=0;var h=Math.max(2,2*p);a[d]<=c?s[d]=1-c+Math.pow(Math.pow(c,h)-Math.pow(a[d]-c,h),1/h):s[d]=c+Math.pow(Math.pow(1-c,h)-Math.pow(a[d]-c,h),1/h)}break;case"poisson":b[0]||(b[0]=.5);var m=Math.max(b[0],Number.EPSILON);for(var d in a)s[d]=Math.exp(0-Math.abs(a[d]-.5)*(1/m));break;case"hann-poisson":case"poisson-hann":case"hannpoisson":case"poissonhann":b[0]||(b[0]=.5);var m=25*Math.max(b[0]*b[0]*b[0]*b[0],Number.EPSILON);for(d in a){var q=.5*(1-Math.cos(TWO_PI*a[d])),r=Math.exp(0-Math.abs(a[d]-.5)*(1/m));s[d]=q*r}break;case"slidinghann-poisson":case"slidingpoisson-hann":case"slidinghannpoisson":case"slidingpoissonhann":b[0]||(b[0]=.5),b[1]||(b[1]=.5);var s,d,m=25*Math.max(b[1]*b[1]*b[1]*b[1],Number.EPSILON);for(d in a){var x=constrain(a[d]+(.5-b[0]),0,1),q=.5*(1-Math.cos(TWO_PI*x)),r=Math.exp(0-Math.abs(x-.5)*(1/m));s[d]=q*r}}return t?s:s[0]},p5.Gen.prototype.waveform=function(a,d){var b,c=!0;switch(Array.isArray(a)||a.constructor===Float32Array||a.constructor===Float64Array||(a=[a],c=!1),Array.isArray(a)?b=new Array(a.length):a.constructor===Float32Array?b=new Float32Array(a.length):a.constructor===Float64Array&&(b=new Float64Array(a.length)),d){case"sine":case"sin":b=this.harmonics(a,[1]);break;case"cosine":case"cos":b=this.triples(a,[1,1,90]);break;case"saw":case"sawtooth":case"sawup":b=this.bpf(a,[0,-1,1,1]);break;case"sawdown":b=this.bpf(a,[0,1,1,-1]);break;case"phasor":b=this.bpf(a,[0,0,1,1]);break;case"square":b=this.bpf(a,[0,1,1,1,1,-1,2,-1]);break;case"rect":case"rectangle":b=this.bpf(a,[0,1,1,1,1,-1,10,-1]);break;case"pulse":b=this.bpf(a,[0,1,1,1,1,-1,100,-1]);break;case"tri":case"triangle":b=this.bpf(a,[0,0,1,1,2,0,3,-1,4,0]);break;case"buzz":b=this.harmonics(a,[.1,.1,.1,.1,.1,.1,.1,.1,.1,.1])}return c?b:b[0]},p5.Gen.prototype.listAlgos=function(){var c=new Array;for(var a in this.__proto__){var b=!0;"listAlgos"==a?b=!1:"fillArray"==a?b=!1:"fillFloat32Array"==a?b=!1:"fillFloat64Array"==a&&(b=!1),b&&c.push(a)}return c},p5.Gen.prototype.fillArray=function(e,b,f,d){var c=new Array(b);if("random"===e)for(var a=0;a=1&&(c=1),c},p5.Ease.prototype.exponentialSmoothedStaircase=function(e,b,a){b||(b=.25),a||(a=3);for(var f=sq(map(b,0,1,5,30)),d=0,c=0;c=b?e:map(c,a,b,d,e):c<=b?e:c>=a?d:map(c,b,a,e,d)},p5.Ease.prototype.doubleOddPolynomialOgee=function(c,a,b,d){a||(a=.25),b||(b=.75),d||(d=3);var f=0+Number.EPSILON,g=1-Number.EPSILON,h=0,i=1;a=constrain(a,f,g),b=constrain(b,h,i);var e=2*d+1;return c<=a?b-b*Math.pow(1-c/a,e):b+(1-b)*Math.pow((c-a)/(1-a),e)},p5.Ease.prototype.doubleLinear=function(c,a,b){a||(a=.25),b||(b=.75);var d=0,e=0+Number.EPSILON,f=1-Number.EPSILON,g=0,h=1;return a=constrain(a,e,f),b=constrain(b,g,h),d=c<=a?b/a*c:b+(1-b)/(1-a)*(c-a)},p5.Ease.prototype.tripleLinear=function(a,b,d,c,e){return b||(b=.25),d||(d=.75),c||(c=.75),e||(e=.25),b=c?map(a,c,1,e,1):map(a,b,c,d,e):a<=c?map(a,0,c,0,e):a>=b?map(a,b,1,d,1):map(a,c,b,e,d)},p5.Ease.prototype.variableStaircase=function(b,e,a){e||(e=.25),a||(a=3);var f=e-.5;if(0==f)return b;var c=Math.floor(b*a)/a,d=Math.ceil(b*a)/a,i=c,j=d,g=.5*(c+d)+f/a,h=.5*(c+d)-f/a;return bc?map(b,c,g,i,h):map(b,g,d,h,j)},p5.Ease.prototype.quadraticBezierStaircase=function(c,r,b){r||(r=.25),b||(b=3);var s=r-.5;if(0==s)return c;var h=Math.floor(c*b)/b,j=Math.ceil(c*b)/b,t=h,u=j,m=.5*(h+j)+s/b,n=.5*(h+j)-s/b,v=(h+m)/2,o=(t+n)/2,p=(j+m)/2,k=(u+n)/2,l=0,g=1/b*.5;if(c<=v&&c>=h){if(0>=Math.floor(c*b))l=map(c,h,m,t,n);else{var a=(h-(p-1/b))/g,i=(t-(k-1/b))/g,q=(c-(p-1/b))/g,e=1-2*a,w=Math.max(0,a*a+e*q),f=(Math.sqrt(w)-a)/e,d=(1-2*i)*(f*f)+2*i*f;d*=k-o,d+=k,c>h&&(d-=1/b),l=d}}else if(c>=p&&c<=j){if(Math.ceil(c*b)>=b)l=map(c,m,j,n,u);else{var a=(j-p)/g,i=(u-k)/g,q=(c-p)/g;.5==a&&(a+=Number.EPSILON);var e=1-2*a;Math.abs(e)=1?1:b+(1-b)/(1-a)*Math.sqrt(sq(1-a)-sq(c-1))},p5.Ease.prototype.doubleCubicOgeeSimplified=function(d,a,b){a||(a=.25),b||(b=.75),b=1-b;var e=0;if(d<=a){if(a<=0)e=0;else{var c=1-d/a;e=b*d+(1-b)*a*(1-c*c*c)}}else if(a>=1)e=1;else{var c=(d-a)/(1-a);e=b*d+(1-b)*(a+(1-a)*c*c*c)}return e},p5.Ease.prototype.raisedInvertedCosine=function(a){return(1-Math.cos(PI*a))/2},p5.Ease.prototype.cosineApproximation=function(b){var a=b*b,c=a*a;return 4/9*(c*a)-17/9*c+22/9*a},p5.Ease.prototype.smoothStep=function(a){return a*a*(3-2*a)},p5.Ease.prototype.smootherStep=function(a){return a*a*a*(a*(6*a-15)+10)},p5.Ease.prototype.cheapStep=function(a){return a=1-(a=1-a*a)*a},p5.Ease.prototype.maclaurinCosine=function(e){for(var g=6,b=1,h=(e*=PI)*e,c=1,d=1,f=b,a=0;a>1)),1/(a*=1.5-c*a*a)},p5.Ease.prototype.doubleExponentialOgee=function(b,a){a||(a=.25);var c=0+Number.EPSILON,d=1-Number.EPSILON;return a=constrain(a,c,d),b<=.5?Math.pow(2*b,1-a)/2:1-Math.pow(2*(1-b),1-a)/2},p5.Ease.prototype.circularFillet=function(e,g,h,z){g||(g=.25),h||(h=.75),z||(z=.75);var A=0,B=0,s=0,P=0,t=0,C=0,i=0,m=0,j=0,ac=0+Number.EPSILON,ad=1-Number.EPSILON,ae=0+Number.EPSILON,af=1-Number.EPSILON;g=constrain(g,ac,ad),h=constrain(h,ae,af);var ag=z;function Q(a,b,e,f,g){var c=0,d=Math.sqrt(a*a+b*b);return 0!=d&&(c=(a*f+b*g+e)/d),c}computefillet:{var R,S,T,U,D,E,F,k,l,G=0,H=0,I=g,J=h,K=g,L=h,M=1,N=1,O=ag,u=I*H-G*J,a=J-H,b=G-I,v=M*L-K*N,c=N-L,d=K-M;if(a*d==c*b||0==(R=Q(a,b,u,T=(K+M)/2,U=(L+N)/2))||0==(S=Q(c,d,v,T=(G+I)/2,U=(H+J)/2)))break computefillet;var f=O;R<=0&&(f=-f),D=u-f*Math.sqrt(a*a+b*b),f=O,S<=0&&(f=-f),E=v-f*Math.sqrt(c*c+d*d),F=a*d-c*b;var n=(E*b-D*d)/F,o=(D*c-E*a)/F,V=0,W=0,X=0,Y=0;0!=(k=a*a+b*b)&&(l=a*o-b*n,V=(-a*u-b*l)/k,W=(a*l-b*u)/k),0!=(k=c*c+d*d)&&(l=c*o-d*n,X=(-c*v-d*l)/k,Y=(c*l-d*v)/k);var p=V-n,q=W-o,w=X-n,x=Y-o,r=Math.atan2(q,p),y=0,Z=Math.sqrt((p*p+q*q)*(w*w+x*x));0!=Z&&(y=Math.acos((p*w+q*x)/Z));var $=p*x-w*q;$<0&&(r-=y);var _=r,aa=r+y;$<0&&(_=r+y,aa=r),i=n,m=o,A=_,B=aa,s=i+(j=O)*Math.cos(A),P=m+j*Math.sin(A),t=i+j*Math.cos(B),C=m+j*Math.sin(B)}var ab=0;return(e=constrain(e,0,1))<=s?s=t?C+(ab=(e-t)/(1-t))*(1-C):e>=i?m-Math.sqrt(sq(j)-sq(e-i)):m+Math.sqrt(sq(j)-sq(e-i))},p5.Ease.prototype.circularArcThroughAPoint=function(k,h,l){h||(h=.25),l||(l=.75);var a={};a.centerX=0,a.centerY=0,a.dRadius=0;var m=0+Number.EPSILON,n=1-Number.EPSILON,o=0+Number.EPSILON,p=1-Number.EPSILON;h=constrain(h,m,n),l=constrain(l,o,p),k=constrain(k,0+Number.EPSILON,1-Number.EPSILON);var b=0,c=0,d=h,e=l,f=1,g=1;function i(e,f,a,b,g,h){var i=b-f,c=a-e,d=h-b,j=g-a;return!(Math.abs(c)<=Number.EPSILON&&Math.abs(d)<=Number.EPSILON)&&(!!(Math.abs(i)<=Number.EPSILON||Math.abs(d)<=Number.EPSILON)||Math.abs(c)<=Number.EPSILON||Math.abs(j)<=Number.EPSILON)}function j(d,b,c,f,h,i,a){var l=f-b,j=c-d,k=i-f,m=h-c;if(Math.abs(j)<=Number.EPSILON&&Math.abs(k)<=Number.EPSILON){a.centerX=.5*(c+h),a.centerY=.5*(b+f),a.dRadius=Math.sqrt(sq(a.centerX-d)+sq(a.centerY-b));return}var e=l/j,g=k/m;Math.abs(e-g)<=Number.EPSILON||(a.centerX=(e*g*(b-i)+g*(d+c)-e*(c+h))/(2*(g-e)),a.centerY=-1*(a.centerX-(d+c)/2)/e+(b+f)/2,a.dRadius=Math.sqrt(sq(a.centerX-d)+sq(a.centerY-b)))}if(i(b,c,d,e,f,g)){if(i(b,c,f,g,d,e)){if(i(d,e,b,c,f,g)){if(i(d,e,f,g,b,c)){if(i(f,g,d,e,b,c)){if(i(f,g,b,c,d,e))return 0;j(f,g,b,c,d,e,a)}else j(f,g,d,e,b,c,a)}else j(d,e,f,g,b,c,a)}else j(d,e,b,c,f,g,a)}else j(b,c,f,g,d,e,a)}else j(b,c,d,e,f,g,a);return a.centerX>0&&a.centerX<1&&(h=a.centerX?a.centerY-Math.sqrt(sq(a.dRadius)-sq(k-a.centerX)):a.centerY+Math.sqrt(sq(a.dRadius)-sq(k-a.centerX))},p5.Ease.prototype.quadraticBezier=function(e,a,b){a||(a=.25),b||(b=.75);var f=0,g=1;a=constrain(a,0,1),b=constrain(b,f,g),.5==a&&(a+=Number.EPSILON);var d=1-2*a,c=(Math.sqrt(a*a+d*e)-a)/d;return(1-2*b)*(c*c)+2*b*c},p5.Ease.prototype.cubicBezier=function(j,b,c,d,e){b||(b=.25),c||(c=.75),d||(d=.75),e||(e=.25);var q=0+Number.EPSILON,r=1-Number.EPSILON,s=0,t=1,u=0+Number.EPSILON,v=1-Number.EPSILON,w=0,x=1;b=constrain(b,q,r),c=constrain(c,s,t),d=constrain(d,u,v),e=constrain(e,w,x);for(var f=0,g=0,h=c,i=b,k=e,l=d,y=1,z=1,m=z-3*l+3*i-g,n=3*l-6*i+3*g,o=3*i-3*g,A=g,B=y-3*k+3*h-f,C=3*k-6*h+3*f,D=3*h-3*f,E=f,a=j,F=5,p=0;p=.5},p5.Ease.prototype.listAlgos=function(){var c=new Array;for(var a in this.__proto__){var b=!0;"listAlgos"==a?b=!1:"fillArray"==a?b=!1:"fillFloat32Array"==a?b=!1:"fillFloat64Array"==a&&(b=!1),b&&c.push(a)}return c},p5.Ease.prototype.fillArray=function(d,b,e){for(var c=new Array(b),a=0;a denominator gain for filter (y[n] term)."),console.log(" b0 -> gain for current input (x[n] term)."),console.log(" b1 -> gain for previous input (x[n-1] term)."),console.log(" b2 -> gain for previous previous input (x[n-2] term)."),console.log(" a1 -> gain for previous output (y[n-1] term)."),console.log(" a2 -> gain for previous previous output (y[n-2] term)."),console.log("when working with 5-coefficient biquad formulae set a0 to 1.0."),console.log("n.b. some systems will refer to y terms as 'b' and x terms as 'a'.")):(this.a0=a,this.b0=b,this.b1=c,this.b2=d,this.a1=e,this.a2=f)},p5.Filt.prototype.precalc=function(){switch(this.A=Math.sqrt(Math.pow(10,this.dB/20)),this.w0=2*PI*this.f0/this.fs,this.cw0=Math.cos(this.w0),this.sw0=Math.sin(this.w0),this.alpha=Math.sin(this.w0)/(2*this.Q),this.soff=2*Math.sqrt(this.A)*this.alpha,this.type){case"LPF":case"lowpass":this.b0=(1-this.cw0)/2,this.b1=1-this.cw0,this.b2=(1-this.cw0)/2,this.a0=1+this.alpha,this.a1=-2*this.cw0,this.a2=1-this.alpha;break;case"HPF":case"highpass":this.b0=(1+this.cw0)/2,this.b1=-(1+this.cw0),this.b2=(1+this.cw0)/2,this.a0=1+this.alpha,this.a1=-2*this.cw0,this.a2=1-this.alpha;break;case"BPF":case"bandpass":this.b0=this.sw0/2,this.b1=0,this.b2=-this.sw0/2,this.a0=1+this.alpha,this.a1=-2*this.cw0,this.a2=1-this.alpha;break;case"BPF0":case"resonant":this.b0=this.alpha,this.b1=0,this.b2=-this.alpha,this.a0=1+this.alpha,this.a1=-2*this.cw0,this.a2=1-this.alpha;break;case"notch":case"bandreject":case"bandstop":this.b0=1,this.b1=-2*this.cw0,this.b2=1,this.a0=1+this.alpha,this.a1=-2*this.cw0,this.a2=1-this.alpha;break;case"APF":case"allpass":this.b0=1-this.alpha,this.b1=-2*this.cw0,this.b2=1+this.alpha,this.a0=1+this.alpha,this.a1=-2*this.cw0,this.a2=1-this.alpha;break;case"peakingEQ":case"peaknotch":this.b0=1+this.alpha*this.A,this.b1=-2*this.cw0,this.b2=1-this.alpha*this.A,this.a0=1+this.alpha/this.A,this.a1=-2*this.cw0,this.a2=1-this.alpha/this.A;break;case"lowShelf":case"lowshelf":this.b0=this.A*(this.A+1-(this.A-1)*this.cw0+this.soff),this.b1=2*this.A*(this.A-1-(this.A+1)*this.cw0),this.b2=this.A*(this.A+1-(this.A-1)*this.cw0-this.soff),this.a0=this.A+1+(this.A-1)*this.cw0+this.soff,this.a1=-2*(this.A-1+(this.A+1)*this.cw0),this.a2=this.A+1+(this.A-1)*this.cw0-this.soff;break;case"highShelf":case"highshelf":this.b0=this.A*(this.A+1+(this.A-1)*this.cw0+this.soff),this.b1=-2*this.A*(this.A-1+(this.A+1)*this.cw0),this.b2=this.A*(this.A+1+(this.A-1)*this.cw0-this.soff),this.a0=this.A+1-(this.A-1)*this.cw0+this.soff,this.a1=2*(this.A-1-(this.A+1)*this.cw0),this.a2=this.A+1-(this.A-1)*this.cw0-this.soff;break;default:this.b0=1,this.b1=0,this.b2=0,this.a0=1,this.a1=0,this.a2=0}},p5.FastFourierTransform=function(d,e,f){this.bufferSize=d||512,this.hopSize=f||this.bufferSize,this.sampleRate=e||60,this.bandwidth=this.sampleRate/this.bufferSize,this.real=new Float64Array(this.bufferSize),this.imag=new Float64Array(this.bufferSize),this.doSpectrum=!0,this.magnitude=new Float64Array(this.bufferSize/2),this.phase=new Float64Array(this.bufferSize/2),this.doFrequency=!1,this.runningphase=new Float64Array(this.bufferSize/2),this.previousphase=new Float64Array(this.bufferSize/2),this.frequency=new Float64Array(this.bufferSize/2),this.peakBand=0,this.peak=0,this.reverseTable=new Uint32Array(this.bufferSize);for(var a,b=1,c=this.bufferSize>>1;b>=1}for(a=0,this.sinTable=new Float64Array(this.bufferSize),this.cosTable=new Float64Array(this.bufferSize);athis.peak&&(this.peakBand=a,this.peak=b),this.magnitude[a]=b,this.phase[a]=e;this.doFrequency&&this.calculateFrequency()},p5.FastFourierTransform.prototype.calculateFrequency=function(){var a=Array.from(this.phase);for(i in this.runningphase=subtractArray(a,this.previousphase),this.runningphase=addArray(this.runningphase,TWO_PI+PI),this.runningphase=moduloArray(this.runningphase,TWO_PI),this.runningphase=subtractArray(this.runningphase,PI),this.previousphase=a,this.frequency)this.frequency[i]=this.bandwidth*i+this.runningphase[i]*this.sampleRate/(TWO_PI*this.hopSize)},p5.FastFourierTransform.prototype.forward=function(k){var f,g,e,d,h,i,l,a,b,m=Math.floor(Math.log(this.bufferSize)/Math.LN2);if(Math.pow(2,m)!==this.bufferSize)throw"buffer size must be a power of 2.";if(this.bufferSize!==k.length)throw"buffer is not the same size as defined FFT. FFT: "+bufferSize+" buffer: "+buffer.length;var c=1;for(a=0;a=_a)return a;if(_a==_b)return _a;if(a<_a)for(b=a;b<_a;)b+=e;else b=(a-_a)%e+_a;return b},p5.prototype.fold=function(c,f,g){_a=Math.min(f,g);var e,d=(_b=Math.max(f,g))-_a;if(c<_b&&c>=_a)return c;if(_a==_b)return _a;if(c<_a){var a=_a-c,b=Math.floor(a/d);b%2==0?(a-=b*d,e=a+_a):(a-=b*d,e=_b-a)}else{var a=c-_b,b=Math.floor(a/d);b%2==0?(a-=b*d,e=_b-a):(a-=b*d,e=a+_a)}return e},p5.prototype.createArray=function(a){var b=new Array(a||0).fill(0),c=a;if(arguments.length>1)for(var d=Array.prototype.slice.call(arguments,1);c--;)b[a-1-c]=this.createArray.apply(this,d);return b},p5.prototype.normalizeArray=function(a){var b=Math.max(Math.max(a),Math.abs(Math.min(a)));return a.map(function(a){return a/b})},p5.prototype.resizeArray=function(b,d){for(var e=[],a=0;a=b&&c[a]b+f?"/":"-",c[a+1]b+f||c[a]>b+f&&c[a+1]=b&&0