GF4J 0.9.4 Beta

gameframe.sound
Class ULawEncoder

java.lang.Object
  |
  +--gameframe.sound.ULawEncoder

public class ULawEncoder
extends java.lang.Object

u-law, A-law and linear PCM conversions.

Since:
GameFrame for Java 0.9
Version:
GameFrame for Java 0.9.4

Field Summary
static int BIAS
          Bias for linear code.
static int NSEGS
          Number of A-law segments.
static int QUANT_MASK
          Quantization field mask.
static int SEG_MASK
          Segment field mask.
static int SEG_SHIFT
          Left shift for segment number.
static int SIGN_BIT
          Sign bit for a A-law byte.
private static int[] ULAW_ENCODE_SEGMENT_LUT
          The u-law segment encoding look up table.
 
Constructor Summary
ULawEncoder()
           
 
Method Summary
 byte[] encode(short[] aOrigData)
          Encodes the input value of linear PCM returns the results as either 8-bit u-law encoded array.
(package private)  byte linear2ulaw(short pcmValue)
          Converts a linear PCM value to u-law.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

SIGN_BIT

public static final int SIGN_BIT
Sign bit for a A-law byte.

QUANT_MASK

public static final int QUANT_MASK
Quantization field mask.

NSEGS

public static final int NSEGS
Number of A-law segments.

SEG_SHIFT

public static final int SEG_SHIFT
Left shift for segment number.

SEG_MASK

public static final int SEG_MASK
Segment field mask.

BIAS

public static final int BIAS
Bias for linear code.

ULAW_ENCODE_SEGMENT_LUT

private static final int[] ULAW_ENCODE_SEGMENT_LUT
The u-law segment encoding look up table.
Constructor Detail

ULawEncoder

public ULawEncoder()
Method Detail

encode

public byte[] encode(short[] aOrigData)
Encodes the input value of linear PCM returns the results as either 8-bit u-law encoded array.
Parameters:
aOrigData - The array containing original data, one sample per array index.

linear2ulaw

byte linear2ulaw(short pcmValue)
Converts a linear PCM value to u-law. Method originally was implemented from Sun Microsystem's free example code, but was then later on changed to this (a bit more speed optimized) version.
Parameters:
pcmValue - PCM sample in 2's complement (16-bit range)
Returns:
u-Law compressed sample.

GF4J 0.9.4 Beta