|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
com.groovemanager.spi.floatEncoding.FloatConversionInputStream
This class is used for converion of PCM_SIGNED encoded audio data to PCM_FLOAT encoding and vice versa. As an additional bonus it can provide PCM_SIGNED to PCM_SIGNED and PCM_FLOAT to PCM_FLOAT conversion.
| Field Summary | |
|---|---|
private static float |
MAXINT
Constants used for conversion |
private static float |
MAXINTBACK
Constants used for conversion |
private static double |
MAXLONG
Constants used for conversion |
private static double |
MAXLONGBACK
Constants used for conversion |
private byte[] |
readTemp
Temporary buffer for reading from the source stream |
private javax.sound.sampled.AudioInputStream |
source
The source stream to be converted |
private javax.sound.sampled.AudioFormat |
sourceFormat
AudioFormat of the source data |
private javax.sound.sampled.AudioFormat |
targetFormat
AudioFormat of the source data |
| Constructor Summary | |
|---|---|
FloatConversionInputStream(javax.sound.sampled.AudioInputStream stream,
javax.sound.sampled.AudioFormat targetFormat)
Constructs a new ConversionInputStream from the given AudioInputStream being converted to the given Format |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
private void |
convert(byte[] from,
byte[] to,
int off,
int length)
Convert the data depending on the source and target format while copying it from the source array to the target array |
private static void |
deleteBytes(byte[] from,
byte[] to,
int off,
int length,
int sampleSize,
int zeroCount,
boolean isBigEndian)
Decrease the sample size of the given audio data by copying it into another smaller array and cutting out the least significant bytes |
private static void |
doubleToLong(byte[] from,
int off,
int length,
boolean isBigEndian)
Convert the data from 64 Bit double to 64 Bit long |
private static void |
floatToInt(byte[] from,
int off,
int length,
boolean isBigEndian)
Convert the data from 32 Bit float to 32 Bit integer |
private long |
getConvertedLength(long len)
Get the length in bytes that will be needed for converting the given length of unconverted data. |
private long |
getUnconvertedLength(long len)
Get the length in bytes of unconverted data which leads to converted data of the given length |
private static void |
insertZeros(byte[] from,
byte[] to,
int off,
int length,
int sampleSize,
int zeroCount,
boolean isBigEndian)
Increase the sample size of the given audio data by copying it into another larger array and filling the samples up with zeros in the least significant bytes |
private static void |
intToFloat(byte[] from,
int off,
int length,
boolean isBigEndian)
Convert the data from 32 Bit integer to 32 Bit float |
private static void |
longToDouble(byte[] from,
int off,
int length,
boolean isBigEndian)
Convert the data from 64 Bit long to 64 Bit double |
void |
mark(int readlimit)
|
boolean |
markSupported()
|
int |
read()
Frame size is at least 2 bytes so this method mustn't be called |
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
long |
skip(long n)
|
private static void |
swap(byte[] from,
int off,
int length,
int sampleSize)
Swap the the samples inside the given array from little endian to big endian or vice versa. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final float MAXINT
private static final float MAXINTBACK
private static final double MAXLONG
private static final double MAXLONGBACK
private byte[] readTemp
private final javax.sound.sampled.AudioInputStream source
private javax.sound.sampled.AudioFormat sourceFormat
private javax.sound.sampled.AudioFormat targetFormat
| Constructor Detail |
|---|
public FloatConversionInputStream(javax.sound.sampled.AudioInputStream stream,
javax.sound.sampled.AudioFormat targetFormat)
stream - The Source AudioInputStream to be convertedtargetFormat - The Format into which the Stream should be converted| Method Detail |
|---|
public int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionInputStream.available()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOExceptionInputStream.close()
private void convert(byte[] from,
byte[] to,
int off,
int length)
from - The array of audio data that should be convertedto - The array to copy the converted data tooff - offset inside the target arraylength - The number of bytes to be processed
private static void deleteBytes(byte[] from,
byte[] to,
int off,
int length,
int sampleSize,
int zeroCount,
boolean isBigEndian)
from - The source arrayto - The target arrayoff - offset inside the target arraylength - The length in bytes of the data to be processedsampleSize - The new sampleSizezeroCount - The number of bytes to cut from each sampleisBigEndian - Indicates whether the bytes should be cut
from the left or from the right side
private static void doubleToLong(byte[] from,
int off,
int length,
boolean isBigEndian)
from - The data to be convertedoff - Offset inside the data arraylength - The number of bytes to be processedisBigEndian - Indicates whether the samples are stored in
big endian or little endian
private static void floatToInt(byte[] from,
int off,
int length,
boolean isBigEndian)
from - The data to be convertedoff - Offset inside the data arraylength - The number of bytes to be processedisBigEndian - Indicates whether the samples are stored in
big endian or little endianprivate long getConvertedLength(long len)
len - The length in bytes of the unconverted data.
private long getUnconvertedLength(long len)
len - The length in bytes of the converted data.
private static void insertZeros(byte[] from,
byte[] to,
int off,
int length,
int sampleSize,
int zeroCount,
boolean isBigEndian)
from - The source arrayto - The target arrayoff - offset inside the target arraylength - The length in bytes of the data to be processedsampleSize - The new sampleSizezeroCount - The number of bytes to fill up per sampleisBigEndian - Indicates whether the zeros should be filled
from the left or from the right side
private static void intToFloat(byte[] from,
int off,
int length,
boolean isBigEndian)
from - The data to be convertedoff - Offset inside the data arraylength - The number of bytes to be processedisBigEndian - Indicates whether the samples are stored in
big endian or little endian
private static void longToDouble(byte[] from,
int off,
int length,
boolean isBigEndian)
from - The data to be convertedoff - Offset inside the data arraylength - The number of bytes to be processedisBigEndian - Indicates whether the samples are stored in
big endian or little endianpublic void mark(int readlimit)
mark in class java.io.InputStreamInputStream.mark(int)public boolean markSupported()
markSupported in class java.io.InputStreamInputStream.markSupported()
public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionInputStream.read()
public int read(byte[] b)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionInputStream.read(byte[])
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionInputStream.read(byte[], int, int)
public void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOExceptionInputStream.reset()
public long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOExceptionInputStream.skip(long)
private static void swap(byte[] from,
int off,
int length,
int sampleSize)
from - The array of audio dataoff - The start address inside the arraylength - The length in bytes of the data to be processedsampleSize - The size of one sample in bytes
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||