Sharkysoft home

lava.riff.wave
Class PcmWaveFormatChunk

java.lang.Object
  |
  +--lava.riff.wave.WaveFormatChunk
        |
        +--lava.riff.wave.PcmWaveFormatChunk

public class PcmWaveFormatChunk
extends WaveFormatChunk

Format chunk for Microsoft PCM .wav files.

Details: A PcmWaveFormatChunk represents the format chunk of a RIFF-Wave file where the sample data is encoded using the Microsoft PCM format.


Field Summary
 short wBitsPerSample
          Number of bits per channel sample.
 
Fields inherited from class lava.riff.wave.WaveFormatChunk
dwAvgBytesPerSec, dwSamplesPerSec, wBlockAlign, wChannels, wFormatTag
 
Constructor Summary
PcmWaveFormatChunk(int channels, int bpcs, int rate)
          Sets sampling parameters.
 
Method Summary
 int getSampleSize()
          Computes bytes per sample.
 byte[] toBytes()
          Serializes chunk.
 java.lang.String toString()
          Serializes to string.
 
Methods inherited from class lava.riff.wave.WaveFormatChunk
clone, validateFields
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wBitsPerSample

public short wBitsPerSample
Number of bits per channel sample.

Details: This member reflects the wBitsPerSample field in a PCM format chunk, or the number of bits per channel sample. This is the number of bits used to sample a single channel, even if wChannels > 1. It is assumed that all channels have the same bits per channel sample.

Constructor Detail

PcmWaveFormatChunk

public PcmWaveFormatChunk(int channels,
                          int bpcs,
                          int rate)
Sets sampling parameters.

Details: This constructor sets the members of this format chunk to reflect the given sampling parameters, namely, the number of channels (channels), the bits per channel sample (bpcs), and the number of samples per second (rate).

Parameters:
channels - the number of channels
bits - per channel sample
sample - rate
Method Detail

getSampleSize

public final int getSampleSize()
Description copied from class: WaveFormatChunk
Computes bytes per sample.

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.

Overrides:
getSampleSize in class WaveFormatChunk
Tags copied from class: WaveFormatChunk
Returns:
number of bytes in full sample

toBytes

public byte[] toBytes()
Serializes chunk.

Details: toBytes serializes this chunk into a string of bytes, as it would appear in a .wav file.

Overrides:
toBytes in class WaveFormatChunk
Returns:
this chunk in byte array form

toString

public java.lang.String toString()
Description copied from class: WaveFormatChunk
Serializes to string.

Details: toString produces a string representation of this chunk. This representation is useful for debugging.

Overrides:
toString in class WaveFormatChunk
Tags copied from class: WaveFormatChunk
Returns:
string representation

Sharkysoft home