public class FloatSampleTools extends Object
Currently, the following bit sizes are supported:
FloatSampleBuffer| Modifier and Type | Field and Description |
|---|---|
static float |
DEFAULT_DITHER_BITS
default number of bits to be dithered: 0.7f
|
| Modifier and Type | Method and Description |
|---|---|
static void |
byte2float(byte[] input,
int inByteOffset,
List<float[]> output,
int outOffset,
int frameCount,
AudioFormat format) |
static void |
byte2float(byte[] input,
int inByteOffset,
List<float[]> output,
int outOffset,
int frameCount,
AudioFormat format,
boolean allowAddChannel)
Conversion function to convert an interleaved byte array to a List of
interleaved float arrays.
|
static void |
byte2float(byte[] input,
int inByteOffset,
Object[] output,
int outOffset,
int frameCount,
AudioFormat format) |
static void |
byte2float(byte[] input,
int inByteOffset,
Object[] output,
int outOffset,
int frameCount,
AudioFormat format,
boolean allowAddChannel) |
static void |
byte2float(int channel,
byte[] input,
int inByteOffset,
float[] output,
int outOffset,
int frameCount,
AudioFormat format)
Conversion function to convert one audio channel in an interleaved byte
array to a float array.
|
static void |
byte2floatInterleaved(byte[] input,
int inByteOffset,
float[] output,
int outOffset,
int frameCount,
AudioFormat format)
Conversion function to convert an interleaved byte array to an
interleaved float array.
|
static void |
float2byte(List<float[]> input,
int inOffset,
byte[] output,
int outByteOffset,
int frameCount,
AudioFormat format,
float ditherBits)
Conversion function to convert a non-interleaved float audio data to an
interleaved byte array.
|
static void |
float2byte(Object[] input,
int inOffset,
byte[] output,
int outByteOffset,
int frameCount,
AudioFormat format,
float ditherBits) |
static void |
float2byteInterleaved(float[] input,
int inOffset,
byte[] output,
int outByteOffset,
int frameCount,
AudioFormat format,
float ditherBits)
Conversion function to convert an interleaved float array to an
interleaved byte array.
|
public static final float DEFAULT_DITHER_BITS
public static void byte2float(byte[] input,
int inByteOffset,
List<float[]> output,
int outOffset,
int frameCount,
AudioFormat format)
public static void byte2float(byte[] input,
int inByteOffset,
Object[] output,
int outOffset,
int frameCount,
AudioFormat format)
output - an array of float[] arraysArrayIndexOutOfBoundsException - if output does not
format.getChannels() elementsbyte2float(byte[] input, int inByteOffset, Object[] output, int
outOffset, int frameCount, AudioFormat format, boolean
allowAddChannel)public static void byte2float(byte[] input,
int inByteOffset,
Object[] output,
int outOffset,
int frameCount,
AudioFormat format,
boolean allowAddChannel)
output - an array of float[] arraysallowAddChannel - if true, and output has fewer channels than
format, then only output.length channels are filledArrayIndexOutOfBoundsException - if output does not
format.getChannels() elementsbyte2float(byte[] input, int inByteOffset, Object[] output, int
outOffset, int frameCount, AudioFormat format, boolean
allowAddChannel)public static void byte2float(byte[] input,
int inByteOffset,
List<float[]> output,
int outOffset,
int frameCount,
AudioFormat format,
boolean allowAddChannel)
format.
Only PCM formats are accepted. The method will convert all byte values
from input[inByteOffset] to
input[inByteOffset + (frameCount * format.getFrameSize()) - 1]
to floats from output(n)[outOffset] to
output(n)[outOffset + frameCount - 1]
input - the audio data in an byte arrayinByteOffset - index in input where to start the conversionoutput - list of float[] arrays which receive the converted audio
data. if the list does not contain enough elements, or
individual float arrays are not large enough, they are
created.outOffset - the start offset in outputframeCount - number of frames to be convertedformat - the input format. Only packed PCM is allowedallowAddChannel - if true, channels may be added to
output to match the number of input channels,
otherwise, only the first output.size() channels of input data
are converted.IllegalArgumentException - if one of the parameters is out of
boundsbyte2floatInterleaved(byte[],int,float[],int,int,AudioFormat)public static void byte2float(int channel,
byte[] input,
int inByteOffset,
float[] output,
int outOffset,
int frameCount,
AudioFormat format)
format.
Only PCM formats are accepted. The method will convert all byte values
from input[inByteOffset] to
input[inByteOffset + (frameCount * format.getFrameSize()) - 1]
to floats from output(n)[outOffset] to
output(n)[outOffset + frameCount - 1]
channel - the channel number to extract from the input audio datainput - the audio data in an byte arrayinByteOffset - index in input where to start the conversionoutput - the of float array which receives the converted audio data.outOffset - the start offset in outputframeCount - number of frames to be convertedformat - the input format. Only packed PCM is allowedIllegalArgumentException - if one of the parameters is out of
boundspublic static void byte2floatInterleaved(byte[] input,
int inByteOffset,
float[] output,
int outOffset,
int frameCount,
AudioFormat format)
format.
Only PCM formats are accepted. The method will convert all byte values
from input[inByteOffset] to
input[inByteOffset + (frameCount * format.getFrameSize()) - 1]
to floats from output[outOffset] to
output[outOffset + (frameCount * format.getChannels()) - 1]
input - the audio data in an byte arrayinByteOffset - index in input where to start the conversionoutput - the float array that receives the converted audio dataoutOffset - the start offset in outputframeCount - number of frames to be convertedformat - the input format. Only packed PCM is allowedIllegalArgumentException - if one of the parameters is out of
boundsbyte2float(byte[],int,List,int,int,AudioFormat)public static void float2byte(List<float[]> input, int inOffset, byte[] output, int outByteOffset, int frameCount, AudioFormat format, float ditherBits)
format. Exactly
format.getChannels() channels are converted regardless of
the number of elements in input. If input
does not provide enough channels, an IllegalArgumentException
is thrown.
Only PCM formats are accepted. The method will convert all samples from
input(n)[inOffset] to
input(n)[inOffset + frameCount - 1] to byte values from
output[outByteOffset] to
output[outByteOffset + (frameCount * format.getFrameSize()) - 1]
Dithering should be used when the output resolution is significantly
lower than the original resolution. This includes if the original data
was 16-bit and it is now converted to 8-bit, or if the data was generated
in the float domain. No dithering need to be used if the original sample
data was in e.g. 8-bit and the resulting output data has a higher
resolution. If dithering is used, a sensitive value is
DEFAULT_DITHER_BITS.
input - a List of float arrays with the input audio datainOffset - index in the input arrays where to start the conversionoutput - the byte array that receives the converted audio dataoutByteOffset - the start offset in outputframeCount - number of frames to be converted.format - the output format. Only packed PCM is allowedditherBits - if 0, do not dither. Otherwise the number of bits to be
ditheredIllegalArgumentException - if one of the parameters is out of
boundsDEFAULT_DITHER_BITS,
float2byteInterleaved(float[],int,byte[],int,int,AudioFormat,float)public static void float2byte(Object[] input, int inOffset, byte[] output, int outByteOffset, int frameCount, AudioFormat format, float ditherBits)
input - an array of float[] arraysArrayIndexOutOfBoundsException - if one of the parameters is out of
boundsfloat2byte(Object[], int, byte[], int, int, AudioFormat, float)public static void float2byteInterleaved(float[] input,
int inOffset,
byte[] output,
int outByteOffset,
int frameCount,
AudioFormat format,
float ditherBits)
format.
Only PCM formats are accepted. The method will convert all samples from
input[inOffset] to
input[inOffset + (frameCount * format.getChannels()) - 1]
to byte values from output[outByteOffset] to
output[outByteOffset + (frameCount * format.getFrameSize()) - 1]
Dithering should be used when the output resolution is significantly lower than the original resolution. This includes if the original data was 16-bit and it is now converted to 8-bit, or if the data was generated in the float domain. No dithering need to be used if the original sample data was in e.g. 8-bit and the resulting output data has a higher resolution. If dithering is used, a sensitive value is DEFAULT_DITHER_BITS.
input - the audio data in normalized samplesinOffset - index in input where to start the conversionoutput - the byte array that receives the converted audio dataoutByteOffset - the start offset in outputframeCount - number of frames to be converted.format - the output format. Only packed PCM is allowedditherBits - if 0, do not dither. Otherwise the number of bits to be
ditheredIllegalArgumentException - if one of the parameters is out of
boundsDEFAULT_DITHER_BITS,
float2byte(List,int,byte[],int,int,AudioFormat,float)Copyright © 2016. All Rights Reserved.