Nothing is working but it is on the right track! ASYNCIFY removed, manual waiting instead and some proxying logic
This commit is contained in:
28
src/processor.js
Normal file
28
src/processor.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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)
|
||||
break
|
||||
case "deinit":
|
||||
this.done = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
process(inputs, outputs, params) {
|
||||
if(this.done) return false;
|
||||
inputs[0].copyFromChannel(this.wasmMem, this.channel)
|
||||
this.recognizerPort.postMessage(".") // Basically an empty message
|
||||
outputs = inputs
|
||||
return true
|
||||
}
|
||||
}
|
||||
registerProcessor("BRProcessor", BRProcessor)
|
||||
}
|
||||
Reference in New Issue
Block a user