• Post Reply Bookmark Topic Watch Topic
  • New Topic

Baffled with IllegalArgumentException  RSS feed

 
Sundar Ram
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Iam using java sound API to play the audio. Iam using the Clip class to
play the audio. Frequently i get the following exception...

java.lang.IllegalArgumentException: No line matching interface Clip
supporting format ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, is
supported.

The exception is thrown in the code line "Targetclip = (Clip)
AudioSystem.getLine(info);"

The code snippet which throws the exception is as follows...

//Converting Audio Format
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
System.out.println("*** Converting...");
format = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
format.getSampleSizeInBits()*2,
format.getChannels(),
format.getFrameSize()*2,
format.getFrameRate(),
true); // big endian
stream2 = AudioSystem.getAudioInputStream(format, stream2);
}
printDebug("((int)stream2.getFrameLength()*format.getFrameSize()):
" + ((int)stream2.getFrameLength()*format.getFrameSize()));
DataLine.Info info = new DataLine.Info(Clip.class,
stream2.getFormat());
// DataLine.Info info2 = new DataLine.Info(Clip.class,
stream2.getFormat(),
((int)stream2.getFrameLength()*format.getFrameSize()));
Targetclip = (Clip) AudioSystem.getLine(info);

What could be wrong?? Why this exception is thrown? How do we solve
this??

Any links, sample code OR help in any form is highly appreciate.

Thanks in advance

-Sundar
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.lang.IllegalArgumentException: No line matching interface Clip
supporting format ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, is
supported.


That looks pretty straightforward to me - the sound library you are using cant match that string to any method or class that it has available. Therefore it throws an IllegalArgumentException to let you know why it can't proceed. Perhaps it is something simple like the formatting of the info string - do you have any input that works with that string?

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!