forked from IDMIL/DigitalAudioWorkbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fili.min.js
7 lines (7 loc) · 25.3 KB
/
fili.min.js
1
2
3
4
5
6
7
/**
* @name fili
* @version 2.0.3 | December 13th 2018
* @author Florian Markert
* @license MIT
*/
!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Fili=r()}}(function(){return function r(t,e,n){function a(o,i){if(!e[o]){if(!t[o]){var s="function"==typeof require&&require;if(!i&&s)return s(o,!0);if(u)return u(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var f=e[o]={exports:{}};t[o][0].call(f.exports,function(r){var e=t[o][1][r];return a(e||r)},f,f.exports,r,t,e,n)}return e[o].exports}for(var u="function"==typeof require&&require,o=0;o<n.length;o++)a(n[o]);return a}({1:[function(r,t,e){"use strict";t.exports={CalcCascades:r("./src/calcCascades"),Fft:r("./src/fft"),FirCoeffs:r("./src/firCoeffs"),FirFilter:r("./src/firFilter"),IirCoeffs:r("./src/iirCoeffs"),IirFilter:r("./src/iirFilter"),TestFilter:r("./src/testFilter")}},{"./src/calcCascades":2,"./src/fft":3,"./src/firCoeffs":4,"./src/firFilter":5,"./src/iirCoeffs":6,"./src/iirFilter":7,"./src/testFilter":8}],2:[function(r,t,e){"use strict";var n=r("./iirCoeffs"),a=new n,u={bessel:{q:[[.57735026919],[.805538281842,.521934581669],[1.02331395383,.611194546878,.510317824749],[1.22566942541,.710852074442,.559609164796,.505991069397],[1.41530886916,.809790964842,.620470155556,.537552151325,.503912727276],[1.59465693507,.905947107025,.684008068137,.579367238641,.525936202016,.502755558204],[1.76552743493,.998998442993,.747625068271,.624777082395,.556680772868,.519027293158,.502045428643],[1.9292718407,1.08906376917,.810410302962,.671382379377,.591144659703,.542678365981,.514570953471,.501578400482],[2.08691792612,1.17637337045,.872034231424,.718163551101,.627261751983,.569890924765,.533371782078,.511523796759,.50125489338],[2.23926560629,1.26117120993,.932397288146,.764647810579,.664052481472,.598921924986,.555480327396,.526848630061,.509345928377,.501021580965],[2.38695091667,1.34368488961,.991497755204,.81060830488,.701011199665,.628878390935,.57943181849,.545207253735,.52208637596,.507736060535,.500847111042],[2.53048919562,1.42411783481,1.04937620183,.85593899901,.737862159044,.659265671705,.604435823473,.565352679646,.537608804383,.51849505465,.506508536474,.500715908905]],f3dB:[[1.27201964951],[1.60335751622,1.43017155999],[1.9047076123,1.68916826762,1.60391912877],[2.18872623053,1.95319575902,1.8320926012,1.77846591177],[2.45062684305,2.20375262593,2.06220731793,1.98055310881,1.94270419166],[2.69298925084,2.43912611431,2.28431825401,2.18496722634,2.12472538477,2.09613322542],[2.91905714471,2.66069088948,2.49663434571,2.38497976939,2.30961462222,2.26265746534,2.24005716132],[3.13149167404,2.87016099416,2.69935018044,2.57862945683,2.49225505119,2.43227707449,2.39427710712,2.37582307687],[3.33237300564,3.06908580184,2.89318259511,2.76551588399,2.67073340527,2.60094950474,2.55161764546,2.52001358804,2.50457164552],[3.52333123464,3.25877569704,3.07894353744,2.94580435024,2.84438325189,2.76691082498,2.70881411245,2.66724655259,2.64040228249,2.62723439989],[3.70566068548,3.44032173223,3.2574059854,3.11986367838,3.01307175388,2.92939234605,2.86428726094,2.81483068055,2.77915465405,2.75596888377,2.74456638588],[3.88040469682,3.61463243697,3.4292654707,3.28812274966,3.17689762788,3.08812364257,3.01720732972,2.96140104561,2.91862858495,2.88729479473,2.8674198668,2.8570800015]],f1dB:[[2.16477559371],[2.70320928596,2.41122332505],[3.25676581436,2.88822569572,2.74246238837],[3.76153580353,3.35675411406,3.14862673032,3.05646412475],[4.22174260104,3.79644757806,3.55260471864,3.41193742197,3.34673435508],[4.64584812552,4.20789257981,3.94082363122,3.76942681446,3.66549975744,3.61617359345],[5.04060395196,4.5944592201,4.3111677248,4.11836351827,3.98822359814,3.90713836715,3.86811234525],[5.41107948467,4.95951159709,4.66435804468,4.45575796102,4.30650679478,4.20286750045,4.13720522991,4.10531748119],[5.76110791853,5.30592898465,5.00182215701,4.7811081045,4.61724509926,4.49660100894,4.41131378918,4.35667671372,4.32997951075],[6.09364309488,5.63609116014,5.32506930789,5.09480346139,4.91939504255,4.78540258409,4.68493280536,4.61302286993,4.56661931366,4.54382759952],[6.41100731543,5.95195558182,5.63550073656,5.39754464742,5.21278891332,5.06801430334,4.95539684456,4.8697869429,4.80814951843,4.76793469612,4.74828032403],[6.71506056052,6.25514029778,5.9343616072,5.69011422355,5.49763642361,5.34401973764,5.22125973611,5.12485045619,5.05037962112,4.99699982231,4.96155789635,4.94441828777]]}},o={bessel:{as:[[1.3617],[1.3397,.7743],[1.2217,.9686,.5131],[1.1112,.9754,.7202,.3728],[1.0215,.9393,.7815,.5604,.2883]],bs:[[.618],[.4889,.389],[.3887,.3505,.2756],[.3162,.2979,.2621,.2087],[.265,.2549,.2351,.2059,.1665]]},butterworth:{as:[[1.4142],[1.8478,.7654],[1.9319,1.4142,.5176],[1.9616,1.6629,1.1111,.3902],[1.9754,1.782,1.4142,.908,.3129]],bs:[[1],[1,1],[1,1,1],[1,1,1,1],[1,1,1,1,1]]},tschebyscheff05:{as:[[1.3614],[2.6282,.3648],[3.8645,.7528,.1589],[5.1117,1.0639,.3439,.0885],[6.3648,1.3582,.4822,.1994,.0563]],bs:[[1.3827],[3.4341,1.1509],[6.9797,1.8573,1.0711],[11.9607,2.9365,1.4206,1.0407],[18.3695,4.3453,1.944,1.252,1.0263]]},tschebyscheff1:{as:[[1.3022],[2.5904,.3039],[3.8437,.6292,.1296],[5.1019,.8916,.2806,.0717],[6.3634,1.1399,.3939,.1616,.0455]],bs:[[1.5515],[4.1301,1.1697],[8.5529,1.9124,1.0766],[14.7608,3.0426,1.4334,1.0432],[22.7468,4.5167,1.9665,1.2569,1.0277]]},tschebyscheff2:{as:[[1.1813],[2.4025,.2374],[3.588,.4925,.0995],[4.7743,.6991,.2153,.0547],[5.9618,.8947,.3023,.1233,.0347]],bs:[[1.7775],[4.9862,1.1896],[10.4648,1.9622,1.0826],[18.151,3.1353,1.4449,1.0461],[28.0376,4.6644,1.9858,1.2614,1.0294]]},tschebyscheff3:{as:[[1.065],[2.1853,.1964],[3.2721,.4077,.0815],[4.3583,.5791,.1765,.0448],[5.4449,.7414,.2479,.1008,.0283]],bs:[[1.9305],[5.5339,1.2009],[11.6773,1.9873,1.0861],[20.2948,3.1808,1.4507,1.0478],[31.3788,4.7363,1.9952,1.2638,1.0304]]},allpass:{as:[[1.6278],[2.337,1.3506],[2.6117,2.0706,1.0967],[2.7541,2.4174,1.785,.9239],[2.8406,2.612,2.1733,1.5583,.8018]],bs:[[.8832],[1.4878,1.1837],[1.7763,1.6015,1.2596],[1.942,1.83,1.6101,1.2822],[2.049,1.9714,1.8184,1.5923,1.2877]]}},i=function(r,t){var e=[],n=0;if("fromPZ"!==t)for(r.order>12&&(r.order=12),n=0;n<r.order;n++){var i,s,c;"matchedZ"===r.transform?e.push(a.lowpassMZ({Fs:r.Fs,Fc:r.Fc,preGain:r.preGain,as:o[r.characteristic].as[r.order-1][n],bs:o[r.characteristic].bs[r.order-1][n]})):("butterworth"===r.characteristic?(i=.5/Math.sin(Math.PI/(2*r.order)*(n+.5)),s=1):(i=u[r.characteristic].q[r.order-1][n],s=r.oneDb?u[r.characteristic].f1dB[r.order-1][n]:u[r.characteristic].f3dB[r.order-1][n]),c="highpass"===t?r.Fc/s:r.Fc*s,"bandpass"!==t&&"bandstop"!==t||"bessel"===r.characteristic&&(c=Math.sqrt(r.order)*c/r.order),e.push(a[t]({Fs:r.Fs,Fc:c,Q:i,BW:r.BW||0,gain:r.gain||0,preGain:r.preGain||!1})))}else for(n=0;n<r.length;n++)e.push(a[t](r[n]));return e},s=function(r){return function(t){return i(t,r)}},c={},f=function(){var r=[];for(var t in a)c[t]=s(t),r.push(t);return c.available=function(){return r},c};t.exports=f},{"./iirCoeffs":6}],3:[function(r,t,e){"use strict";var n=function(r){if(!function(r){return!(r&r-1)}(r))return!1;var t={};t.length=r,t.buffer=new Float64Array(r),t.re=new Float64Array(r),t.im=new Float64Array(r),t.reI=new Float64Array(r),t.imI=new Float64Array(r),t.twiddle=new Int32Array(r),t.sinTable=new Float64Array(r-1),t.cosTable=new Float64Array(r-1);var e=2*Math.PI,n=Math.floor(Math.log(r)/Math.LN2);for(u=t.sinTable.length;u--;)t.sinTable[u]=Math.sin(e*(u/r)),t.cosTable[u]=Math.cos(e*(u/r));for(var a=r>>1,u=0,o=0;t.twiddle[u]=o,!(++u>=r);){for(n=a;n<=o;)o-=n,n>>=1;o+=n}var i=Math.PI,s=2*Math.PI,c=Math.abs,f=Math.pow,l=Math.cos,h=Math.sin,p=function(r){return h(i*r)/(i*r)},v=Math.E,b={rectangular:{calc:function(){return 1},values:[],correction:1},none:{calc:function(){return 1},values:[],correction:1},hanning:{calc:function(r,t){return.5*(1-l(s*r/(t-1)))},values:[],correction:2},hamming:{calc:function(r,t){return.54-.46*l(s*r/(t-1))},values:[],correction:1.8518999946875638},tukery:{calc:function(r,t,e){return r<e*(t-1)/2?.5*(1+l(i*(2*r/(e*(t-1))-1))):(t-1)*(1-e/2)<r?.5*(1+l(i*(2*r/(e*(t-1))-2/e+1))):1},values:[],correction:4/3},cosine:{calc:function(r,t){return h(i*r/(t-1))},values:[],correction:1.570844266360796},lanczos:{calc:function(r,t){return p(2*r/(t-1)-1)},values:[],correction:1.6964337576195783},triangular:{calc:function(r,t){return 2/(t+1)*((t+1)/2-c(r-(t-1)/2))},values:[],correction:2},bartlett:{calc:function(r,t){return 2/(t-1)*((t-1)/2-c(r-(t-1)/2))},values:[],correction:2},gaussian:{calc:function(r,t,e){return f(v,-.5*f((r-(t-1)/2)/(e*(t-1)/2),2))},values:[],correction:5/3},bartlettHanning:{calc:function(r,t){var e=s*r/(t-1);return.62-.48*c(r/(t-1)-.5)-.38*l(e)},values:[],correction:2},blackman:{calc:function(r,t,e){var n=(1-e)/2,a=e/2,u=s*r/(t-1);return n-.5*l(u)+a*l(2*u)},values:[],correction:4/3},blackmanHarris:{calc:function(r,t){var e=s*r/(t-1);return.35875-.48829*l(e)+.14128*l(2*e)-.01168*l(3*e)},values:[],correction:1.5594508635},nuttall3:{calc:function(r,t){var e=s*r/(t-1);return.375-.5*l(e)+.125*l(2*e)},values:[],correction:1.56},nuttall3a:{calc:function(r,t){var e=s*r/(t-1);return.40897-.5*l(e)+.09103*l(2*e)},values:[],correction:1.692},nuttall3b:{calc:function(r,t){var e=s*r/(t-1);return.4243801-.4973406*l(e)+.078793*l(2*e)},values:[],correction:1.7372527},nuttall4:{calc:function(r,t){var e=s*r/(t-1);return.3125-.46875*l(e)+.1875*l(2*e)-.03125*l(3*e)},values:[],correction:1.454543},nuttall4a:{calc:function(r,t){var e=s*r/(t-1);return.338946-.481973*l(e)+.161054*l(2*e)-.018027*l(3*e)},values:[],correction:1.512732763},nuttall4b:{calc:function(r,t){var e=s*r/(t-1);return.355768-.481973*l(e)+.144232*l(2*e)-.012604*l(3*e)},values:[],correction:1.55223262},nuttall4c:{calc:function(r,t){var e=s*r/(t-1);return.3635819-.4891775*l(e)+.1365995*l(2*e)-.0106411*l(3*e)},values:[],correction:1.57129067},sft3f:{calc:function(r,t){var e=s*r/(t-1);return.26526-.5*l(e)+.23474*l(2*e)},values:[],correction:1.3610238},sft4f:{calc:function(r,t){var e=s*r/(t-1);return.21706-.42103*l(e)+.28294*l(2*e)-.07897*l(3*e)},values:[],correction:1.2773573},sft5f:{calc:function(r,t){var e=s*r/(t-1);return.1881-.36923*l(e)+.28702*l(2*e)-.13077*l(3*e)+.02488*l(4*e)},values:[],correction:1.23167769},sft3m:{calc:function(r,t){var e=s*r/(t-1);return.28235-.52105*l(e)+.19659*l(2*e)},values:[],correction:1.39343451},sft4m:{calc:function(r,t){var e=s*r/(t-1);return.241906-.460841*l(e)+.2552381*l(2*e)-.041872*l(3*e)},values:[],correction:1.3190596},sft5m:{calc:function(r,t){var e=s*r/(t-1);return.209671-.407331*l(e)+.281225*l(2*e)-.092669*l(3*e)+.0091036*l(4*e)},values:[],correction:1.26529456464},nift:{calc:function(r,t){var e=s*r/(t-1);return.2810639-.5208972*l(e)+.1980399*l(2*e)},values:[],correction:1.39094182},hpft:{calc:function(r,t){var e=s*r/(t-1);return(1-1.912510941*l(e)+1.079173272*l(2*e)-.1832630879*l(3*e))/t},values:[],correction:1},srft:{calc:function(r,t){var e=s*r/(t-1);return(1-1.93*l(e)+1.29*l(2*e)-.388*l(3*e)+.028*l(4*e))/t},values:[],correction:1},hft70:{calc:function(r,t){var e=s*r/(t-1);return(1-1.90796*l(e)+1.07349*l(2*e)-.18199*l(3*e))/t},values:[],correction:1},hft95:{calc:function(r,t){var e=s*r/(t-1);return(1-1.9383379*l(e)+1.3045202*l(2*e)-.402827*l(3*e)+.0350665*l(4*e))/t},values:[],correction:1},hft90d:{calc:function(r,t){var e=s*r/(t-1);return(1-1.942604*l(e)+1.340318*l(2*e)-.440811*l(3*e)+.043097*l(4*e))/t},values:[],correction:1},hft116d:{calc:function(r,t){var e=s*r/(t-1);return(1-1.9575375*l(e)+1.4780705*l(2*e)-.6367431*l(3*e)+.1228389*l(4*e)-.0066288*l(5*e))/t},values:[],correction:1},hft144d:{calc:function(r,t){var e=s*r/(t-1);return(1-1.96760033*l(e)+1.57983607*l(2*e)-.81123644*l(3*e)+.22583558*l(4*e)-.02773848*l(5*e)+9036e-7*l(6*e))/t},values:[],correction:1},hft196d:{calc:function(r,t){var e=s*r/(t-1);return(1-1.97441842*l(e)+1.65409888*l(2*e)-.95788186*l(3*e)+.3367342*l(4*e)-.06364621*l(5*e)+.00521942*l(6*e)-10599e-8*l(7*e))/t},values:[],correction:1},hft223d:{calc:function(r,t){var e=s*r/(t-1);return(1-1.98298997309*l(e)+1.75556083063*l(2*e)-1.19037717712*l(3*e)+.56155440797*l(4*e)-.17296769663*l(5*e)+.03233247087*l(6*e)-.00324954578*l(7*e)+.0001380104*l(8*e)-132725e-11*l(9*e))/t},values:[],correction:1},hft248d:{calc:function(r,t){var e=s*r/(t-1);return(1-1.985844164102*l(e)+1.791176438506*l(2*e)-1.282075284005*l(3*e)+.667777530266*l(4*e)-.240160796576*l(5*e)+.056656381764*l(6*e)-.008134974479*l(7*e)+.00062454465*l(8*e)-19808998e-12*l(9*e)+1.32974e-7*l(10*e))/t},values:[],correction:1}},m=function(r){return b[r.name].values.length!==r.N?(0===r.n&&(b[r.name].values.length=0),b[r.name].values[r.n]=b[r.name].correction*b[r.name].calc(r.n,r.N,r.a),b[r.name].values[r.n]):b[r.name].values};return{forward:function(r,e){var n,a,u,o,i,s,c,f,l,h,p,v;u=t.buffer.length;var b={name:e,N:u,a:.5,n:0},d=m(b);if("number"==typeof d)for(n=0;n<u;++n)b.n=n,t.buffer[n]=r[n]*m(b);else for(n=0;n<u;++n)t.buffer[n]=r[n]*d[n];for(n=u;n--;)t.re[n]=t.buffer[t.twiddle[n]],t.im[n]=0;for(o=1;o<u;o=i)for(s=0,i=o+o,c=u/i,a=0;a<o;a++){for(f=t.cosTable[s],l=t.sinTable[s],n=a;n<u;n+=i)h=n+o,p=l*t.im[h]+f*t.re[h],v=f*t.im[h]-l*t.re[h],t.re[h]=t.re[n]-p,t.re[n]+=p,t.im[h]=t.im[n]-v,t.im[n]+=v;s+=c}return{re:t.re,im:t.im}},inverse:function(r,e){var n,a,u,o,i,s,c,f,l,h,p,v;for(u=r.length,n=u;n--;)a=t.twiddle[n],t.reI[n]=r[a],t.imI[n]=-e[a];for(o=1;o<u;o=i)for(s=0,i=o+o,c=u/i,a=0;a<o;a++){for(f=t.cosTable[s],l=t.sinTable[s],n=a;n<u;n+=i)h=n+o,p=l*t.imI[h]+f*t.reI[h],v=f*t.imI[h]-l*t.reI[h],t.reI[h]=t.reI[n]-p,t.reI[n]+=p,t.imI[h]=t.imI[n]-v,t.imI[n]+=v;s+=c}for(n=u;n--;)t.buffer[n]=t.reI[n]/u;return t.buffer},magnitude:function(r){for(var t=[],e=0;e<r.re.length;e++)t.push(Math.sqrt(r.re[e]*r.re[e]+r.im[e]*r.im[e]));return t},magToDb:function(r){for(var t=[],e=0;e<r.length;e++)t.push(20*Math.log(r[e])*Math.LOG10E);return t},phase:function(r){for(var t=[],e=0;e<r.re.length;e++)t.push(Math.atan2(r.im[e],r.re[e]));return t},windows:function(){var r=[];for(var t in b)r.push(t);return r}}};t.exports=n},{}],4:[function(r,t,e){"use strict";var n=function(){var r=function(r){var t=r.Fs,e=r.Fa,n=r.Fb,a=r.order||51,u=r.Att||100,o=function(r){for(var t=0,e=1,n=1;e>1e-6*n;)t+=2,e*=r*r/(t*t),n+=e;return n};a/2-Math.floor(a/2)==0&&a++;var i,s=(a-1)/2,c=[],f=0,l=0,h=[];for(c[0]=2*(n-e)/t,l=1;l<=s;l++)c[l]=(Math.sin(2*l*Math.PI*n/t)-Math.sin(2*l*Math.PI*e/t))/(l*Math.PI);for(f=u<21?0:u>50?.1102*(u-8.7):.5842*Math.pow(u-21,.4)+.07886*(u-21),i=o(f),l=0;l<=s;l++)h[s+l]=c[l]*o(f*Math.sqrt(1-l*l/(s*s)))/i;for(l=0;l<s;l++)h[l]=h[a-1-l];return h},t=function(r){var t=r.Fs,e=r.Fc,n=r.order,a=2*Math.PI*e/t,u=0,o=0,i=[];for(u=0;u<=n;u++)u-n/2==0?i[u]=a:(i[u]=Math.sin(a*(u-n/2))/(u-n/2),i[u]*=.54-.46*Math.cos(2*Math.PI*u/n)),o+=i[u];for(u=0;u<=n;u++)i[u]/=o;return i},e=function(r){var t;for(t=0;t<r.length;t++)r[t]=-r[t];return r[(r.length-1)/2]++,r},n=function(r){for(var n=t({order:r.order,Fs:r.Fs,Fc:r.F2}),a=e(t({order:r.order,Fs:r.Fs,Fc:r.F1})),u=[],o=0;o<n.length;o++)u.push(n[o]+a[o]);return u};return{lowpass:function(r){return t(r)},highpass:function(r){return e(t(r))},bandstop:function(r){return n(r)},bandpass:function(r){return e(n(r))},kbFilter:function(t){return r(t)},available:function(){return["lowpass","highpass","bandstop","bandpass","kbFilter"]}}};t.exports=n},{}],5:[function(r,t,e){"use strict";var n=r("./utils"),a=n.runMultiFilter,u=n.runMultiFilterReverse,o=n.complex,i=n.evaluatePhase,s=function(r){var t=r,e=[],n=0;for(n=0;n<t.length;n++)e[n]={re:t[n],im:0};var s=function(r){var t,e=[];for(t=0;t<r;t++)e.push(0);return{buf:e,pointer:0}},c=s(t.length-1),f=function(r,e){e.buf[e.pointer]=r;var a=0;for(n=0;n<e.buf.length;n++)a+=t[n]*e.buf[(e.pointer+n)%e.buf.length];return e.pointer=(e.pointer+1)%e.buf.length,a},l=function(r){var e=s(t.length-1);return a(r,e,f)},h=function(r){for(var n=r.Fs,a=r.Fr,u=-Math.PI*(a/n)*2,i={re:0,im:0},s=0;s<t.length-1;s++)i=o.add(i,o.mul(e[s],{re:Math.cos(u*s),im:Math.sin(u*s)}));var c=o.magnitude(i);return{magnitude:c,phase:o.phase(i),dBmagnitude:20*Math.log(c)*Math.LOG10E}};return{responsePoint:function(r){return h(r)},response:function(r){r=r||100;var t=[],e=0,n=2*r;for(e=0;e<r;e++)t[e]=h({Fs:n,Fr:e});return i(t),t},simulate:function(r){return l(r)},singleStep:function(r){return f(r,c)},multiStep:function(r,t){return a(r,c,f,t)},filtfilt:function(r,t){return u(a(r,c,f,t),c,f,!0)},reinit:function(){c=s(t.length-1)}}};t.exports=s},{"./utils":9}],6:[function(r,t,e){"use strict";var n=function(){var r=function(r,t){var e=r.Q,n=r.Fc,a=r.Fs,u={},o=2*Math.PI*n/a;return r.BW?u.alpha=Math.sin(o)*Math.sinh(Math.log(2)/2*r.BW*o/Math.sin(o)):u.alpha=Math.sin(o)/(2*e),u.cw=Math.cos(o),u.a0=1+u.alpha,t.a0=u.a0,t.a.push(-2*u.cw/u.a0),t.k=1,t.a.push((1-u.alpha)/u.a0),u},t=function(r){var t=r.Q,e=r.Fc,n=r.Fs,a={},u=2*Math.PI*e/n;return a.alpha=Math.sin(u)/(2*t),a.cw=Math.cos(u),a.A=Math.pow(10,r.gain/40),a},e=function(){var r={};return r.z=[0,0],r.a=[],r.b=[],r};return{fromPZ:function(r){var t=e();return t.a0=1,t.b.push(1),t.b.push(-r.z0.re-r.z1.re),t.b.push(r.z0.re*r.z1.re-r.z0.im*r.z1.im),t.a.push(-r.p0.re-r.p1.re),t.a.push(r.p0.re*r.p1.re-r.p0.im*r.p1.im),"lowpass"===r.type?t.k=(1+t.a[0]+t.a[1])/(1+t.b[1]+t.b[2]):t.k=(1-t.a[0]+t.a[1])/(1-t.b[1]+t.b[2]),t},lowpassMZ:function(r){var t=e();t.a0=1;var n=r.as,a=r.bs,u=2*Math.PI*r.Fc/r.Fs,o=-n/(2*a);return t.a.push(2*-Math.pow(Math.E,o*u)*Math.cos(-u*Math.sqrt(Math.abs(Math.pow(n,2)/(4*Math.pow(a,2))-1/a)))),t.a.push(Math.pow(Math.E,2*o*u)),r.preGain?(t.b.push(1),t.k=t.a0+t.a[0]+t.a[1]):(t.b.push(t.a0+t.a[0]+t.a[1]),t.k=1),t.b.push(0),t.b.push(0),t},lowpassBT:function(r){var t=e();return r.Q=1,t.wp=Math.tan(2*Math.PI*r.Fc/(2*r.Fs)),t.wp2=t.wp*t.wp,r.BW&&delete r.BW,t.k=1,t.a0=3*t.wp+3*t.wp2+1,t.b.push(3*t.wp2*r.Q/t.a0),t.b.push(2*t.b[0]),t.b.push(t.b[0]),t.a.push((6*t.wp2-2)/t.a0),t.a.push((3*t.wp2-3*t.wp+1)/t.a0),t},highpassBT:function(r){var t=e();return r.Q=1,t.wp=Math.tan(2*Math.PI*r.Fc/(2*r.Fs)),t.wp2=t.wp*t.wp,r.BW&&delete r.BW,t.k=1,t.a0=t.wp+t.wp2+3,t.b.push(3*r.Q/t.a0),t.b.push(2*t.b[0]),t.b.push(t.b[0]),t.a.push((2*t.wp2-6)/t.a0),t.a.push((t.wp2-t.wp+3)/t.a0),t},lowpass:function(t){var n=e();t.BW&&delete t.BW;var a=r(t,n);return t.preGain?(n.k=.5*(1-a.cw),n.b.push(1/a.a0)):(n.k=1,n.b.push((1-a.cw)/(2*a.a0))),n.b.push(2*n.b[0]),n.b.push(n.b[0]),n},highpass:function(t){var n=e();t.BW&&delete t.BW;var a=r(t,n);return t.preGain?(n.k=.5*(1+a.cw),n.b.push(1/a.a0)):(n.k=1,n.b.push((1+a.cw)/(2*a.a0))),n.b.push(-2*n.b[0]),n.b.push(n.b[0]),n},allpass:function(t){var n=e();t.BW&&delete t.BW;var a=r(t,n);return n.k=1,n.b.push((1-a.alpha)/a.a0),n.b.push(-2*a.cw/a.a0),n.b.push((1+a.alpha)/a.a0),n},bandpassQ:function(t){var n=e(),a=r(t,n);return n.k=1,n.b.push(a.alpha*t.Q/a.a0),n.b.push(0),n.b.push(-n.b[0]),n},bandpass:function(t){var n=e(),a=r(t,n);return n.k=1,n.b.push(a.alpha/a.a0),n.b.push(0),n.b.push(-n.b[0]),n},bandstop:function(t){var n=e(),a=r(t,n);return n.k=1,n.b.push(1/a.a0),n.b.push(-2*a.cw/a.a0),n.b.push(n.b[0]),n},peak:function(r){var n=e(),a=t(r);return n.k=1,n.a0=1+a.alpha/a.A,n.a.push(-2*a.cw/n.a0),n.a.push((1-a.alpha/a.A)/n.a0),n.b.push((1+a.alpha*a.A)/n.a0),n.b.push(-2*a.cw/n.a0),n.b.push((1-a.alpha*a.A)/n.a0),n},lowshelf:function(r){var n=e();r.BW&&delete r.BW;var a=t(r);n.k=1;var u=2*Math.sqrt(a.A)*a.alpha;return n.a0=a.A+1+(a.A-1)*a.cw+u,n.a.push(-2*(a.A-1+(a.A+1)*a.cw)/n.a0),n.a.push((a.A+1+(a.A-1)*a.cw-u)/n.a0),n.b.push(a.A*(a.A+1-(a.A-1)*a.cw+u)/n.a0),n.b.push(2*a.A*(a.A-1-(a.A+1)*a.cw)/n.a0),n.b.push(a.A*(a.A+1-(a.A-1)*a.cw-u)/n.a0),n},highshelf:function(r){var n=e();r.BW&&delete r.BW;var a=t(r);n.k=1;var u=2*Math.sqrt(a.A)*a.alpha;return n.a0=a.A+1-(a.A-1)*a.cw+u,n.a.push(2*(a.A-1-(a.A+1)*a.cw)/n.a0),n.a.push((a.A+1-(a.A-1)*a.cw-u)/n.a0),n.b.push(a.A*(a.A+1+(a.A-1)*a.cw+u)/n.a0),n.b.push(-2*a.A*(a.A-1+(a.A+1)*a.cw)/n.a0),n.b.push(a.A*(a.A+1+(a.A-1)*a.cw-u)/n.a0),n},aweighting:function(r){var t=e();t.k=1;var n=2*Math.PI*r.Fc/r.Fs,a=2*Math.tan(n/2),u=r.Q,o=Math.pow(a,2);return t.a0=4*u+o*u+2*a,t.a.push(2*o*u-8*u),t.a.push(4*u+o*u-2*a),t.b.push(o*u),t.b.push(2*o*u),t.b.push(o*u),t}}};t.exports=n},{}],7:[function(r,t,e){"use strict";var n=r("./utils"),a=n.complex,u=n.runMultiFilter,o=n.runMultiFilterReverse,i=n.evaluatePhase,s=function(r){for(var t=r,e={re:1,im:0},n=[],s=[],c=0;c<t.length;c++){n[c]={};var f=t[c];n[c].b0={re:f.b[0],im:0},n[c].b1={re:f.b[1],im:0},n[c].b2={re:f.b[2],im:0},n[c].a1={re:f.a[0],im:0},n[c].a2={re:f.a[1],im:0},n[c].k={re:f.k,im:0},n[c].z=[0,0],s[c]={},s[c].b1=f.b[1]/f.b[0],s[c].b2=f.b[2]/f.b[0],s[c].a1=f.a[0],s[c].a2=f.a[1]}var l=function(r,t){var e=t*r.k.re-r.a1.re*r.z[0]-r.a2.re*r.z[1],n=r.b0.re*e+r.b1.re*r.z[0]+r.b2.re*r.z[1];return r.z[1]=r.z[0],r.z[0]=e,n},h=function(r,t){var e=r,n=0;for(n=0;n<t.length;n++)e=l(t[n],e);return e},p=function(r,t){var n=r.Fs,u=r.Fr,o=-Math.PI*(u/n)*2,i={re:Math.cos(o),im:Math.sin(o)},s=a.mul(t.k,a.add(t.b0,a.mul(i,a.add(t.b1,a.mul(t.b2,i))))),c=a.add(e,a.mul(i,a.add(t.a1,a.mul(t.a2,i)))),f=a.div(s,c);return{magnitude:a.magnitude(f),phase:a.phase(f)}},v=function(r){var t=0,e={magnitude:1,phase:0};for(t=0;t<n.length;t++){var a=p(r,n[t]);e.magnitude*=a.magnitude,e.phase+=a.phase}return e.dBmagnitude=20*Math.log(e.magnitude)*Math.LOG10E,e},b=function(){for(var r=[],e=0;e<t.length;e++)r[e]={b0:{re:f.b[0],im:0},b1:{re:f.b[1],im:0},b2:{re:f.b[2],im:0},a1:{re:f.a[0],im:0},a2:{re:f.a[1],im:0},k:{re:f.k,im:0},z:[0,0]};return r},m=function(r){var t=b();return u(r,t,h)},d=function(r,t){var e={},n=[],a=0;for(a=0;a<t;a++)n.push(r(a));e.out=m(n);var u=!1,o=!1;for(a=0;a<t-1;a++)if(e.out[a]>e.out[a+1]&&!u&&(u=!0,e.max={sample:a,value:e.out[a]}),u&&!o&&e.out[a]<e.out[a+1]){o=!0,e.min={sample:a,value:e.out[a]};break}return e},M=function(r,t){var e=Math.pow(r/2,2)-t;return e<0?[{re:-r/2,im:Math.sqrt(Math.abs(e))},{re:-r/2,im:-Math.sqrt(Math.abs(e))}]:[{re:-r/2+Math.sqrt(e),im:0},{re:-r/2-Math.sqrt(e),im:0}]},g=function(){for(var r=[],t=0;t<s.length;t++)r[t]={},r[t].z=M(s[t].b1,s[t].b2),r[t].p=M(s[t].a1,s[t].a2);return r};return{singleStep:function(r){return h(r,n)},multiStep:function(r,t){return u(r,n,h,t)},filtfilt:function(r,t){return o(u(r,n,h,t),n,h,!0)},simulate:function(r){return m(r)},stepResponse:function(r){return d(function(){return 1},r)},impulseResponse:function(r){return d(function(r){return 0===r?1:0},r)},responsePoint:function(r){return v(r)},response:function(r){r=r||100;var t=[],e=0,n=2*r;for(e=0;e<r;e++)t[e]=v({Fs:n,Fr:e});return i(t),t},polesZeros:function(){return g()},reinit:function(){for(c=0;c<n.length;c++)n[c].z=[0,0]}}};t.exports=s},{"./utils":9}],8:[function(r,t,e){"use strict";var n=function(r){var t,e=r,n=[],a=function(r){for(t=0;t<r.steps;t++)n.push(e.singleStep((Math.random()-.5)*r.pp+r.offset))},u=function(r){var a=r.offset+r.pp,u=r.offset-r.pp;for(t=0;t<r.steps;t++)t%200<100?n.push(e.singleStep(a)):n.push(e.singleStep(u))},o=function(r){var a=r.offset+r.pp,u=r.offset-r.pp;for(t=0;t<r.steps;t++)t%100==0?n.push(e.singleStep(a)):n.push(e.singleStep(u))},i=function(r){var a=r.offset+r.pp,u=r.offset-r.pp,o=u,i=(a-u)/100;for(t=0;t<r.steps;t++)t%200<100?o+=i:o-=i,n.push(e.singleStep(o))};return{randomStability:function(r){for(e.reinit(),n.length=0,a(r),t=r.setup;t<n.length;t++)if(n[t]>r.maxStable||n[t]<r.minStable)return n[t];return!0},directedRandomStability:function(r){e.reinit(),n.length=0;var s;for(s=0;s<r.tests;s++){var c=Math.random();c<.25?a(r):c<.5?u(r):c<.75?o(r):i(r)}for(a(r),t=r.setup;t<n.length;t++)if(n[t]>r.maxStable||n[t]<r.minStable)return n[t];return!0},evaluateBehavior:function(){}}};t.exports=n},{}],9:[function(r,t,e){"use strict";e.evaluatePhase=function(r){var t=0,e=0,n=Math.PI,a=2*n,u=[];for(e=0;e<r.length;e++)u.push(r[e].phase);for(r[0].unwrappedPhase=r[0].phase,r[0].groupDelay=0,e=1;e<u.length;e++){var o=u[e]-u[e-1];if(o>n)for(t=e;t<u.length;t++)u[t]-=a;else if(o<-n)for(t=e;t<u.length;t++)u[t]+=a;u[e]<0?r[e].unwrappedPhase=-u[e]:r[e].unwrappedPhase=u[e],r[e].phaseDelay=r[e].unwrappedPhase/(e/r.length),r[e].groupDelay=(r[e].unwrappedPhase-r[e-1].unwrappedPhase)/(n/r.length),r[e].groupDelay<0&&(r[e].groupDelay=-r[e].groupDelay)}0!==r[0].magnitude?(r[0].phaseDelay=r[1].phaseDelay,r[0].groupDelay=r[1].groupDelay):(r[0].phaseDelay=r[2].phaseDelay,r[0].groupDelay=r[2].groupDelay,r[1].phaseDelay=r[2].phaseDelay,r[1].groupDelay=r[2].groupDelay)},e.runMultiFilter=function(r,t,e,n){var a=[];n&&(a=r);var u;for(u=0;u<r.length;u++)a[u]=e(r[u],t);return a},e.runMultiFilterReverse=function(r,t,e,n){var a=[];n&&(a=r);var u;for(u=r.length-1;u>=0;u--)a[u]=e(r[u],t);return a};var n=function(r,t){for(var e=!0;e;){var n=r,a=t;if(e=!1,a||(a=1),n!==Math.floor(n)||a!==Math.floor(a))return 1;if(0===n||1===n)return a;r=n-1,t=a*n,e=!0}};e.besselFactors=function(r){for(var t=[],e=0;e<r+1;e++){var a=n(2*r-e),u=Math.pow(2,r-e)*n(e)*n(r-e);t.unshift(Math.floor(a/u))}return t};var a=function(r,t){for(var e=0,n=0;n<t;n++){var a=1/Math.pow(2,n+1);r>a&&(r-=a,e+=a)}return e},u=function(r,t){return r&Math.pow(2,t)},o=function(r,t,e){var n=Math.abs(r),o=r-n;return{number:u(n,t).toString(),fraction:a(o,e).toString(),numberBits:t,fractionBits:e}};e.fixedPoint={convert:function(r,t,e){return o(r,t,e)},add:function(r,t){},sub:function(r,t){},mul:function(r,t){},div:function(r,t){}},e.complex={div:function(r,t){var e=r.re,n=r.im,a=t.re,u=t.im,o=a*a+u*u;return{re:(e*a+n*u)/o,im:(n*a-e*u)/o}},mul:function(r,t){var e=r.re,n=r.im,a=t.re,u=t.im;return{re:e*a-n*u,im:(e+n)*(a+u)-e*a-n*u}},add:function(r,t){return{re:r.re+t.re,im:r.im+t.im}},sub:function(r,t){return{re:r.re-t.re,im:r.im-t.im}},phase:function(r){return Math.atan2(r.im,r.re)},magnitude:function(r){return Math.sqrt(r.re*r.re+r.im*r.im)}}},{}]},{},[1])(1)});