public class WAVWriter

  1. Object
  2. 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 IOExceptionCreates a new writer for writing a WAV file.

Methods

public void write(float[] pcmData, int offset, int len) throws IOExceptionWrites PCM data to the file.
public void close() throws ExceptionCloses the writer, and writes the WAV file.

Inherited methods

Constructor details

WAVWriter

public WAVWriter(File outputFile, int samplingRate, int channels, int numBits) throws IOException
Creates a new writer for writing a WAV file.

Parameters

outputFile File
The output file.
samplingRate int
The sampling rate. E.g. 44100
channels int
The number of channels. E.g. 1 or 2
numBits int
8 or 16

Method details

write

public void write(float[] pcmData, int offset, int len) throws IOException
Writes PCM data to the file.

Parameters

pcmData float[]
PCM data to write. These are float values between -1 and 1.
offset int
Offset in pcmData array to start writing.
len int
Length in pcmData array to write.

close

public void close() throws Exception
Closes the writer, and writes the WAV file.

Throws

Exception