Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | List of all members
om::sound::io::WaveEncoder Class Reference

A class that handles streaming encoding of the PCM WAVE audio format. More...

#include <omSoundWaveEncoder.h>

Inheritance diagram for om::sound::io::WaveEncoder:
om::sound::base::SoundOutputStream

Public Member Functions

 WaveEncoder (DataOutputStream *outputStream, Size numChannels, SampleType newSampleType=SampleType::SAMPLE_16)
 Create a .wav stream encoder with the given number of channels and sample type. More...
 
 WaveEncoder (DataOutputStream *outputStream, Size numChannels, SampleType newSampleType, SampleRate newSampleRate)
 Create a .wav stream encoder with the given number of channels, sample type, and sample rate. More...
 
virtual ~WaveEncoder ()
 Destroy this wave encoder and release all associated resources. More...
 
virtual void flush ()
 Flush all pending sound data to be encoded to the encoder's data output stream. More...
 
virtual Bool canSeek () const
 Return whether or not seeking is allowed by this wave file encoder. More...
 
virtual Bool canSeek (Int64 relativeSampleOffset) const
 Return if this wave encoder's current position can be moved by the specified signed sample offset. More...
 
virtual Int64 seek (Int64 relativeSampleOffset)
 Move the current sample frame position of the encoder by the specified signed amount. More...
 
SoundSize getLengthInSamples () const
 Return the total number of samples that have been encoded by this wave encoder. More...
 
Double getLengthInSeconds () const
 Return the total length of sound in seconds that has been encoded by this wave encoder. More...
 
virtual Size getChannelCount () const
 Return the number of channels that are being written by the wave encoder. More...
 
virtual SampleRate getSampleRate () const
 Return the sample rate at which this wave encoder is encoding. More...
 
virtual SampleType getNativeSampleType () const
 Return the type of sample data that is being written by this wave encoder. More...
 
virtual Bool isValid () const
 Return whether or not this wave encoder is writing a valid WAVE file. More...
 
- Public Member Functions inherited from om::sound::base::SoundOutputStream
virtual ~SoundOutputStream ()
 Destroy this sound output stream and release any resources associated with it. More...
 
SoundResult write (const SoundBuffer &buffer, Size numSamples)
 Write the specified number of samples from a sound buffer to the output stream. More...
 

Additional Inherited Members

Detailed Description

A class that handles streaming encoding of the PCM WAVE audio format.

This class uses an abstract data stream for output, allowing it to encode .WAV data to a file, network destination, or other destination.

Constructor & Destructor Documentation

om::sound::io::WaveEncoder::WaveEncoder ( DataOutputStream outputStream,
Size  numChannels,
SampleType  newSampleType = SampleType::SAMPLE_16 
)

Create a .wav stream encoder with the given number of channels and sample type.

An encoder created by this constructor will write a .wav file with the specified number of channels and sample type. The default sample type is a 16-bit signed integer sample type. The encoder automatically detects the sample rate of the first incoming buffer of audio and uses that sample rate for the entire wave file.

om::sound::io::WaveEncoder::WaveEncoder ( DataOutputStream outputStream,
Size  numChannels,
SampleType  newSampleType,
SampleRate  newSampleRate 
)

Create a .wav stream encoder with the given number of channels, sample type, and sample rate.

An encoder created by this constructor will write a .wav file stream with the specified number of channels and sample type. The default sample type is a 16-bit signed integer sample type. The encoder automatically uses the specified sample rate for all incoming audio, automatically sample rate converting any audio that doesn't match the output sample rate.

virtual om::sound::io::WaveEncoder::~WaveEncoder ( )
virtual

Destroy this wave encoder and release all associated resources.

Member Function Documentation

virtual void om::sound::io::WaveEncoder::flush ( )
virtual

Flush all pending sound data to be encoded to the encoder's data output stream.

Implements om::sound::base::SoundOutputStream.

virtual Bool om::sound::io::WaveEncoder::canSeek ( ) const
virtual

Return whether or not seeking is allowed by this wave file encoder.

Reimplemented from om::sound::base::SoundOutputStream.

virtual Bool om::sound::io::WaveEncoder::canSeek ( Int64  relativeSampleOffset) const
virtual

Return if this wave encoder's current position can be moved by the specified signed sample offset.

This sample offset is specified as the number of sample frames to move in the stream - a frame is equal to one sample for each channel in the stream.

Reimplemented from om::sound::base::SoundOutputStream.

virtual Int64 om::sound::io::WaveEncoder::seek ( Int64  relativeSampleOffset)
virtual

Move the current sample frame position of the encoder by the specified signed amount.

This method attempts to seek the position of the encoder by the specified amount. The method returns the signed amount that the position in the stream was changed by. Thus, if seeking is not allowed, 0 is returned. Otherwise, the stream should seek as far as possible in the specified direction and return the actual change in position.

Reimplemented from om::sound::base::SoundOutputStream.

SoundSize om::sound::io::WaveEncoder::getLengthInSamples ( ) const
inline

Return the total number of samples that have been encoded by this wave encoder.

Double om::sound::io::WaveEncoder::getLengthInSeconds ( ) const
inline

Return the total length of sound in seconds that has been encoded by this wave encoder.

virtual Size om::sound::io::WaveEncoder::getChannelCount ( ) const
virtual

Return the number of channels that are being written by the wave encoder.

This is the number of channels that should be provided to the write() method. If less than this number of channels is provided, silence is written for the other channels. Superfluous channels are ignored.

This value is set in a constructor of the encoder and once set, is read-only.

Implements om::sound::base::SoundOutputStream.

virtual SampleRate om::sound::io::WaveEncoder::getSampleRate ( ) const
virtual

Return the sample rate at which this wave encoder is encoding.

This is the sample rate to which all incoming sound data is converted to before being written to the output stream. The output sample rate can be set in the encoder's constructor. After contruction, the sample rate is read-only and cannot be changed. If not set during construction, the encoder can automatically auto-detect the sample rate of the first buffer of output audio and use that sample rate thenceforth. In that case, this method will return a sample rate of 0 until the incoming sample rate is detected.

Implements om::sound::base::SoundOutputStream.

virtual SampleType om::sound::io::WaveEncoder::getNativeSampleType ( ) const
virtual

Return the type of sample data that is being written by this wave encoder.

This sample type is set when the encoder is first created but is read-only after construction. The default sample type is 16-bit signed integer samples.

Implements om::sound::base::SoundOutputStream.

virtual Bool om::sound::io::WaveEncoder::isValid ( ) const
inlinevirtual

Return whether or not this wave encoder is writing a valid WAVE file.

Implements om::sound::base::SoundOutputStream.


The documentation for this class was generated from the following file: