@alexanderolsen/silence-listener-node
Version:
Pseudo-AudioNode to notify when an audio stream becomes silent.
1 lines • 4.39 kB
JavaScript
(()=>{var t={506:t=>{t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},575:t=>{t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},100:(t,e,r)=>{var n=r(489),o=r(67);function i(e,r,s){return o()?t.exports=i=Reflect.construct:t.exports=i=function(t,e,r){var o=[null];o.push.apply(o,e);var i=new(Function.bind.apply(t,o));return r&&n(i,r.prototype),i},i.apply(null,arguments)}t.exports=i},913:t=>{function e(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}},754:t=>{function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},e(r)}t.exports=e},205:(t,e,r)=>{var n=r(489);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}},430:t=>{t.exports=function(t){return-1!==Function.toString.call(t).indexOf("[native code]")}},67:t=>{t.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}},585:(t,e,r)=>{var n=r(8),o=r(506);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?o(t):e}},489:t=>{function e(r,n){return t.exports=e=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},e(r,n)}t.exports=e},8:t=>{function e(r){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=e=function(t){return typeof t}:t.exports=e=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(r)}t.exports=e},957:(t,e,r)=>{var n=r(754),o=r(489),i=r(430),s=r(100);function u(e){var r="function"==typeof Map?new Map:void 0;return t.exports=u=function(t){if(null===t||!i(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(t))return r.get(t);r.set(t,e)}function e(){return s(t,arguments,n(this).constructor)}return e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),o(e,t)},u(e)}t.exports=u}},e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=r(575),e=r.n(t),n=r(913),o=r.n(n),i=r(506),s=r.n(i),u=r(205),c=r.n(u),a=r(585),f=r.n(a),l=r(754),p=r.n(l),y=r(957);var h=function(t){c()(u,t);var r,n,i=(r=u,n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=p()(r);if(n){var o=p()(this).constructor;t=Reflect.construct(e,arguments,o)}else t=e.apply(this,arguments);return f()(this,t)});function u(){var t;return e()(this,u),(t=i.call(this)).port.onmessage=t._onMessage.bind(s()(t)),t.silent=!1,t.silentRuns=0,t.silenceThreshold=Math.floor(344.53125),t}return o()(u,[{key:"process",value:function(t,e,r){for(var n=!0,o=0;o<t.length;o++)for(var i=t[o],s=0;s<i.length;s++)for(var u=i[s],c=0;c<u.length;c++)e[o][s][c]=u[c],0!==u[c]&&(n=!1);return this.silent&&!n?(this.port.postMessage({command:"stateChange",silent:n}),this.silentRuns=0,this.silent=!1):!this.silent&&n&&(this.silentRuns++,this.silentRuns===this.silenceThreshold&&(this.port.postMessage({command:"stateChange",silent:n}),this.silent=!0)),!0}},{key:"_onMessage",value:function(t){switch(t.data.command){case"init":this.silenceThreshold=t.data.silenceThreshold;break;default:throw Error("unknown command ".concat(t.data.command))}}}]),u}(r.n(y)()(AudioWorkletProcessor));registerProcessor("SilenceListenerNode",h)})()})();