Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4391108
Votes 1
Synopsis Writing au files with ulaw encoding is broken
Category java:classes_sound
Reported Against 1.3
Release Fixed 1.4(merlin-rc1)
State 10-Fix Delivered, bug
Priority: 4-Low
Related Bugs
Submit Date 21-NOV-2000
Description
Writing au files with ulaw encoding is broken




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)

***
 xxxxx@xxxxx  2001-08-16


 xxxxx@xxxxx  2001-08-20
The bug still failed on Xhipra's test case.
Work Around




none to get the desired ulaw-encoded AU file.
======================================================================
Evaluation
This is very basic functionality of Java Sound and should be fixed soon.

 xxxxx@xxxxx  2001-10-01
	Should be fixed in Merlin. Need to be verified. Push to Hopper.


 xxxxx@xxxxx  2002-04-16
	Had been indeed fixed for Merlin.
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang