Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cinder::audio::SourceFileOggVorbis Class Reference

SourceFile implementation for decoding ogg vorbis files. More...

#include <FileOggVorbis.h>

Inheritance diagram for cinder::audio::SourceFileOggVorbis:
[legend]

Public Member Functions

 SourceFileOggVorbis ()
 
 SourceFileOggVorbis (const DataSourceRef &dataSource, size_t sampleRate)
 
virtual ~SourceFileOggVorbis ()
 
SourceFileRef cloneWithSampleRate (size_t sampleRate) const override
 Returns an copy of this Source with all properties identical except the sampleRate. This is useful if the SourceFile must match a samplerate that was unknown when it was first constructed. More...
 
size_t getNumChannels () const override
 Returns the number of channels. More...
 
size_t getSampleRateNative () const override
 Returns the true samplerate of the Source. More...
 
size_t performRead (Buffer *buffer, size_t bufferFrameOffset, size_t numFramesNeeded) override
 
void performSeek (size_t readPositionFrames) override
 Implement to perform seek. readPositionFrames is in native file units. More...
 
std::string getMetaData () const override
 Returns the metadata, if any, as a string. More...
 
size_t read (Buffer *buffer) override
 Loads either as many frames as buffer can hold, or as many as there are left. More...
 
SourceFileRef clone () const
 Returns a copy of this Source, with identical properties and pointing at the same data source. More...
 
BufferRef loadBuffer ()
 Loads and returns the entire contents of this SourceFile. More...
 
void seek (size_t readPositionFrames)
 Seek the read position to readPositionFrames. More...
 
void seekToTime (double readPositionSeconds)
 Seek to read position readPositionSeconds. More...
 
size_t getReadPosition () const
 Returns the current read position in frames. More...
 
double getReadPositionSeconds () const
 Returns the current read position in seconds. More...
 
size_t getNumFrames () const
 Returns the length in frames. More...
 
double getNumSeconds () const
 Returns the length in seconds. More...
 
size_t getSampleRate () const
 Returns the user facing samplerate (output). More...
 
size_t getMaxFramesPerRead () const
 Returns the maximum number of frames that can be read with one call to read(). More...
 
virtual void setMaxFramesPerRead (size_t count)
 Sets the maximum number of frames that can be read in one chunk. More...
 

Static Public Member Functions

static std::unique_ptr
< SourceFile
create (const DataSourceRef &dataSource, size_t sampleRate=0)
 Creates a new SourceFile from dataSource, with optional output samplerate. If sampleRate equals 0 the native file's samplerate is used. More...
 
static std::vector< std::stringgetSupportedExtensions ()
 Returns a vector of extensions that SourceFile support for loading. Suitable for the extensions parameter of getOpenFilePath(). More...
 

Protected Member Functions

virtual void setupSampleRateConversion ()
 Sets up samplerate conversion if needed. Can be overridden by implementation if they handle samplerate conversion in a specific way, else it is handled generically with a dsp::Converter. More...
 
virtual bool supportsConversion ()
 Implementations should override and return true if they can provide samplerate conversion. If false (default), a Converter will be used if needed. More...
 
void setSampleRate (size_t sampleRate)
 Allows implementations to set the output samplerate. More...
 

Protected Attributes

size_t mNumFrames
 
size_t mFileNumFrames
 
size_t mReadPos
 
std::unique_ptr< dsp::ConvertermConverter
 
BufferDynamic mConverterReadBuffer
 

Detailed Description

SourceFile implementation for decoding ogg vorbis files.

Constructor & Destructor Documentation

cinder::audio::SourceFileOggVorbis::SourceFileOggVorbis ( )
cinder::audio::SourceFileOggVorbis::SourceFileOggVorbis ( const DataSourceRef dataSource,
size_t  sampleRate 
)
cinder::audio::SourceFileOggVorbis::~SourceFileOggVorbis ( )
virtual

Member Function Documentation

SourceFileRef cinder::audio::SourceFileOggVorbis::cloneWithSampleRate ( size_t  sampleRate) const
overridevirtual

Returns an copy of this Source with all properties identical except the sampleRate. This is useful if the SourceFile must match a samplerate that was unknown when it was first constructed.

Implements cinder::audio::SourceFile.

