Horrible sound quality

Hello, I’ve written a sound player class using Clip and SourceDataLine from the javax.sound.sampled package.

My goal is to produce a sound when a button is pressed.
However, if the button is clicked and held, the action and sound will rapid fire.

If the button is clicked once everything is fine. When clicked and held, for rapid fire, the audio sounds like hell with popping and clicking noises added in.

I thought it might be caused by AudioInputStream being opened and closed in SoundDataLine. So I wrote a Clip interface to cache the whole thing in RAM. Still no love.

I’ve been playing with the entire API since Saturday and I’m at my wits end. Any suggestions. Am I using the wrong API entirely? My box is a Pentium 4, Windows XP.

Thanks in advance, Ray

Clips are horrible for performance, especially repeating sound. Use only SourceDataLines. You can check out the GAGESound source for an example.