public class WAVWriter
- Object
- WAVWriter
ImplementsAutoCloseable
A class that can write raw PCM data to a WAV file.
Constructors
public WAVWriter(File outputFile, int samplingRate, int channels, int numBits)
throws IOException | Creates a new writer for writing a WAV file. |
Methods
public void write(float[] pcmData, int offset, int len)
throws IOException | Writes PCM data to the file. |
public void close()
throws Exception | Closes the writer, and writes the WAV file. |
Inherited methods
Constructor details
WAVWriter
public WAVWriter(File outputFile, int samplingRate, int channels, int numBits)
throws IOExceptionCreates a new writer for writing a WAV file.
Parameters
outputFileFile- The output file.
samplingRateint- The sampling rate. E.g. 44100
channelsint- The number of channels. E.g. 1 or 2
numBitsint- 8 or 16
Throws
Method details
write
public void write(float[] pcmData, int offset, int len)
throws IOExceptionWrites PCM data to the file.
Parameters
pcmDatafloat[]- PCM data to write. These are float values between -1 and 1.
offsetint- Offset in pcmData array to start writing.
lenint- Length in pcmData array to write.
Throws
close
public void close()
throws ExceptionCloses the writer, and writes the WAV file.