-
Bug
-
Resolution: Fixed
-
P4
-
1.3.0
-
rc1
-
generic
-
generic
Name: yyT116575 Date: 11/20/2000
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
This code should convert the input file and write as an ulaw encoded AU file:
AudioInputStream ais = AudioSystem.getAudioInputStream(new File("pcm.wav"));
ais = AudioSystem.getAudioInputStream(AudioFormat.Encoding.ULAW, ais);
AudioSystem.write(ais, AudioFileFormat.Type.AU, new File("ulaw.au"));
However, an exception is thrown. The problem can be traced to
com.sun.media.sound.AuFileWriter:271 and following lines: when the input format
is not big endian, it is tried to convert it to some PCM format, which doesn't
make any sense, as the input stream is ulaw and with ulaw, endianness doesn't
matter. Constructing an output AudioFormat instance with bigendian=true and
using AudioSystem.getAudioInputStream(AudioFormat, AudioInputStream) doesn't
throw an exception (as no conversion is tried in AuFileWriter), but the
resulting file is not properly transformed to ulaw. This is another bug.
(Review ID: 112555)
======================================================================
***
The following test case was used to verify this bug:
import javax.sound.sampled.*;
import java.io.*;
public class bug4391108
{
public static void main(String args[])
{
try{
AudioInputStream ais = AudioSystem.getAudioInputStream(new File("blues1.wav"));
ais = AudioSystem.getAudioInputStream(AudioFormat.Encoding.ULAW, ais);
File out = new File("ulaw.au");
int t = AudioSystem.write(ais, AudioFileFormat.Type.AU, out);
AudioFileFormat format = AudioSystem.getAudioFileFormat(out);
System.out.println(format);
AudioFileFormat.Type type = format.getType();
System.out.println(type);
}
catch(Exception e)
{ e.printStackTrace();
}
}
}
Above code gives the following exception:
java.lang.IllegalArgumentException: Unsupported conversion: ULAW from PCM_UNSIGN
ED, 8000.0 Hz, 8 bit, mono, audio data
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:
445)
at bug4391108.main(bug4391108.java:12)
***
###@###.### 2001-08-16
###@###.### 2001-08-20
The bug still failed on Xhipra's test case.