audio
Class AudioCodecAlaw

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

public class AudioCodecAlaw
extends AbstractCODEC

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

Author:
Mikica B Kocic, based on Sun Microsystem's C source code.

Nested Class Summary
 
Nested classes/interfaces inherited from interface audio.AudioInterface
AudioInterface.Packetizer
 
Field Summary
private static int QUANT_MASK
           
private  int sampleSize
           
private static int[] seg_end
           
private static int SEG_MASK
           
private static int SEG_SHIFT
           
private static int SIGN_BIT
           
 
Fields inherited from class audio.AbstractCODEC
audio, inputPcmBuf, outputPcmBuf
 
Constructor Summary
AudioCodecAlaw(AudioInterfacePCM audio)
          Constructs A-Law CODEC above existing PCM audio interface
 
Method Summary
private static short alaw2linear(byte alaw_value)
          Converts an 8-bit A-law value to 16-bit linear PCM
 void convertFromPCM(byte[] in, byte[] out)
          Decodes data from PCM, i.e. converts samples from CODEC to A-Law format.
 void convertToPCM(byte[] in, byte[] out)
          Encodes data to PCM, i.e. converts samples from A-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
private static byte linear2alaw(short pcm_value)
          Converts a 16-bit linear PCM value to 8-bit A-law
 
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

SIGN_BIT

private static final int SIGN_BIT
See Also:
Constant Field Values

QUANT_MASK

private static final int QUANT_MASK
See Also:
Constant Field Values

SEG_SHIFT

private static final int SEG_SHIFT
See Also:
Constant Field Values

SEG_MASK

private static final int SEG_MASK
See Also:
Constant Field Values

seg_end

private static final int[] seg_end
Constructor Detail

AudioCodecAlaw

public AudioCodecAlaw(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 A-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 CODEC to A-Law format.

Specified by:
convertFromPCM in class AbstractCODEC

linear2alaw

private static byte linear2alaw(short pcm_value)
Converts a 16-bit linear PCM value to 8-bit A-law


alaw2linear

private static short alaw2linear(byte alaw_value)
Converts an 8-bit A-law value to 16-bit linear PCM