Hi,
This is my first post, and I’m a total beginner when it comes to Java. But I’m working on a basic-style programming language for Windows (http://www.naalaa.com). I recently made it possible for the compiler to generate java code (applets) instead of standalone executable files. There are some problems regarding sound though.
As soon as play is called for an Audioclip, the applets slow down a lot. I know that the audio isn’t loaded until it’s played for the first time, but that’s not the problem in this case. As long as any audioclip is playing the applets run slowly. If no clip has been played for a while, the speed returns to normal. I’ve tested the applets on several computers, and the only one that managed not to slow down had four really fast processors. Playing an audioclip shouldn’t really require that, right?
This is an example applet with sound: http://www.naalaa.com/applets/Blastemroids.html
And this is the same applet but without sound: http://www.naalaa.com/applets/BlastemroidsNS.html
Are audioclips slow, or could it be something else? For example, the code uses System.currentTimeMillis() in combination with Thread.sleep(…) to maintain a constant fps. Are those reliable, or can they be affected by the sound playback (which I assume is performed in another thread somewhere)?
Would it help to use the java sound api instead?
/Marcus