Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Java sound problem with PCM -> ULaw conversion

843802Dec 11 2006 — edited Jan 21 2009
I'm experiencing java sound conversion from PCM to U-Law or A-Law but 'ive got a lot of problems. With or without Tritonius, i've got an unsupported conversion error. I'm on JDK 1.5, so maybe there's a problem with this version ?

Here is the stacktrace of the java error :
java.lang.IllegalArgumentException: Unsupported conversion: ULAW 8000.0 Hz, 8 bit, mono, 8 bytes/frame,  from PCM_UNSIGNED 11025.0 Hz, 8 bit, mono, 1 bytes/frame, 

      at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)

      at fr.ft.dps.utils.TestSoundConverter.testWav2Wav(TestSoundConverter.java:53)
And the simple code i use to do that :
File sourceFile = new File("D:/Projets/Contact EveryOne/Developpements/Contact EveryOne/src-test/fr/ft/dps/utils/Calling.wav");

File targetFile = new File("D:/Projets/Contact EveryOne/Developpements/Contact EveryOne/src-test/fr/ft/dps/utils/Calling2.wav");

AudioInputStream sourceAudioInputStream = AudioSystem.getAudioInputStream(sourceFile);

AudioFormat targetFormat = new AudioFormat(new AudioFormat.Encoding("ULAW"), 8000, 8, 1, 8, 8000, true);

AudioInputStream targetAudioInputStream = AudioSystem.getAudioInputStream(targetFormat, sourceAudioInputStream);

AudioSystem.write(targetAudioInputStream, AudioFileFormat.Type.WAVE, targetFile);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 18 2009
Added on Dec 11 2006
4 comments
3,820 views