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;
}

Upcoming Training Events

0 AM
Visual Studio Live! San Diego
September 8-12, 2025
Live! 360 Orlando
November 16-21, 2025
Cloud & Containers Live! Orlando
November 16-21, 2025
Data Platform Live! Orlando
November 16-21, 2025
Visual Studio Live! Orlando
November 16-21, 2025