|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.riff.wave.WaveFormatChunk
Base format chunk.
Details: A WaveFormatChunk
represents the mandatory portion of a wave format ('fmt') chunk in a RIFF-WAVE file. All RIFF-WAVE format chunks begin with the fields represented in this class, and then continue with their own, format-windows.h
" notation):
struct { WORD wFormatTag; // Format category WORD wChannels; // Number of channels DWORD dwSamplesPerSec; // Sampling rate DWORD dwAvgBytesPerSec; // For buffer estimation WORD wBlockAlign; // Data block size }
Field Summary | |
int |
dwAvgBytesPerSec
Average bytes per second. |
int |
dwSamplesPerSec
Full sample rate. |
short |
wBlockAlign
Block alignment. |
short |
wChannels
Number of channels. |
short |
wFormatTag
Indicates encoding format. |
Constructor Summary | |
protected |
WaveFormatChunk()
Default constructor. |
protected |
WaveFormatChunk(RiffChunkReader rcr)
Initializes from open chunk. |
Method Summary | |
java.lang.Object |
clone()
Replicates instance. |
abstract int |
getSampleSize()
Computes bytes per sample. |
byte[] |
toBytes()
Serializes to bytes. |
java.lang.String |
toString()
Serializes to string. |
protected void |
validateFields()
Validates members. |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public short wFormatTag
Details: This member is a magic value that indicates the encoding format use for the wave file. Some possible values include:
WAVE_FORMAT_PCM | 0x0001 | Microsoft Pulse Code Modulation (PCM) |
IBM_FORMAT_MULAW | 0x0101 | IBM mu-law format |
IBM_FORMAT_ALAW | 0x0102 | IBM a-law format |
IBM_FORMAT_ADPCM | 0x0103 | IBM AVC Adaptive Differential Pulse Code Modulation format |
The value of this field also determines the presence of additional fields following the wBlockAlign
field.
public short wChannels
Details: This member indicates the number of channels represented in the waveform data, i.e., 1 for mono, 2 for stereo, etc.
public int dwSamplesPerSec
Details: This member indicates the number of samples per second, or the number of times per second each individual channel is sampled.
public int dwAvgBytesPerSec
Details: This member indicates the average number of bytes per second at which the waveform data will need to be processed. Playback and recording software can use this estimate when setting up buffers.
public short wBlockAlign
Details: This member indicates the block alignment (in bytes) of the waveform data. Playback software will need to process data blocks of this size. This value can be used to ensure buffer alignment.
Constructor Detail |
protected WaveFormatChunk()
Details: This constructor initializes all members to 0.
protected WaveFormatChunk(RiffChunkReader rcr) throws java.io.IOException
Details: This constructor initializes the members of this WaveFormatChunk
with values read from the given RIFF chunk. It is convenient to use this constructor when parsing wave format chunks.
the
- RIFF chunk to process as a WaveFormatChunkMethod Detail |
protected void validateFields() throws lava.io.FileFormatException
Details: This method verifies that the values of this format chunk's fields actually make sense. If they do not, a FileFormatException
is thrown.
public abstract int getSampleSize()
Details: This method returns the number of bytes per sample. :
Details: getSampleSize
returns the number of bytes required to contain a single, full sample. The value is determined by considering the number of bits per channel sample and the number of channels, as follows:
bits per channel sample | mono | stereo |
---|---|---|
1-8 | 1 byte | 2 bytes |
9-16 | 2 byte | 4 bytes |
17-24 | 3 byte | 6 bytes |
25-32 | 4 byte | 8 bytes |
These values are calculated without allowing bits from different channel samples to be packed into the same byte.
public byte[] toBytes()
Details: toBytes
serializes this chunk into a string of bytes, as it would appear in a .wav file.
public java.lang.String toString()
Details: toString
produces a string representation of this chunk. This representation is useful for debugging.
public final java.lang.Object clone()
Details: This method returns a perfect replica of this instance.
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |