-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp5.func.min.js
1 lines (1 loc) · 39.5 KB
/
p5.func.min.js
1
/*! 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 <partial, amp, phase> 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<c.length;f++)b[d]+=c[f]*e,Tn2=i,e=2*h*(i=e)-Tn2}return g?b:b[0]},p5.Gen.prototype.bpf=function(a,b){var d,i=!0;if(Array.isArray(a)||a.constructor===Float32Array||a.constructor===Float64Array||(a=[a],i=!1),b.length%2!=0)return console.log("p5.Gen : incomplete <time, value> 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<b.length;c+=2){if(e=b[c-1]*l,g=b[c],c<b.length-1?(f=b[c+1]*l,h=b[c+2]):(f=e,h=g),f-e<0)return console.log("p5.Gen : bpf times music be in ascending order!"),0;if(a[i]>=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;h<f;h++)g+=random();b[c]=i*(g-f/2)+.5;break;case"cauchy":var j=.00628338;do{do b[c]=random();while(.5==b[c])b[c]=j*tan(b[c]*PI)+.5}while(b[c]<0||b[c]>1)}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<b;a++)d?c[a]=a/(b-1)*1e4+d:c[a]="-1";else for(var a=0;a<b;a++)c[a]=a/(b-1);return this[e](c,f,d)},p5.Gen.prototype.fillFloat32Array=function(e,b,f,d){var c=new Float32Array(b);if(new Float32Array(b),"random"===e)for(var a=0;a<b;a++)d?c[a]=a/(b-1)*1e4+d:c[a]="-1";else for(var a=0;a<b;a++)c[a]=a/(b-1);return this[e](c,f,d)},p5.Gen.prototype.fillFloat64Array=function(e,b,f,d){var c=new Float64Array(b);if(new Float64Array(b),"random"===e)for(var a=0;a<b;a++)d?c[a]=a/(b-1)*1e4+d:c[a]="-1";else for(var a=0;a<b;a++)c[a]=a/(b-1);return this[e](c,f,d)},p5.Ease=function(){this.version=.01},p5.Ease.prototype.linear=function(a){return a},p5.Ease.prototype.quadraticIn=function(a){return a*a},p5.Ease.prototype.quadraticOut=function(a){return-(a*(a-2))},p5.Ease.prototype.quadraticInOut=function(a){return a<.5?2*a*a:-2*a*a+4*a-1},p5.Ease.prototype.cubicIn=function(a){return a*a*a},p5.Ease.prototype.cubicOut=function(b){var a=b-1;return a*a*a+1},p5.Ease.prototype.cubicInOut=function(a){if(a<.5)return 4*a*a*a;var b=2*a-2;return .5*b*b*b+1},p5.Ease.prototype.quarticIn=function(a){return a*a*a*a},p5.Ease.prototype.quarticOut=function(b){var a=b-1;return a*a*a*(1-b)+1},p5.Ease.prototype.quarticInOut=function(a){if(a<.5)return 8*a*a*a*a;var b=a-1;return -8*b*b*b*b+1},p5.Ease.prototype.quinticIn=function(a){return a*a*a*a*a},p5.Ease.prototype.quinticOut=function(b){var a=b-1;return a*a*a*a*a+1},p5.Ease.prototype.quinticInOut=function(a){if(a<.5)return 16*a*a*a*a*a;var b=2*a-2;return .5*b*b*b*b*b+1},p5.Ease.prototype.sineIn=function(a){return Math.sin((a-1)*HALF_PI)+1},p5.Ease.prototype.sineOut=function(a){return Math.sin(a*HALF_PI)},p5.Ease.prototype.sineInOut=function(a){return .5*(1-Math.cos(a*PI))},p5.Ease.prototype.circularIn=function(a){return 1-Math.sqrt(1-a*a)},p5.Ease.prototype.circularOut=function(a){return Math.sqrt((2-a)*a)},p5.Ease.prototype.circularInOut=function(a){return a<.5?.5*(1-Math.sqrt(1-4*(a*a))):.5*(Math.sqrt(-(2*a-3)*(2*a-1))+1)},p5.Ease.prototype.exponentialIn=function(a){return 0==a?a:Math.pow(2,10*(a-1))},p5.Ease.prototype.exponentialOut=function(a){return 1==a?a:1-Math.pow(2,-10*a)},p5.Ease.prototype.exponentialInOut=function(a){return 0==a||1==a?a:a<.5?.5*Math.pow(2,20*a-10):-0.5*Math.pow(2,-20*a+10)+1},p5.Ease.prototype.elasticIn=function(a){return Math.sin(13*HALF_PI*a)*Math.pow(2,10*(a-1))},p5.Ease.prototype.elasticOut=function(a){return Math.sin(-13*HALF_PI*(a+1))*Math.pow(2,-10*a)+1},p5.Ease.prototype.elasticInOut=function(a){return a<.5?.5*Math.sin(13*HALF_PI*(2*a))*Math.pow(2,10*(2*a-1)):.5*(Math.sin(-13*HALF_PI*(2*a-1+1))*Math.pow(2,-10*(2*a-1))+2)},p5.Ease.prototype.backIn=function(a){return a*a*a-a*Math.sin(a*PI)},p5.Ease.prototype.backOut=function(b){var a=1-b;return 1-(a*a*a-a*Math.sin(a*PI))},p5.Ease.prototype.backInOut=function(b){if(b<.5){var a=2*b;return .5*(a*a*a-a*Math.sin(a*PI))}var a=1-(2*b-1);return .5*(1-(a*a*a-a*Math.sin(a*PI)))+.5},p5.Ease.prototype.bounceIn=function(a){return 1-this.bounceOut(1-a)},p5.Ease.prototype.bounceOut=function(a){return a<4/11?121*a*a/16:a<8/11?9.075*a*a-9.9*a+3.4:a<.9?4356/361*a*a-35442/1805*a+16061/1805:10.8*a*a-20.52*a+10.72},p5.Ease.prototype.bounceInOut=function(a){return a<.5?.5*this.bounceIn(2*a):.5*this.bounceOut(2*a-1)+.5},p5.Ease.prototype.brycesCubic=function(b,a){a||(a=3);var c=Math.pow(b,a-1),d=c*b;return a*c-(a-1)*d},p5.Ease.prototype.staircase=function(b,a){a||(a=3);var c=Math.floor(b*a)/(a-1);return b>=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<a;c++)d+=1/(a-1)/(1+Math.exp(f*((c+1)/a-e)));return constrain(d,0,1)},p5.Ease.prototype.gompertz=function(d,a){a||(a=.25);var b=-8,c=0-16*(a=Math.max(a,0+Number.EPSILON)),e=Math.exp(b*Math.exp(c*d)),f=Math.exp(b*Math.exp(c)),g=Math.exp(b);return map(e,g,f,0,1)},p5.Ease.prototype.generalizedLinearMap=function(c,a,d,b,e){return a||(a=0),d||(d=0),b||(b=1),e||(e=1),a<b?c<=a?d: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?a<=b?map(a,0,b,0,d):a>=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 b<g&&b>c?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)<Number.EPSILON&&(e=(e<0?-1:1)*Number.EPSILON);var 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,l=d}}else{var a=(m-v)/g,i=(n-o)/g,q=(c-v)/g;.5==a&&(a+=Number.EPSILON);var e=1-2*a,f=(Math.sqrt(a*a+e*q)-a)/e,d=(1-2*i)*(f*f)+2*i*f;d*=k-o,d+=o,l=d}return l},p5.Ease.prototype.doubleExponentialSigmoid=function(b,a){a||(a=.75);var c=0+Number.EPSILON,d=1-Number.EPSILON;return a=1-(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.adjustableCenterDoubleExponentialSigmoid=function(d,a,b){a||(a=.75),b||(b=.5);var e=0+Number.EPSILON,f=1-Number.EPSILON;a=1-(a=constrain(a,e,f));var c=Math.max(0,Math.min(1,d-(b-.5)));return c<=.5?Math.pow(2*c,1/a)/2:1-Math.pow(2*(1-c),1/a)/2},p5.Ease.prototype.doubleQuadraticSigmoid=function(a){return a<=.5?sq(2*a)/2:1-sq(2*(a-1))/2},p5.Ease.prototype.doublePolynomialSigmoid=function(b,a){return a||(a=3),a%2==0?b<=.5?Math.pow(2*b,a)/2:1-Math.pow(2*(b-1),a)/2:b<=.5?Math.pow(2*b,a)/2:1+Math.pow(2*(b-1),a)/2},p5.Ease.prototype.doubleEllipticOgee=function(c,a,b){a||(a=.25),b||(b=.75);var d=0+Number.EPSILON,e=1-Number.EPSILON;return a=constrain(a,d,e),c<=a?b/a*Math.sqrt(sq(a)-sq(c-a)):1-(1-b)/(1-a)*Math.sqrt(sq(1-a)-sq(c-a))},p5.Ease.prototype.doubleCubicOgee=function(c,a,b){a||(a=.25),b||(b=.75);var d=0+Number.EPSILON,e=1-Number.EPSILON,f=0,g=1;return a=constrain(a,d,e),b=constrain(b,f,g),c<=a?b-b*Math.pow(1-c/a,3):b+(1-b)*Math.pow((c-a)/(1-a),3)},p5.Ease.prototype.doubleCircularSigmoid=function(b,a){return a||(a=.25),b<=a?a-Math.sqrt(a*a-b*b):a+Math.sqrt(sq(1-a)-sq(b-1))},p5.Ease.prototype.doubleSquircularSigmoid=function(c,a,d){a||(a=.25),d||(d=3);var b=Math.max(2,2*d);return c<=a?a-Math.pow(Math.pow(a,b)-Math.pow(c,b),1/b):a+Math.pow(Math.pow(1-a,b)-Math.pow(c-1,b),1/b)},p5.Ease.prototype.doubleQuadraticBezier=function(m,h,i,j,k){h||(h=.25),i||(i=.75),j||(j=.75),k||(k=.25);var a,d,l,b,f,c=(h+j)/2,e=(i+k)/2;c=constrain(c,Number.EPSILON,1-Number.EPSILON),e=constrain(e,Number.EPSILON,1-Number.EPSILON);var g=0;return m<=c?(l=m/c,b=h/c,f=i/e,a=1-2*b,0==a&&(a=Number.EPSILON),d=(Math.sqrt(b*b+a*l)-b)/a,g=(1-2*f)*(d*d)+2*f*d,g*=e):(l=(m-c)/(1-c),b=(j-c)/(1-c),f=(k-e)/(1-e),a=1-2*b,0==a&&(a=Number.EPSILON),d=(Math.sqrt(b*b+a*l)-b)/a,g=(1-2*f)*(d*d)+2*f*d,g*=1-e,g+=e),g},p5.Ease.prototype.doubleEllipticSigmoid=function(c,a,b){return a||(a=.25),b||(b=.75),c<=a?a<=0?0:b*(1-Math.sqrt(sq(a)-sq(c))/a):a>=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<g;a++)b*=h,c=0-c,d*=2*a+1,d*=2*a+2,f+=c*(b/d);return(1-f)/2},p5.Ease.prototype.catmullRomInterpolate=function(a,b,c){b||(b=.25),c||(c=.75);var d=b,e=c,f=a*a,g=-0.5*d+.5*e-1.5,h=d-.5*e+2,i=-0.5*d+.5,j=g*a*f+h*f+i*a;return constrain(j,0,1)},p5.Ease.prototype.hermite=function(d,a,b,c,e){a||(a=.25),b||(b=0),c||(c=1),e||(e=.25),a=map(a,0,1,-1,1);var f=((c=map(c,0,1,-1,1))-a)*.5,g=b-c,h=f+g,i=h+g+(e-b)*.5,j=h+i,k=((i*d-j)*d+f)*d+b;return k},p5.Ease.prototype.hermite2=function(b,h,i,j,k){h||(h=.25),i||(i=.75),j||(j=.75),k||(k=.25);var l,m,c=map(j,0,1,-1,1),d=map(k,0,1,-1,1),e=0,f=1,n=i,a=b*b,g=a*b;l=(e-2*(h-.5))*(1+d)*(1-c)/2,l+=(f-e)*(1-d)*(1-c)/2,m=(f-e)*(1+d)*(1-c)/2;var o=2*g-3*a+1,p=g-2*a+b,q=g-a,r=-2*g+3*a,s=o*e+p*l+q*(m+=(n-f)*(1-d)*(1-c)/2)+r*f;return s},p5.Ease.prototype.normalizedErf=function(f){var d=2,g=.99532226501,b=map(f,0,1,0-d,d),c=b*b,e=8*(PI-3)/(3*PI*(4-PI)),a=Math.sqrt(1-Math.exp(0-c*((e*c+4/PI)/(e*c+1))));return b<0&&(a=0-a),a/=g,a=(a+1)/2},p5.Ease.prototype.normalizedInverseErf=function(g){var h=2,d=.99532226501,b=map(g,0,1,-d,d),e=b*b,f=8*(PI-3)/(3*PI*(4-PI)),c=2/(PI*f)+Math.log(1-e)/2,i=Math.log(1-e)/f,a=Math.sqrt(Math.sqrt(c*c-i)-c);return b<0&&(a=0-a),a/=h,a+=1,a/=2,a=constrain(a,0,1)},p5.Ease.prototype.exponentialEmphasis=function(c,a){a||(a=.25);var d=0+Number.EPSILON,e=1-Number.EPSILON;if((a=constrain(a,d,e))<.5){var b=Math.pow(c,a*=2);return b}var b=Math.pow(c,1/(1-(a=2*(a-.5))));return b},p5.Ease.prototype.iterativeSquareRoot=function(c){for(var a=.5,d=6,b=0;b<d;b++)a=(a+c/a)/2;return a},p5.Ease.prototype.fastSquareRoot=function(a){var c=.5*a,b=f2ib(a);return a=ib2f(b=1597463007-(b>>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<Math.EPSILON?0:(ab=e/s)*P:e>=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.centerX=1,a.centerY=0,a.dRadius=1):(a.centerX=0,a.centerY=1,a.dRadius=1)),k>=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<F;p++){var G=m*(a*a*a)+n*(a*a)+o*a+A,H=1/(3*m*a*a+2*n*a+o);a-=(G-j)*H,a=constrain(a,0,1)}return B*(a*a*a)+C*(a*a)+D*a+E},p5.Ease.prototype.parabolaThroughAPoint=function(c,a,b){a||(a=.25),b||(b=.75);var e=0+Number.EPSILON,f=1-Number.EPSILON,g=0,h=1;a=constrain(a,e,f),b=constrain(b,g,h);var d=(1-b)/(1-a)-b/a,i=(d*(a*a)-b)/a,j=d*(c*c)-i*c;return constrain(j,0,1)},p5.Ease.prototype.dampedSinusoid=function(c,a){a||(a=.25);var b=c;return Math.pow(2.718281828459045,-6.90775527*b)*Math.cos(100*a*b+0)},p5.Ease.prototype.dampedSinusoidReverse=function(c,a){a||(a=.25);var b=1-c;return Math.pow(2.718281828459045,-6.90775527*b)*Math.cos(100*a*b+0)},p5.Ease.prototype.cubicBezierThrough2Points=function(z,d,e,j,k){d||(d=.25),e||(e=.75),j||(j=.75),k||(k=.25);var g,n,f,l,m=0,A=0+Number.EPSILON,B=1-Number.EPSILON,C=0+Number.EPSILON,D=1-Number.EPSILON;d=constrain(d,A,B),e=constrain(e,C,D);var o=0,p=0,E=d,F=e,G=j,H=k,q=1,r=1,a=.3,b=.7,s=(1-a)*(1-a)*(1-a),c=3*a*(1-a)*(1-a),h=3*a*a*(1-a),t=a*a*a,u=(1-b)*(1-b)*(1-b),i=3*b*(1-b)*(1-b),v=3*b*b*(1-b),w=b*b*b,x=E-o*s-q*t,y=F-p*s-r*t,I=G-o*u-q*w,J=H-p*u-r*w;return f=(x-I*c/i)/(h-c*v/i),l=(y-J*c/i)/(h-c*v/i),g=(x-f*h)/c,n=(y-l*h)/c,g=constrain(g,0+Number.EPSILON,1-Number.EPSILON),f=constrain(f,0+Number.EPSILON,1-Number.EPSILON),m=this.cubicBezier(z,g,n,f,l),m=constrain(m,0,1)},p5.Ease.prototype.doubleCircularOgee=function(b,a){return a||(a=.25),a=constrain(a,0,1),b<=a?Math.sqrt(sq(a)-sq(b-a)):1-Math.sqrt(sq(1-a)-sq(b-a))},p5.Ease.prototype.doubleSquircularOgee=function(c,a,d){a||(a=.25),d||(d=3),a=constrain(a,0,1);var b=2*d;return c<=a?Math.pow(Math.pow(a,b)-Math.pow(c-a,b),1/b):1-Math.pow(Math.pow(1-a,b)-Math.pow(c-a,b),1/b)},p5.Ease.prototype.generalSigmoidLogitCombo=function(d,a,b){a||(a=.25),b||(b=.75);var c=0;if(a<.5)c=b-.5+this.normalizedLogit(d,1-2*a);else{var e=b-.5;c=this.normalizedLogitSigmoid(d+e,2*(a-.5))}return constrain(c,0,1)},p5.Ease.prototype.normalizedLogitSigmoid=function(b,a){a||(a=.25);var c=0+Number.EPSILON,d=1-Number.EPSILON,e=5;a=1/(1-(a=constrain(a,c,d)))-1,a*=e;var f=1/(1+Math.exp(0-(b-.5)*a)),g=1/(1+Math.exp(.5*a)),h=1/(1+Math.exp(-0.5*a));return map(f,g,h,0,1)},p5.Ease.prototype.normalizedLogit=function(b,a){a||(a=.25);var d=0+Number.EPSILON,e=1-Number.EPSILON,f=5;a=1/(1-(a=constrain(a,d,e)))-1,a*=f;var g=1/(1+Math.exp(.5*a)),h=1/(1+Math.exp(-0.5*a));b=map(b,0,1,g,h);var c=Math.log(b/(1-b));return c*=1/a,c+=.5,c=constrain(c,0,1)},p5.Ease.prototype.generalizedQuartic=function(c,a,b){a||(a=.25),b||(b=.75);var e=0,f=1;a=constrain(a,0,1),b=constrain(b,e,f);var d=(1-2*(a=1-a))*(c*c)+2*a*c;return(1-2*b)*(d*d)+2*b*d},p5.Ease.prototype.boxcar=function(a){return a>=.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<b;a++){var f=a/(b-1);c[a]=this[d](f,e)}return c},p5.Ease.prototype.fillFloat32Array=function(d,b,e){for(var c=new Float32Array(b),a=0;a<b;a++){var f=a/(b-1);c[a]=this[d](f,e)}return c},p5.Ease.prototype.fillFloat64Array=function(d,b,e){for(var c=new Float64Array(b),a=0;a<b;a++){var f=a/(b-1);c[a]=this[d](f,e)}return c},p5.ArrayEval=function(){this.version=.01},p5.ArrayEval.prototype.eval=function(_evalstr,_l1){this.l1=_l1;var e,_dest,multi=0;if(Array.isArray(_evalstr)&&(multi=1),_dest=multi?createArray(_l1,_evalstr.length):createArray(_l1),multi)for(e in _evalstr)_evalstr[e]=_evalstr[e].replace(/cu/g,"i"),_evalstr[e]=_evalstr[e].replace(/du/g,"l1"),_evalstr[e]=_evalstr[e].replace(/su/g,"(i/(l1-1)*2.-1.)"),_evalstr[e]=_evalstr[e].replace(/u/g,"(i/(l1-1))");else _evalstr=(_evalstr=(_evalstr=(_evalstr=_evalstr.replace(/cu/g,"i")).replace(/du/g,"l1")).replace(/su/g,"(i/(l1-1)*2.-1.)")).replace(/u/g,"(i/(l1-1))");for(var i=0;i<this.l1;i++)if(multi)for(e=0;e<_evalstr.length;e++)_dest[i][e]=eval("with(this) { "+_evalstr[e]+" }");else _dest[i]=eval("with(this) { "+_evalstr+" }");return _dest},p5.ArrayEval.prototype.eval1d=function(a,b){return this.eval(a,b)},p5.ArrayEval.prototype.eval2d=function(_evalstr,_l1,_l2){this.l1=_l1,this.l2=_l2;var e,_dest,multi=0;if(Array.isArray(_evalstr)&&(multi=1),_dest=multi?createArray(_l1,_l2,_evalstr.length):createArray(_l1,_l2),multi)for(e in _evalstr)_evalstr[e]=_evalstr[e].replace(/cu/g,"i"),_evalstr[e]=_evalstr[e].replace(/du/g,"l1"),_evalstr[e]=_evalstr[e].replace(/su/g,"(i/(l1-1)*2.-1.)"),_evalstr[e]=_evalstr[e].replace(/u/g,"(i/(l1-1))"),_evalstr[e]=_evalstr[e].replace(/cv/g,"j"),_evalstr[e]=_evalstr[e].replace(/dv/g,"l2"),_evalstr[e]=_evalstr[e].replace(/sv/g,"(j/(l2-1)*2.-1.)"),_evalstr[e]=_evalstr[e].replace(/v/g,"(j/(l2-1))");else _evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=_evalstr.replace(/cu/g,"i")).replace(/du/g,"l1")).replace(/su/g,"(i/(l1-1)*2.-1.)")).replace(/u/g,"(i/(l1-1))")).replace(/cv/g,"j")).replace(/dv/g,"l2")).replace(/sv/g,"(j/(l2-1)*2.-1.)")).replace(/v/g,"(j/(l2-1))");for(var i=0;i<this.l1;i++)for(var j=0;j<this.l2;j++)if(multi)for(e=0;e<_evalstr.length;e++)_dest[i][j][e]=eval("with(this) { "+_evalstr[e]+" }");else _dest[i][j]=eval("with(this) { "+_evalstr+" }");return _dest},p5.ArrayEval.prototype.eval3d=function(_evalstr,_l1,_l2,_l3){this.l1=_l1,this.l2=_l2,this.l3=_l3;var e,_dest,multi=0;if(Array.isArray(_evalstr)&&(multi=1),_dest=multi?createArray(_l1,_l2,_l3,_evalstr.length):createArray(_l1,_l2,_l3),multi)for(e in _evalstr)_evalstr[e]=_evalstr[e].replace(/cu/g,"i"),_evalstr[e]=_evalstr[e].replace(/du/g,"l1"),_evalstr[e]=_evalstr[e].replace(/su/g,"(i/(l1-1)*2.-1.)"),_evalstr[e]=_evalstr[e].replace(/u/g,"(i/(l1-1))"),_evalstr[e]=_evalstr[e].replace(/cv/g,"j"),_evalstr[e]=_evalstr[e].replace(/dv/g,"l2"),_evalstr[e]=_evalstr[e].replace(/sv/g,"(j/(l2-1)*2.-1.)"),_evalstr[e]=_evalstr[e].replace(/v/g,"(j/(l2-1))"),_evalstr[e]=_evalstr[e].replace(/cw/g,"k"),_evalstr[e]=_evalstr[e].replace(/dw/g,"l3"),_evalstr[e]=_evalstr[e].replace(/sw/g,"(k/(l3-1)*2.-1.)"),_evalstr[e]=_evalstr[e].replace(/w/g,"(k/(l3-1))");else _evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=(_evalstr=_evalstr.replace(/cu/g,"i")).replace(/du/g,"l1")).replace(/su/g,"(i/(l1-1)*2.-1.)")).replace(/u/g,"(i/(l1-1))")).replace(/cv/g,"j")).replace(/dv/g,"l2")).replace(/sv/g,"(j/(l2-1)*2.-1.)")).replace(/v/g,"(j/(l2-1))")).replace(/cw/g,"k")).replace(/dw/g,"l3")).replace(/sw/g,"(k/(l3-1)*2.-1.)")).replace(/w/g,"(k/(l3-1))");for(var i=0;i<this.l1;i++)for(var j=0;j<this.l2;j++)for(var k=0;k<this.l3;k++)if(multi)for(e=0;e<_evalstr.length;e++)_dest[i][j][k][e]=eval("with(this) { "+_evalstr[e]+" }");else _dest[i][j][k]=eval("with(this) { "+_evalstr+" }");return _dest},p5.Filt=function(a){a||(a=60),this.version=.01,this.a0=1,this.b0=1,this.a1=0,this.b1=0,this.a2=0,this.b2=0,this.xn=0,this.yn=0,this.xpn=0,this.ypn=0,this.xppn=0,this.yppn=0,this.fs=a,this.type="LPF",this.f0=this.fs/4,this.dB=0,this.Q=1,this.A,this.w0,this.cw0,this.sw0,this.alpha,this.soff,this.precalc()},p5.Filt.prototype.set=function(a,b,c,d){a&&(this.type=a),b&&(this.f0=b),c&&(this.Q=c),d&&(this.dB=d),this.precalc()},p5.Filt.prototype.setFs=function(a){a&&(this.fs=a),this.precalc()},p5.Filt.prototype.setType=function(a){a&&(this.type=a),this.precalc()},p5.Filt.prototype.setFreq=function(a){a&&(this.f0=a),this.precalc()},p5.Filt.prototype.setQ=function(a){a&&(this.Q=a),this.precalc()},p5.Filt.prototype.setGain=function(a){a&&(this.dB=a),this.precalc()},p5.Filt.prototype.setBW=function(a){a&&(this.Q=this.f0/a),this.precalc()},p5.Filt.prototype.process=function(a){var b;for(var c in 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)b[c]=this.tick(a[c]);return b},p5.Filt.prototype.tick=function(a){return this.xn=a,this.yn=this.b0/this.a0*this.xn+this.b1/this.a0*this.xpn+this.b2/this.a0*this.xppn-this.a1/this.a0*this.ypn-this.a2/this.a0*this.yppn,this.xppn=this.xpn,this.xpn=this.xn,this.yppn=this.ypn,this.ypn=this.yn,this.yn},p5.Filt.prototype.clear=function(){this.xn=0,this.yn=0,this.xpn=0,this.ypn=0,this.xppn=0,this.yppn=0},p5.Filt.prototype.coeffs=function(a,b,c,d,e,f){6!=arguments.length?(console.log("p5.Filt needs six coefficients for raw biquad:"),console.log(" a0 -> 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<this.bufferSize;){for(a=0;a<b;a++)this.reverseTable[a+b]=this.reverseTable[a]+c;b<<=1,c>>=1}for(a=0,this.sinTable=new Float64Array(this.bufferSize),this.cosTable=new Float64Array(this.bufferSize);a<this.bufferSize;a++)this.sinTable[a]=Math.sin(-PI/a),this.cosTable[a]=Math.cos(-PI/a)},p5.FastFourierTransform.prototype.getBandFrequency=function(a){return this.bandwidth*a},p5.FastFourierTransform.prototype.calculateSpectrum=function(){var c,d,b,e,f=2/this.bufferSize;this.peakBand=0,this.peak=0;for(var a=0,g=this.bufferSize/2;a<g;a++)b=f*Math.sqrt((c=this.real[a])*c+(d=this.imag[a])*d),e=Math.atan2(d,c),b>this.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<this.bufferSize;a++)this.real[a]=k[this.reverseTable[a]],this.imag[a]=0;for(;c<this.bufferSize;){f=this.cosTable[c],g=this.sinTable[c],e=1,d=0;for(var j=0;j<c;j++){for(a=j;a<this.bufferSize;)b=a+c,h=e*this.real[b]-d*this.imag[b],i=e*this.imag[b]+d*this.real[b],this.real[b]=this.real[a]-h,this.imag[b]=this.imag[a]-i,this.real[a]+=h,this.imag[a]+=i,a+=c<<1;e=(l=e)*f-d*g,d=l*g+d*f}c<<=1}this.doSpectrum&&this.calculateSpectrum()},p5.FastFourierTransform.prototype.inverse=function(b,c){b=b||this.real,c=c||this.imag;var h,i,g,e,f,j,k,m,a,d=1;for(a=0;a<this.bufferSize;a++)c[a]*=-1;var n=new Float64Array(this.bufferSize),o=new Float64Array(this.bufferSize);for(a=0;a<b.length;a++)n[a]=b[this.reverseTable[a]],o[a]=c[this.reverseTable[a]];for(b=n,c=o;d<this.bufferSize;){h=this.cosTable[d],i=this.sinTable[d],g=1,e=0;for(var l=0;l<d;l++){for(a=l;a<this.bufferSize;)j=g*b[f=a+d]-e*c[f],k=g*c[f]+e*b[f],b[f]=b[a]-j,c[f]=c[a]-k,b[a]+=j,c[a]+=k,a+=d<<1;g=(m=g)*h-e*i,e=m*i+e*h}d<<=1}var p=new Float64Array(this.bufferSize);for(a=0;a<this.bufferSize;a++)p[a]=b[a]/this.bufferSize;return p},p5.prototype.imap=function(c,d,e,a,b){return constrain(Math.floor(map(c,d,e,a,b)),Math.min(a,b),Math.max(a,b)-1)},p5.prototype.wrap=function(a,c,d){_a=Math.min(c,d);var b,e=(_b=Math.max(c,d))-_a;if(a<_b&&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<d;a++){var c=map(a,0,d-1,0,b.length-1),f=Math.floor(c),g=Math.ceil(c),h=c%1;e[a]=lerp(b[f],b[g],h)}return e},p5.prototype.multiplyArray=function(c,a){Array.isArray(a)||(a=[a]);var d=[];c.length!=a.length&&(a=resizeArray(a,c.length));for(var b=0;b<c.length;b++)d[b]=c[b]*a[b];return d},p5.prototype.addArray=function(c,a){Array.isArray(a)||(a=[a]);var d=[];c.length!=a.length&&(a=resizeArray(a,c.length));for(var b=0;b<c.length;b++)d[b]=c[b]+a[b];return d},p5.prototype.subtractArray=function(c,a){Array.isArray(a)||(a=[a]);var d=[];c.length!=a.length&&(a=resizeArray(a,c.length));for(var b=0;b<c.length;b++)d[b]=c[b]-a[b];return d},p5.prototype.divideArray=function(c,a){Array.isArray(a)||(a=[a]);var d=[];c.length!=a.length&&(a=resizeArray(a,c.length));for(var b=0;b<c.length;b++)d[b]=c[b]/a[b];return d},p5.prototype.moduloArray=function(c,a){Array.isArray(a)||(a=[a]);var d=[];c.length!=a.length&&(a=resizeArray(a,c.length));for(var b=0;b<c.length;b++)d[b]=c[b]%a[b];return d},p5.prototype.sumArray=function(a){return a.reduce(function(a,b){return a+b})},p5.prototype.f2ib=function(b){var a=new Int8Array(4),c=new Int32Array(a.buffer,0,1);return new Float32Array(a.buffer,0,1)[0]=b,c[0]},p5.prototype.ib2f=function(b){var a=new Int8Array(4),c=new Int32Array(a.buffer,0,1),d=new Float32Array(a.buffer,0,1);return c[0]=b,d[0]},p5.prototype.sinc=function(a){return Math.sin(PI*a)/(PI*a)},p5.prototype.besselI0=function(b){var c,d,a;return 0==b?1:(d=(a=b*b)*(a*(a*(a*(a*(a*(a*(a*(a*(a*(a*(a*(a*(210580722890567e-37*a+380715242345326e-34)+4794402575483e-29)+435125971262668e-28)+30093112711296e-24)+160224679395361e-22)+654858370096785e-20)+.00202591084143397)+.463076284721)+75.4337328948189)+8307.92541809429)+571661.130563785)+21641557.2361227)+356644482.244025)+1440482982.27235,c=a*(a*(a-3076.46912682801)+3476263.32405882)-1440482982.27235,-d/c)},p5.prototype.fplot=function(d,k){Array.isArray(d)||(l=[d]),Array.isArray(d)&&(l=d),d.constructor==Float32Array&&(l=Array.prototype.slice.call(d)),d.constructor==Float64Array&&(l=Array.prototype.slice.call(d));var l,f,b,g,a,h,m,i=80,j=23,c=[],e="";for(g=0,m=d.length,c=normalizeArray(c=resizeArray(l,i)),f=1/((j-1)/2),b=1;g<j;g++){for(a=0,h=0,e=g%2?"~":"|";a<i-1;a++)isNaN(c[a])&&(c[a]=0),c[a]>=b&&c[a]<b+f?(e+=c[a+1]>b+f?"/":"-",c[a+1]<b&&(e+="\\"),h=a):c[a]<b&&c[a+1]>b+f||c[a]>b+f&&c[a+1]<b?(e+="|",h=a):e+=" ";if(0>=b&&0<b+f){for(a=0,e="~";a<i;a++)e+="-";h=i-2}console.log("%c"+e,k),b-=f}return 0}})