mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
23 lines
504 B
JavaScript
23 lines
504 B
JavaScript
class RecorderProcessor extends AudioWorkletProcessor {
|
|
constructor() {
|
|
super()
|
|
this._active = true
|
|
this.port.onmessage = (e) => {
|
|
if (e.data === 'stop') {
|
|
this._active = false
|
|
}
|
|
}
|
|
}
|
|
|
|
process(inputs) {
|
|
if (!this._active) return false
|
|
const input = inputs[0]
|
|
if (input && input[0] && input[0].length > 0) {
|
|
this.port.postMessage(new Float32Array(input[0]))
|
|
}
|
|
return true
|
|
}
|
|
}
|
|
|
|
registerProcessor('recorder-processor', RecorderProcessor)
|