Hello.
My English and program may be poor, but I’d like to post them anyway.
https://piyoneer.itch.io/audiosystem
Out of technical curiosity, I made this.
It contains the module "audioserver" and the contraption "instrument".
The loop callback of play[] sequentially reads buffers.
I'll briefly explain how to use it.
Just copy and paste the following from "on loop do"...
To write sound, use audioserver.overdub[sound cursor].
Here, the cursor is the sample position in the stream, which can be referenced with audioserver.stream[].
audioserver.overtake[cursor sound.size] allows you to determine if the sound you are writing will collide with the read position.
I made it, but it frequently stops due to garbage collection.
Also, it does not play smoothly in the browser.
Feel free to modify it as you like, and let me know if you have any suggestions for improvement.