hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
10.74k stars 649 forks source link

examples/audio: reduce the delay for the sound effect #2360

Open xyproto opened 1 year ago

xyproto commented 1 year ago

When playing a sound effect with p, there is a noticeable delay before the sound starts to play.

This delay is reduced when applying the patch from #2357, but this patch stops multiple sound effects from being played at the same time.

This is a feature request for finding a different method for reducing the delay. (Perhaps in Ebiten itself, and not in the example?).

I'm on Arch Linux, using JACK and Go 1.19.1.

Thanks for creating Ebiten!

hajimehoshi commented 1 year ago

Probably creating a pool of players would be the way to go, if we fix the example.

tinne26 commented 1 year ago

@xyproto if you run the example from https://ebitengine.org/en/examples/audio.html, does it also have delay?

I have tested on Windows 11 and wasm, and I can't notice any delay difference between the patched and the original version, so I was wondering if it could be an issue specific to Linux / Arch or if there was something else that could be affecting the performance. As far as I know, NewPlayerFromBytes shouldn't be a problem as it doesn't involve significant allocations or copies or anything. It could be something in the mixing related to the new player, but I couldn't notice anything on my end.

hajimehoshi commented 1 year ago

Is the issue about playing the first SE, or playing any SEs?

xyproto commented 1 year ago

Not just the first SE, as I recall.

If I find the time, I'll test on Windows, macOS and again on Linux.

hajimehoshi commented 1 year ago

Could you try the latest version (Ebitengine v2.5.0-alpha.8)?