size_t cinder::audio::SourceFileOggVorbis::getNumChannels ( ) const
overridevirtual

Returns the number of channels.

Implements cinder::audio::Source.

size_t cinder::audio::SourceFileOggVorbis::getSampleRateNative ( ) const
overridevirtual

Returns the true samplerate of the Source.

Note
Actual output samplerate may differ.
See also
getSampleRate()

Implements cinder::audio::Source.

size_t cinder::audio::SourceFileOggVorbis::performRead ( Buffer buffer,
size_t  bufferFrameOffset,
size_t  numFramesNeeded 
)
overridevirtual

Implement to perform read of frames into buffer starting at offset bufferFrameOffset

Returns
the actual number of frames read.

Implements cinder::audio::Source.

void cinder::audio::SourceFileOggVorbis::performSeek ( size_t  readPositionFrames)
overridevirtual

Implement to perform seek. readPositionFrames is in native file units.

Implements cinder::audio::SourceFile.

string cinder::audio::SourceFileOggVorbis::getMetaData ( ) const
overridevirtual

Returns the metadata, if any, as a string.

Reimplemented from cinder::audio::Source.

unique_ptr< SourceFile > cinder::audio::SourceFile::create ( const DataSourceRef dataSource,
size_t  sampleRate = 0 
)
staticinherited

Creates a new SourceFile from dataSource, with optional output samplerate. If sampleRate equals 0 the native file's samplerate is used.

size_t cinder::audio::SourceFile::read ( Buffer buffer)
overridevirtualinherited

Loads either as many frames as buffer can hold, or as many as there are left.

Returns
number of frames read into buffer.

Implements cinder::audio::Source.

SourceFileRef cinder::audio::SourceFile::clone ( ) const
inherited

Returns a copy of this Source, with identical properties and pointing at the same data source.

BufferRef cinder::audio::SourceFile::loadBuffer ( )
inherited

Loads and returns the entire contents of this SourceFile.

Returns
a BufferRef containing the file contents.
void cinder::audio::SourceFile::seek ( size_t  readPositionFrames)
inherited

Seek the read position to readPositionFrames.

void cinder::audio::SourceFile::seekToTime ( double  readPositionSeconds)
inherited

Seek to read position readPositionSeconds.

size_t cinder::audio::SourceFile::getReadPosition ( ) const
inherited

Returns the current read position in frames.

double cinder::audio::SourceFile::getReadPositionSeconds ( ) const
inherited

Returns the current read position in seconds.

size_t cinder::audio::SourceFile::getNumFrames ( ) const
inherited

Returns the length in frames.

double cinder::audio::SourceFile::getNumSeconds ( ) const
inherited

Returns the length in seconds.

vector< std::string > cinder::audio::SourceFile::getSupportedExtensions ( )
staticinherited

Returns a vector of extensions that SourceFile support for loading. Suitable for the extensions parameter of getOpenFilePath().

void cinder::audio::SourceFile::setupSampleRateConversion ( )
protectedvirtualinherited

Sets up samplerate conversion if needed. Can be overridden by implementation if they handle samplerate conversion in a specific way, else it is handled generically with a dsp::Converter.

size_t cinder::audio::Source::getSampleRate ( ) const
inherited

Returns the user facing samplerate (output).

size_t cinder::audio::Source::getMaxFramesPerRead ( ) const
inherited

Returns the maximum number of frames that can be read with one call to read().

virtual void cinder::audio::Source::setMaxFramesPerRead ( size_t  count)
virtualinherited

Sets the maximum number of frames that can be read in one chunk.

virtual bool cinder::audio::Source::supportsConversion ( )
protectedvirtualinherited

Implementations should override and return true if they can provide samplerate conversion. If false (default), a Converter will be used if needed.

void cinder::audio::Source::setSampleRate ( size_t  sampleRate)
protectedinherited

Allows implementations to set the output samplerate.

Member Data Documentation

size_t cinder::audio::SourceFile::mNumFrames
protectedinherited
size_t cinder::audio::SourceFile::mFileNumFrames
protectedinherited
size_t cinder::audio::SourceFile::mReadPos
protectedinherited
std::unique_ptr<dsp::Converter> cinder::audio::Source::mConverter
protectedinherited
BufferDynamic cinder::audio::Source::mConverterReadBuffer
protectedinherited

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