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 audio. If more than one, the samples are interleaved.numFrames
- The number of frames of audiovalidBits
- The number of bits used to store each sample, that is, the number of bits used to specify the amplitude of each sample, e.g., 16sampleRate
- The sample rate for the audio samples in samples per second (Hz). Typical sample rates are 44,100 Hz, 32,000 Hz, 22,050 Hz, 11,025 Hz, and 8,000 Hz.public 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