class MicrophoneAudioProcessor extends AudioWorkletProcessor{static get parameterDescriptors(){return[{name:"frequency",defaultValue:44100,minValue:16e3,maxValue:48e3},{name:"channels",defaultValue:2,minValue:1,maxValue:2},{name:"recording",defaultValue:0,minValue:0,maxValue:1},]}constructor(){super()}process(e,r,n){if(0==n.recording[0])return!0;var t=null;for(let a=0;a<e.length;a++){var l=[...e[a]];t={channels:l.length,data:[]},l=this.changeBitrate(l,sampleRate,n.frequency[0],n.channels[0]);for(let o=0;o<l.length;o++)t.data[o]=l[o];this.port.postMessage(t)}return!0}changeBitrate(e,r,n,t){if(null===e||r===n||0==e.length)return e;for(var a=0;a<t;a++)void 0!=e[a]&&e[a].length>=64&&e[a].length<4*n&&(e[a]=this.downsampleBitrate(e[a],r,n));return e}downsampleBitrate(e,r,n){if(null===e||r===n)return e;for(var t=r/n,a=Math.round(e.length/t),l=new Float32Array(a),o=0,u=0;o<l.length;){for(var s=Math.round((o+1)*t),$=0,i=0,c=u;c<s&&c<e.length;c++)$+=e[c],i++;l[o]=$/i,o++,u=s}return l}}registerProcessor("microphone-worklet",MicrophoneAudioProcessor);