public final class AudioUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Random |
rng
A handy random number generator.
|
Constructor and Description |
---|
AudioUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
byteToFloat(float[] out,
byte[] in,
boolean bigEndian)
Converts a buffer of bytes to a buffer of floats with a given byte order.
|
static void |
byteToFloat(float[] out,
byte[] in,
boolean bigEndian,
int numFloats)
Converts a buffer of bytes to a buffer of floats with a given byte order.
|
static void |
byteToFloat(float[] out,
byte[] in,
boolean bigEndian,
int startIndexInByteArray,
int numFloats)
Converts a buffer of bytes to a buffer of floats with a given byte order.
|
static void |
byteToFloat(float[] out,
byte[] in,
boolean bigEndian,
int startIndexInByteArray,
int startIndexInFloatArray,
int numFloats)
Converts a buffer of bytes to a buffer of floats with a given byte order.
|
static void |
deinterleave(float[] source,
int nChannels,
int nFrames,
float[][] result)
De-interleave an interleaved buffer of floats to form a 2D array of
floats of size nChannels x nFrames.
|
static double |
fastPow01(double a,
double b)
Does a freaky shortcut for calculating pow (limited to base with range 0-1), faster but less accurate than regular Math.pow().
|
static java.io.File |
fileFromString(java.lang.String s)
Equivalent to fileFromURL(urlFromString(s)).
|
static java.io.File |
fileFromURL(java.net.URL url)
Attempts to get a File from a URL, suppressing warnings.
|
static void |
floatToByte(byte[] out,
float[] in,
boolean bigEndian)
Converts a buffer of floats to a buffer of bytes with a given byte order.
|
static void |
floatToByte(byte[] out,
int outstart,
float[] in,
int instart,
int inlength,
boolean bigEndian)
Converts a buffer of floats to a buffer of bytes with a given byte order.
|
static void |
floatToShort(short[] out,
float[] in)
Converts a buffer of floats to a buffer of shorts.
|
static void |
interleave(float[][] source,
int nChannels,
int nFrames,
float[] result)
Interleave a 2D array of floats of size nChannels x nFrames to form a
single interleaved buffer of floats.
|
static void |
interleave(float[][] source,
int nChannels,
int nFrames,
int offset,
float[] result)
Interleave a 2D array of floats of size nChannels x nFrames to form a
single interleaved buffer of floats.
|
static void |
reverseBuffer(float[][] buffer)
Reverse the data in each channel.
|
static void |
shortToFloat(float[] out,
short[] in)
Converts a buffer of shorts to a buffer of floats.
|
static void |
stretchBuffer(float[][] source,
float[][] dest)
"Stretches" source into dest.
|
static java.net.URL |
urlFromString(java.lang.String s)
Attempts to determine a URL given a String.
|
public static final void shortToFloat(float[] out, short[] in)
out
- buffer of floats.in
- buffer of shorts.public static final void floatToShort(short[] out, float[] in)
out
- buffer of shorts.in
- buffer of floats.public static final void floatToByte(byte[] out, float[] in, boolean bigEndian)
out
- buffer of bytes.in
- buffer of floats.bigEndian
- true for big endian byte order, false otherwise.public static final void floatToByte(byte[] out, int outstart, float[] in, int instart, int inlength, boolean bigEndian)
out
- Output arrayoutstart
- Start index of outputin
- Input arrayinstart
- Start index of inputinlength
- Number of floats to copybigEndian
- Formatpublic static final void byteToFloat(float[] out, byte[] in, boolean bigEndian)
out
- buffer of floats.in
- buffer of bytes.bigEndian
- true for big endian byte order, false otherwise.public static final void byteToFloat(float[] out, byte[] in, boolean bigEndian, int numFloats)
out
- buffer of floats.in
- buffer of bytes.bigEndian
- true for big endian byte order, false otherwise.numFloats
- number of elements to copy into outpublic static final void byteToFloat(float[] out, byte[] in, boolean bigEndian, int startIndexInByteArray, int numFloats)
out
- buffer of floats.in
- buffer of bytes.bigEndian
- true for big endian byte order, false otherwise.startIndexInByteArray
- where to start copying fromnumFloats
- number of elements to copy into outpublic static final void byteToFloat(float[] out, byte[] in, boolean bigEndian, int startIndexInByteArray, int startIndexInFloatArray, int numFloats)
out
- buffer of floats.in
- buffer of bytes.bigEndian
- true for big endian byte order, false otherwise.startIndexInByteArray
- where to start copying fromstartIndexInFloatArray
- where to start copying tonumFloats
- number of elements to copy into outpublic static final void deinterleave(float[] source, int nChannels, int nFrames, float[][] result)
source
- interleaved buffer of floats.nChannels
- first dimension of resulting 2D array.nFrames
- second dimension of resulting 2D array.result
- the resultpublic static final void interleave(float[][] source, int nChannels, int nFrames, float[] result)
source
- 2D array of floats.nChannels
- first dimension of input 2D array.nFrames
- second dimension of input 2D array.result
- the resultpublic static final void interleave(float[][] source, int nChannels, int nFrames, int offset, float[] result)
source
- 2D array of floats.nChannels
- first dimension of input 2D array.nFrames
- second dimension of input 2D array.offset
- the number of frames offsetresult
- the resultpublic static final void stretchBuffer(float[][] source, float[][] dest)
source
- dest
- public static final void reverseBuffer(float[][] buffer)
buffer
- public static double fastPow01(double a, double b)
a
- the base.b
- the exponent.public static java.net.URL urlFromString(java.lang.String s)
s
- String to interpret as System Resource, URL or file path.public static java.io.File fileFromURL(java.net.URL url)
url
- to get File from.public static java.io.File fileFromString(java.lang.String s)
s
- the String to interpret as System Resource, URL or file path.