public class WavFile
extends java.lang.Object
Constructor and Description |
---|
WavFile(java.lang.String fileName,
java.lang.String fileMode)
Open a wav file for reading or writing.
|
Modifier and Type | Method and Description |
---|---|
boolean |
append(double[][] doubleArray)
Append to an audio file.
|
void |
close() |
WavHeader |
getWavHeader() |
boolean |
positionAtData() |
int |
readData(double[][] doubleArray)
Read data into a preallocated double array.
|
int |
readData(short[][] shortArray)
Read data into a preallocated double array.
|
WavHeader |
readWavHeader() |
boolean |
setPosition(long sampleNumber)
Set the file pointer at a specific sample.
|
boolean |
write(javax.sound.sampled.AudioFormat format,
double[][] doubleArray)
Writes an array of double values to a WAV file.
|
boolean |
write(float sampleRate,
int numChannels,
double[][] doubleArray)
Writes an array of double values to a WAV file.
|
boolean |
writeSingleChannel(javax.sound.sampled.AudioFormat format,
double[] doubleArray)
Writes an array of double values to a WAV file.
|
public WavFile(java.lang.String fileName, java.lang.String fileMode)
fileName
- file name with full pathfileMode
- mode = "r" for read or "w" for writepublic WavHeader readWavHeader()
public WavHeader getWavHeader()
public boolean positionAtData()
public boolean setPosition(long sampleNumber)
sampleNumber
- sample numberpublic void close()
public int readData(double[][] doubleArray)
doubleArray
- double array to receive datapublic int readData(short[][] shortArray)
doubleArray
- double array to receive datapublic boolean writeSingleChannel(javax.sound.sampled.AudioFormat format, double[] doubleArray)
format
- AudioFormat
object describing the desired filedoubleArray
- the array of double values to savepublic boolean write(float sampleRate, int numChannels, double[][] doubleArray)
sampleRate
- The sample rate of the raw acoustic datanumChannels
- The number of channels to savedoubleArray
- the array of double values to save. Note that this is
defined as a 2D array. If a single-channel 1D vector is passed, it
doesn't seem to be a problem.public boolean write(javax.sound.sampled.AudioFormat format, double[][] doubleArray)
format
- AudioFormat
object describing the desired filedoubleArray
- the array of double values to save. Note that this is
defined as a 2D array. If a single-channel 1D vector is passed, it
doesn't seem to be a problem.public boolean append(double[][] doubleArray)
moreData
- data to add to the file.