Loads and reads from an audio file source. More...
#include <Source.h>
Public Member Functions | |
virtual | ~SourceFile () |
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... | |
virtual SourceFileRef | cloneWithSampleRate (size_t sampleRate) const =0 |
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... | |
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... | |
virtual size_t | getNumChannels () const =0 |
Returns the number of channels. More... | |
virtual size_t | getSampleRateNative () const =0 |
Returns the true samplerate of the Source. 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... | |
virtual std::string | getMetaData () const |
Returns the metadata, if any, as a string. 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::string > | getSupportedExtensions () |
Returns a vector of extensions that SourceFile support for loading. Suitable for the extensions parameter of getOpenFilePath(). More... | |
Protected Member Functions | |
SourceFile (size_t sampleRate) | |
virtual void | performSeek (size_t readPositionFrames)=0 |
Implement to perform seek. readPositionFrames is in native file units. More... | |
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 size_t | performRead (Buffer *buffer, size_t bufferFrameOffset, size_t numFramesNeeded)=0 |
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::Converter > | mConverter |
BufferDynamic | mConverterReadBuffer |
Loads and reads from an audio file source.
|
virtual |
|
protected |
|
static |
Creates a new SourceFile from dataSource, with optional output samplerate. If sampleRate equals 0 the native file's samplerate is used.
|
overridevirtual |
Loads either as many frames as buffer can hold, or as many as there are left.
Implements cinder::audio::Source.
SourceFileRef cinder::audio::SourceFile::clone | ( | ) | const |
Returns a copy of this Source, with identical properties and pointing at the same data source.
|
pure virtual |
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.
Implemented in cinder::audio::cocoa::SourceFileCoreAudio, and cinder::audio::SourceFileOggVorbis.
BufferRef cinder::audio::SourceFile::loadBuffer | ( | ) |
Loads and returns the entire contents of this SourceFile.
void cinder::audio::SourceFile::seek | ( | size_t | readPositionFrames | ) |
Seek the read position to readPositionFrames.
void cinder::audio::SourceFile::seekToTime | ( | double | readPositionSeconds | ) |
Seek to read position readPositionSeconds.
size_t cinder::audio::SourceFile::getReadPosition | ( | ) | const |
Returns the current read position in frames.
double cinder::audio::SourceFile::getReadPositionSeconds | ( | ) | const |
Returns the current read position in seconds.
size_t cinder::audio::SourceFile::getNumFrames | ( | ) | const |
Returns the length in frames.
double cinder::audio::SourceFile::getNumSeconds | ( | ) | const |
Returns the length in seconds.
|
static |
Returns a vector of extensions that SourceFile support for loading. Suitable for the extensions parameter of getOpenFilePath().
|
protectedpure virtual |
Implement to perform seek. readPositionFrames is in native file units.
Implemented in cinder::audio::SourceFileOggVorbis.
|
protectedvirtual |
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.
|
inherited |
Returns the user facing samplerate (output).
|
pure virtualinherited |
Returns the number of channels.
Implemented in cinder::audio::cocoa::SourceFileCoreAudio, and cinder::audio::SourceFileOggVorbis.
|
pure virtualinherited |
Returns the true samplerate of the Source.
Implemented in cinder::audio::cocoa::SourceFileCoreAudio, and cinder::audio::SourceFileOggVorbis.
|
inherited |
Returns the maximum number of frames that can be read with one call to read().
|
virtualinherited |
Sets the maximum number of frames that can be read in one chunk.
|
virtualinherited |
Returns the metadata, if any, as a string.
Reimplemented in cinder::audio::SourceFileOggVorbis.
|
protectedpure virtualinherited |
Implement to perform read of frames into buffer starting at offset bufferFrameOffset
Implemented in cinder::audio::SourceFileOggVorbis.
|
protectedvirtualinherited |
Implementations should override and return true if they can provide samplerate conversion. If false (default), a Converter will be used if needed.
|
protectedinherited |
Allows implementations to set the output samplerate.
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |