This repository has been archived on 2026-02-28. You can view files and clone it, but cannot push or open issues or pull requests.
ServerSpacebarOld/assets/public/client/3d0c138fed5f94750ddc.worklet.js
2025-12-08 19:46:42 +02:00

5 lines
3.6 KiB
JavaScript

(()=>{"use strict";var t=function(){function t(n){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t);this.size=n;this.head=0;this.samples=new Array(n).fill(0)}var n=t.prototype;n.addSample=function(t){this.head=(this.head+1)%this.size;this.samples[this.head]=t};n.mean=function(){var t=0,n=1/this.size,e=!0,r=!1,o=void 0;try{for(var i,u=this.samples[Symbol.iterator]();!(e=(i=u.next()).done);e=!0){t+=i.value*n}}catch(t){r=!0;o=t}finally{try{e||null==u.return||u.return()}finally{if(r)throw o}}return t};return t}();function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{Date.prototype.toString.call(Reflect.construct(Date,[],(function(){})));return!0}catch(t){return!1}}function e(t,r,o){e=n()?Reflect.construct:function(t,n,e){var r=[null];r.push.apply(r,n);var o=new(Function.bind.apply(t,r));e&&i(o,e.prototype);return o}
;return e.apply(null,arguments)}function r(t){r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)};return r(t)}function o(t,n){return!n||"object"!==c(n)&&"function"!=typeof n?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):n}function i(t,n){i=Object.setPrototypeOf||function(t,n){t.__proto__=n;return t};return i(t,n)}var u,c=function(t){return t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t};function a(t){var n="function"==typeof Map?new Map:void 0;a=function(t){if(null===t||!(o=t,-1!==Function.toString.call(o).indexOf("[native code]")))return t;var o;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(t))return n.get(t);n.set(t,u)}function u(){return e(t,arguments,r(this).constructor)}u.prototype=Object.create(t.prototype,{constructor:{value:u,enumerable:!1,
writable:!0,configurable:!0}});return i(u,t)};return a(t)}function f(t){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})));return!0}catch(t){return!1}}();return function(){var e,i=r(t);if(n){var u=r(this).constructor;e=Reflect.construct(i,arguments,u)}else e=i.apply(this,arguments);return o(this,e)}}!function(t){t[t.NONE=0]="NONE";t[t.VOICE=1]="VOICE";t[t.SOUNDSHARE=2]="SOUNDSHARE";t[t.PRIORITY=4]="PRIORITY"}(u||(u={}));if("undefined"!=typeof AudioWorkletProcessor){var s=function(n){!function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(n&&n.prototype,{constructor:{value:t,writable:!0,configurable:!0}});n&&i(t,n)}(r,n);var e=f(r);function r(){!function(t,n){
if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,r);var n;(n=e.call(this)).running=!0;n.lastSpeaking=u.NONE;n.dBFSHistogram=new t(20);n.port.onmessage=function(t){"close"===t.data&&(n.running=!1)};return n}r.prototype.process=function(t,n,e){var r=t[0],o=u.NONE;if(r.length>0&&r[0].length>0){for(var i=r[0].length,c=0,a=0;a<r.length;++a)for(var f=r[a],s=0;s<f.length;++s)c+=f[s]*f[s];c=20*Math.log10(Math.sqrt(c/(i*r.length)))+Math.sqrt(2);this.dBFSHistogram.addSample(c>-100?c:-100);o=this.dBFSHistogram.mean()>-80?u.VOICE:u.NONE}if(this.lastSpeaking!==o){this.port.postMessage(o);this.lastSpeaking=o}return this.running};return r}(a(AudioWorkletProcessor));registerProcessor("level-processor",s)}})();
//# sourceMappingURL=3d0c138fed5f94750ddc.worklet.js.map