public class WaveFileWriter extends java.lang.Object implements AudioOutputStream
WaveFileWriter writer = new WaveFileWriter(file);
writer.setFrameRate(22050);
writer.setBitsPerSample(24);
writer.write(floatArray);
writer.close();
Constructor and Description |
---|
WaveFileWriter(java.io.File outputFile)
Create a writer that will write to the specified file.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
int |
getBitsPerSample() |
int |
getFrameRate() |
int |
getSamplesPerFrame() |
void |
setBitsPerSample(int bits)
Only 16 or 24 bit samples supported at the moment.
|
void |
setFrameRate(int frameRate) |
void |
setSamplesPerFrame(int samplesPerFrame)
For stereo, set this to 2.
|
void |
write(double value)
Write single audio data value to the WAV file.
|
void |
write(double[] buffer)
Write entire buffer of audio samples to the WAV file.
|
void |
write(double[] buffer,
int start,
int count)
Write audio to the WAV file.
|
void |
write(float[] buffer)
Write audio to the WAV file.
|
void |
write(float[] buffer,
int start,
int count)
Write audio to the WAV file.
|
void |
writeDataChunkHeader()
Write a 'data' chunk header to the WAV file.
|
void |
writeFormatChunk()
Write an 'fmt ' chunk to the WAV file containing the given information.
|
void |
writeIntLittle(int n)
Write a 32 bit integer to the stream in Little Endian format.
|
void |
writeShortLittle(short n)
Write a 16 bit integer to the stream in Little Endian format.
|
public WaveFileWriter(java.io.File outputFile) throws java.io.FileNotFoundException
outputFile
- java.io.FileNotFoundException
public void setFrameRate(int frameRate)
frameRate
- default is 44100public int getFrameRate()
public void setSamplesPerFrame(int samplesPerFrame)
public int getSamplesPerFrame()
public void setBitsPerSample(int bits)
public int getBitsPerSample()
public void close() throws java.io.IOException
close
in interface AudioOutputStream
java.io.IOException
public void write(double[] buffer) throws java.io.IOException
write
in interface AudioOutputStream
java.io.IOException
public void write(float[] buffer) throws java.io.IOException
java.io.IOException
public void write(double value) throws java.io.IOException
write
in interface AudioOutputStream
java.io.IOException
public void write(double[] buffer, int start, int count) throws java.io.IOException
write
in interface AudioOutputStream
java.io.IOException
public void write(float[] buffer, int start, int count) throws java.io.IOException
java.io.IOException
public void writeIntLittle(int n) throws java.io.IOException
java.io.IOException
public void writeShortLittle(short n) throws java.io.IOException
java.io.IOException
public void writeFormatChunk() throws java.io.IOException
java.io.IOException
public void writeDataChunkHeader() throws java.io.IOException
java.io.IOException