Spaces:
Running
Running
File size: 682 Bytes
b8cc2bf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | /**
* Simple AudioWorkletProcessor for capturing raw audio chunks.
* Minimal logic to keep latency low.
*/
class CaptureProcessor extends AudioWorkletProcessor {
process(inputs: Float32Array[][], _outputs: Float32Array[][]): boolean {
const input = inputs[0];
if (!input || input.length === 0) return true;
// Use only the first channel (mono)
const channelData = input[0];
// Send audio chunk to the main thread
// We clone the data to avoid issues with SharedArrayBuffer (if not available)
this.port.postMessage(channelData);
return true;
}
}
registerProcessor('capture-processor', CaptureProcessor);
|