Make use of multi-threading in an AudioWorklet (WASM)

Hi everyone,

is there a way to make use of multi-threading for an AudioWorklet? (I'm 
specifically asking for an implementation WebAssembly)

IIUC AudioWorklets can never have a background task being active between 
two calls of process(...). So if there was a way to use multi-threading 
in an AudioWorklet, all threads would have to finish their work within 
the time frame of a single render quantum.

If we move the multi-threading part to ordinary WebWorkers, they would 
be able to collaboratively work on preparing the next audio data. 
Ideally the AudioWorklet would just collect the prepared data. But 
there's no guarantee about the priority of those threads. If the browser 
decides to reduce the threads' performance, the AudioWorklet may not 
receive its data in time.

It would be possible to perform the remaining computations in the 
AudioWorklet but then we might run into dependency issues like priority 
inversions (AudioWorklet waiting for a stalled Worker).

Sorry if this sounds over-complicated, but the Web Audio API is a 
huuuuuuge API compared to what I essentially need: compute samples 
chunk-wise in real time. I'm having a hard time filtering out everything 
I don't need.

I'd be happy if someone could shed some light on this.

Thank you!

Received on Wednesday, 22 April 2020 23:14:43 UTC