Operating system or device - Godot version:
Godot 2.1-stable on Xubuntu 14.10 64-bit. Project also tested on Android 4 6.
Issue description (what happened, and what was expected):
I wanted to play audio streams in sync using StreamPlayer nodes.
I tested 4 streams starting to play all at once, induced by _on_TouchScreenButton_pressed().
All four voices should play in the same time, creating chords.
Instead of chords, we hear out of sync arpeggios when streams play noticeably one after another instead starting all together with unnoticeable delays.

Setting different values to StreamPlayer "Buffering Ms" does not change anything.
Steps to reproduce:
My testing project explaining audio problems attached - it's problem nr 1.
Link to minimal example project (optional but very welcome):
Audio_problems.zip
I can get it synced from time to time (by repeatedly triggering play). There is a hard coded min mix buffer size of 1024 samples for opus and ogg streams. The audio server runs in a separate thread I think, and there is plenty of locking in the code. So it might be a threading issue.
@logzero Yes, even in my above test streams 2 and 3 were initiated in the exactly same time, so I expect that after all it is possible.
I am currently trying to create a multi stream system similar to the one in this issue (4 channels to simulate gameboy sound system), and I can confirm that the sync is apparently random. Sometimes it syncs fine and other times it is desynced by arbitrarily differring magnitudes.
My code to reproduce is very simple:
channels = [<4x StreamPlayer>]
for chan in channels:
chan.play()
@williamd1k0 Thx for the confirmation.
I tried using "4 channels" again in latest version (2.1.3) and it seems to work fine.
Our "audio specialist" @viniciuskps also tested using latest version and approved its performance/results.
But he can't test this on platforms other than Windows...
OK, thanks for the info. I am still using 2.1-stable, but I will try to test it on 2.1.3 then. Maybe someone fixed it already!
@freemanfromgodotengine Have you any news about this? The new versions does play in sync?
Disclaimer: I am asking and not doing because right now I do have not the knowledge to do the test roundtrip
@alanjds When I use Godot, I still use 2.1.2-stable, becasue of some other issues in newer versions.
I'm also playing with 3.0 beta, to see how it goes overall, but not really audio related stuff yet. I decided to wait for Godot 3.0 to get stable, before making any audio tests or writing anything.
OK, I will try to find some time to compile current stable 2.1 and test it again with the same method I did last time.
I test it again. This time Godot 2.1.4-stable downloaded from official website.
It's not perfect yet, but the latency between 4 streams in my test is better, down to ≈ 25 ms delay between each stream.

With my 4 stream example, the difference in time between first and the last stream ≈ 70 ms, so out of sync "arpeggio" effect can still be heard, but it's much faster now. This probably can pass unnoticed when used with non-musical, random in their nature sound fx or even not so rhythmic music, especially with sounds with longer attack and release time.
However it is still noticable in tasks needing tight timing, like playing synchronized rhythmic music streams.
I just realized the attached .zip w/ the project.
On this last test w/ 2.1.4-stable, had you tried w/ the SamplePlayer node pre-got instead?
onready var SyncExampleSamplePlayer = get_node("sync/SyncExampleSamplePlayer")
(...)
func _on_SmpPlStartButton_pressed():
get_node("sync/SmpPlStartButton").hide()
SyncExampleSamplePlayer.play("bass")
SyncExampleSamplePlayer.play("tenor")
SyncExampleSamplePlayer.play("alt")
SyncExampleSamplePlayer.play("soprano")
get_node("sync/SmpPlStopButton").show()
So the way to go is w/ Event (Tracker) music for now... Thanks for pointing
@alanjds I did not test SamplePlayer here. I was testing StreamPlayers and without onready, but after your comment I checked again with onready var in that context (StreamPlayer), but it did not make any difference.
I remember you asked me in that other latency issue if I could test onready var and SamplePlayer. I need to check that yet.
Ah, if you tested w/ onready var then will make no difference for the SamplePlayer too.
Ok. Thanks.
I was finally able to test audio in Godot 3.1.1-stable.
All tests were done on linux and projects were not executed from binary, but strait from running along Godot engine. Latency measured on projects running from binary should be even smaller.
StreamPlayer node is gone, so I tested AudioStreamPlayer - 4 instances playing in sync.
The audio engine works just excellent now!
The latency when playing 4 waves (I did not test ogg) is so small it can be ignored. Comparing to previous test illustrated above (latency of 0.094 ms), it now got down to less than 0.006 ms!
I've also tested latency between clicking the button and hearing the triggered sound playing.
In previous versions of Godot that "reaction time" was sometimes as bad as 0.285 ms as I mentioned long time ago https://github.com/godotengine/godot/issues/7603#issuecomment-274364970
Now, in my tests it was down to around 0.075 ms.
All I can say is just bravo @reduz and other developers who were working on this!!
Godot clearly can be recommended as an engine for creating sound and rhythm games.
Most helpful comment
I was finally able to test audio in Godot 3.1.1-stable.
All tests were done on linux and projects were not executed from binary, but strait from running along Godot engine. Latency measured on projects running from binary should be even smaller.
StreamPlayer node is gone, so I tested AudioStreamPlayer - 4 instances playing in sync.
The audio engine works just excellent now!
The latency when playing 4 waves (I did not test ogg) is so small it can be ignored. Comparing to previous test illustrated above (latency of 0.094 ms), it now got down to less than 0.006 ms!
I've also tested latency between clicking the button and hearing the triggered sound playing.
In previous versions of Godot that "reaction time" was sometimes as bad as 0.285 ms as I mentioned long time ago https://github.com/godotengine/godot/issues/7603#issuecomment-274364970
Now, in my tests it was down to around 0.075 ms.
All I can say is just bravo @reduz and other developers who were working on this!!
Godot clearly can be recommended as an engine for creating sound and rhythm games.