Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Serious stutter in Java Sound  (Read 2953 times)
0 Members and 1 Guest are viewing this topic.
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Posted 2004-11-16 08:21:56 »

I was reviving and old game I did in 2002, which worked fine at the time. Since then Sun has somehow managed to break Java Sound.
When my character moves around, and a sound is played for each move made, the animation starts to stutter. I have created a simple example that exhibit the same behaviour:
http://matzon.dk/brian/Random%20Junk/SoundTest.zip

Extract and run like this:
Quote
java -cp bin;res SoundTest

It works fine in 1.3 (except the Thread exit bug which was first fixed in 1.5).
1.4 Stutters, and sounds different
1.5 is just as crappy - and required me to FORCE usage of the software implementation since their default implementation sucks, and only plays some of the sounds it sees fit.
I have tried to switch to .au files (using sun.audio.AudioPlayer) - and performance is WAY better - no stutter at all. However this implementation produces some serious artifacts in the stream (clicks and pops).

Could someone please explain to me how people have used Java Sound since 1.3 ??
Or am i misusing the clip interface?

Offline Chman

Junior Member




Nothing more that... Java games are cool !


« Reply #1 - Posted 2004-11-16 10:33:41 »

Quote
Could someone please explain to me how people have used Java Sound since 1.3 ??

JavaSound has alwais been crappy... I've used it when I was playing with Java 1.1... But it's pretty slow, buggy on last JDK versions. Now, there are many ways to handle sounds in java, you can use fmod, openal, audiere (very fast native lib) and some others. If you want pure java, there are javazoom player which can play mp3, or jOrbis, the well-known, which can play ogg...
If java is missing something, it's the sound part... Hope the future version of Java will handle sounds better !

Chman
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #2 - Posted 2004-11-16 10:45:59 »

I know about the native libs Wink - but I want to do this without signing my applet!
javazoom uses javasound - so will suck equally well - I have no need to play mp3 or ogg vorbis...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Bombadil

Senior Member





« Reply #3 - Posted 2004-11-16 11:33:50 »

Unfortunately I can't help at the moment, but I'd like to say I've got the same problem with my game project and Java sound: it should be a smoothly scrolling game and it is - until I play several wave sounds then it starts to stutter which kills the whole idea of the scrolling game. :-(

It's Java 1.5 and I use Yuri's workaround to fix the broken standard 1.5 sound system (ie the workaround is to use software sound)...
Offline TheAnalogKid

JGO Coder


Projects: 2



« Reply #4 - Posted 2004-11-16 18:33:29 »

Quote

JavaSound has alwais been crappy... I've used it when I was playing with Java 1.1... But it's pretty slow, buggy on last JDK versions. Now, there are many ways to handle sounds in java, you can use fmod, openal, audiere (very fast native lib) and some others. If you want pure java, there are javazoom player which can play mp3, or jOrbis, the well-known, which can play ogg...
If java is missing something, it's the sound part... Hope the future version of Java will handle sounds better !

Chman

Chman, do you know where I can find a good tutorial on fmod for java? (http://topresult.tomato.co.uk/~jerome/index2.html)

Thanks!

Offline Chman

Junior Member




Nothing more that... Java games are cool !


« Reply #5 - Posted 2004-11-25 12:55:17 »

Sorry for the late reply...

Well the only fmod binding I know is the one included in lwjgl, but I works without all others lwjgl libs. You could take a look at the demos included in for help on initializing fmod in java. Then, using fmod in java is the same as using it with C... Just read a C fmod tutorial, or the official fmod manual and you'll have all what you need.

I've made very simple application that use fmod (lwjgl binding). You can find it here. Smiley

Chman
Offline TheAnalogKid

JGO Coder


Projects: 2



« Reply #6 - Posted 2004-11-26 14:02:36 »

OK thanks for help! Wink I will check that.

Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Reply #7 - Posted 2004-12-15 03:48:48 »

Rimscape just uses Clips.  Check it out... is that considered good?

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #8 - Posted 2004-12-16 10:42:34 »

Clips work fine as long as you keep your sound effects to a minimum. The problem comes in when you need to stop and restart sounds. Stopping and/or restarting Clips force them to drain. The only problem is that draining the sound results in blocking (!), which is a very bad thing in games.

The alternative to using Clips is to use a SourceDataLine. With a SourceDataLine, you can feed it raw audio data as needed. You can even create your own mixer! There's only one problem with it: If you overflow the internal buffer, the line will block! (Just can't win, can we?)

GAGESound solves these problems by feeding a SourceDataLine every few milliseconds. It basically guesses as to the amount of audio data that will need to be written in order to cover the next frame. Not only does this avoid blocking, but it decreases latency to nearly unnoticable levels. (i.e. The player notices no lag between hitting the fire key, and hearing the "BOOM" of a cannon.)

Java Game Console Project
Last Journal Entry: 12/17/04
Offline TheAnalogKid

JGO Coder


Projects: 2



« Reply #9 - Posted 2004-12-16 14:03:47 »

I gave up my Java Sound layer and I now use the fmod3 package from LWJGL. It's so much more easy with LWJGL, very fast and stable too.

I spent too much time trying to get things working nicely by using an OGG SPI for Java Sound and as JBane mentionned the buffer overflow/underrun problems are really tough to solve.

So my conclusion: Java Sound is still crappy for games. With LWJGL you get all of that freely with any sound/music format and it works so well!

Just one issue: if you plan to use it for commercial purposes than you have to know that the fmod licence is very expensive for a small company.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (37 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (30 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (52 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!