I am unable to play a multi channel wave file in java using javax.sound.sampled package. I am using an external USB 7.1 surround sound card from logilink. The wave file is generated by myself. If I generate a stereo track, I am able to play the file. If I use the 6 channel track, I get the following error message:
javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 48000.0 Hz, 16 bit, 6 channels, 12 bytes/frame, little-endian not supported.
I checked if the line is supported and it is by using this code
AudioFormat format = new AudioFormat(48000, 16, 6, true, false);
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
if (info.isFormatSupported(format)) {
// is supported
}
I play the wave file as follows:
AudioListener listener = new AudioListener();
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(clipFile);
Clip clip = null;
clip = AudioSystem.getClip();
clip.addLineListener(listener);
clip.open(audioInputStream);
clip.start();
Any idea what is wrong?