Support for emscripten
This will probably be a priority for ggez someday, right now the best(???) option appears to basically be to target the emscripten SDL2 audio or maybe OpenAL backends.
I didn't update this issue, but basically the problem is that the WebAudio is not low-level enough and didn't provide some critical functionnalities, although I don't remember what exactly.
Conversation on a possible approach
14:55 < tomaka> well, there's just no way to stream data
14:55 < tomaka> their interface is high-level, they expect you to send sound files or something
14:55 < tomaka> but it's not that far away from being possible
14:55 < jpernst> there is a way to do it
14:55 < jpernst> i'm doing it in the openal impl
14:56 < tomaka> you can send buffers with arbitrary data, but there's no timeout when it's finished or something like that
14:56 < Icefoz> There's that too.
14:56 < jpernst> ahhh, right
14:56 < tomaka> I don't remember at this point what was missing
14:56 < jpernst> there is no callback, that's true
14:56 < jpernst> openal is poll based, so it works
14:56 < jpernst> but if you rely on accurate callbacks, that is a problem
14:56 < tomaka> I don't need accurate callbacks, just callbacks at all
14:57 < jpernst> you could simulate it with an interval proc
14:57 < jpernst> for example, the openal impl runs a refresh method every 25ms or so
14:57 < tomaka> I think you could use setTimeout, but since there's no way to know when a sound is finished maybe you're 2 minutes ahead of the playback and you don't know it
14:58 < tomaka> I mean, if you start playing a sound that lasts 20ms and setup a callback for 20ms later, you're going to be too short
14:58 < tomaka> so you should setup your callback for 19ms later or something like that
14:58 < jpernst> the audio context has a "current time" field
14:58 < jpernst> which you can use to find out when a sound is done
14:58 < tomaka> ah
14:59 < jpernst> i have a queue of pending buffers and flush them out once they're "finished"
15:00 < jpernst> now, it is true that webaudio doesn't actually support buffer queueing
15:00 < jpernst> so you can get clicks and pops if your buffer times aren't exactly representable as a double, or if there's lots of resampling involved
15:01 < jpernst> but if you keep them the same rate as the native rate, and using perfect durations, it does work
This can be closed now that CPAL works on web right?
Edit: Also I had a question about the README which says that Emscripten is a tested target: does CPAL actually use emscripten or just web-sys and the wasm32-unknown-unknown target?