public class WavFile
extends java.lang.Object
The file format is based on information from:
Constructor and Description |
---|
WavFile(java.lang.String filename)
Constructor for creating a WavFile object to be read from a file. The argument must include the entire filename including the extension.
|
WavFile(java.lang.String filename,
int numChannels,
long numFrames,
int validBits,
long sampleRate)
Constructor for creating a WavFile object to be written to a file. The argument must include the entire filename including the extension.
|
Modifier and Type | Method and Description |
---|---|
boolean |
close()
Frees up resources associated with the object and releases
the file associated with the object
|
int |
getNumChannels() |
long |
getNumFrames() |
long |
getSampleRate() |
java.util.ArrayList<java.lang.Double> |
getSamples()
Gets all of the audio samples for the wav file
|
int |
getValidBits() |
boolean |
setSamples(java.util.ArrayList<java.lang.Double> samples)
Writes the audio samples passed to the wav file
|
java.lang.String |
toString() |
public WavFile(java.lang.String filename)
filename
- The filename of the file to be read into this object. The argument must include the entire filename including the extension.public WavFile(java.lang.String filename, int numChannels, long numFrames, int validBits, long sampleRate)
filename
- The filename of the file this object should be written to. The argument must include the entire filename including the extension.numChannels
- The number of channels of audionumFrames
- The number of frames of audiovalidBits
- The number of bits used to store each sample, e.g., 16sampleRate
- The sample rate for the audio samplespublic int getNumChannels()
public long getNumFrames()
public long getSampleRate()
public int getValidBits()
public java.util.ArrayList<java.lang.Double> getSamples()
This method should only be called once.
Returns null if an IO exception was encountered.
public boolean setSamples(java.util.ArrayList<java.lang.Double> samples)
This method should only be called once.
samples
- The audio samples for the wav filepublic boolean close()
public java.lang.String toString()
toString
in class java.lang.Object