public class WaveHeader
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static short |
FORMAT_ALAW
Indicates ALAW format.
|
static short |
FORMAT_PCM
Indicates PCM format.
|
static short |
FORMAT_ULAW
Indicates ULAW format.
|
Constructor and Description |
---|
WaveHeader()
Construct a WaveHeader, with all fields defaulting to zero.
|
WaveHeader(short format,
short numChannels,
int sampleRate,
short bitsPerSample,
int numBytes)
Construct a WaveHeader, with fields initialized.
|
Modifier and Type | Method and Description |
---|---|
short |
getBitsPerSample()
Get the number of bits per sample.
|
short |
getFormat()
Get the format field.
|
int |
getNumBytes()
Get the size of audio data after this header, in bytes.
|
short |
getNumChannels()
Get the number of channels.
|
int |
getSampleRate()
Get the sample rate.
|
int |
read(java.io.InputStream in)
Read and initialize a WaveHeader.
|
WaveHeader |
setBitsPerSample(short bitsPerSample)
Set the number of bits per sample.
|
WaveHeader |
setFormat(short format)
Set the format field.
|
WaveHeader |
setNumBytes(int numBytes)
Set the size of audio data after this header, in bytes.
|
WaveHeader |
setNumChannels(short numChannels)
Set the number of channels.
|
WaveHeader |
setSampleRate(int sampleRate)
Set the sample rate.
|
java.lang.String |
toString() |
int |
write(java.io.OutputStream out)
Write a WAVE file header.
|
public static final short FORMAT_PCM
public static final short FORMAT_ALAW
public static final short FORMAT_ULAW
public WaveHeader()
public WaveHeader(short format, short numChannels, int sampleRate, short bitsPerSample, int numBytes)
format
- format of audio data,
one of FORMAT_PCM
, FORMAT_ULAW
, or FORMAT_ALAW
.numChannels
- 1 for mono, 2 for stereo.sampleRate
- typically 8000, 11025, 16000, 22050, or 44100 hz.bitsPerSample
- usually 16 for PCM, 8 for ULAW or 8 for ALAW.numBytes
- size of audio data after this header, in bytes.public short getFormat()
FORMAT_PCM
, FORMAT_ULAW
, or FORMAT_ALAW
.public WaveHeader setFormat(short format)
format
- one of FORMAT_PCM
, FORMAT_ULAW
, or FORMAT_ALAW
.public short getNumChannels()
public WaveHeader setNumChannels(short numChannels)
numChannels
- 1 for mono, 2 for stereo.public int getSampleRate()
public WaveHeader setSampleRate(int sampleRate)
sampleRate
- sample rate, typically 8000, 11025, 16000, 22050, or 44100 hz.public short getBitsPerSample()
public WaveHeader setBitsPerSample(short bitsPerSample)
bitsPerSample
- number of bits per sample,
usually 16 for PCM, 8 for ULAW or 8 for ALAW.public int getNumBytes()
public WaveHeader setNumBytes(int numBytes)
numBytes
- size of audio data after this header, in bytes.public int read(java.io.InputStream in) throws java.io.IOException
in
- InputStream
to read from.java.io.IOException
public int write(java.io.OutputStream out) throws java.io.IOException
out
- OutputStream
to receive the header.java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object