Java Sound format not supported

Using the following code: http://pastebin.com/5iVnttiP

I get this error:

javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 16000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported. at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(Unknown Source) at com.sun.media.sound.AbstractDataLine.open(Unknown Source) at com.sun.media.sound.AbstractDataLine.open(Unknown Source) at com.AIComputer.model.Recorder.<init>(Recorder.java:124) at com.AIComputer.AIComputer.main(AIComputer.java:7) 

Now I did some research and found out that not all sound cards support each format, however, when I started this demo: http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/ I managed to create a record, using the same parameters (linear, 16000, 16, signed, a bit endian, stereo).

I have no idea what I'm doing wrong here (also, since I'm still new to Java coding).

Any help would be greatly appreciated!

+4
source share
1 answer

Can you tell from which line to your code this exception is selected?

docs in LineUnavailableException says

This situation occurs most often when the requested string is already in use by another application.

You open two lines in your code. When you try to open the second, the existence of the first blocks it.

+6
source

All Articles