Need a work around - 1.5 issue

Hello,
this is my first post on this forum - only just found it - I shall be around more now!!
Anyhow to my issue.

You may or may not be aware of this bug:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5070730
which is meant to be fixed. However with my game it doesn’t appear to be fixed >:( .

I’m using the classic Applet.getAudioClip which has been working great is earlier JVM’s. My issue is that I need to play many short clips very very close together (for example balls breaking in a game of pool). Currently you are either hear silence or the occasionaly sound clip.

Reading the bug report (thats meant to be fixed but is’nt) - there is a work around using java sound (Mixers,Clip,Line,etc) - however I need to emulate the behaviour of the classic Applet.getAudioClip . - this is great as AudioClip.play() is asyncronous - every time I call it returns immeadiatly and every time I call the same instance again - it plays another sound. I find with java sound this doesn’t seem possible .

Any ideas on how I can fixed my issue?

thanks.

I use the Clip class. I decode .ogg’s into a byte[], and then use:


AudioFormat audioFormat = new AudioFormat(
      rate,
      16,
      channels,
      true,  // PCM_Signed
      false  // littleEndian
);

DataLine.Info info = new DataLine.Info(
      Clip.class,
      audioFormat
);
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(audioFormat, audio, 0, size);
clip.stop();

To load it into memory. When you want to play it, use:
clip.start();
To reset it, use clip.stop(); if you haven’t already or it hasn’t played through on its own, then clip.setFramePosition(0);

I hope that’s enough to get you started :slight_smile: Let me know if you have more questions.

HI,
thanks for that!. I’ll try this later tonight.
Quick question though - is the synchronous or asynchronous? when you call clip.start() does it reutn immeadiatly or after its finshed?

thanks