emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

Block size specification for audio worklet

Open msqr1 opened this issue 10 months ago • 3 comments

Audio worklet right now has an unchangable block size of 128, which lowers the latency, but it can come in too fast, or unfit for the provided processing algorithm.

msqr1 avatar Apr 11 '24 01:04 msqr1

This can also be a waste of performance in case of a multi-threaded audio processor. For example, if one generates audio blocks of 2048 samples, the audio callback is called at a higher frequency than processing. I'm pretty sure this implies more cache misses and more context switches in the long run. Would it be a difficult feature to add ?

MatthieuMv avatar Apr 28 '24 22:04 MatthieuMv

I think it can be easy if block size allowed is a multiple of 128, since we can just allocate it once, accumulate with calculated offset while keeping track of count, and run the callback function on the buffer. Then we can keep reusing it since this is shared memory

msqr1 avatar Apr 29 '24 05:04 msqr1

@juj any feedback on this? IIRC this has maybe come up before?

sbc100 avatar Apr 29 '24 20:04 sbc100