Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Protected Member Functions | List of all members
om::sound::base::SoundOutputStream Class Referenceabstract

A class that abstracts a write-only destination of sound samples. More...

#include <omSoundOutputStream.h>

Inheritance diagram for om::sound::base::SoundOutputStream:
om::sound::io::AIFFEncoder om::sound::io::FLACEncoder om::sound::io::OggEncoder om::sound::io::WaveEncoder

Public Member Functions

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...
 
virtual void flush ()=0
 Flush the sound output stream, sending all internally buffered samples to the destination. More...
 
virtual Bool canSeek () const
 Return whether or not seeking is allowed in this output stream. More...
 
virtual Bool canSeek (Int64 relativeSampleOffset) const
 Return whether or not this output stream's current position can be moved by the specified signed sample offset. More...
 
virtual Int64 seek (Int64 relativeSampleOffset)
 Move the current sample frame position in the stream by the specified signed amount. More...
 
virtual Size getChannelCount () const =0
 Return the number of channels that are being written by the sound output stream. More...
 
virtual SampleRate getSampleRate () const =0
 Return the sample rate of the sound output stream's destination audio data. More...
 
virtual SampleType getNativeSampleType () const =0
 Return the actual sample type used in the stream. More...
 
virtual Bool isValid () const =0
 Return whether or not the stream has a valid destination for sound data. More...
 

Protected Member Functions

virtual SoundResult writeSamples (const SoundBuffer &outputBuffer, Size numSamples)=0
 Write the specified number of samples from the output buffer to the output stream. More...
 

Detailed Description

A class that abstracts a write-only destination of sound samples.

This class serves as an interface for things like sound file output, streaming output, etc. Writing to a SoundOutputStream is very similar to writing to a file.

Constructor & Destructor Documentation

virtual om::sound::base::SoundOutputStream::~SoundOutputStream ( )
virtual

Destroy this sound output stream and release any resources associated with it.

Member Function Documentation

SoundResult om::sound::base::SoundOutputStream::write ( const SoundBuffer buffer,
Size  numSamples 
)
inline

Write the specified number of samples from a sound buffer to the output stream.

This method attempts to write the specified number of samples to the stream from the buffer. It then returns the total number of valid samples which were written to the output stream. The current write position in the stream is advanced by the number of samples that are written.

virtual void om::sound::base::SoundOutputStream::flush ( )
pure virtual

Flush the sound output stream, sending all internally buffered samples to the destination.

This method causes all currently pending output audio data to be sent to it's final destination. This method blocks the current thread until it ensures that this is done and that all internal data buffers are emptied if they have any contents.

Implemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual Bool om::sound::base::SoundOutputStream::canSeek ( ) const
virtual

Return whether or not seeking is allowed in this output stream.

The defaut implementation returns FALSE, disabling seeking. Override the function to allow seeking of input streams.

Reimplemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual Bool om::sound::base::SoundOutputStream::canSeek ( Int64  relativeSampleOffset) const
virtual

Return whether or not this output stream'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.

The defaut implementation returns FALSE, disabling seeking. Override the function to allow seeking of input streams.

Reimplemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual Int64 om::sound::base::SoundOutputStream::seek ( Int64  relativeSampleOffset)
virtual

Move the current sample frame position in the stream by the specified signed amount.

This method attempts to seek the position in the stream 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.

The defaut implementation returns FALSE, disabling seeking. Override the function to allow seeking of input streams.

Reimplemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual Size om::sound::base::SoundOutputStream::getChannelCount ( ) const
pure virtual

Return the number of channels that are being written by the sound output stream.

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.

Implemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual SampleRate om::sound::base::SoundOutputStream::getSampleRate ( ) const
pure virtual

Return the sample rate of the sound output stream's destination audio data.

This is the sampling rate at which the output stream is writing its audio data. The user should call this method to determine the output sample rate and provide all of the output sample data in that sampling rate. If sample data with a different sampling rate is provided, it is converted to the destination sample rate if deemed necessary by the output stream.

Implemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual SampleType om::sound::base::SoundOutputStream::getNativeSampleType ( ) const
pure virtual

Return the actual sample type used in the stream.

This is the format of the stream's destination data. For instance, a file might be encoded with 8-bit, 16-bit or 24-bit samples. This value indicates that sample type. For formats that don't have a native sample type, such as those which use frequency domain encoding, this function should return SampleType::SAMPLE_32F, indicating that the stream's native format is undefined and can use 32-bit floating point samples.

Implemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual Bool om::sound::base::SoundOutputStream::isValid ( ) const
pure virtual

Return whether or not the stream has a valid destination for sound data.

This method should return TRUE if everything is OK, but might return FALSE if the data output stream is not valid (file not found, etc) or if the input data has improper format.

Implemented in om::sound::io::AIFFEncoder, om::sound::io::WaveEncoder, om::sound::io::FLACEncoder, and om::sound::io::OggEncoder.

virtual SoundResult om::sound::base::SoundOutputStream::writeSamples ( const SoundBuffer outputBuffer,
Size  numSamples 
)
protectedpure virtual

Write the specified number of samples from the output buffer to the output stream.

This method attempts to write the specified number of samples to the stream from the output buffer. It then returns the total number of valid samples which were written to the output stream. The current write position in the stream is advanced by the number of samples that are written.


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