Class TConversionTool

java.lang.Object
  extended byTConversionTool

public class TConversionTool
extends java.lang.Object


Constructor Summary
TConversionTool()
           
 
Method Summary
static short alaw2linear(byte ulawbyte)
           
static int bytesToInt16(byte[] buffer, int byteOffset, boolean bigEndian)
          Converts 2 successive bytes starting at byteOffset in buffer to a signed integer sample with 16bit range.
static int bytesToInt24(byte[] buffer, int byteOffset, boolean bigEndian)
          Converts 3 successive bytes starting at byteOffset in buffer to a signed integer sample with 24bit range.
static int bytesToInt32(byte[] buffer, int byteOffset, boolean bigEndian)
          Converts a 4 successive bytes starting at byteOffset in buffer to a signed 32bit integer sample.
static void intToBytes16(int sample, byte[] buffer, int byteOffset, boolean bigEndian)
          Converts a 16 bit sample of type int to 2 bytes in an array.
static void intToBytes24(int sample, byte[] buffer, int byteOffset, boolean bigEndian)
          Converts a 24 bit sample of type int to 3 bytes in an array.
static void intToBytes32(int sample, byte[] buffer, int byteOffset, boolean bigEndian)
          Converts a 32 bit sample of type int to 4 bytes in an array.
static byte intToUnsignedByte(int sample)
           
static void intToUnsignedBytes16(int sample, byte[] buffer, int byteOffset, boolean bigEndian)
           
static void intToUnsignedBytes24(int sample, byte[] buffer, int byteOffset, boolean bigEndian)
           
static void intToUnsignedBytes32(int sample, byte[] buffer, int byteOffset, boolean bigEndian)
           
static byte linear2alaw(short pcm_val)
           
static byte linear2ulaw(int sample)
          Converts a linear signed 16bit sample to a uLaw byte.
static short ulaw2linear(byte ulawbyte)
           
static int unsignedByteToInt(byte b)
           
static int unsignedByteToInt16(byte[] buffer, int offset, boolean isBigEndian)
           
static int unsignedByteToInt24(byte[] buffer, int offset, boolean isBigEndian)
           
static int unsignedByteToInt32(byte[] buffer, int offset, boolean isBigEndian)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TConversionTool

public TConversionTool()
Method Detail

bytesToInt16

public static int bytesToInt16(byte[] buffer,
                               int byteOffset,
                               boolean bigEndian)
Converts 2 successive bytes starting at byteOffset in buffer to a signed integer sample with 16bit range.

For little endian, buffer[byteOffset] is interpreted as low byte, whereas it is interpreted as high byte in big endian.

This is a reference function.


bytesToInt24

public static int bytesToInt24(byte[] buffer,
                               int byteOffset,
                               boolean bigEndian)
Converts 3 successive bytes starting at byteOffset in buffer to a signed integer sample with 24bit range.

For little endian, buffer[byteOffset] is interpreted as lowest byte, whereas it is interpreted as highest byte in big endian.

This is a reference function.


bytesToInt32

public static int bytesToInt32(byte[] buffer,
                               int byteOffset,
                               boolean bigEndian)
Converts a 4 successive bytes starting at byteOffset in buffer to a signed 32bit integer sample.

For little endian, buffer[byteOffset] is interpreted as lowest byte, whereas it is interpreted as highest byte in big endian.

This is a reference function.


ulaw2linear

public static short ulaw2linear(byte ulawbyte)

linear2ulaw

public static byte linear2ulaw(int sample)
Converts a linear signed 16bit sample to a uLaw byte. Ported to Java by fb.
Originally by:
Craig Reese: IDA/Supercomputing Research Center
Joe Campbell: Department of Defense
29 September 1989


alaw2linear

public static short alaw2linear(byte ulawbyte)

linear2alaw

public static byte linear2alaw(short pcm_val)

intToBytes16

public static void intToBytes16(int sample,
                                byte[] buffer,
                                int byteOffset,
                                boolean bigEndian)
Converts a 16 bit sample of type int to 2 bytes in an array. sample is interpreted as signed (as Java does).

For little endian, buffer[byteOffset] is filled with low byte of sample, and buffer[byteOffset+1] is filled with high byte of sample + sign bit.

For big endian, this is reversed.

Before calling this function, it should be assured that sample is in the 16bit range - it will not be clipped.

This is a reference function.


intToBytes24

public static void intToBytes24(int sample,
                                byte[] buffer,
                                int byteOffset,
                                boolean bigEndian)
Converts a 24 bit sample of type int to 3 bytes in an array. sample is interpreted as signed (as Java does).

For little endian, buffer[byteOffset] is filled with low byte of sample, and buffer[byteOffset+2] is filled with the high byte of sample + sign bit.

For big endian, this is reversed.

Before calling this function, it should be assured that sample is in the 24bit range - it will not be clipped.

This is a reference function.


intToBytes32

public static void intToBytes32(int sample,
                                byte[] buffer,
                                int byteOffset,
                                boolean bigEndian)
Converts a 32 bit sample of type int to 4 bytes in an array. sample is interpreted as signed (as Java does).

For little endian, buffer[byteOffset] is filled with lowest byte of sample, and buffer[byteOffset+3] is filled with the high byte of sample + sign bit.

For big endian, this is reversed.

This is a reference function.


unsignedByteToInt

public static int unsignedByteToInt(byte b)

unsignedByteToInt16

public static int unsignedByteToInt16(byte[] buffer,
                                      int offset,
                                      boolean isBigEndian)

unsignedByteToInt24

public static int unsignedByteToInt24(byte[] buffer,
                                      int offset,
                                      boolean isBigEndian)

unsignedByteToInt32

public static int unsignedByteToInt32(byte[] buffer,
                                      int offset,
                                      boolean isBigEndian)

intToUnsignedByte

public static byte intToUnsignedByte(int sample)

intToUnsignedBytes16

public static void intToUnsignedBytes16(int sample,
                                        byte[] buffer,
                                        int byteOffset,
                                        boolean bigEndian)

intToUnsignedBytes24

public static void intToUnsignedBytes24(int sample,
                                        byte[] buffer,
                                        int byteOffset,
                                        boolean bigEndian)

intToUnsignedBytes32

public static void intToUnsignedBytes32(int sample,
                                        byte[] buffer,
                                        int byteOffset,
                                        boolean bigEndian)