public abstract class ByteConverter
extends java.lang.Object
The double data will often need to be packed into a nChan*nSamples 2D array, so provide functionality for this as well as packing single channels of data.
Wav files follow a Windows standard of little endienness and Aif files follow the Mac/Linux standard of bigendienness. Java is Bigendian.
Constructor and Description |
---|
ByteConverter() |
Modifier and Type | Method and Description |
---|---|
abstract int |
bytesToDouble(byte[] byteData,
double[][] doubleData,
int numBytes)
Converts a byte array into a double array.
|
static ByteConverter |
createByteConverter(javax.sound.sampled.AudioFormat audioFormat) |
static ByteConverter |
createByteConverter(int bytesPerSample,
boolean bigEndian,
javax.sound.sampled.AudioFormat.Encoding encoding)
Create a byte converter based on the number of bytes per sample
and on the endianness of the byte data.
|
abstract int |
doubleToBytes(double[][] doubleData,
byte[] byteData,
int numSamples)
Converts a double array into a byte array.
|
public static ByteConverter createByteConverter(int bytesPerSample, boolean bigEndian, javax.sound.sampled.AudioFormat.Encoding encoding)
WAV files are in little endian format AIFF files are in big endian format AU files are in big endian format. Java uses big endian irrespective of platform. Therefore wav files need to be byte swapped, AIFF and AU files don't.
bytesPerSample
- number of bytes per sample (1,2,3 or 4)bigEndian
- true if it's big Endian data, false for small Endians.public static ByteConverter createByteConverter(javax.sound.sampled.AudioFormat audioFormat)
public abstract int bytesToDouble(byte[] byteData, double[][] doubleData, int numBytes)
byteData
- byte datadoubleData
- double datapublic abstract int doubleToBytes(double[][] doubleData, byte[] byteData, int numSamples)
doubleData
- double databyteData
- byte data