ULAW format to PCM format conversion.

Java to go!
Java Sound QuickStart

Tony Loton
Listing 3. ULAW format to PCM format conversion.


if (
    (format.getEncoding() ==
    AudioFormat.Encoding.ULAW)
    ||(format.getEncoding() ==
    AudioFormat.Encoding.ALAW)
) 
{
  AudioFormat newFormat = new AudioFormat
  (AudioFormat.Encoding.PCM_SIGNED,
   format.getSampleRate(),
   format.getSampleSizeInBits() * 2,
   format.getChannels(),
   format.getFrameSize() * 2,
   format.getFrameRate(),
   true);

  stream =AudioSystem
   .getAudioInputStream(newFormat, stream);

  format = newFormat;
}