hunni.space/recorder.worklet.js
mowetentertainment1 730de334a7 initial
2025-12-05 11:05:33 -05:00

2 lines
1.5 KiB
JavaScript

(()=>{"use strict";function e(t){return e="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(t)}function t(t){var r=function(t,r){if("object"!=e(t)||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,r||"default");if("object"!=e(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==e(r)?r:r+""}function r(e,r,n){return(r=t(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function n(e,t){return new Array(t).fill(e)}let i=function(e){return e.Timekeep="timekeep",e.AmplitudeMark="amplitude_mark",e}({});n(0,39);function o(e,t,r){const n=(e-t)/(r-t);return Number.isNaN(n)?0:n}function u(e){return Math.round(16*(e+Number.EPSILON))/16}class s extends AudioWorkletProcessor{constructor(...e){super(...e),r(this,"nextAmplitudeSecond",0),r(this,"amplitudeIndex",0)}process(e,t,r){const n=u(currentTime);if(n===this.nextAmplitudeSecond||0===this.nextAmplitudeSecond){const t=e[0][0],r=Math.min(...t),s=o(Math.max(...t),-1,1)-o(r,-1,1);this.port.postMessage({ev:i.AmplitudeMark,amplitude:s,forIndex:this.amplitudeIndex++}),this.nextAmplitudeSecond=u(n+1/16)}return this.port.postMessage({ev:i.Timekeep,timeSeconds:currentTime}),!0}}registerProcessor("mx-voice-worklet",s)})();
//# sourceMappingURL=recorder.worklet.js.map