|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ritolaaudio.simplewavio.Utils
public class Utils
General utilities for reading and writing WAV (RIFF) files.
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static void |
flipEndian(byte[] original,
byte[] output)
Reverse the order of a byte array and write that reordered array to the given output. |
static void |
floatsToWAV(float[][] buffer,
java.io.File destFile,
float sampleRate)
Write an array of float[] frames as a RIFF (.WAV) file, expecting floats within the range [-1,1]. |
static void |
toByteArray(int value,
int numBytes,
byte[] dest,
int off)
Converts a signed int into an array of bytes and writes it to a byte array t the given offset. |
static float[][] |
WAVToFloats(java.io.File input)
Open a .WAV (RIFF) file and return its contents as a 2-dimensional array of floats. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static final void toByteArray(int value, int numBytes, byte[] dest, int off)
value
- The integral value to byte-ify.numBytes
- The number of bytes desired to describe this value (up to 4)dest
- The byte array to which to write said bytes.off
- The offset index within said byte array from which to start writing said bytes.public static final void flipEndian(byte[] original, byte[] output)
original
- input array to reverse (does not get changed)output
- output array for results of byte order reversal.public static float[][] WAVToFloats(java.io.File input) throws java.io.IOException
srcFile
-
java.io.FileNotFoundException
- Failure to find the file specified; read aborted.
javax.sound.sampled.UnsupportedAudioFileException
- Java Media Framework could not recognize the format of the specified file.
java.io.IOException
- Some general IO error occurred while trying to process the file. Probably a bug in SimpleWAVIO.public static void floatsToWAV(float[][] buffer, java.io.File destFile, float sampleRate) throws java.io.IOException
buffer
- 2-dimensional float array, where the first dimension represents single sample-wide frames, and the second dimension
representing a single-sample channel of that frame. i.e. a mono clip 44000 samples long would have the dimensions [44000][1]destFile
- Destination File. Does not need to exist beforehand.sampleRate
-
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |