Sharkysoft home

lava.riff.wave
Class PcmWaveStreamWriter

java.lang.Object
  |
  +--lava.riff.wave.WaveStreamWriter
        |
        +--lava.riff.wave.PcmWaveStreamWriter

public class PcmWaveStreamWriter
extends WaveStreamWriter

Writes standard Microsoft PCM wave files.

Details: No details available.

Since:
1999
Version:
1999

Fields inherited from class lava.riff.wave.WaveStreamWriter
rsw
 
Constructor Summary
PcmWaveStreamWriter(IRiffOutput raos, PcmWaveFormatChunk fmt)
           
 
Method Summary
 void beginSamples(long duration)
          Opens wave sample data chunk.
 void close()
          Closes stream.
 void endSamples()
          Closes wave data chunk.
 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
 

Constructor Detail

PcmWaveStreamWriter

public PcmWaveStreamWriter(IRiffOutput raos,
                           PcmWaveFormatChunk fmt)
                    throws java.io.IOException
Method Detail

beginSamples

public void beginSamples(long duration)
                  throws java.io.IOException
Description copied from class: WaveStreamWriter
Opens wave sample data chunk.

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.

Overrides:
beginSamples in class WaveStreamWriter
Tags copied from class: WaveStreamWriter
Parameters:
duration - number of samples
Throws:
java.io.IOException - if an I/O error occurs

writeSamples

public void writeSamples(java.lang.Object samples,
                         int samples_from,
                         int duration)
                  throws java.io.IOException
Description copied from class: WaveStreamWriter
Encodes and writes samples.

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.

Overrides:
writeSamples in class WaveStreamWriter
Tags copied from class: WaveStreamWriter
Parameters:
samples - sample array
samples_from - starting offset into array
duration - number of samples to process
Throws:
java.io.IOException - if an I/O error occurs

endSamples

public void endSamples()
                throws java.io.IOException
Description copied from class: WaveStreamWriter
Closes wave data chunk.

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.

Overrides:
endSamples in class WaveStreamWriter
Tags copied from class: WaveStreamWriter
Throws:
java.io.IOException - if an I/O error occurs

close

public void close()
           throws java.io.IOException
Description copied from class: WaveStreamWriter
Closes stream.

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.

Overrides:
close in class WaveStreamWriter
Tags copied from class: WaveStreamWriter
Throws:
java.io.IOException - if an I/O error occurs

Sharkysoft home