|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.riff.wave.WaveStreamReader | +--lava.riff.wave.PcmWaveStreamReader
Reads standard Microsoft PCM .wav file.
Details: This class parses a standard, uncompressed .wav file whose sample data is encoded in the Microsoft Pulse Code Modulation (PCM) format. This is the format most commonly used for .wav files.
Fields inherited from class lava.riff.wave.WaveStreamReader |
fmt,
riff |
Constructor Summary | |
PcmWaveStreamReader(IRiffInput rais)
Sets input source. |
Method Summary | |
long |
countSamples()
Returns number of samples. |
void |
freeSamples(long when,
int duration)
Releases samples from buffer. |
int |
getBitsPerChannelSample()
Returns number of bits per channel sample. |
int |
getChannelSampleSize()
Returns size of individual channel sample. |
java.lang.Object |
readSamples(long when,
java.lang.Object dest,
int dest_from,
int duration)
Reads and decodes samples. |
Methods inherited from class lava.riff.wave.WaveStreamReader |
close,
countChannels,
findChunk,
getAdtlChunkReader,
getChunkReader,
getCuePoints,
getFormatChunk |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Constructor Detail |
public PcmWaveStreamReader(IRiffInput rais) throws java.io.IOException
Details: This constructor sets the .wav file input source (rais) and parses the format chunk.
rais
- the input sourceMethod Detail |
public int getBitsPerChannelSample()
Details: This method returns the number of bits per sample per channel.
public long countSamples() throws java.io.IOException
Details: This method returns the number of samples contained in this wave stream. This value devided by the sample rate is the duration of the sound.
public java.lang.Object readSamples(long when, java.lang.Object dest, int dest_from, int duration) throws java.io.IOException
Details: This method reads sample data from the source file and returns the samples in a sample array. Exactly amount samples are read, beginning with the whenth sample in the sample stream (where 0 is the index of the first sample). The samples are copied into the given array (dest). If that array is not the correct type for the sample resolution of this wave stream, the samples are automatically converted to the resolution required by the array. (See the package header for more details.)
If dest is null
, an array of the most natural type for this stream is automatically created, and its length is set just large enough to accomodate the request. The new sample array is then treated exactly as if it had been provided as the original dest parameter.
The first sample written into dest is written into dest [dest_from]. Exactly duration * wChannels values are decoded and written into the array, where wChannels is the number of channels as set in the format chunk.
when
- sample positiondest
- destination arraydest_from
- starting index in destination arrayduration
- number of samples to readpublic void freeSamples(long when, int duration) throws java.io.IOException
Details: This method informs this wave stream reader that the client will no longer requires access to the given range of samples. Calling this method allows this implementation to send buffering hints to the underlying .wav file input source, which may be buffering the data stream.
when
- beginning sample indexduration
- number of samples to releaseIRiffInput.free(long, long)
public int getChannelSampleSize() throws java.io.IOException
Details: getChannelSampleSize
returns the size of the data type used by readSamples
to store a single channel sample. The value returned by this method indicates the type of array most naturally preferred by this instance in calls to readSamples
.
channel sample size | value returned | array type |
---|---|---|
1-8 bits | 1 | byte |
9-16 bits | 2 | short |
17-32 bits | 4 | int |
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |