Java Sound API: Capturing sound output from a Target Port
- by Kyle Kampy
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.