To answer your first question, you can check if the Line.Info object matches the Port.Info.LINE_IN entry as follows:
public static boolean isLineIn(Line.Info lineInfo) { Line.Info[] detected = AudioSystem.getSourceLineInfo(Port.Info.LINE_IN); for (Line.Info lineIn : detected) { if (lineIn.matches(lineInfo)) { return true; } } return false; }
However, this does not work with operating systems or sound card driver APIs that do not provide the type of each mixer channel available. Therefore, when I test it on Windows, it works, but not on Linux or Mac. For more information and recommendations, see this FAQ .
As for the second question, you can try changing the recording input settings using the Control class. In particular, see FloatControl.Type for some general settings. Keep in mind that the availability of these controls depends on the operating system and sound card drivers, as well as for input detection.
source share