Java Sound API: Capturing sound output from a Target Port
Posted
by Kyle Kampy
on Stack Overflow
See other posts from Stack Overflow
or by Kyle Kampy
Published on 2010-05-19T22:28:37Z
Indexed on
2010/05/19
22:30 UTC
Read the original article
Hit count: 405
I'm writing a simple piece of software that streams audio over LAN. I have all of the network parts implemented, but what I'm stumbling on is using the Java Sound API. I have successfully captured audio from the microphone, and line-in, but I can't seem to capture from any target ports, like the speakers. My question is, is it possible to capture from the Master target port? Here is the piece of code that works on initializing the line.
private boolean startCapture(){
try{
DataLine.Info info = new DataLine.Info( TargetDataLine.class, format);
line = (TargetDataLine)AudioSystem.getLine(info);
audioBuffer = new byte[bufferSize];
line.open(format);
line.start();
return true;
}catch(Exception e){
System.out.println("Exception thrown when capturing audio:\n" + e);
return false;
}
}
Running the code like this will just use the microphone as my line. Here is info about my sound system. Most important is probably the fact that I'm running Linux.
Thanks in advance for any and all help you can give me.
© Stack Overflow or respective owner