Whenever I’m looking for a wel designed audio API, I always look towards this high quality C++ library : https://www.music.mcgill.ca/~gary/rtaudio/
Hopefully, some spec can be done for “pull” style audio API for the web. The rest can clearly be done with the existing APIs.
That API seemingly forces you to use threads. I don’t like it.
From glancing the docs, I don’t see how to calculate latency either. streamTime looks like a clue but the docs are vague about it: https://www.music.mcgill.ca/%7Egary/rtaudio/RtAudio_8h.html#a112c7b7e25a974977f6fc094cef1a31f