I have had this working on the mac OS X 10.4.1 with Java 1.5.0
try {
// Initialise Sound System
AudioFormat audioFormat = new AudioFormat(RATE, 16, 1, true, true);
DataLine.Info info = new DataLine.Info(Clip.class, audioFormat);
music = (Clip)AudioSystem.getLine(info);
music.open(audioFormat, musicLoop, 0, musicLoop.length);
music.loop(Clip.LOOP_CONTINUOUSLY);
fire = (Clip)AudioSystem.getLine(info);
fire.open(audioFormat, fireSound, 0, fireSound.length);
} catch (Exception e) {
e.printStackTrace(); // Display error, but keep going
}
RATE = 16000f;
The differences are that I’m using the alternative constructor for AudioFormat, where I leave it to java to decide on the frame size and that I’m creating a Clip rather than a TargetDataLine. Both Clip and TargetDataLine are subclasses of DataLine.
I’d try the alternative constructor for AudioFormat first. If no joy, then there must be something unique to TargetDataLine, not inherited from DataLine which is causing the problem, in which case looking at the source might help.
/Edit Looking at this some more. TargetDataLine is a source, while Clip is a sink. This suggests the the microphone doesn’t support the same data formats as the sound synthesiser.
/Edit I think it’s the sample rate. Browsing the web suggests 11025, 22050 and 44100 (CD sampling rate) as possibles.
Alan