finnkuusisto / TinySound

Simple library for playing sounds and music in Java
http://finnkuusisto.github.com/TinySound
BSD 2-Clause "Simplified" License
99 stars 26 forks source link

TinySound has high latency with default Mixer on some Linux machines #10

Closed finnkuusisto closed 12 years ago

finnkuusisto commented 12 years ago

I noticed some major latency issues using TinySound on my old laptop (currently running Fedora 14). After some testing I determined that the latency wasn't coming from TinySound, but the default Mixer selected when opening the SourceDataLine. The latency sounds on the order of 100s of ms after completion of writing to the line. Testing all of the Mixers available, I found that the Pulse Audio mixer did not produce the latency issue. Perhaps TinySound should try to select a better Mixer than the default.

finnkuusisto commented 12 years ago

http://www.java-gaming.org/topics/selecting-non-default-mixer/26342/view.html

The upshot is that the mixer selected by AudioSystem.getLine() may not be low latency. Typically, the earlier mixers in the array returned by getMixerInfo() will be better.

finnkuusisto commented 12 years ago

TinySound now picks the first Mixer that can open a line. There is also now an alternative init() function for those who want to be able to pick which Mixer the line is opened on.