fastframes-voice / assets /capture.js
fffiloni's picture
Build private live voice direction studio
1d797bd verified
Raw History Blame Contribute Delete
539 Bytes
class VoiceCapture extends AudioWorkletProcessor {
constructor() { super(); this.buffer = new Float32Array(1024); this.pos = 0; }
process(inputs) {
const channel = inputs[0]?.[0];
if (channel) {
for (const x of channel) {
this.buffer[this.pos++] = x;
if (this.pos === this.buffer.length) {
this.port.postMessage(this.buffer, [this.buffer.buffer]); this.buffer = new Float32Array(1024); this.pos = 0;
}
}
}
return true;
}
}
registerProcessor("ffv-capture", VoiceCapture);