Nazariglez / notan

Cross-platform multimedia layer
https://nazariglez.github.io/notan-web/
Apache License 2.0
802 stars 55 forks source link

Audio latency #320

Open troyc opened 6 months ago

troyc commented 6 months ago

I noticed audio latency when playing audio with the wasm build (it was also noticeable on the Linux desktop build, but that doesn't concern me). It might be due to the way cpal currently works with wasm (old thread, maybe still relevant: https://github.com/RustAudio/cpal/pull/372). I ended up making bindings to howler.js for audio on wasm. This is a video with the same sounds being played via howler.js bindings and notan_audio/oddio/cpal: https://youtu.be/lyZKoDjTZY0. I was able to confirm that the delayed sound is from Notan.

Nazariglez commented 6 months ago

Thanks for the report @troyc! I'll take a look.

troyc commented 6 months ago

These are the bindings I used: https://gist.github.com/troyc/9be9b26b1b8af61ef0e2e54ec2077d0a

Nazariglez commented 3 months ago

This is interesting, is it the video showing the latency? I think that I can hear at first two sounds with a short time amount between them, and then after a few seconds the same sounds have a bigger gap between them. Is that the issue? My guess it that the first one is using howler and the last one is using notan right?

troyc commented 3 months ago

My guess it that the first one is using howler and the last one is using notan right?

Right

Nazariglez commented 3 months ago

I guess that could be something related to cpal, or to the notan's implementation of how notan starts sound, maybe the code is awaiting for the sound to end to start other? Could be a few things, but I am not too worried about this because I have a few ideas to fix it, and at the end of the day we can always implement WebAudio directly in the web backend.

Thanks, I'll investigate it!