1

I'm interested in using the Java sound API for finding out the names of all available microphone / audio input devices, and audio output devices / speakers.

I tried the following to view what information can be provided from DataLine.Info:

final AudioFormat format = new AudioFormat(22000, 16, 2, true, true);
                final TargetDataLine line;
                final DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
                System.out.println(info.toString());

This gave the following output:

interface TargetDataLine supporting format PCM_SIGNED 22000.0 Hz, 16 bit, stereo, 4 bytes/frame, big-endian

Which doesn't give a name of the device, though it does give some useful information.

In short: how do I use the Java Sound API (or an external library) find audio input / output information?

For anyone interested, I need the names of the devices as I'm trying to automate the set up of some Virtual Audio Cables (VACs), following the guide here, which requires certain parameters, and I'd rather not have the user type them out!

Dr Ken Reid
  • 577
  • 4
  • 22
  • 1
    The `Mixer.Info` array returned by `AudioSystem.getMixerInfo()` has some limited information about mixers. There isn't much else that reports names of anything. – greg-449 Mar 12 '18 at 17:15
  • maybe helpful or useful: [Get audio device name in Ubuntu using Java](https://stackoverflow.com/questions/34202918/get-audio-device-name-in-ubuntu-using-java) – chickity china chinese chicken Mar 12 '18 at 17:20
  • See the `MediaTypes` source code on [this answer](https://stackoverflow.com/a/7616206/418556) for obtaining all the useful information that the Java Sound API will provide. – Andrew Thompson Mar 13 '18 at 06:56
  • 1
    That's exactly what I'm looking for. Thanks Andrew. I'll water down that answer and post a simpler version of the code for anyone else who wants to reuse it. – Dr Ken Reid Mar 13 '18 at 10:53

0 Answers0