This commit is contained in:
msqr1
2024-01-31 22:49:07 -08:00
parent 1b74781a9d
commit 9d21692993
5 changed files with 29 additions and 35 deletions

View File

@@ -1,28 +1,26 @@
// A copy and pass processor, check if already registered
if(typeof BRProcessor === "undefined") {
var BRProcessor = class extends AudioWorkletProcessor {
constructor(options) {
super(options)
this.done = false
this.port.onmessage = (ev) => {
switch(ev.cmd) {
case "init":
this.recognizerPort = ev.ports[0]
this.wasmMem = new Float32Array(WebAssembly.Memory.buffer).subarray(ev.ptr, ev.ptr+512)
this.channel = ev.channel;
break
case "deinit":
this.done = true
}
// A copy and pass processor
registerProcessor("BRProcessor", class extends AudioWorkletProcessor {
constructor(options) {
super(options)
this.done = false
this.port.onmessage = (ev) => {
switch(ev.cmd) {
case "init":
this.recognizerPort = ev.ports[0]
this.wasmMem = new Float32Array(WebAssembly.Memory.buffer).subarray(ev.ptr, ev.ptr+512)
this.channel = ev.channel
break
case "deinit":
this.done = true
}
}
process(inputs, outputs, params) {
if(this.done) return false;
this.wasmMem.set(inputs[0].getChannelData(this.channel));
this.recognizerPort.postMessage(".")
outputs = inputs
return true
}
}
registerProcessor("BRProcessor", BRProcessor)
}
process(inputs, outputs, params) {
if(this.done) return false;
this.wasmMem.set(inputs[0].getChannelData(this.channel));
this.recognizerPort.postMessage(".")
outputs = inputs
return true
}
})