What are class com.sun.media.sound.PortMixer-s?
I am looking for a way to select one specific microphone to capture sound from. I found that the开发者_如何学编程re are mixers, having isLineSupported(Port.Info.MICROPHONE)==true
.
But these mixers are of undocumented class com.sun.media.sound.PortMixer
and I can do nothing with them.
For example, I can't read data from TargetLines
of these mixers, because they are not of TargetDataLine
type.
What for these mixers are? Just to create some mess?
After looking at this more closely, I think this might help.
running this on the return values from AudioSystem.getMixerInfo()
mixerDetails.getDescription()
mixerDetails.getName()
gives the following:
Direct Audio Device: DirectSound Playback
Primary Sound Driver
Direct Audio Device: DirectSound Playback
Realtek HD Audio output
Direct Audio Device: DirectSound Playback
Microsoft LifeChat LX-3000
Direct Audio Device: DirectSound Capture
Primary Sound Capture Driver
Direct Audio Device: DirectSound Capture
Microsoft LifeChat LX-3000
Direct Audio Device: DirectSound Capture
Realtek HD Audio Input
Software mixer and synthesizer
Java Sound Audio Engine
Port Mixer
Port Realtek HD Audio output
Port Mixer
Port Realtek HD Audio Input
Port Mixer
Port Microsoft LifeChat LX-3000
I had the same issue with the 'port mixer' 'Port Microsoft LifeChat LX-3000 ', which was an instance of 'com.sun.media.sound.PortMixer'. Calling
AudioSystem.getTargetDataLine(format, mixerInfo)
on this mixer gives the following:
Exception in thread "main" java.lang.IllegalArgumentException: Line unsupported: interface TargetDataLine
Downloading the source and running in debug in eclipse shows that for my instance of this port, it only has javax.sound.sampled.Port.class available, so calls to AudioSystem.getTargetDataLine which under the covers do this:
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
Mixer mixer = AudioSystem.getMixer(mixerinfo);
return (TargetDataLine) mixer.getLine(info);
fail - Only lines of javax.sound.sampled.Port.class are available in the portMixer. In my port, that line was a speaker, but even if it wasn't, the targetlines stored internally all seem to be ports, which isn't particularly helpful. Even the comments in the class say 'A Mixer which only provides Ports.'
So whatever it's used for, it doesn't appear to be getting source/target lines. Do be honest, I can't see what it's used for. I would try looking at other mixers on your system. If yours is like mine, there'll be a directsound capture that you can use instead.
I hope this source code can be of any use to you.
精彩评论