Hi there,
I’m new to Java game development and having a question about sound problems.
Using Ubuntu Linux 8.10, I encounter enormous playback latency when playing
sounds like the code sample below. For learning purposes, I’m programming
a Space Invaders clone, and taking every sound approx. 0,5 seconds to
happen isn’t really acceptable here.
This is only on Linux/Firefox (where it also affects Flash games), on Windows
systems there is nearly no problem. Starting the clip from the GUI thread or
from an extra created thread does not change anything.
My question: Is there any way to give some runtime parameters to the JVM
whether to use Alsa, PulseAudio or OSS ?
As I’ve seen on the forum, many problems disappear when using OpenAL-Wrapper
libraries instead of the javax.sound framework. I’m trying to avoid any extra libraries,
so if there is an solution, please let me know…
Thanks in advance,
Michael
private Clip loadSound(String name)
{
Clip clip=null;
try
{
URL url=getClass().getResource(resDir + name);
AudioInputStream sample=AudioSystem.getAudioInputStream(url);
clip=AudioSystem.getClip();
clip.open(sample);
}
catch (Exception e)
{
System.err.println(e.getMessage() + " : " + name);
}
return clip;
}
private void playSound(Clip sound)
{
sound.setFramePosition(0);
sound.loop(0);
}



