6

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?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Dims
  • 47,675
  • 117
  • 331
  • 600
  • Check out the source I posted on [JavaSound mixer with both Port(s) and DataLine(s)?](http://stackoverflow.com/questions/5304001/javasound-mixer-with-both-ports-and-datalines/5337619#5337619) for similar source intended to explore Java Sound. – Andrew Thompson Jun 07 '11 at 07:21
  • Are you analyzing names? Will it work with multilingual? I have garbage in most names. – Dims Jun 07 '11 at 08:26
  • Never tried it under locales that were not English. Your report is worrying. – Andrew Thompson Jun 07 '11 at 08:33
  • Even if it was no garbage, how one would be able to know how the word "microphone" is translated into hundreds of languages? The creators of Java Sound API were to provide logical way to find appropriate line. – Dims Jun 07 '11 at 09:11
  • 1
    Have you succeed? Can you post the solution? Thanks! – André Nov 06 '12 at 16:19

2 Answers2

2

Left-field suggestion.

Provide a visual rendering of each sound line, in a component along the lines of the AudioPlotPanel or a simpler RMS volume. It should not take the user too long to figure which sound line they are yodeling through. ;)

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
0

I'm trying to do the same thing. I haven't quite found a good solution yet but I can tell you that's not working out because you're trying to get a DataLine from a Port mixer. If and when I figure it out I'll be sure to let you know.

Kevin Bigler
  • 256
  • 1
  • 2
  • 9