Sign in to follow this  

[java] sound api lag in linux but not windows

This topic is 4712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, i am having another problem with lagging in linux Before, it was animation lagging because the toolkit's sync wasn't called. Now, its sound lagging because something isn't called. Any ideas what that something is? Heres the outline: Event happens. (insert lag here) Sound plays. but in windows, there is no lag. I think i need to flush a buffer somehow. any help is appreciated. -pink PS: I am using the clip class

Share this post


Link to post
Share on other sites
Are you using Java 1.4? Some claim that JavaSound is broke, and
"late" sound on Linux is a known issue. Some say it has been
resolved in 1.5, some disagree. I can't really give an answer,
since I haven't meddled too much with it myself.

You are using Clip... Does the sound lag at once, or does it stutter
momentarily after stopping and/or restarting? Clips that are stopped and/or restarted actually cause blocks, which naturally give off bad results,
(especially in a game).

There are several other solutions for using sounds out there (most of it native though). If you need to ust javasound, you can always check out this link:

http://www.jsresources.org

It has some decent info on using java sound.

Share this post


Link to post
Share on other sites
Quote:
Original post by Addictman
Are you using Java 1.4? Some claim that JavaSound is broke, and
"late" sound on Linux is a known issue. Some say it has been
resolved in 1.5, some disagree. I can't really give an answer,
since I haven't meddled too much with it myself.

You are using Clip... Does the sound lag at once, or does it stutter
momentarily after stopping and/or restarting? Clips that are stopped and/or restarted actually cause blocks, which naturally give off bad results,
(especially in a game).

There are several other solutions for using sounds out there (most of it native though). If you need to ust javasound, you can always check out this link:

http://www.jsresources.org

It has some decent info on using java sound.

actually, I've found it the other way around, going from 1.4 to 1.5 made my sound laggy and weird.

Share this post


Link to post
Share on other sites
Ok, heres what i have found out so far:
I upgraded to jdk1.5 and the lag went away, but then the clips only would play once.
So, I added, before all the play statements, a clip.setPosition(0); statement, but then there was a highpitched click at the end of each clip.
So, I added a clip.flush(); before the setPosition, and it works flawlessly.
Hopefully I won't run into any more problems.

-pink

Share this post


Link to post
Share on other sites

This topic is 4712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this