The tutorial http://download.oracle.com/javase/tutorial/sound/capturing.html does not cover how to select microphone.
I am enumerating mixers with the following code
System.out.println("Searching for microphones");
for(Mixer.Info mixerinfo : AudioSystem.getMixerInfo()) {
mixer = AudioSystem.getMixer(mixerinfo);
//System.out.println(mixerinfo.toString());
if( mixer.isLineSupported(Port.Info.MICROPHONE) ) {
mixers.add(mixer);
System.out.println(Integer.toString(mixers.size()) + ": " + mixerinfo.toString());
}
}
i.e. by presense of microphone input. But next, having a mixer, I can't get line to read.
If I use mixer.getTargetLineInfo()
, I receive an array of one Info
, which when passing to mixer.getLine
returns an object of type com.sun.media.sound.PortMixer$PortMixerPort
, which is not ducumented.
If I use mixer.getTargetLines()
I get an empty array.
If I create my own DataLine.Info
and pass it to the mixer's getLine
, I get unsupported exception.
So, what to do?