Posted By:
Rocio_Katsanis
Posted On:
Saturday, June 30, 2001 01:02 PM
I'm trying to open a line from a Mixer. The line in question DOES exist, but any of the 2 statements: AudioSystem.getLine (myline) or Mixer.getLine(myline) throws me an exception: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException at com.sun.media.sound.SimpleInputDevice.getLine(SimpleInputDevice.java:32 2) at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:297) at get_mixers.main(get_mixers.java:31) Note that from the first loop in the code, I know which mixer I want (the second one
More>>
I'm trying to open a line from a Mixer. The line in question DOES exist, but any of the 2 statements:
AudioSystem.getLine
(myline)
or
Mixer.getLine(myline)
throws me an exception:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at com.sun.media.sound.SimpleInputDevice.getLine(SimpleInputDevice.java:32
2)
at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:297)
at get_mixers.main(get_mixers.java:31)
Note that from the first loop in the code, I know which mixer I want (the second one that supports TargetDataLine)
Here is my code:
import java.io.*;
import javax.sound.sampled.*;
public class get_mixers {
public static void main(String[] args) {
Mixer.Info[] mixersList = AudioSystem.getMixerInfo();
System.out.println("List of Mixers installed on this system:");
for (int i=0; i
System.out.println("
"+i+") "+mixersList[i].toString());
System.out.println(" NAME: "+mixersList[i].getName());
System.out.println(" VENDOR: "+mixersList[i].getVendor());
System.out.println("DESCRIPTION: "+mixersList[i].getDescription());
System.out.println(" VENDOR: "+mixersList[i].getVersion());
Line.Info[] lines_mixer =
AudioSystem.getMixer(mixersList[i]).getTargetLineInfo();
System.out.println(" Lines supported by this Mixer:");
for (int j=0; j
System.out.println(" "+lines_mixer[j].toString());
}
TargetDataLine targetline = null;
Mixer mixer = AudioSystem.getMixer(mixersList[1]);
Line.Info[] lines_mixer = mixer.getTargetLineInfo();
System.out.println("FOOO: "+lines_mixer[0].toString());
if (AudioSystem.isLineSupported(lines_mixer[0])) {
try {
targetline =
(TargetDataLine) AudioSystem.getLine(lines_mixer[0]);
if (targetline.isActive())
targetline.open();
System.out.println("Opened Line for Mixer #1");
} catch (LineUnavailableException ex) {
System.out.println("Unable to open input line.");
System.exit(1);
}
}
}
}
<<Less