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 JVMwhether to use Alsa, PulseAudio or OSS ?

As I've seen on the forum, many problems disappear when using OpenAL-Wrapperlibraries instead of the javax.sound framework. I'm trying to avoid any extra libraries,so if there is an solution, please let me know...

Java has it's own mixer implementation that seams to have a massive fixed size delay buffer which screws you for any real time sound in Linux. The problem is not seen on windows because the default mixer is usually not Suns one. There are a few ways round this, you can use a properties file in the Java dir to set the default mixer to be something other than Suns, but this doesn't help with distribution. Alternatively use getClip(Mixer.Info mixerInfo) and pass a decent mixer. AudioSystem.getMixer(null).getMixerInfo() seems to return the system default mixer which should be the one you are after. If you know what sort of sound format you are using you can also do this:

Keep in mind that clips are not particularly nice as they use one SourceDataLine each and you have no control over it. Mixers have a limited number of lines that can be open at any time and each clip grabs one. What you really want to do is use a single SourceDataLine and write bytes to it. SourceDataLine also has a buffer size parameter in it's open() method which can help with latency problems.

Assuming that I've spent 24/7 for two months on this topic, sure. But it had other reasons which needed my fully attention. I've been aware of that while posting the first message, that's why I said that. I know what you want to say: "If you are too dumb or do not have enough time, simply don't try to get started in java game programming, you won't arrive anyhwere, TGT. And don't bother us here any longer."

Assuming that I've spent 24/7 for two months on this topic, sure. But it had other reasons which needed my fully attention. I've been aware of that while posting the first message, that's why I said that. I know what you want to say: "If you are too dumb or do not have enough time, simply don't try to get started in java game programming, you won't arrive anyhwere, TGT. And don't bother us here any longer."

Don't worry about that, I'm sure heckboy didn't mean it in that way. He just likes to comment on everything. You should ignore his remark. Judging by how many spelling mistakes he makes, I'm not even sure if he even reads his own posts.

I did not mean it like that! Just imagine that I hadn't removed my extremely sarcastic post .

Ok, lets put some cooldown and peace here. You simply caught me on the wrong foot as I was already angry having so little time for this hobby. Was like throwing oil on the fire. Sorry if I sounded like a hothead here...

Meantime, I managed to get the game online: http://www.mibran-games.de/. Still have to implement loading screen and the ufo. Code is ugly, nearly no OOP right now, simply 'hack & forget' spaghetti. And there is a tiny bug when aliens change direction sometimes. But hey, first running game, helpful comments welcome Has anybody bad experiences by violating copyrights of real classic arcade games (being some decades old)?

Thanks for all the advocacy, looks like I have found the right forum after all.

Ok, lets put some cooldown and peace here. You simply caught me on the wrong foot as I was already angry having so little time for this hobby. Was like throwing oil on the fire. Sorry if I sounded like a hothead here...

Meantime, I managed to get the game online: http://www.mibran-games.de/. Still have to implement loading screen and the ufo. Code is ugly, nearly no OOP right now, simply 'hack & forget' spaghetti. And there is a tiny bug when aliens change direction sometimes. But hey, first running game, helpful comments welcome Has anybody bad experiences by violating copyrights of real classic arcade games (being some decades old)?

Thanks very much, same issue with it. But even Flash plays sounds laggy. I really think now that it must be an OS problem...

cuMichael

really for the sound & game kind you are targetting just use

1 2 3

AudioCilipsound=getAudioClip("yoursound.au");sound.play(); //this is no requiered but for the first sound play you will do it avoid lag by preloadingsound.stop();

then do sound.play() when you want to play that sound, this is the most stable way and for the kind of sound you use it will work nice for everyone

EDIT: ouch... my ears !you must hande when Applet is destroyed to stop all sound... leaving when there is the Red alien make the sound continue to play even when game web page closed and that's really annoying

EDIT: ouch... my ears ! you must hande when Applet is destroyed to stop all sound... leaving when there is the Red alien make the sound continue to play even when game web page closed and that's really annoying

Ups, of course My wife discovered the problem a few minutes ago when I proudly presented the new page look to her. Ok, fixed that.

I noticed another interesting thing: The sound in Ubuntu plays *ways* better if I use Applet.newAudioClip() instead of the JApplet-Method getAudioClip(). The latency problems gets better, the sounds are all preloaded before first play, the sound stutters less.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org