|
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
Base class for all .wav stream decoders.
Details: A WaveStreamReader
reads and returns information, including format data and wave samples, from a RIFF-wave file. WaveStreamReader
is the abstract superclass of all wave decoders, such as PcmWaveFileReader
.
Field Summary | |
protected WaveFormatChunk |
fmt
Parsed format chunk. |
protected RiffStreamReader |
riff
Parses RIFF stream. |
Constructor Summary | |
protected |
WaveStreamReader(IRiffInput rais)
Sets wave stream source. |
Method Summary | |
void |
close()
Closes wave stream. |
int |
countChannels()
Returns number of channels. |
abstract long |
countSamples()
Returns number of samples. |
protected int |
findChunk(int from,
int tag)
Returns chunk reader by tag. |
abstract void |
freeSamples(long when,
int duration)
Releases samples from buffer. |
WaveAdtlChunkReader |
getAdtlChunkReader()
Returns ADTL chunk parser. |
abstract int |
getBitsPerChannelSample()
Returns number of bits per channel sample. |
abstract int |
getChannelSampleSize()
Returns size of individual channel sample. |
protected RiffChunkReader |
getChunkReader(int n)
Returns chunk reader by index. |
WaveCuePointList |
getCuePoints()
Parses cue points chunk. |
WaveFormatChunk |
getFormatChunk()
Returns format chunk. |
abstract java.lang.Object |
readSamples(long when,
java.lang.Object dest,
int dest_from,
int duration)
Reads and decodes samples. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected final RiffStreamReader riff
Details: This member is the RiffStreamReader
used by this WaveStreamReader
uses to parse the wave stream, which is a special type of RIFF stream.
protected WaveFormatChunk fmt
Details: fmt represents the parsed format chunk from this wave stream. This member must be set by the subclass, or some methods in this superclass which require access to the chunk will throw an exception.
Constructor Detail |
protected WaveStreamReader(IRiffInput rais) throws java.io.IOException
Details: This constructor sets the stream that this WaveStreamReader
will decode.
raise
- the streamMethod Detail |
protected RiffChunkReader getChunkReader(int n) throws java.io.IOException
Details: This method returns a RiffChunkReader
for the nth chunk in this wave stream (where the first chunk has index 0). Beware that if the requested chunk hasn't been reached yet, the RIFF source may be read until the chunk is found or until the EOS is reached. This may place a strain on the buffering mechanism of the underlying IRiffInput
. null
is returned if the chunk doesn't exist.
n
- the chunk numberprotected int findChunk(int from, int tag) throws java.io.IOException
Details: This method searchs, starting with the fromth chunk, for a chunk whose tag (chunk type identifier) is equal to tag. Beware that if the chunk being sought hasn't been reached yet, the RIFF source may be read until the chunk is found, or until the RIFF source has been exhausted, possibly placing a strain on the buffering mechanism of the underlying IRiffInput
. null
is returned if the chunk can't be found.
from
- the starting chunktag
- the chunk type identifierpublic WaveCuePointList getCuePoints() throws java.io.IOException
Details: This method (partially) parses the wave stream's cue point list, if there is one, and returns an object which can be used to query specific details from the list. If this wave stream has no cue point list, this method returns null
.
public WaveAdtlChunkReader getAdtlChunkReader() throws java.io.IOException
Details: This method returns a WaveAdtlChunkReader
, or an object capable of parsing this stream's ADTL (associated data list) chunk. The ADTL chunk can contain a wealth of information abou this stream's cue points. If this wave stream has no ADTL chunk, this method returns null
.
public WaveFormatChunk getFormatChunk()
Details: This method returns an object representing the parsed format chunk. The returned object is a mutable clone of the original.
public int countChannels()
Details: This method returns the number of audio channels represented by this wave stream. Typically, 1 indicates monoaural sound and 2 indicates stereo sound.
public abstract int getBitsPerChannelSample()
Details: This method returns the number of bits per sample per channel.
public abstract 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 abstract 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 abstract 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 void close() throws java.io.IOException
Details: This method closes the RIFF source that this WaveStreamReader
was processing. Calls to other methods in the class may fail after calling close
.
public abstract 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 |