When I query all the mixers on my Macintosh (MacPro 13inch; 10.13.1), all that shows up is 6 iterations of "Default Audio Device, version Unknown Version".
I am simply wondering why this is, and how I might be able to fix it. If it matters, I am compiling the code through NetBeans 8.2
Here's the method:
public static void displayMixers() {
Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); //save info of all mixers on system to an array
System.out.println("Available mixers: ");
for (int i = 0; i < mixerInfo.length; i++) { //for loop that iterates over the array we just established
System.out.println(mixerInfo[0].toString()); //print description of mixer each time
}
}
Your index into mixerInfo
is [0]
so you are just listing the first entry 6 times, Use [i]
:
for (int i = 0; i < mixerInfo.length; i++) {
System.out.println(mixerInfo[i]);
}
Note that you don't need the toString()
call as println
will do that for you.
Assuming you are using Java 5 or later it would be better to use the 'enhanced for loop' which removes the chance of using the wrong index:
for (Mixer.Info info : mixerInfo) {
System.out.println(info);
}
On Java 8 or later you could even use a stream:
Arrays.stream(mixerInfo).forEachOrdered(System.out::println);