JavaSound : Port.Info

M

Mosiuoa Tsietsi

I'm trying to capture sound in Java by using the Port.Info class. My
sound card does support recording from the line in because I've tested
it using the Sound Recorder program in Windows. But when I try to use
the following code :

if (AudioSystem.isLineSupported(Port.Info.LINE_IN)) {
try {
Port line = (Port)
AudioSystem.getLine(Port.Info.LINE_IN);
}catch(LineUnavailableException e){
}
}

it never executes the content of the if statement. If I use the
condition:

if (!AudioSystem.isLineSupported(Port.Info.LINE_IN)) {....}
instead, I get the following error:

java.lang.IllegalArgumentException: No line matching LINE_IN source
port is supported at
javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:309)
Can anyway help? Thanks in advance.
 
K

Knute Johnson

Mosiuoa said:
I'm trying to capture sound in Java by using the Port.Info class. My
sound card does support recording from the line in because I've tested
it using the Sound Recorder program in Windows. But when I try to use
the following code :

if (AudioSystem.isLineSupported(Port.Info.LINE_IN)) {
try {
Port line = (Port)
AudioSystem.getLine(Port.Info.LINE_IN);
}catch(LineUnavailableException e){
}
}

it never executes the content of the if statement. If I use the
condition:

if (!AudioSystem.isLineSupported(Port.Info.LINE_IN)) {....}
instead, I get the following error:

java.lang.IllegalArgumentException: No line matching LINE_IN source
port is supported at
javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:309)
Can anyway help? Thanks in advance.

What you are trying won't work. You can't get a line from a PORT. A
Java PORT is really a place to get mixer controls. I know it doesn't
make a lot of sense but that's the way it is. You probably (depending
on your OS and sound card) can get an enable/disable control from the
LINE_IN.

If you are going to be doing any work with JavaSound you need to be on
this mailing list: (e-mail address removed). Search for it at
java.sun.com and you can subscribe.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top