UNPKG

frequency-sweep

Version:
5 lines (4 loc) 1.57 kB
var m="function"==typeof Object.defineProperties?Object.defineProperty:function(g,f,b){g!=Array.prototype&&g!=Object.prototype&&(g[f]=b.value)},n="undefined"!=typeof window&&window===this?this:"undefined"!=typeof global&&null!=global?global:this;function r(g,f){if(f){for(var b=n,d=g.split("."),a=0;a<d.length-1;a++){var c=d[a];c in b||(b[c]={});b=b[c]}d=d[d.length-1];a=b[d];c=f(a);c!=a&&null!=c&&m(b,d,{configurable:!0,writable:!0,value:c})}} r("Math.sign",function(g){return g?g:function(f){f=Number(f);return 0===f||isNaN(f)?f:0<f?1:-1}});var t=this; function u(g){var f={noise:function(){return 2*Math.random()+-1},sine:function(b,d,a,c,h,e){a=2*Math.PI*b*(c+(h-c)*d/2);return Math.sin(a+e)},triangle:function(b,d,a,c,h,e){a=2*Math.PI*b*(c+(h-c)*d/2);return 2/Math.PI*Math.asin(Math.sin(a+e))},sawtooth:function(b,d,a,c,h,e){a=2*Math.PI*b*(c+d/2*(h-c))/2;return 2/Math.PI*Math.atan(Math.tan(a+e))},square:function(b,d,a,c,h,e){a=2*Math.PI*b*(c+(h-c)*d/2);return Math.sign(Math.sin(a+e))}};g.sweep=function(b,d,a){var c=0,h=0,e;if(void 0===a?0:a){for(e= a=0;e<b.length;e++)a+=Math.round(d*b[e].time);var p=new Float64Array(a)}else p=[];for(var k=0,l=0;k<b.length;k++){a=Math.round(d*b[k].time);e=a/d;for(var v=a+l;l<v;l++){var q=l/a;p[l]=f[b[k].wave](e*q,q,h,b[k].start,b[k].end,c)}h=2*Math.PI*e*(b[k].start+(b[k].end-b[k].start)/2);c+=h}return p};Object.defineProperty(g,"__esModule",{value:!0})}"object"===typeof exports&&"undefined"!==typeof module?u(exports):"function"===typeof define&&define.a?define(["exports"],u):(t=t||self,u(t.frequencySweep={}));