As discussed in #6965 and in great part fixed in #7425 by @lonesurvivor, SamplePlayer before 2.1.2 and 3.0 used to have a big latency (~200 ms) due to a bad initialisation of the audio drivers.
We should try to ensure that all drivers now behave properly, so this new issue can serve to gather feedback about all platforms/drivers to identify those that might still need a fix. If someone can make a test project that can be used to benchmark the latency, that would be great too :)
Platforms/drivers to check:
Testing can be done with the official 2.1.2 binaries as they contain the fix from #7425, and that branch is arguably easier to test than the master branch with a disabled audio engine right now :p
Of course platforms like Haiku or BB10 are not strongly maintained, so if we can't check/fix them, it's not a huge problem :)
Definitely a lot better for me on Windows 10 (with the default Microsoft driver), thanks for the fix!
OS and Godot version: Godot 2.1.2-stable Xubuntu 14.04 64-bit
My previous tests #6965 were done on modified version of Godot and templates that I compile with options like openssl=no musepack=no disable_3d=yes etc..
For now I tested 2.1.2 using default version downloaded from the website, so the testing environment was not exactly the same.
Test 1 - SamplePlayer :
Project run from Godot
Short audio sample (576 kB)

Latency: 118 ms
Test 2 - SamplePlayer:
Project exacuted from binary
Short audio sample (576 kB)

Latency: 97 ms
Test 3 - SamplePlayer :
Project run from Godot
Longer audio sample (2 MB)

Latency: 153 ms
Test 4 - AudioServer:
Project executed from binary
Longer audio sample (2 MB)

Latency: 185 ms
Test 5 - AudioServer:
Project executed from binary
Longer audio sample (2 MB)
I was trying to get more than one result for the same action, to see if the latency is consistent:

Latency: 134 ms
It looks like SamplePlayer in the Godot 2.1.2-stable audio latency is noticeably lower now.
Comparing to previous values of 285 ms for SamplePlayer and 235 ms for AudioServer the latency was cut in half.
Tests 4 and 5 show that the difference between trials can be as high as ~50 ms.
@cbrwn Can you measure the values or even compare with Godot 2.1? I am able to check only Linux for now.
I checked it with windows 10 and it worked pretty well. There might have been some clicking but that was probably the sound I was using above anything else.
Never mind, was just using a bad sample. The audio seems to be working fine on my end. Not nearly as noticeable delay now between actions and audio.
The driver im using is "Realtek High Definition Audio"
@freemanfromgodotengine That doesn't look too bad. Theoretically, however, the audio buffer lag should be only around 20 - 30 ms with the standard setting. I wonder where the rest comes from. I couldn't find any more problems in the AudioServer code. Hmm, maybe it is just input lag.
For me it sounded like it was way shorter though. I should make a measurement too, I guess.
It would be nice to know which of the built in drivers you used (RtAudio, XAudio2, ALSA, PulseAudio, ...). The used one can be found in the editor under project settings/audio/driver.
@lonesurvivor I am testing on default Xubuntu 14.04.5 LTS so it's PulseAudio. Previous tests as well. By the way thanks for a great work on this one.
old audio engine is gone in 3.0, so closing this
@freemanfromgodotengine Just to be sure, had you tried to measure or ripoff the node retrieval of SamplePlayer? Should be peanuts, but you can onready var player = get_node(...) and save some cycles on the event processing, right?
onready var sample_player = get_node("SamplePlayer")
func _on_TouchScreenButton_pressed():
sample_player.play("sample")
@alanjds No, I did not tried that. But some of my first tests , before @lonesurvivor repaired AudioServer, were done playing sounds from code directly on the AuiodServer, without creating SamplePlayer nodes as far as I can remamber... #6965 .
Yes, it is worth testing. Thanks for the tip.
I will probably try it when Godot 3.0 gets stable.
Most helpful comment
@lonesurvivor I am testing on default Xubuntu 14.04.5 LTS so it's PulseAudio. Previous tests as well. By the way thanks for a great work on this one.