|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--lava.riff.wave.WaveStreamWriter
Base class for .wav file encoders.
Details: WaveStreamWriter
is the generic base class for wave file encoders. This class handles basic wave stream writing tasks that are common to all wave writers regardless of the encoding format.
Field Summary | |
protected RiffStreamWriter |
rsw
RIFF file generator. |
Constructor Summary | |
WaveStreamWriter(IRiffOutput raos,
WaveFormatChunk fmt_chunk)
Outputs format chunk. |
Method Summary | |
abstract void |
beginSamples(long duration)
Opens wave sample data chunk. |
abstract void |
close()
Closes stream. |
abstract void |
endSamples()
Closes wave data chunk. |
abstract void |
writeSamples(java.lang.Object samples,
int samples_from,
int duration)
Encodes and writes samples. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected RiffStreamWriter rsw
Details: rsw is the underlying RiffStreamWriter
used to generate this .wav file, which is a special kind of RIFF file.
Constructor Detail |
public WaveStreamWriter(IRiffOutput raos, WaveFormatChunk fmt_chunk) throws java.io.IOException
Details: This constructor opens a new RiffStreamWriter
and writes the given wave format chunk (fmt_chunk), in preparation for generating the rest of the .wav file.
raos
- the destination output streamfmt_chunk
- the format chunkMethod Detail |
public abstract void beginSamples(long duration) throws java.io.IOException
Details: beginSamples
prepares this WaveStreamWriter
to begin recording wave sample data. This method must be called before writeSamples
can be called.
If the number of (full) samples to be written is known ahead of time, that value should be provided in the duration parameter; otherwise, set this parameter to 0. Providing the duration value ahead of time allows the RIFF writer to complete the header that must appear before the sample data. Otherwise, the RIFF writer will need to seek backward in the file to complete the header after endSamples
is called, which can strain the underlying buffering mechanisms if the data isn't being written to a standard random access file.
duration
- number of samplespublic abstract void writeSamples(java.lang.Object samples, int samples_from, int duration) throws java.io.IOException
Details: writeSamples
writes the given samples (in samples) into the wave file's wave data chunk. The sample values are given in a sample array, which is described in the package header. If the sample resolution implied by the array's primitive type is not the sample resolution of this wave file (as set in the format chunk), this method will automatically convert the samples before writing them.
The first sample in the given array is taken from samples [samples_from]. Exactly duration * wChannels values are encoded and written to the stream, where wChannels is the number of channels as set in the format chunk.
samples
- sample arraysamples_from
- starting offset into arrayduration
- number of samples to processpublic abstract void endSamples() throws java.io.IOException
Details: Call endSamples
when there are no more wave samples to encode and write to the wave stream. Because this method causes the underlying RIFF stream generator to close the wave data chunk, no more samples can be written after this method is called.
public abstract void close() throws java.io.IOException
Details: This method closes all open chunks in the wave stream and completes the stream. The close method of the underlying RiffStreamWriter is also called, which in turn calls the close method of its underlying IRiffOutput.
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |