-
Notifications
You must be signed in to change notification settings - Fork 2
/
biquad-filter.min.js
1 lines (1 loc) · 3.7 KB
/
biquad-filter.min.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.BiquadFilter=e()}}(function(){return function e(t,i,r){function s(n,f){if(!i[n]){if(!t[n]){var c="function"==typeof require&&require;if(!f&&c)return c(n,!0);if(o)return o(n,!0);var a=new Error("Cannot find module '"+n+"'");throw a.code="MODULE_NOT_FOUND",a}var u=i[n]={exports:{}};t[n][0].call(u.exports,function(e){var i=t[n][1][e];return s(i?i:e)},u,u.exports,e,t,i,r)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n<r.length;n++)s(r[n]);return s}({1:[function(e,t,i){t.exports=e("./dist/biquad-filter")},{"./dist/biquad-filter":2}],2:[function(e,t,i){"use strict";var r=e("babel-runtime/helpers/create-class")["default"],s=e("babel-runtime/helpers/class-call-check")["default"];Object.defineProperty(i,"__esModule",{value:!0});var o=function(){function e(){s(this,e),this.coefficients=[],this.numberOfCascade=1,this.resetMemories()}return r(e,[{key:"setCoefficients",value:function(e){if(e){this.numberOfCascade=this.getNumberOfCascadeFilters(e),this.coefficients=[],this.coefficients.g=e[0];for(var t=0;t<this.numberOfCascade;t++)this.coefficients[t]={b1:e[1+4*t],b2:e[2+4*t],a1:e[3+4*t],a2:e[4+4*t]};return this.resetMemories(),!0}throw new Error("No coefficients are set")}},{key:"getNumberOfCascadeFilters",value:function(e){return(e.length-1)/4}},{key:"resetMemories",value:function(){this.memories=[{xi1:0,xi2:0,yi1:0,yi2:0}];for(var e=1;e<this.numberOfCascade;e++)this.memories[e]={yi1:0,yi2:0}}},{key:"process",value:function(e,t){for(var i,r,s,o,n,f,c,a,u,l,m,h=[],d=0;d<e.length;d++){i=e[d],r=this.coefficients[0].b1,s=this.coefficients[0].b2,o=this.coefficients[0].a1,n=this.coefficients[0].a2,f=this.memories[0].xi1,c=this.memories[0].xi2,a=this.memories[0].yi1,u=this.memories[0].yi2,h[0]=i+r*f+s*c-o*a-n*u;for(var b=1;b<this.numberOfCascade;b++)r=this.coefficients[b].b1,s=this.coefficients[b].b2,o=this.coefficients[b].a1,n=this.coefficients[b].a2,l=this.memories[b-1].yi1,m=this.memories[b-1].yi2,a=this.memories[b].yi1,u=this.memories[b].yi2,h[b]=h[b-1]+r*l+s*m-o*a-n*u;t[d]=h[this.numberOfCascade-1]*this.coefficients.g,this.memories[0].xi2=this.memories[0].xi1,this.memories[0].xi1=i;for(var p=0;p<this.numberOfCascade;p++)this.memories[p].yi2=this.memories[p].yi1,this.memories[p].yi1=h[p]}}}]),e}();i["default"]=o,t.exports=i["default"]},{"babel-runtime/helpers/class-call-check":4,"babel-runtime/helpers/create-class":5}],3:[function(e,t,i){t.exports={"default":e("core-js/library/fn/object/define-property"),__esModule:!0}},{"core-js/library/fn/object/define-property":6}],4:[function(e,t,i){"use strict";i["default"]=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i.__esModule=!0},{}],5:[function(e,t,i){"use strict";var r=e("babel-runtime/core-js/object/define-property")["default"];i["default"]=function(){function e(e,t){for(var i=0;i<t.length;i++){var s=t[i];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),r(e,s.key,s)}}return function(t,i,r){return i&&e(t.prototype,i),r&&e(t,r),t}}(),i.__esModule=!0},{"babel-runtime/core-js/object/define-property":3}],6:[function(e,t,i){var r=e("../../modules/$");t.exports=function(e,t,i){return r.setDesc(e,t,i)}},{"../../modules/$":7}],7:[function(e,t,i){var r=Object;t.exports={create:r.create,getProto:r.getPrototypeOf,isEnum:{}.propertyIsEnumerable,getDesc:r.getOwnPropertyDescriptor,setDesc:r.defineProperty,setDescs:r.defineProperties,getKeys:r.keys,getNames:r.getOwnPropertyNames,getSymbols:r.getOwnPropertySymbols,each:[].forEach}},{}]},{},[1])(1)});