Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

audio-node-suite

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

audio-node-suite - npm Package Compare versions

Comparing version 0.9.8 to 0.9.9

src/audio-node-suite-7-amplitude.js

26

lib/audio-node-suite.js

@@ -26,20 +26,22 @@ /*

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AudioNodeSuite = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.gainTodBFS=exports.dBFSToGain=void 0;var dBFSToGain=function(o){return Math.pow(10,o/20)};exports.dBFSToGain=dBFSToGain;var gainTodBFS=function(o){return 20*Math.log10(o)};exports.gainTodBFS=gainTodBFS;
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.weightedAverage=exports.getFrequencyValue=exports.gainTodBFS=exports.ensureWithin=exports.dBFSToGain=exports.AnimationFrameTimer=void 0;var dBFSToGain=function(e){return Math.pow(10,e/20)};exports.dBFSToGain=dBFSToGain;var gainTodBFS=function(e){return 20*Math.log10(e)};exports.gainTodBFS=gainTodBFS;var getFrequencyValue=function(e,t,r){var n=e.sampleRate/2;return r[Math.round(t/n*r.length)]};exports.getFrequencyValue=getFrequencyValue;var ensureWithin=function(e,t,r){return e<t?e=t:e>r&&(e=r),e};exports.ensureWithin=ensureWithin;var weightedAverage=function(e,t,r,n){for(var i=e.length<n?e.length:n,o=0,a=0,u=0;u<=r;u++){var s=u+(i-r);o+=s*e[u],a+=s}if(!t)for(var l=r+1;l<i;l++){var f=l-(r+1);o+=f*e[l],a+=f}return o/=a};exports.weightedAverage=weightedAverage;var AnimationFrameTimer=function(){function e(t){var r=this;if(_classCallCheck(this,e),this.timer=null,void 0!==window){this.timer={repeat:!0};window.requestAnimationFrame(function e(){t(),r.timer.repeat&&window.requestAnimationFrame(e)})}else this.timer=setInterval(function(){return t()},1e3/60)}return _createClass(e,[{key:"clear",value:function(){void 0!==window?this.timer.repeat=!1:clearTimeout(this.timer)}}]),e}();exports.AnimationFrameTimer=AnimationFrameTimer;
},{}],2:[function(_dereq_,module,exports){
"use strict";function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,c=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return i=e.done,e},e:function(e){c=!0,a=e},f:function(){try{i||null==r.return||r.return()}finally{if(c)throw a}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeComposite=void 0;var AudioNodeComposite=_createClass(function e(t,r){if(_classCallCheck(this,e),"object"!==_typeof(t)||!(t instanceof AudioNode))throw new Error("input has to be a valid AudioNode");"object"!==_typeof(r)&&(r=t);var n=t.context.createGain();return n.connect(t),n._targets=[],n._bypass=!1,n._connect=n.connect,n.connect=function(){for(var e,t,o=arguments.length,a=new Array(o),i=0;i<o;i++)a[i]=arguments[i];return n._targets.push(a),n.dispatchEvent(new CustomEvent("connect-before",{detail:{target:a}})),t=n._bypass?n._connect.apply(n,a):(e=r).connect.apply(e,a),n.dispatchEvent(new CustomEvent("connect-after",{detail:{result:t,target:a}})),t},n._disconnect=n.disconnect,n.disconnect=function(){for(var e,t,o=arguments.length,a=new Array(o),i=0;i<o;i++)a[i]=arguments[i];return n.dispatchEvent(new CustomEvent("disconnect-before",{detail:{target:a}})),t=n._bypass?n._disconnect.apply(n,a):(e=r).disconnect.apply(e,a),n._targets=n._targets.filter(function(e){if(e.length!==a.length)return!0;for(var t=0;t<a.length;t++)if(e[t]!==a[t])return!0;return!1}),n.dispatchEvent(new CustomEvent("disconnect-after",{detail:{result:t,target:a}})),t},n.bypass=function(e){if(n._bypass!==e)if(n._bypass=e,n._bypass){n.dispatchEvent(new CustomEvent("bypass-enable-before")),n._disconnect(t);var o,a=_createForOfIteratorHelper(n._targets);try{for(a.s();!(o=a.n()).done;){var i,c=o.value;(i=r).disconnect.apply(i,_toConsumableArray(c)),n._connect.apply(n,_toConsumableArray(c))}}catch(e){a.e(e)}finally{a.f()}n.dispatchEvent(new CustomEvent("bypass-enable-after"))}else{n.dispatchEvent(new CustomEvent("bypass-disable-before"));var s,l=_createForOfIteratorHelper(n._targets);try{for(l.s();!(s=l.n()).done;){var u,y=s.value;n._disconnect.apply(n,_toConsumableArray(y)),(u=r).connect.apply(u,_toConsumableArray(y))}}catch(e){l.e(e)}finally{l.f()}n._connect(t),n.dispatchEvent(new CustomEvent("bypass-disable-after"))}},n});exports.AudioNodeComposite=AudioNodeComposite;
},{}],3:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeLimiter=exports.AudioNodeGain=exports.AudioNodeCompressor=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js");function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeGain=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),r=Object.assign({},{gain:0},r);var o=t.createGain();return o.gain.setValueAtTime((0,_audioNodeSuite1Util.dBFSToGain)(r.gain),t.currentTime),o});exports.AudioNodeGain=AudioNodeGain;var AudioNodeCompressor=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),r=Object.assign({},{threshold:-16,attack:.003,release:.4,knee:3,ratio:2},r);var o=t.createDynamicsCompressor();return o.threshold.value=r.threshold,o.knee.value=r.knee,o.ratio.value=r.ratio,o.attack.value=r.attack,o.release.value=r.release,o});exports.AudioNodeCompressor=AudioNodeCompressor;var AudioNodeLimiter=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];_classCallCheck(this,e),r=Object.assign({},{threshold:-3,attack:.003,release:.05,knee:0,ratio:20});var o=t.createDynamicsCompressor();return o.threshold.value=r.threshold,o.knee.value=r.knee,o.ratio.value=r.ratio,o.attack.value=r.attack,o.release.value=r.release,o});exports.AudioNodeLimiter=AudioNodeLimiter;
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeNoise=exports.AudioNodeLimiter=exports.AudioNodeGain=exports.AudioNodeCompressor=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js");function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,r){if(e){if("string"==typeof e)return _arrayLikeToArray(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(e,r):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var a=r[t];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,_toPropertyKey(a.key),a)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var r=_toPrimitive(e,"string");return"symbol"===_typeof(r)?r:String(r)}function _toPrimitive(e,r){if("object"!==_typeof(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var a=t.call(e,r||"default");if("object"!==_typeof(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}function _classCallCheck(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var AudioNodeNoise=_createClass(function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),t=Object.assign({},{type:"pink",channels:1},t);var a=5*r.sampleRate,o=r.createBuffer(t.channels,a,r.sampleRate);if("white"===t.type)for(var i=0;i<a;i++)for(var n=2*Math.random()-1,s=0;s<t.channels;s++){o.getChannelData(s)[i]=n}else if("pink"===t.type){for(var l=[],u=0;u<t.channels;u++){l[u]=new Float32Array(a);for(var c=[0,0,0,0,0,0,0],d=0;d<a;d++){var m=2*Math.random()-1;c[0]=.99886*c[0]+.0555179*m,c[1]=.99332*c[1]+.0750759*m,c[2]=.969*c[2]+.153852*m,c[3]=.8665*c[3]+.3104856*m,c[4]=.55*c[4]+.5329522*m,c[5]=-.7616*c[5]-.016898*m,l[u][d]=c[0]+c[1]+c[2]+c[3]+c[4]+c[5]+c[6]+.5362*m,c[6]=.115926*m}}for(var p=[],y=[],f=0;f<l.length;f++)p.push(Math.min.apply(Math,_toConsumableArray(l[f]))),y.push(Math.max.apply(Math,_toConsumableArray(l[f])));for(var h=Math.min.apply(Math,p),v=Math.max.apply(Math,y),A=.9999999995343387/Math.max(Math.abs(h),v),b=0;b<t.channels;b++)for(var _=0;_<a;_++)o.getChannelData(b)[_]=l[b][_]*A}var T=r.createBufferSource();return T.buffer=o,T.loop=!0,T.start(0),T});exports.AudioNodeNoise=AudioNodeNoise;var AudioNodeGain=_createClass(function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),t=Object.assign({},{gain:0},t);var a=r.createGain();return a.gain.setValueAtTime((0,_audioNodeSuite1Util.dBFSToGain)(t.gain),r.currentTime),a.adjustGainDecibel=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;a.gain.linearRampToValueAtTime((0,_audioNodeSuite1Util.dBFSToGain)(e),r.currentTime+t)},a});exports.AudioNodeGain=AudioNodeGain;var AudioNodeCompressor=_createClass(function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),t=Object.assign({},{threshold:-16,attack:.003,release:.4,knee:3,ratio:2},t);var a=r.createDynamicsCompressor();return a.threshold.setValueAtTime(t.threshold,r.currentTime),a.knee.setValueAtTime(t.knee,r.currentTime),a.ratio.setValueAtTime(t.ratio,r.currentTime),a.attack.setValueAtTime(t.attack,r.currentTime),a.release.setValueAtTime(t.release,r.currentTime),a});exports.AudioNodeCompressor=AudioNodeCompressor;var AudioNodeLimiter=_createClass(function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),t=Object.assign({},{threshold:-3,attack:.001,release:.05,knee:0,ratio:20},t);var a=r.createDynamicsCompressor();return a.threshold.setValueAtTime(t.threshold,r.currentTime),a.knee.setValueAtTime(t.knee,r.currentTime),a.ratio.setValueAtTime(t.ratio,r.currentTime),a.attack.setValueAtTime(t.attack,r.currentTime),a.release.setValueAtTime(t.release,r.currentTime),a});exports.AudioNodeLimiter=AudioNodeLimiter;
},{"./audio-node-suite-1-util.js":1}],4:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeEqualizer=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js");function _defineProperties(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var r=o.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeEqualizer=_createClass(function e(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e);var r=[];if((o=Object.assign({},{bands:[]},o)).bands.length<1)throw new Error("at least one band has to be specified");for(var i=0;i<o.bands.length;i++){var n=Object.assign({},{type:"peaking",freq:64*Math.pow(2,i),q:1,gain:1},o.bands[i]),a=t.createBiquadFilter();a.type=n.type,a.frequency.value=n.freq,a.Q.value=n.q,a.gain.value=n.gain,r.push(a),i>0&&r[i-1].connect(r[i])}return 1===o.bands.length?r[0]:new _audioNodeSuite2Composite.AudioNodeComposite(r[0],r[r.length-1])});exports.AudioNodeEqualizer=AudioNodeEqualizer;
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeEqualizer=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js");function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeEqualizer=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e);var o=[];if((r=Object.assign({},{bands:[]},r)).bands.length<1)throw new Error("at least one band has to be specified");for(var i=0;i<r.bands.length;i++){var n=Object.assign({},{type:"peaking",freq:64*Math.pow(2,i),q:1,gain:1},r.bands[i]),a=t.createBiquadFilter();a.type=n.type,a.frequency.setValueAtTime(n.freq,t.currentTime),a.Q.setValueAtTime(n.q,t.currentTime),a.gain.setValueAtTime(n.gain,t.currentTime),o.push(a),i>0&&o[i-1].connect(o[i])}return 1===r.bands.length?o[0]:new _audioNodeSuite2Composite.AudioNodeComposite(o[0],o[o.length-1])});exports.AudioNodeEqualizer=AudioNodeEqualizer;
},{"./audio-node-suite-2-composite.js":2}],5:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeMeter=void 0;var AudioNodeMeter=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),r=Object.assign({},{fftSize:2048,minDecibels:-100,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:1e3/120,intervalLength:100},r);var n=t.createAnalyser();n.fftSize=r.fftSize,n.minDecibels=r.minDecibels,n.maxDecibels=r.maxDecibels,n.smoothingTimeConstant=r.smoothingTimeConstant;var o=new Float32Array(n.frequencyBinCount),i=new Float32Array(n.frequencyBinCount),a=[],l=-1,s=[],f=-1,u=function(e,t,r){for(var n=e.length<r?e.length:r,o=0,i=0,a=0;a<=t;a++){var l=a+(n-t);o+=l*e[a],i+=l}for(var s=t+1;s<n;s++){var f=s-(t+1);o+=f*e[s],i+=f}return o/=i,o},v=function(){n.getFloatFrequencyData(o);for(var e={},t=0,v=0;v<o.length;v++)o[v]<n.minDecibels?o[v]=n.minDecibels:o[v]>n.maxDecibels&&(o[v]=n.maxDecibels),t+=o[v]*o[v],i[v]=o[v];e.avg=Math.sqrt(t/o.length),i.sort(),e.min=i[0];var c=Math.floor(i.length/8);e.q1=i[1*c],e.q2=i[2*c],e.q3=i[3*c],e.med=i[4*c],e.q4=i[5*c],e.q5=i[6*c],e.q6=i[7*c],e.max=i[i.length-1],l=(l+1)%r.intervalLength,a[l]=e.max,e.lvlAvg=u(a,l,r.intervalLength),e.lvlDev=Math.abs(e.max-e.lvlAvg),f=(f+1)%r.intervalLength,s[f]=e.lvlDev,e.devAvg=u(s,f,r.intervalLength),e.devDev=Math.abs(e.lvlDev-e.devAvg),n._stat=e};return setInterval(v,r.intervalTime),v(),n.data=function(){return o},n.stat=function(){return n._stat},n});exports.AudioNodeMeter=AudioNodeMeter;
},{}],6:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeGate=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js"),_audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js");function _defineProperties(e,t){for(var o=0;o<t.length;o++){var i=t[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeGate=_createClass(function e(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),o=Object.assign({},{threshold:-50,hysteresis:-6,reduction:-50,interval:2,attack:4,hold:40,release:20},o);var i=new _audioNodeSuite5Meter.AudioNodeMeter(t,{fftSize:2048,minDecibels:-120,maxDecibels:0,smoothingTimeConstant:0,intervalTime:o.interval,intervalLength:1}),r=t.createGain();i.connect(r);var n="open",a=null;return setTimeout(function e(){var u=i.stat().lvlAvg;"closed"===n?u>=o.threshold&&(n="attack",r.gain.exponentialRampToValueAtTime(1,t.currentTime+o.attack/1e3),null!==a&&clearTimeout(a),a=setTimeout(function(){n="open"},o.attack)):"open"===n?u<o.threshold+o.hysteresis&&(n="hold",null!==a&&clearTimeout(a),a=setTimeout(function(){n="release";var e=(0,_audioNodeSuite1Util.dBFSToGain)(o.reduction);r.gain.exponentialRampToValueAtTime(e,t.currentTime+o.release/1e3),a=setTimeout(function(){n="closed"},o.release)},o.hold)):"hold"===n?u>=o.threshold&&(n="open",null!==a&&clearTimeout(a)):"release"===n&&u>=o.threshold&&(r.gain.cancelScheduledValues(t.currentTime),n="attack",r.gain.linearRampToValueAtTime(1,t.currentTime+o.attack/1e3),null!==a&&clearTimeout(a),a=setTimeout(function(){n="open"},o.attack)),setTimeout(e,o.interval)},o.interval),new _audioNodeSuite2Composite.AudioNodeComposite(i,r)});exports.AudioNodeGate=AudioNodeGate;
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeMeter=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js");function _defineProperties(e,t){for(var i=0;i<t.length;i++){var r=t[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_toPropertyKey(r.key),r)}}function _createClass(e,t,i){return t&&_defineProperties(e.prototype,t),i&&_defineProperties(e,i),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var i=e[Symbol.toPrimitive];if(void 0!==i){var r=i.call(e,t||"default");if("object"!==_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeMeter=_createClass(function e(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),i=Object.assign({},{fftSize:512,minDecibels:-94,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:3,intervalCount:100},i);var r=t.createAnalyser();r.fftSize=i.fftSize,r.minDecibels=i.minDecibels,r.maxDecibels=i.maxDecibels,r.smoothingTimeConstant=i.smoothingTimeConstant;var o={peak:-1/0,rms:-1/0,rmsM:-1/0,rmsS:-1/0},n=i.intervalCount,a=!0,u=0,l=[],s=new Float32Array(r.fftSize),f=new Float32Array(r.frequencyBinCount),c=function(){r.getFloatTimeDomainData(s),r.getFloatFrequencyData(f);for(var e=0,t=-1/0,c=0;c<s.length;c++){var m=s[c]*s[c];e+=m,t<m&&(t=m)}o.rms=(0,_audioNodeSuite1Util.ensureWithin)((0,_audioNodeSuite1Util.gainTodBFS)(Math.sqrt(e/s.length)),i.minDecibels,i.maxDecibels),o.peak=(0,_audioNodeSuite1Util.ensureWithin)((0,_audioNodeSuite1Util.gainTodBFS)(Math.sqrt(t)),i.minDecibels,i.maxDecibels),n>0&&(u===n-1&&a&&(a=!1),l[u=(u+1)%n]=o.rms,o.rmsM=(0,_audioNodeSuite1Util.weightedAverage)(l,a,u,n))};return setInterval(c,i.intervalTime),c(),r.dataT=function(){return s},r.dataF=function(){return f},r.stat=function(){return o},r});exports.AudioNodeMeter=AudioNodeMeter;
},{"./audio-node-suite-1-util.js":1}],6:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeGate=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js"),_audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js");function _defineProperties(e,t){for(var o=0;o<t.length;o++){var i=t[o];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,t,o){return t&&_defineProperties(e.prototype,t),o&&_defineProperties(e,o),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var i=o.call(e,t||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeGate=_createClass(function e(t){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),o=Object.assign({},{threshold:-45,hysteresis:-3,reduction:-30,interval:2,attack:4,hold:40,release:200},o);var i=new _audioNodeSuite5Meter.AudioNodeMeter(t,{fftSize:512,minDecibels:-94,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:2,intervalCount:25}),r=t.createGain();i.connect(r);var n="open",a=null,u=(0,_audioNodeSuite1Util.dBFSToGain)(o.reduction);return setTimeout(function e(){var l=i.stat().rmsM;"closed"===n?l>=o.threshold&&(n="attack",r.gain.cancelScheduledValues(t.currentTime),r.gain.linearRampToValueAtTime(1,t.currentTime+o.attack/1e3),null!==a&&clearTimeout(a),a=setTimeout(function(){n="open"},o.attack)):"attack"===n?l<o.threshold+o.hysteresis&&(n="release",r.gain.cancelScheduledValues(t.currentTime),r.gain.linearRampToValueAtTime(u,t.currentTime+o.release/1e3),null!==a&&clearTimeout(a),a=setTimeout(function(){n="closed"},o.release)):"open"===n?l<o.threshold+o.hysteresis&&(n="hold",null!==a&&clearTimeout(a),a=setTimeout(function(){n="release",r.gain.cancelScheduledValues(t.currentTime),r.gain.linearRampToValueAtTime(u,t.currentTime+o.release/1e3),a=setTimeout(function(){n="closed"},o.release)},o.hold)):"hold"===n?l>=o.threshold&&(n="open",null!==a&&clearTimeout(a)):"release"===n&&l>=o.threshold&&(n="attack",r.gain.cancelScheduledValues(t.currentTime),r.gain.linearRampToValueAtTime(u,t.currentTime+o.attack/1e3),null!==a&&clearTimeout(a),a=setTimeout(function(){n="open"},o.attack)),setTimeout(e,o.interval)},o.interval),new _audioNodeSuite2Composite.AudioNodeComposite(i,r)});exports.AudioNodeGate=AudioNodeGate;
},{"./audio-node-suite-1-util.js":1,"./audio-node-suite-2-composite.js":2,"./audio-node-suite-5-meter.js":5}],7:[function(_dereq_,module,exports){
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeSpectrum=void 0;var _audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js");function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var i=0,o=function(){};return{s:o,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,n=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw n}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var i=t[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var i=r.call(e,t||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var AnimationFrameTimer=function(){function e(t){var r=this;if(_classCallCheck(this,e),this.timer=null,void 0!==window){this.timer={repeat:!0};window.requestAnimationFrame(function e(){t(),r.timer.repeat&&window.requestAnimationFrame(e)})}else this.timer=setInterval(function(){return t()},1e3/60)}return _createClass(e,[{key:"clear",value:function(){void 0!==window?this.timer.repeat=!1:clearTimeout(this.timer)}}]),e}(),AudioNodeSpectrum=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),r=Object.assign({},{fftSize:4096,minDecibels:-150,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:1e3/60,intervalLength:10,layers:[-120,-90,-60,-30],slices:[40,80,160,320,640,1280,2560,5120,10240,20480],colorBackground:"#000000",colorBars:"#00cc00",colorAvg:"#00ff00",colorLayers:"#009900",colorSlices:"#009900",logarithmic:!0},r);var i=new _audioNodeSuite5Meter.AudioNodeMeter(t,{fftSize:r.fftSize,minDecibels:r.minDecibels,maxDecibels:r.maxDecibels,smoothingTimeConstant:r.smoothingTimeConstant,intervalTime:r.intervalTime,intervalLength:r.intervalLength}),o=[],n=null;return i.draw=function(e){o.push(e),1===o.length&&(n=new AnimationFrameTimer(function(){var e,t=_createForOfIteratorHelper(o);try{for(t.s();!(e=t.n()).done;){var r=e.value;i._draw(r)}}catch(e){t.e(e)}finally{t.f()}}))},i.undraw=function(e){0===(o=o.filter(function(t){return t!==e})).length&&n.clear()},i._draw=function(e){var t=i.data(),o=i.stat().lvlAvg,n=e.getContext("2d");n.fillStyle=r.colorBackground,n.fillRect(0,0,e.width,e.height),n.fillStyle=r.colorLayers;var a,l=_createForOfIteratorHelper(r.layers);try{for(l.s();!(a=l.n()).done;){var c=a.value,u=Math.abs(c-i.minDecibels)/(i.maxDecibels-i.minDecibels)*e.height;n.fillRect(0,e.height-u,e.width,1)}}catch(e){l.e(e)}finally{l.f()}n.fillStyle=r.colorSlices;var f,s=_createForOfIteratorHelper(r.slices);try{for(s.s();!(f=s.n()).done;){var h=f.value,m=Math.log2(h/20)*(e.width/10);n.fillRect(m,0,1,e.height)}}catch(e){s.e(e)}finally{s.f()}n.fillStyle=r.colorAvg;var y=Math.abs(o-i.minDecibels)/(i.maxDecibels-i.minDecibels)*e.height;if(n.fillRect(0,e.height-y,e.width,1),n.fillStyle=r.colorBars,r.logarithmic)for(var d=0;d<e.width;d++){var v=20*Math.pow(2,10*d/e.width),p=20*Math.pow(2,10*(d+1)/e.width),b=Math.round(v*(t.length/(20*Math.pow(2,10)))),g=Math.round(p*(t.length/(20*Math.pow(2,10))))-1;g<b&&(g=b);for(var w=0,_=b;_<=g;_++)w+=t[_];w/=g+1-b;var S=Math.abs(w-i.minDecibels)/(i.maxDecibels-i.minDecibels)*e.height;n.fillRect(d,e.height-S,1,S)}else for(var A=0,D=e.width/t.length,T=0;T<t.length;T++){var M=t[T],C=Math.abs(M-i.minDecibels)/(i.maxDecibels-i.minDecibels)*e.height;n.fillRect(A,e.height-C,D-.5,C),A+=D}},i});exports.AudioNodeSpectrum=AudioNodeSpectrum;
},{"./audio-node-suite-5-meter.js":5}],8:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeVoice=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js");function _defineProperties(e,o){for(var t=0;t<o.length;t++){var i=o[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,o,t){return o&&_defineProperties(e.prototype,o),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var o=_toPrimitive(e,"string");return"symbol"===_typeof(o)?o:String(o)}function _toPrimitive(e,o){if("object"!==_typeof(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,o||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===o?String:Number)(e)}function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}var AudioNodeVoice=_createClass(function e(o){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),t=Object.assign({},{gain:0},t);var i=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"highpass",freq:80,q:1},{type:"notch",freq:50,q:20},{type:"notch",freq:960,q:1.5},{type:"lowpass",freq:20480,q:.5}]}),r=new _audioNodeSuite6Gate.AudioNodeGate(o,{threshold:-50,hysteresis:-6,reduction:-50,interval:2,attack:4,hold:40,release:20}),n=new _audioNodeSuite3Standard.AudioNodeCompressor(o,{threshold:-16,attack:.003,release:.4,knee:3,ratio:2}),a=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"peaking",freq:240,q:.75,gain:3},{type:"highshelf",freq:3840,q:.75,gain:6}]}),u=new _audioNodeSuite3Standard.AudioNodeGain(o,{gain:-6+t.gain}),d=new _audioNodeSuite3Standard.AudioNodeLimiter(o,{threshold:-3});return i.connect(r),r.connect(n),n.connect(a),a.connect(u),u.connect(d),new _audioNodeSuite2Composite.AudioNodeComposite(i,d)});exports.AudioNodeVoice=AudioNodeVoice;
},{"./audio-node-suite-2-composite.js":2,"./audio-node-suite-3-standard.js":3,"./audio-node-suite-4-equalizer.js":4,"./audio-node-suite-6-gate.js":6}],9:[function(_dereq_,module,exports){
"use strict";var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js"),_audioNodeSuite7Spectrum=_dereq_("./audio-node-suite-7-spectrum.js"),_audioNodeSuite8Voice=_dereq_("./audio-node-suite-8-voice.js");module.exports={AudioNodeComposite:_audioNodeSuite2Composite.AudioNodeComposite,AudioNodeGain:_audioNodeSuite3Standard.AudioNodeGain,AudioNodeCompressor:_audioNodeSuite3Standard.AudioNodeCompressor,AudioNodeLimiter:_audioNodeSuite3Standard.AudioNodeLimiter,AudioNodeEqualizer:_audioNodeSuite4Equalizer.AudioNodeEqualizer,AudioNodeMeter:_audioNodeSuite5Meter.AudioNodeMeter,AudioNodeGate:_audioNodeSuite6Gate.AudioNodeGate,AudioNodeSpectrum:_audioNodeSuite7Spectrum.AudioNodeSpectrum,AudioNodeVoice:_audioNodeSuite8Voice.AudioNodeVoice};
},{"./audio-node-suite-2-composite.js":2,"./audio-node-suite-3-standard.js":3,"./audio-node-suite-4-equalizer.js":4,"./audio-node-suite-5-meter.js":5,"./audio-node-suite-6-gate.js":6,"./audio-node-suite-7-spectrum.js":7,"./audio-node-suite-8-voice.js":8}]},{},[1,2,3,4,5,6,7,8,9])(9)
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeAmplitude=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js");function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,n=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw n}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeAmplitude=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),r=Object.assign({},{fftSize:512,minDecibels:-60,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:1e3/60,intervalCount:Math.round(18),decibelBars:[-60,-45,-21,-6],colorBars:["#306090","#00b000","#e0d000","#e03030"],colorBarsDeactive:["#606060","#808080","#a0a0a0","#c0c0c0"],colorRMS:"#ffffff",colorBackground:"#000000",horizontal:!1},r);var o=new _audioNodeSuite5Meter.AudioNodeMeter(t,{fftSize:r.fftSize,minDecibels:r.minDecibels,maxDecibels:r.maxDecibels,smoothingTimeConstant:r.smoothingTimeConstant,intervalTime:r.intervalTime,intervalCount:r.intervalCount}),i=[],n=null,a=!1;return o.deactive=function(e){a=e},o.draw=function(e){i.push(e),1===i.length&&(n=new _audioNodeSuite1Util.AnimationFrameTimer(function(){var e,t=_createForOfIteratorHelper(i);try{for(t.s();!(e=t.n()).done;){var r=e.value;o._draw(r)}}catch(e){t.e(e)}finally{t.f()}}))},o.undraw=function(e){0===(i=i.filter(function(t){return t!==e})).length&&n.clear()},o._draw=function(e){var t=o.stat().peak,i=o.stat().rmsM,n=e.getContext("2d");n.fillStyle=r.colorBackground,n.fillRect(0,0,e.width,e.height);for(var l=a?r.colorBarsDeactive:r.colorBars,u=function(t){return r.horizontal?t/(o.maxDecibels-o.minDecibels)*e.width:t/(o.maxDecibels-o.minDecibels)*e.height},c=function(t,i,a){var l=u(Math.abs(i-o.minDecibels)),c=u(Math.abs(i-t));n.fillStyle=a,r.horizontal?n.fillRect(l-c,0,c,e.height):n.fillRect(0,e.height-l,e.width,c)},f=Math.min(r.decibelBars.length,l.length),s=o.minDecibels,d=l[0],m=0;m<f&&!(t<r.decibelBars[m]);m++){var y=r.decibelBars[m];c(s,y,d),d=l[m],s=y}c(s,t,d);var b=u(Math.abs(i-o.minDecibels));n.fillStyle=r.colorRMS,r.horizontal?n.fillRect(b-1,0,1,e.height):n.fillRect(0,e.height-b,e.width,1)},o});exports.AudioNodeAmplitude=AudioNodeAmplitude;
},{"./audio-node-suite-1-util.js":1,"./audio-node-suite-5-meter.js":5}],8:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeSpectrum=void 0;var _audioNodeSuite1Util=_dereq_("./audio-node-suite-1-util.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js");function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,a=!0,l=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){l=!0,n=e},f:function(){try{a||null==r.return||r.return()}finally{if(l)throw n}}}}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,o=new Array(t);r<t;r++)o[r]=e[r];return o}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var o=t[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==_typeof(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var AudioNodeSpectrum=_createClass(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),r=Object.assign({},{fftSize:8192,minDecibels:-144,maxDecibels:0,smoothingTimeConstant:.8,intervalTime:1e3/60,layers:[-120,-90,-60,-50,-40,-30,-20,-10],slices:[40,80,160,320,640,1280,2560,5120,10240,20480],colorBackground:"#000000",colorBars:"#00cc00",colorLayers:"#009900",colorSlices:"#009900",logarithmic:!0},r);var o=new _audioNodeSuite5Meter.AudioNodeMeter(t,{fftSize:r.fftSize,minDecibels:r.minDecibels,maxDecibels:r.maxDecibels,smoothingTimeConstant:r.smoothingTimeConstant,intervalTime:r.intervalTime,intervalCount:0}),i=[],n=null;return o.draw=function(e){i.push(e),1===i.length&&(n=new _audioNodeSuite1Util.AnimationFrameTimer(function(){var e,t=_createForOfIteratorHelper(i);try{for(t.s();!(e=t.n()).done;){var r=e.value;o._draw(r)}}catch(e){t.e(e)}finally{t.f()}}))},o.undraw=function(e){0===(i=i.filter(function(t){return t!==e})).length&&n.clear()},o._draw=function(e){var t=o.dataF(),i=e.getContext("2d");i.fillStyle=r.colorBackground,i.fillRect(0,0,e.width,e.height);var n=function(t){return t/(o.maxDecibels-o.minDecibels)*e.height};i.fillStyle=r.colorLayers;var a,l=_createForOfIteratorHelper(r.layers);try{for(l.s();!(a=l.n()).done;){var u=a.value,c=n(Math.abs(u-o.minDecibels));i.fillRect(0,e.height-c,e.width,1)}}catch(e){l.e(e)}finally{l.f()}i.fillStyle=r.colorSlices;var f,s=_createForOfIteratorHelper(r.slices);try{for(s.s();!(f=s.n()).done;){var y=f.value,d=Math.log2(y/20)*(e.width/10);i.fillRect(d,0,1,e.height)}}catch(e){s.e(e)}finally{s.f()}if(i.fillStyle=r.colorBars,r.logarithmic)for(var m=0;m<e.width;m++){var h=20*Math.pow(2,10*m/e.width),p=20*Math.pow(2,10*(m+1)/e.width),v=Math.round(h*(t.length/(20*Math.pow(2,10)))),b=Math.round(p*(t.length/(20*Math.pow(2,10))))-1;b<v&&(b=v);for(var g=0,_=v;_<=b;_++)g+=t[_];var S=n((g/=b+1-v)-o.minDecibels);i.fillRect(m,e.height-S,1,S)}else for(var w=0,A=e.width/t.length,T=0;T<t.length;T++){var C=n(t[T]-o.minDecibels);i.fillRect(w,e.height-C,A-.5,C),w+=A}},o});exports.AudioNodeSpectrum=AudioNodeSpectrum;
},{"./audio-node-suite-1-util.js":1,"./audio-node-suite-5-meter.js":5}],9:[function(_dereq_,module,exports){
"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.AudioNodeVoice=void 0;var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js");function _defineProperties(e,o){for(var t=0;t<o.length;t++){var i=o[t];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,_toPropertyKey(i.key),i)}}function _createClass(e,o,t){return o&&_defineProperties(e.prototype,o),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var o=_toPrimitive(e,"string");return"symbol"===_typeof(o)?o:String(o)}function _toPrimitive(e,o){if("object"!==_typeof(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var i=t.call(e,o||"default");if("object"!==_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===o?String:Number)(e)}function _classCallCheck(e,o){if(!(e instanceof o))throw new TypeError("Cannot call a class as a function")}var AudioNodeVoice=_createClass(function e(o){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};_classCallCheck(this,e),t=Object.assign({},{gain:0},t);var i=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"highpass",freq:80,q:4},{type:"notch",freq:50,q:1.5},{type:"notch",freq:960,q:1.5},{type:"lowpass",freq:20480,q:.25}]}),r=new _audioNodeSuite6Gate.AudioNodeGate(o),n=new _audioNodeSuite3Standard.AudioNodeCompressor(o),a=new _audioNodeSuite4Equalizer.AudioNodeEqualizer(o,{bands:[{type:"peaking",freq:240,q:.75,gain:3},{type:"highshelf",freq:3840,q:.75,gain:6}]}),u=new _audioNodeSuite3Standard.AudioNodeGain(o,{gain:-9+t.gain}),d=new _audioNodeSuite3Standard.AudioNodeLimiter(o);i.connect(r),r.connect(n),n.connect(a),a.connect(u),u.connect(d);var s=new _audioNodeSuite2Composite.AudioNodeComposite(i,d);return s.adjustGainDecibel=function(e){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:10;u.adjustGainDecibel(-9+e,o)},s});exports.AudioNodeVoice=AudioNodeVoice;
},{"./audio-node-suite-2-composite.js":2,"./audio-node-suite-3-standard.js":3,"./audio-node-suite-4-equalizer.js":4,"./audio-node-suite-6-gate.js":6}],10:[function(_dereq_,module,exports){
"use strict";var _audioNodeSuite2Composite=_dereq_("./audio-node-suite-2-composite.js"),_audioNodeSuite3Standard=_dereq_("./audio-node-suite-3-standard.js"),_audioNodeSuite4Equalizer=_dereq_("./audio-node-suite-4-equalizer.js"),_audioNodeSuite5Meter=_dereq_("./audio-node-suite-5-meter.js"),_audioNodeSuite6Gate=_dereq_("./audio-node-suite-6-gate.js"),_audioNodeSuite7Amplitude=_dereq_("./audio-node-suite-7-amplitude.js"),_audioNodeSuite8Spectrum=_dereq_("./audio-node-suite-8-spectrum.js"),_audioNodeSuite9Voice=_dereq_("./audio-node-suite-9-voice.js");module.exports={AudioNodeComposite:_audioNodeSuite2Composite.AudioNodeComposite,AudioNodeNoise:_audioNodeSuite3Standard.AudioNodeNoise,AudioNodeGain:_audioNodeSuite3Standard.AudioNodeGain,AudioNodeCompressor:_audioNodeSuite3Standard.AudioNodeCompressor,AudioNodeLimiter:_audioNodeSuite3Standard.AudioNodeLimiter,AudioNodeEqualizer:_audioNodeSuite4Equalizer.AudioNodeEqualizer,AudioNodeMeter:_audioNodeSuite5Meter.AudioNodeMeter,AudioNodeGate:_audioNodeSuite6Gate.AudioNodeGate,AudioNodeAmplitude:_audioNodeSuite7Amplitude.AudioNodeAmplitude,AudioNodeSpectrum:_audioNodeSuite8Spectrum.AudioNodeSpectrum,AudioNodeVoice:_audioNodeSuite9Voice.AudioNodeVoice};
},{"./audio-node-suite-2-composite.js":2,"./audio-node-suite-3-standard.js":3,"./audio-node-suite-4-equalizer.js":4,"./audio-node-suite-5-meter.js":5,"./audio-node-suite-6-gate.js":6,"./audio-node-suite-7-amplitude.js":7,"./audio-node-suite-8-spectrum.js":8,"./audio-node-suite-9-voice.js":9}]},{},[1,2,3,4,5,6,7,8,9,10])(10)
});
{
"name": "audio-node-suite",
"version": "0.9.8",
"version": "0.9.9",
"description": "Audio-Node-Suite -- Web Audio API AudioNode Suite",

@@ -5,0 +5,0 @@ "keywords": [ "web", "audio", "api", "audionode", "suite" ],

@@ -25,5 +25,70 @@ /*

/* utility functions for converting between dBFS (0.0 .. -120.0) and Gain (1.0 .. 0.0) */
export const dBFSToGain = (dbfs) => Math.pow(10, dbfs / 20)
export const gainTodBFS = (gain) => 20 * Math.log10(gain)
/* utility functions for converting from dBFS (0.0 .. -120.0) to Gain (1.0 .. 0.0) */
export const dBFSToGain = (dbfs) =>
Math.pow(10, dbfs / 20)
/* utility functions for converting from Gain (1.0 .. 0.0) to dBFS (0.0 .. -120.0) */
export const gainTodBFS = (gain) =>
20 * Math.log10(gain)
/* get the value at a certain frequency in a bucket of frequencies (as returned by "getFloatFrequencyData" */
export const getFrequencyValue = (ctx, freq, buckets) => {
const nyquist = ctx.sampleRate / 2
const index = Math.round(freq / nyquist * buckets.length)
return buckets[index]
}
/* ensure a value is within min/max boundaries */
export const ensureWithin = (val, min, max) => {
if (val < min)
val = min
else if (val > max)
val = max
return val
}
/* calculate weighted average value */
export const weightedAverage = (arr, init, pos, len) => {
const max = arr.length < len ? arr.length : len
let avg = 0
let num = 0
for (let i = 0; i <= pos; i++) {
const w = i + (max - pos)
avg += w * arr[i]
num += w
}
if (!init) {
for (let i = pos + 1; i < max; i++) {
const w = i - (pos + 1)
avg += w * arr[i]
num += w
}
}
avg /= num
return avg
}
/* a window "requestAnimationFrame" based timer */
export class AnimationFrameTimer {
constructor (cb) {
this.timer = null
if (window !== undefined) {
this.timer = { repeat: true }
const once = () => {
cb()
if (this.timer.repeat)
window.requestAnimationFrame(once)
}
window.requestAnimationFrame(once)
}
else
this.timer = setInterval(() => cb(), 1000 / 60) /* 60 fps */
}
clear () {
if (window !== undefined)
this.timer.repeat = false
else
clearTimeout(this.timer)
}
}

