Help with sound

Hi,

Im trying to do a game, and i worked a lot to put the sound in that game.

I read lots of forums, some tips, but still could not do it.

I want to put a backgound music and especial efects when the ship accelerates.

It is a simple game, and i think that is a easy problem.

Please, help me.

tanks

Carti

gotcha
i found the parcial solution in:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Sound;action=display;num=1062877058

but the background music still dont work.
now when the games beginning, only the music play and the game not works.

Somebody knows how to play music with a game together?

tanks

Carti

You might want to look at GAGESound. It allows you to play multiple sounds + background MIDI music. All the source code is included for you to peruse. :slight_smile:

jbanes tankyou so muth for the help.

but i´m looking for a something more simple.
Im looking for a single class that i can instace and play, without a lots of things.

carti

sigh

Sound:


WaveEngine wave = new WaveEngine()
int sound;

sound = wave.load(getClass().getResource("/mysound.wav"));
wave.play(sound);

while(true) { wave.render();}

Music:


MusicEngine music = new MusicEngine()
int sound;

sound = muic.load(getClass().getResource("/mysound.mid"));
music.play(sound);

while(music.isPlaying()) { Thread.yield();}

I seriously doubt you’ll find anything simpler. :-/

tanks a lot jbanes

:slight_smile:

Carti

[quote]sigh

Sound:


WaveEngine wave = new WaveEngine()
int sound;

sound = wave.load(getClass().getResource("/mysound.wav"));
wave.play(sound);

while(true) { wave.render();}

Music:


MusicEngine music = new MusicEngine()
int sound;

sound = muic.load(getClass().getResource("/mysound.mid"));
music.play(sound);

while(music.isPlaying()) { Thread.yield();}

I seriously doubt you’ll find anything simpler. :-/
[/quote]
I’m a JAR newbie, how do I add your jar to my project so that I can use your classes and put sound in my game?

If it makes a difference, I’m using Eclipse as my editor.

Thanks for your help =)

[quote]I’m a JAR newbie, how do I add your jar to my project so that I can use your classes and put sound in my game?

If it makes a difference, I’m using Eclipse as my editor.

Thanks for your help =)
[/quote]
Ok. deep breath here:

  1. Right click on the project folder
  2. Select “Properties”
  3. Click on “Java Build Path”
  4. Click on “Libraries” tab
  5. Click “Add External JARs…”
  6. Select “sound.jar” and click OK a few times

You’re done. :slight_smile:

Awesome!

I haven’t used the JAR et, I just put your code into my project, but I’m gonna change it to the jar later. Your sounds thing works awesome!

You can check it out in the game at http://ucfpawn.homelinux.com/java/twinserpents/client/GameApplet.html

Thanks, bro