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

A class that handles streaming encoding of the compressed .ogg audio format. More...

#include <omSoundFLACEncoder.h>

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

Public Member Functions

 FLACEncoder (DataOutputStream *outputStream, Size numChannels, SampleRate newSampleRate, const SoundFormatSettings &newFormatSettings=SoundFormatSettings())
 Create a .ogg stream encoder with the given number of channels, bitrate, and sample rate. More...
 
virtual ~FLACEncoder ()
 Destroy this .ogg 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 .ogg file encoder. More...
 
virtual Bool canSeek (Int64 relativeSampleOffset) const
 Return if this .ogg 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 .ogg encoder. More...
 
Double getLengthInSeconds () const
 Return the total length of sound in seconds that has been encoded by this .ogg encoder. More...
 
virtual Size getChannelCount () const
 Return the number of channels that are being written by the .ogg encoder. More...
 
virtual SampleRate getSampleRate () const
 Return the sample rate at which this .ogg encoder is encoding. More...
 
virtual SampleType getNativeSampleType () const
 Return the type of sample data that is being written by this .ogg encoder. More...
 
virtual Bool isValid () const
 Return whether or not this .ogg encoder is writing a valid FLAC 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 compressed .ogg audio format.

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

Constructor & Destructor Documentation

om::sound::io::FLACEncoder::FLACEncoder ( DataOutputStream outputStream,
Size  numChannels,
SampleRate  newSampleRate,
const SoundFormatSettings newFormatSettings = SoundFormatSettings() 
)

Create a .ogg stream encoder with the given number of channels, bitrate, and sample rate.

An encoder created by this constructor will write an .ogg file stream with the specified number of channels and bit rate. The constructor also allows the user to specify whether or not variable-bitrate encoding is used, the default is yes. The encoder 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::FLACEncoder::~FLACEncoder ( )
virtual

Destroy this .ogg encoder and release all associated resources.

Member Function Documentation

virtual void om::sound::io::FLACEncoder::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::FLACEncoder::canSeek ( ) const
virtual

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

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

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

Return if this .ogg 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::FLACEncoder::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::FLACEncoder::getLengthInSamples ( ) const
inline

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

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

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

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

Return the number of channels that are being written by the .ogg 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::FLACEncoder::getSampleRate ( ) const
virtual

Return the sample rate at which this .ogg 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::FLACEncoder::getNativeSampleType ( ) const
virtual

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

Since FLAC encodes data in frequency domain, this method always returns the type of SAMPLE_32F.

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

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

Return whether or not this .ogg encoder is writing a valid FLAC file.

This method can return FALSE, indicating the encoder cannot be used, and should be checked by the user to see if the chosen FLAC format is supported by the encoder. The encoder can also be invalid if the destination file or stream cannot be opened or is not valid.

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


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