@@ -28,2 +28,72 @@ /*

/* custom AudioNode: noise */
export class AudioNodeNoise {
constructor (context, params = {}) {
/* provide parameter defaults */
params = Object.assign({}, {
type: "pink",
channels: 1
}, params)
/* generate noise */
const lengthInSamples = 5 * context.sampleRate
const buffer = context.createBuffer(params.channels, lengthInSamples, context.sampleRate)
if (params.type === "white") {
/* generate WHITE noise, i.e., random amplitudes across the entire frequency range */
for (let i = 0; i < lengthInSamples; i++) {
const rand = (Math.random() * 2) - 1
for (let j = 0; j < params.channels; j++) {
const data = buffer.getChannelData(j)
data[i] = rand
}
}
}
else if (params.type === "pink") {
/* generate PINK noise, i.e., random amplitudes across the entire frequency range and
where the amplitudes of the higher frequences are less strong than the low frequences. */
/* phase 1: generate PINK noise.
This is based on the approximating algorithm from Paul Kellett.
(see https://www.musicdsp.org/en/latest/_downloads/84bf8a1271c6bb0b3c88253c0546ae0f/pink.txt) */
let pink = []
for (let i = 0; i < params.channels; i++) {
pink[i] = new Float32Array(lengthInSamples)
let b = [ 0, 0, 0, 0, 0, 0, 0 ]
for (let j = 0; j < lengthInSamples; j++) {
const white = (Math.random() * 2) - 1
b[0] = 0.99886 * b[0] + white * 0.0555179
b[1] = 0.99332 * b[1] + white * 0.0750759
b[2] = 0.96900 * b[2] + white * 0.1538520
b[3] = 0.86650 * b[3] + white * 0.3104856
b[4] = 0.55000 * b[4] + white * 0.5329522
b[5] = -0.7616 * b[5] - white * 0.0168980
pink[i][j] = b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6] + white * 0.5362
b[6] = white * 0.115926
}
}
/* phase 2: normalize to +/-1 and prevent positive saturation. */
let minA = []
let maxA = []
for (let i = 0; i < pink.length; i++) {
minA.push(Math.min(...pink[i]))
maxA.push(Math.max(...pink[i]))
}
const min = Math.min(...minA)
const max = Math.max(...maxA)
const coefficient = (2147483647 / 2147483648) / Math.max(Math.abs(min), max)
for (let i = 0; i < params.channels; i++)
for (let j = 0; j < lengthInSamples; j++)
buffer.getChannelData(i)[j] = pink[i][j] * coefficient
}
/* create underlying BufferSource node */
const bs = context.createBufferSource()
bs.buffer = buffer
bs.loop = true
bs.start(0)
return bs
}
}
/* custom AudioNode: gain */

