Hi Theodore,
Thank you very much for your reply. I included Gervill into my Java project and replaced AudioInputStream with AudioFloatInputStream as you proposed:
AudioFloatInputStream stream = AudioFloatInputStream.getInputStream(file);
AudioFormat format = stream.getFormat();
System.out.println("Encoding of file " + file.getName() + ": " + format.getEncoding());
System.out.println("Sample Rate: " + format.getSampleRate());
System.out.println("Sample Size Bite: " + format.getSampleSizeInBits()*2);
System.out.println("Channels: " + format.getChannels());
System.out.println("Frame Size: " + format.getFrameSize()*2);
System.out.println("Frame Rate: " + format.getFrameRate());
The sysout's result in the following output:
Encoding of file MINUS.wav: PCM_FLOAT
Sample Rate: 44100.0
Sample Size Bite: 64
Channels: 2
Frame Size: 16
Frame Rate: 352800.0
Afterwards I need to get a SourceDataLine object because my current implementation needs it for playing audio files. When I try to execute the following code
SourceDataLine.Info info = new DataLine.Info(SourceDataLine.class, stream.getFormat(), ((int)stream.getFrameLength()*format.getFrameSize()));
line = (SourceDataLine) AudioSystem.getSourceDataLine(format);
line.open(stream.getFormat());
line.start();
line.addLineListener(observer);
I get the following exception when executing "AudioSystem.getSourceDataLine(format)":
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format PCM_FLOAT 44100.0 Hz, 32 bit, stereo, 8 bytes/frame, 352800.0 frames/second, is supported.
at javax.sound.sampled.AudioSystem.getLine(AudioSystem.java:459)
at javax.sound.sampled.AudioSystem.getSourceDataLine(AudioSystem.java:587)
Do you have any idea what could be wrong? Do I need to convert the file with the help of AudioFloatConverter?
Thanks in advance,
Michael