net.sf.fmj.media.codec.audio.alaw
Class ALawEncoderUtil

java.lang.Object
  extended by net.sf.fmj.media.codec.audio.alaw.ALawEncoderUtil

public class ALawEncoderUtil
extends java.lang.Object

Turns 16-bit linear PCM values into 8-bit A-law bytes. Adapted from code by Marc Sweetgall at http://www.codeproject.com/csharp/g711audio.asp


Field Summary
static int MAX
           
 
Constructor Summary
ALawEncoderUtil()
           
 
Method Summary
static void aLawEncode(boolean bigEndian, byte[] data, int offset, int length, byte[] target)
          Encode an array of pcm values into a pre-allocated target array
static byte aLawEncode(int pcm)
          Encode a pcm value into a a-law byte
static byte aLawEncode(short pcm)
          Encode a pcm value into a a-law byte
static void aLawEncodeBigEndian(byte[] data, int offset, int length, byte[] target)
           
static void aLawEncodeLittleEndian(byte[] data, int offset, int length, byte[] target)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX

public static final int MAX
See Also:
Constant Field Values
Constructor Detail

ALawEncoderUtil

public ALawEncoderUtil()
Method Detail

aLawEncode

public static byte aLawEncode(int pcm)
Encode a pcm value into a a-law byte

Parameters:
pcm - A 16-bit pcm value
Returns:
A a-law encoded byte

aLawEncode

public static byte aLawEncode(short pcm)
Encode a pcm value into a a-law byte

Parameters:
pcm - A 16-bit pcm value
Returns:
A a-law encoded byte

aLawEncode

public static void aLawEncode(boolean bigEndian,
                              byte[] data,
                              int offset,
                              int length,
                              byte[] target)
Encode an array of pcm values into a pre-allocated target array

Parameters:
data - An array of bytes in Little-Endian format
target - A pre-allocated array to receive the A-law bytes. This array must be at least half the size of the source.

aLawEncodeLittleEndian

public static void aLawEncodeLittleEndian(byte[] data,
                                          int offset,
                                          int length,
                                          byte[] target)

aLawEncodeBigEndian

public static void aLawEncodeBigEndian(byte[] data,
                                       int offset,
                                       int length,
                                       byte[] target)