Sign in to follow this  
mako_5

[java] Sound with Java

Recommended Posts

mako_5    103
Hello everyone! I've spent the two months working on an 2D asteroids clone. I'm trying to make sure I do everything right (there's dozen(s) of projects I've started and not finished properly, so this has all the high-scores, ok graphics, instructions giving, neat title screen, simple physics, made simple scripting, etc.) and the last thing I'm left with is doing background music and sound effects. I'm using LWJGL, and know it has OpenAL support (which I know nothing about), but was wondering what anyone else has had that works. I've used Java sound API a little before (with AudioClips, ehh, not much control) but it doesn't provide notifications for when a sound ends that I could find. Does anyone have any suggestions for how to add sound to my nearly complete game? Should I just make the step and learn OpenAL? Note: I have a way of putting my game available for download (is web hosting the name for it?) and will try to post it for IOTD (~~provided I figure out how to do it~~, I have some rather ok looking particle effects, etc.) as soon as I get sound working. Also, I'm thinking about posting source w/ Javadoc so others can learn the lessons I've spent the last 2 months figuring out. [Edited by - mako_5 on August 16, 2006 7:37:30 PM]

Share this post


Link to post
Share on other sites
scgrn    168
I'd recommend going ahead and learning OpenAL. It's really not too difficult to learn, LWJGL already supports it, and you'll be able to use it with other languages if you want.

I found these tutorials over at devmaster.net were a good place to start when I was learning OpenAL. I've only used it in C++, not the Java bindings, but everything should be pretty much the same.

If you decide to stick with javasound, there are a few good code samples here (how to detect when a clip has finished playing, etc).

Good luck with everything.

Share this post


Link to post
Share on other sites
mako_5    103
Those tutorials look like exactly what I was looking for. Thanks for the help. I think I'm going to hide the audio type behind an interface with some simple commands (isDone() or length() or similar things) and then implement classes using both ways you suggested to see which I like better.

Rate++;

Share this post


Link to post
Share on other sites

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