participate


Java Sound - Problems with playing WAV Audio Files - UnsupportedAudioException
This question is not answered.

<<   Back to Forum  |   Give us Feedback
This topic has 2 replies on 1 page.
ElPablo
Posts:4
Registered: 9/25/07
Problems with playing WAV Audio Files - UnsupportedAudioException   
Apr 8, 2008 2:45 AM
 
 
Hi,

I'm trying to play audio files (WAV format, data rate 2822 Kbit/s, Stereo and 32 Bit encoding) with Java 1.5. Unfortunately I always get the following exception when I try to do the following:

AudioInputStream stream = AudioSystem.getAudioInputStream(file);

javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1170)

Any help would be very appreciated.

Thanks,

Michael
 
Lyko_Johny
Posts:2
Registered: 4/5/08
Re: Problems with playing WAV Audio Files - UnsupportedAudioException   
Apr 8, 2008 11:29 AM (reply 1 of 2)  (In reply to original post )
 
 
Dear Michael,

I don't think that Java Sound supports 32 bit (float) resolution from itself. I suggest you use from [Gervill project|https://gervill.dev.java.net/|Gervill project] (an external implementation for Java Sound) AudioFloatInputStream class (javadoc link: https://gervill.dev.java.net/javadoc/com/sun/media/sound/package-summary.html ) insteed of
AudioInputStream and AudioSystem.

I hope that will solve your problem,

Theodore
 
ElPablo
Posts:4
Registered: 9/25/07
Re: Problems with playing WAV Audio Files - UnsupportedAudioException   
Apr 10, 2008 9:44 AM (reply 2 of 2)  (In reply to #1 )
 
 
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
 
This topic has 2 replies on 1 page.
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 28
  • Guests : 129

About Sun forums
  • Oracle Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Oracle Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums