1/** 2 * Audio Worklet Processor for PCM Audio Capture 3 * Captures microphone audio and converts to PCM format for WebSocket transmission 4 */ 5 6class PCMProcessor extends AudioWorkletProcessor { 7 constructor() { 8 super(); 9 this.bufferSize = 4096; 10 this.buffer = new Float32Array(this.bufferSize); 11 this.bufferIndex = 0; 12 } 13 14 process(inputs, outputs, parameters) { 15 const input = inputs[0]; 16 17 if (input.length > 0) { 18 const inputChannel = input[0]; 19 20 for (let i = 0; i < inputChannel.length; i++) { 21 this.buffer[this.bufferIndex++] = inputChannel[i]; 22 23 // When buffer is full, send it to main thread 24 if (this.bufferIndex >= this.bufferSize) { 25 this.port.postMessage(this.buffer.slice(0, this.bufferIndex)); 26 this.bufferIndex = 0; 27 } 28 } 29 } 30 31 return true; // Keep processor alive 32 } 33} 34 35registerProcessor('pcm-processor', PCMProcessor);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.