@@ -40,2 +110,5 @@ export class AudioNodeGain {

gain.gain.setValueAtTime(dBFSToGain(params.gain), context.currentTime)
gain.adjustGainDecibel = (db, ms = 10) => {
gain.gain.linearRampToValueAtTime(dBFSToGain(db), context.currentTime + ms)
}
return gain

@@ -54,3 +127,3 @@ }

knee: 3.0,
ratio: 2.0
ratio: 2
}, params)

@@ -60,7 +133,7 @@

const compressor = context.createDynamicsCompressor()
compressor.threshold.value = params.threshold
compressor.knee.value = params.knee
compressor.ratio.value = params.ratio
compressor.attack.value = params.attack
compressor.release.value = params.release
compressor.threshold.setValueAtTime(params.threshold, context.currentTime)
compressor.knee.setValueAtTime(params.knee, context.currentTime)
compressor.ratio.setValueAtTime(params.ratio, context.currentTime)
compressor.attack.setValueAtTime(params.attack, context.currentTime)
compressor.release.setValueAtTime(params.release, context.currentTime)
return compressor

@@ -76,15 +149,15 @@ }

threshold: -3.0,
attack: 0.003,
attack: 0.001,
release: 0.050,
knee: 0.0,
ratio: 20.0
})
knee: 0,
ratio: 20
}, params)
/* create and configure underlying Compressor node */
const limiter = context.createDynamicsCompressor()
limiter.threshold.value = params.threshold
limiter.knee.value = params.knee
limiter.ratio.value = params.ratio
limiter.attack.value = params.attack
limiter.release.value = params.release
limiter.threshold.setValueAtTime(params.threshold, context.currentTime)
limiter.knee.setValueAtTime(params.knee, context.currentTime)
limiter.ratio.setValueAtTime(params.ratio, context.currentTime)
limiter.attack.setValueAtTime(params.attack, context.currentTime)
limiter.release.setValueAtTime(params.release, context.currentTime)
return limiter

