audio
Class AudioCodecUlaw

java.lang.Object
  extended by audio.AbstractCODEC
      extended by audio.AudioCodecUlaw
All Implemented Interfaces:
AudioInterface

public class AudioCodecUlaw
extends AbstractCODEC

Converts a 16-bit linear PCM stream from and to 8-bit u-law.

Author:
Mikica B Kocic, based on Craig Reese's and Joe Campbell's C source code.

Nested Class Summary
 
Nested classes/interfaces inherited from interface audio.AudioInterface
AudioInterface.Packetizer
 
Field Summary
private static short BIAS
           
private static int CLIP
           
private static int[] exp_lut1
           
private  int sampleSize
           
private static short[] ulaw2lin_table
           
private static boolean ZEROTRAP
           
 
Fields inherited from class audio.AbstractCODEC
audio, inputPcmBuf, outputPcmBuf
 
Constructor Summary
AudioCodecUlaw(AudioInterfacePCM audio)
          Constructs A-Law CODEC above existing PCM audio interface
 
Method Summary
 void convertFromPCM(byte[] in, byte[] out)
          Decodes data from PCM, i.e. converts samples from u-Law to PCM format.
 void convertToPCM(byte[] in, byte[] out)
          Encodes data to PCM, i.e. converts samples from u-Law to CODEC format.
 int getSampleSize()
          Returns the minimum sample size for use in creating buffers etc.
 int getVoicePduSubclass()
          Gets the VoicePDU subclass attribute of the AbstractAudio object
static byte linear2ulaw(int sample)
          Converts a linear signed 16bit sample to a uLaw byte.
static short ulaw2linear(byte ulawbyte)
          Converts an 8-bit u-law value to 16-bit linear PCM
 
Methods inherited from class audio.AbstractCODEC
cleanUp, getByFormat, readWithTimestamp, setAudioSender, startPlay, startRecording, startRinging, stopPlay, stopRecording, stopRinging, writeBuffered, writeDirectly
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sampleSize

private int sampleSize

ZEROTRAP

private static final boolean ZEROTRAP
See Also:
Constant Field Values

BIAS

private static final short BIAS
See Also:
Constant Field Values

CLIP

private static final int CLIP
See Also:
Constant Field Values

exp_lut1

private static final int[] exp_lut1

ulaw2lin_table

private static short[] ulaw2lin_table
Constructor Detail

AudioCodecUlaw

public AudioCodecUlaw(AudioInterfacePCM audio)
Constructs A-Law CODEC above existing PCM audio interface

Method Detail

getVoicePduSubclass

public int getVoicePduSubclass()
Gets the VoicePDU subclass attribute of the AbstractAudio object

Specified by:
getVoicePduSubclass in interface AudioInterface
Specified by:
getVoicePduSubclass in class AbstractCODEC

getSampleSize

public int getSampleSize()
Returns the minimum sample size for use in creating buffers etc.


convertToPCM

public void convertToPCM(byte[] in,
                         byte[] out)
Encodes data to PCM, i.e. converts samples from u-Law to CODEC format.

Specified by:
convertToPCM in class AbstractCODEC

convertFromPCM

public void convertFromPCM(byte[] in,
                           byte[] out)
Decodes data from PCM, i.e. converts samples from u-Law to PCM format.

Specified by:
convertFromPCM in class AbstractCODEC

linear2ulaw

public static byte linear2ulaw(int sample)
Converts a linear signed 16bit sample to a uLaw byte.


ulaw2linear

public static short ulaw2linear(byte ulawbyte)
Converts an 8-bit u-law value to 16-bit linear PCM