@@ -91,0 +164,0 @@ }

@@ -51,6 +51,6 @@ /*

const band = context.createBiquadFilter()
band.type = options.type
band.frequency.value = options.freq
band.Q.value = options.q
band.gain.value = options.gain
band.type = options.type
band.frequency.setValueAtTime(options.freq, context.currentTime)
band.Q.setValueAtTime(options.q, context.currentTime)
band.gain.setValueAtTime(options.gain, context.currentTime)

@@ -57,0 +57,0 @@ /* assemble bands */

@@ -25,2 +25,5 @@ /*

/* internal requirements */
import { gainTodBFS, ensureWithin, weightedAverage } from "./audio-node-suite-1-util.js"
/* custom AudioNode: meter */

@@ -31,11 +34,11 @@ export class AudioNodeMeter {

params = Object.assign({}, {
fftSize: 2048,
minDecibels: -100,
fftSize: 512,
minDecibels: -94,
maxDecibels: 0,
smoothingTimeConstant: 0.8,
intervalTime: 1000 / 120,
intervalLength: 100
intervalTime: 3,
intervalCount: 100
}, params)
/* create analyser filter */
/* create underlying analyser node */
const analyser = context.createAnalyser()

@@ -47,76 +50,39 @@ analyser.fftSize = params.fftSize

/* create storage bins */
const data = new Float32Array(analyser.frequencyBinCount)
const dataSorted = new Float32Array(analyser.frequencyBinCount)
/* initialize internal state */
const stat = { peak: -Infinity, rms: -Infinity, rmsM: -Infinity, rmsS: -Infinity }
const rmsLen = params.intervalCount
let rmsInit = true
let rmsPos = 0
const rmsArr = []
const dataT = new Float32Array(analyser.fftSize)
const dataF = new Float32Array(analyser.frequencyBinCount)
/* internal state */
const lvlAvgArr = []
let lvlAvgPos = -1
const devAvgArr = []
let devAvgPos = -1
/* measure the metrics */
const measure = () => {
/* store time/amplitude data into storage bin */
analyser.getFloatTimeDomainData(dataT)
/* calculate weighted average value */
const avg = (arr, pos, len) => {
const max = arr.length < len ? arr.length : len
/* store frequency/decibel data into storage bin */
analyser.getFloatFrequencyData(dataF)
let avg = 0
let num = 0
for (let i = 0; i <= pos; i++) {
const w = i + (max - pos)
avg += w * arr[i]
num += w
/* calculate the instant RMS and Peak amplitude of the signal */
let rms = 0
let peak = -Infinity
for (let i = 0; i < dataT.length; i++) {
const square = dataT[i] * dataT[i]
rms += square
if (peak < square)
peak = square
}
for (let i = pos + 1; i < max; i++) {
const w = i - (pos + 1)
avg += w * arr[i]
num += w
}
avg /= num
return avg
}
stat.rms = ensureWithin(gainTodBFS(Math.sqrt(rms / dataT.length)), params.minDecibels, params.maxDecibels)
stat.peak = ensureWithin(gainTodBFS(Math.sqrt(peak)), params.minDecibels, params.maxDecibels)
/* measure the metrics */
const measure = () => {
/* store FFT data into storage bin */
analyser.getFloatFrequencyData(data)
/* calculate the average decibel level of the signal over all frequencies */
const stat = {}
let total = 0
for (let i = 0; i < data.length; i++) {
if (data[i] < analyser.minDecibels)
data[i] = analyser.minDecibels
else if (data[i] > analyser.maxDecibels)
data[i] = analyser.maxDecibels
total += data[i] * data[i]
dataSorted[i] = data[i]
/* determine RMS over time */
if (rmsLen > 0) {
if (rmsPos === (rmsLen - 1) && rmsInit)
rmsInit = false
rmsPos = (rmsPos + 1) % rmsLen
rmsArr[rmsPos] = stat.rms
stat.rmsM = weightedAverage(rmsArr, rmsInit, rmsPos, rmsLen)
}
stat.avg = Math.sqrt(total / data.length)
/* sort frequencies and determine quantiles */
dataSorted.sort()
stat.min = dataSorted[0]
const q = Math.floor(dataSorted.length / 8)
stat.q1 = dataSorted[q * 1]
stat.q2 = dataSorted[q * 2]
stat.q3 = dataSorted[q * 3]
stat.med = dataSorted[q * 4]
stat.q4 = dataSorted[q * 5]
stat.q5 = dataSorted[q * 6]
stat.q6 = dataSorted[q * 7]
stat.max = dataSorted[dataSorted.length - 1]
/* find time-based average */
lvlAvgPos = (lvlAvgPos + 1) % params.intervalLength
lvlAvgArr[lvlAvgPos] = stat.max
stat.lvlAvg = avg(lvlAvgArr, lvlAvgPos, params.intervalLength)
stat.lvlDev = Math.abs(stat.max - stat.lvlAvg)
/* find time-based deviation */
devAvgPos = (devAvgPos + 1) % params.intervalLength
devAvgArr[devAvgPos] = stat.lvlDev
stat.devAvg = avg(devAvgArr, devAvgPos, params.intervalLength)
stat.devDev = Math.abs(stat.lvlDev - stat.devAvg)
analyser._stat = stat
}

@@ -127,5 +93,7 @@ setInterval(measure, params.intervalTime)

/* allow caller to access internals */
analyser.data = () => data
analyser.stat = () => analyser._stat
analyser.dataT = () => dataT
analyser.dataF = () => dataF
analyser.stat = () => stat
/* return underlying node */
return analyser

@@ -132,0 +100,0 @@ }

@@ -35,19 +35,19 @@ /*

params = Object.assign({}, {
threshold: -50, /* open above threshold (dbFS) */
hysteresis: -6, /* close below threshold+hysteresis (dbFS) */
reduction: -50, /* reduction of volume gain (dbFS) */
threshold: -45, /* open above threshold (dbFS) */
hysteresis: -3, /* close below threshold+hysteresis (dbFS) */
reduction: -30, /* reduction of volume gain (dbFS) */
interval: 2, /* tracking interval (ms) */
attack: 4, /* time to attack/clamp-up volume (ms) */
hold: 40, /* time to hold volume after it dropped below threshold+hysteresis (ms) */
release: 20 /* time to release/clamp-down volume (ms) */
release: 200 /* time to release/clamp-down volume (ms) */
}, params)
/* leverage Level Meter node for determining volume level */
/* leverage Meter node for determining volume level */
const meter = new AudioNodeMeter(context, {
fftSize: 2048,
minDecibels: -120,
fftSize: 512,
minDecibels: -94,
maxDecibels: 0,
smoothingTimeConstant: 0.0,
intervalTime: params.interval,
intervalLength: 1
smoothingTimeConstant: 0.8,
intervalTime: 2,
intervalCount: 25
})

@@ -62,5 +62,7 @@

let timer = null
const gainOpen = 1.0
const gainClosed = dBFSToGain(params.reduction)
const controlGain = () => {
/* determine current level */
const level = meter.stat().lvlAvg
/* determine current average level */
const level = meter.stat().rmsM

@@ -72,3 +74,4 @@ /* dispatch according to current state */

state = "attack"
gain.gain.exponentialRampToValueAtTime(1.0, context.currentTime + params.attack / 1000)
gain.gain.cancelScheduledValues(context.currentTime)
gain.gain.linearRampToValueAtTime(gainOpen, context.currentTime + params.attack / 1000)
if (timer !== null)

@@ -82,2 +85,15 @@ clearTimeout(timer)

}
else if (state === "attack") {
if (level < params.threshold + params.hysteresis) {
/* re-close again with a re-release */
state = "release"
gain.gain.cancelScheduledValues(context.currentTime)
gain.gain.linearRampToValueAtTime(gainClosed, context.currentTime + params.release / 1000)
if (timer !== null)
clearTimeout(timer)
timer = setTimeout(() => {
state = "closed"
}, params.release)
}
}
else if (state === "open") {

@@ -92,4 +108,4 @@ if (level < params.threshold + params.hysteresis) {

state = "release"
const reduction = dBFSToGain(params.reduction)
gain.gain.exponentialRampToValueAtTime(reduction, context.currentTime + params.release / 1000)
gain.gain.cancelScheduledValues(context.currentTime)
gain.gain.linearRampToValueAtTime(gainClosed, context.currentTime + params.release / 1000)
timer = setTimeout(() => {

@@ -112,5 +128,5 @@ state = "closed"

/* re-open again with a re-attack */
state = "attack"
gain.gain.cancelScheduledValues(context.currentTime)
state = "attack"
gain.gain.linearRampToValueAtTime(1.0, context.currentTime + params.attack / 1000)
gain.gain.linearRampToValueAtTime(gainClosed, context.currentTime + params.attack / 1000)
if (timer !== null)

@@ -117,0 +133,0 @@ clearTimeout(timer)

@@ -26,15 +26,16 @@ /*!

declare module "AudioNodeSuite" {
/* Composite `AudioNode` subclass by wrapping the node chain
from an input node to an output node (if not given, it is the same as the input node).
The `AudioContext` for the node is taken over from the input node.
/* Composite `AudioNode` subclass by wrapping the node chain from an
input node to an output node (if not given, it is the same as the
input node). The `AudioContext` for the node is taken over from the
input node.
As an `AudioNode` is an `EventEmitter`, this composite
node emits the following `CustomEvent` instances
for the calls `result = node.[dis]connect(target)`:
`CustomEvent("[dis]connect-before", { detail: { target }
})` and `CustomEvent("[dis]connect-after", { detail: {
result, target } })`. Similar, for the `node.bypass(enable)`
calls, it emits: `CustomEvent("bypass-enable-before")`,
`CustomEvent("bypass-enable-after")`, `CustomEvent("bypass-disable-before")`,
or `CustomEvent("bypass-disable-after")`. */
As an `AudioNode` is an `EventEmitter`, this composite node emits the
following `CustomEvent` instances for the calls `result = node.[dis]connect(target)`:
`CustomEvent("[dis]connect-before", { detail: { target } })` and
`CustomEvent("[dis]connect-after", { detail: { result, target } })`.
Similar, for the `node.bypass(enable)` calls, it emits:
`CustomEvent("bypass-enable-before")`,
`CustomEvent("bypass-enable-after")`,
`CustomEvent("bypass-disable-before")`, or
`CustomEvent("bypass-disable-after")`. */
export class AudioNodeComposite extends AudioNode {

@@ -50,3 +51,18 @@ public constructor(

/* standard `AudioNode` for convenient Gain control. */
/* `AudioNode` for convenient noise generation.
White noise is random amplitudes across the entire frequency range, and
pink noise is random amplitudes across the entire frequency range and
where the amplitudes of the higher frequences are less strong than the low frequences. */
export class AudioNodeNoise extends AudioNode {
public constructor(
context: AudioContext, /* context to associate */
params?: {
type?: string, /* type of noise ("white" or "pink") (default: "pink"), */
channels?: number /* number of audio channels (default: 1) */
}
)
}
/* `AudioNode` for convenient Gain control
which acts on decibels instead of ampliture gain. */
export class AudioNodeGain extends AudioNode {

@@ -56,8 +72,12 @@ public constructor(

params?: {
gain: number /* decibel to change the gain (default: 0) */
gain?: number /* decibel to change the gain (default: 0) */
}
)
adjustGainDecibel(
db: number, /* target decibel */
ms?: number /* linear adjust time in milliseconds */
): void
}
/* standard `AudioNode` for convenient Compressor effect. */
/* `AudioNode` for convenient Compressor effect. */
export class AudioNodeCompressor extends AudioNode {

@@ -67,7 +87,7 @@ public constructor(

params?: {
threshold: number, /* threshold in decibel to compress above (default: -16.0), */
attack: number, /* time in seconds to attack/clamp-up volume (default: 0.003) */
release: number, /* time in seconds to release/clamp-down volume (default: 0.400) */
knee: number, /* smoothing "knee" in decibels at threshold (default: 3.0) */
ratio: number /* ratio for decibels to compress above threshold (default: 2.0) */
threshold?: number, /* threshold in decibel to compress above (default: -16.0), */
attack?: number, /* time in seconds to attack/clamp-up volume (default: 0.003) */
release?: number, /* time in seconds to release/clamp-down volume (default: 0.400) */
knee?: number, /* smoothing "knee" in decibels at threshold (default: 3.0) */
ratio?: number /* ratio for decibels to compress above threshold (default: 2) */
}

@@ -77,3 +97,3 @@ )

/* standard `AudioNode` for convenient Limiter effect.
/* `AudioNode` for convenient Limiter effect.
(effectively, a maximum Compressor near the clipping zone) */

@@ -84,7 +104,7 @@ export class AudioNodeLimiter extends AudioNode {

params?: {
threshold: number, /* threshold in decibel to compress above (default: -3.0), */
attack: number, /* time in seconds to attack/clamp-up volume (default: 0.003) */
release: number, /* time in seconds to release/clamp-down volume (default: 0.050) */
knee: number, /* smoothing "knee" in decibels at threshold (default: 0.0) */
ratio: number /* ratio for decibels to compress above threshold (default: 20.0) */
threshold?: number, /* threshold in decibel to compress above (default: -3.0), */
attack?: number, /* time in seconds to attack/clamp-up volume (default: 0.001) */
release?: number, /* time in seconds to release/clamp-down volume (default: 0.050) */
knee?: number, /* smoothing "knee" in decibels at threshold (default: 0.0) */
ratio?: number /* ratio for decibels to compress above threshold (default: 20) */
}

@@ -94,3 +114,3 @@ )

/* standard `AudioNode` for multi-band parameteric equalizer. */
/* `AudioNode` for parametric multi-band equalizer. */
export class AudioNodeEqualizer extends AudioNodeComposite {

@@ -100,8 +120,8 @@ public constructor(

params?: {
bands: {
type: string, /* type of Biquad filter (default: "peaking"), */
freq: number, /* base frequency to act on (default: 64*2^i) */
q: number, /* Q factor to apply (default: 1.0) */
bands?: Array<{
type?: string, /* type of Biquad filter (default: "peaking"), */
freq?: number, /* base frequency to act on (default: 64*2^i) */
q?: number, /* Q factor to apply (default: 1.0) */
gain?: number /* gain to apply (default: 1.0) */
}[]
}>
}

@@ -111,13 +131,13 @@ )

/* standard `AudioNode` for meter, measuring the volume. */
/* `AudioNode` for meter, measuring the amplitude. */
export class AudioNodeMeter extends AudioNode {
public constructor(
context: AudioContext, /* context to associate */
context: AudioContext, /* context to associate */
params?: {
fftSize: number, /* FFT size (default: 2048) */
minDecibels: number, /* FFT minimum decibels (default: -100) */
maxDecibels: number, /* FFT maximum decibels (default: 0) */
smoothingTimeConstant: number, /* FFT smoothing time constant (default: 0.8) */
intervalTime: number, /* interval time in milliseconds to act (default: 1000 / 120) */
intervalLength: number /* interval length for average calculations (default: 100) */
fftSize?: number, /* FFT size (default: 512) */
minDecibels?: number, /* FFT minimum decibels (default: -94) */
maxDecibels?: number, /* FFT maximum decibels (default: 0) */
smoothingTimeConstant?: number, /* FFT smoothing time constant (default: 0.8) */
intervalTime?: number, /* interval time in milliseconds to act (default: 3) */
intervalCount?: number /* interval count for average calculations (default: 100) */
}

@@ -127,14 +147,14 @@ )

/* standard `AudioNode` for noise gate. */
export class AudioNodeMeter extends AudioNodeComposite {
/* `AudioNode` for noise gate. */
export class AudioNodeGate extends AudioNode {
public constructor(
context: AudioContext, /* context to associate */
context: AudioContext, /* context to associate */
params?: {
threshold: number, /* open above threshold (dbFS) (default: -50) */
hysteresis: number, /* close below threshold+hysteresis (dbFS) (default: -6) */
reduction: number, /* reduction of volume gain (dbFS) (default: -50) */
interval: number, /* tracking interval (ms) (default: 2) */
attack: number, /* time to attack/clamp-up volume (ms) (default: 4) */
hold: number, /* time to hold volume after it dropped below threshold+hysteresis (ms) (default: 40) */
release: number /* time to release/clamp-down volume (ms) (default: 20) */
threshold?: number, /* open above threshold (dbFS) (default: -45) */
hysteresis?: number, /* close below threshold+hysteresis (dbFS) (default: -3) */
reduction?: number, /* reduction of volume gain (dbFS) (default: -30) */
interval?: number, /* tracking interval (ms) (default: 2) */
attack?: number, /* time to attack/clamp-up volume (ms) (default: 4) */
hold?: number, /* time to hold volume after it dropped below threshold+hysteresis (ms) (default: 40) */
release?: number /* time to release/clamp-down volume (ms) (default: 200) */
}

@@ -144,3 +164,24 @@ )

/* standard `AudioNode` for spectrum visualization. */
/* `AudioNode` for amplitude visualization. */
export class AudioNodeAmplitude extends AudioNode {
public constructor(
context: AudioContext, /* context to associate */
params?: {
fftSize?: number, /* FFT size (default: 512) */
minDecibels?: number, /* FFT minimum decibels (default: -60) */
maxDecibels?: number, /* FFT maximum decibels (default: 0) */
smoothingTimeConstant?: number, /* FFT smoothing time constant (default: 0.8) */
intervalTime?: number, /* interval time in milliseconds to act (default: 1000 / 60) */
intervalLength?: number /* interval length for average calculations (default: 300 / (1000 / 60)) */
decibelBars?: number[], /* list of decibel layers to draw (default: [ -60, -45, -21, -6 ]) */
colorBars?: string[], /* list of color layers to draw (default: [ "#306090", "#00b000", "#e0d000", "#e03030" ]) */
colorBarsDeactive?: string[], /* list of color layers to draw (default: [ "#606060", "#808080", "#a0a0a0", "#c0c0c0" ]) */
colorRMS?: string, /* color of the RMS decibel (default: "#ffffff") */
colorBackground?: string, /* color of the background (default: "#000000") */
horizontal?: boolean /* whether to draw horizontall instead of vertically (default: false) */
}
)
}
/* `AudioNode` for spectrum visualization ("spectrogram" style). */
export class AudioNodeSpectrum extends AudioNode {

@@ -150,16 +191,14 @@ public constructor(

params?: {
fftSize: number, /* FFT size (default: 2048) */
minDecibels: number, /* FFT minimum decibels (default: -100) */
maxDecibels: number, /* FFT maximum decibels (default: 0) */
smoothingTimeConstant: number, /* FFT smoothing time constant (default: 0.8) */
intervalTime: number, /* interval time in milliseconds to act (default: 1000 / 60) */
intervalLength: number /* interval length for average calculations (default: 10) */
layers: number[], /* list of decibel layers to draw (default: [ -120, -90, -60, -30 ]) */
slices: number[], /* list of frequency slices to draw (default: [ 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480 ]) */
colorBackground: string, /* color of the background (default: "#000000") */
colorBars: string, /* color of the spectrum bars (default: "#00cc00") */
colorAvg: string, /* color of the average maximum decibel (default: "#00ff00") */
colorLayers: string, /* color of the decibel layer lines (default: "#009900") */
colorSlices: string, /* color of the frequency slice lines (default: "#009900") */
logarithmic: boolean /* whether to use logarithmic scale for frequencies (default: true) */
fftSize?: number, /* FFT size (default: 8192) */
minDecibels?: number, /* FFT minimum decibels (default: -144) */
maxDecibels?: number, /* FFT maximum decibels (default: 0) */
smoothingTimeConstant?: number, /* FFT smoothing time constant (default: 0.8) */
intervalTime?: number, /* interval time in milliseconds to act (default: 1000 / 60) */
layers?: number[], /* list of decibel layers to draw (default: [ -120, -90, -60, -50, -40, -30, -20, -10 ]) */
slices?: number[], /* list of frequency slices to draw (default: [ 40, 80, 160, 320, 640, 1280, 2560, 5120, 10240, 20480 ]) */
colorBackground?: string, /* color of the background (default: "#000000") */
colorBars?: string, /* color of the spectrum bars (default: "#00cc00") */
colorLayers?: string, /* color of the decibel layer lines (default: "#009900") */
colorSlices?: string, /* color of the frequency slice lines (default: "#009900") */
logarithmic?: boolean /* whether to use logarithmic scale for frequencies (default: true) */
}

@@ -169,3 +208,3 @@ )

/* standard `AudioNode` for opinionated voice filtering. */
/* `AudioNode` for opinionated voice filtering. */
export class AudioNodeVoice extends AudioNodeComposite {

@@ -175,7 +214,11 @@ public constructor(

params?: {
gain: number /* additional decibel to change the gain after processing (default: 0) */
gain?: number /* additional decibel to change the gain after processing (default: 0) */
}
)
adjustGainDecibel(
db: number, /* target decibel */
ms?: number /* linear adjust time in milliseconds */
): void
}
}

@@ -30,2 +30,3 @@ /*

import {
AudioNodeNoise,
AudioNodeGain,

@@ -45,7 +46,10 @@ AudioNodeCompressor,

import {
AudioNodeAmplitude
} from "./audio-node-suite-7-amplitude.js"
import {
AudioNodeSpectrum
} from "./audio-node-suite-7-spectrum.js"
} from "./audio-node-suite-8-spectrum.js"
import {
AudioNodeVoice
} from "./audio-node-suite-8-voice.js"
} from "./audio-node-suite-9-voice.js"

@@ -56,2 +60,3 @@ /* export the traditional way for interoperability reasons

AudioNodeComposite,
AudioNodeNoise,
AudioNodeGain,

@@ -63,2 +68,3 @@ AudioNodeCompressor,

AudioNodeGate,
AudioNodeAmplitude,
AudioNodeSpectrum,

@@ -65,0 +71,0 @@ AudioNodeVoice

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc