![]() |
pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
|
Audio file reader. More...
Inherits SmartPointerContainer< SmartPointerType, enableWeak >.
Public Member Functions | |
AudioFileReader () throw () | |
Creates a null object. | |
AudioFileReader (Text const &path) throw () | |
Creates an audio file reader from the given path. | |
AudioFileReader (const char *path) throw () | |
Creates an audio file reader from the given path. | |
AudioFileReader (FilePath const &path) throw () | |
Creates an audio file reader from the given path. | |
AudioFileReader (const char *path, const int bufferSize, AudioFileMetaDataIOFlags const &metaDataIOFlags) throw () | |
Creates an audio file reader from the given path. | |
AudioFileReader (const char *path, const int bufferSize, UnsignedInt const &metaDataIOFlags) throw () | |
Creates an audio file reader from the given path. | |
AudioFileReader (FilePathArray const &paths, const AudioFile::MultiFileTypes multiMode=AudioFile::MultiFileArraySequenceLoop, const int bufferSize=0) throw () | |
Creates a multiple audio file reader from the given paths. | |
AudioFileReader (FilePathArray const &paths, IntVariable const &nextIndex, const int bufferSize=0) throw () | |
Creates a multiple audio file reader from the given paths. | |
AudioFileReader (AudioFileReader const ©) throw () | |
Copy constructor. | |
AudioFileReader & | operator= (AudioFileReader const &other) throw () |
Assignment operator. | |
AudioFile::Format | getFormat () const throw () |
Get the format of the audio file. | |
AudioFile::Encoding | getEncoding () const throw () |
Get the encoding of the audio file. | |
AudioFile::SampleType | getSampleType () const throw () |
Get the sample type of the audio file. | |
int | getBitsPerSample () const throw () |
Get the number of bits used per sample in the file. | |
int | getBytesPerFrame () const throw () |
Get the number of bytes in each frame of the file. | |
int | getBytesPerSample () const throw () |
Get the number of bytes in each sample of the file. | |
int | getNumChannels () const throw () |
Get the number of channels in the file. | |
void | setDefaultNumChannels (const int numChannels) throw () |
Set the default number of channels in the file. | |
int | getDefaultNumChannels () const throw () |
Get the default number of channels in the file. | |
double | getSampleRate () const throw () |
Get the sample rate of the file. | |
LongLong | getNumFrames () const throw () |
Get the total number of frames in the file. | |
LongLong | getFramePosition () const throw () |
Get the current frame position. | |
void | setFramePosition (const LongLong position) throw () |
Set the frame position to a particular frame. | |
void | setFramePositionOnNextRead (const LongLong position) throw () |
Set the frame position to a particular frame just before the next read operation. | |
void | resetFramePosition () throw () |
Resets the frame position back to the start of the frames. | |
template<class SampleType > | |
void | readFrames (NumericalArray< SampleType > &data, IntVariable &numLoops) throw () |
Read frames into a pre-allocated NumericalArray and apply scaling. | |
template<class SampleType > | |
void | readFramesDirect (NumericalArray< SampleType > &data, IntVariable &numLoops) throw () |
Read frames into a pre-allocated NumericalArray without scaling. | |
template<class SampleType > | |
void | initSignal (SignalBase< SampleType > &signal, const int numFrames=0) const throw () |
Initialises a Signal object in the appropriate format for the audio in the file. | |
template<class SampleType > | |
void | readSignal (SignalBase< SampleType > &signal) throw () |
Read frames into a pre-allocated Signal object and apply scaling. | |
template<class SampleType > | |
void | readSignalDirect (SignalBase< SampleType > &signal) throw () |
Read frames into a pre-allocated Signal object without scaling. | |
template<class SampleType > | |
NumericalArray< SampleType > | readAllFrames (const bool applyScaling) throw () |
Reads all the frames in the file and returns them in an interleaved array. | |
template<class SampleType > | |
operator NumericalArray< SampleType > () throw () | |
Reads all the frames in the file and returns them in an interleaved array. | |
template<class SampleType > | |
operator SignalBase< SampleType > () throw () | |
Reads all the frames in the file and returns them in Signal object. | |
template<class SampleType > | |
SignalBase< SampleType > | getOtherSignal () throw () |
Reads all the frames in the file and returns them in Signal object. | |
SignalBase< PLONK_TYPE_DEFAULT > | getSignal () throw () |
Reads all the frames in the file and returns them in Signal object. | |
bool | isReady () const throw () |
Determines whether the audio data is ready to be read. | |
Static Public Member Functions | |
static AudioFileReader | fromWeak (Weak const &weak) throw () |
Get a weakly linked copy of this object. |
Audio file reader.
This can read audio frames from WAV, AIFF, AIFC or (with the appropriately enabled compile time options), Ogg Vorbis or Opus files.
AudioFileReader::AudioFileReader | ( | ) | throw () [inline] |
Creates a null object.
Use open to open a file.
AudioFileReader::AudioFileReader | ( | Text const & | path | ) | throw () [inline] |
Creates an audio file reader from the given path.
The default buffer size is used given by AudioFile::DefaultBufferSize (32768).
path | The path of the file to read. |
AudioFileReader::AudioFileReader | ( | const char * | path | ) | throw () [inline] |
Creates an audio file reader from the given path.
The default buffer size is used given by AudioFile::DefaultBufferSize (32768).
path | The path of the file to read. |
AudioFileReader::AudioFileReader | ( | FilePath const & | path | ) | throw () [inline] |
Creates an audio file reader from the given path.
The default buffer size is used given by AudioFile::DefaultBufferSize (32768).
path | The path of the file to read. |
AudioFileReader::AudioFileReader | ( | const char * | path, |
const int | bufferSize, | ||
AudioFileMetaDataIOFlags const & | metaDataIOFlags | ||
) | throw () [inline] |
Creates an audio file reader from the given path.
path | The path of the file to read. |
bufferSize | The buffer size to use when reading. |
AudioFileReader::AudioFileReader | ( | const char * | path, |
const int | bufferSize, | ||
UnsignedInt const & | metaDataIOFlags | ||
) | throw () [inline] |
Creates an audio file reader from the given path.
path | The path of the file to read. |
bufferSize | The buffer size to use when reading. |
AudioFileReader::AudioFileReader | ( | FilePathArray const & | paths, |
const AudioFile::MultiFileTypes | multiMode = AudioFile::MultiFileArraySequenceLoop , |
||
const int | bufferSize = 0 |
||
) | throw () [inline] |
Creates a multiple audio file reader from the given paths.
paths | The paths of the files to read. |
bufferSize | The buffer size to use when reading. |
AudioFileReader::AudioFileReader | ( | FilePathArray const & | paths, |
IntVariable const & | nextIndex, | ||
const int | bufferSize = 0 |
||
) | throw () [inline] |
Creates a multiple audio file reader from the given paths.
paths | The paths of the files to read. |
bufferSize | The buffer size to use when reading. |
AudioFileReader::AudioFileReader | ( | AudioFileReader const & | copy | ) | throw () [inline] |
Copy constructor.
Note that a deep copy is not made, the copy will refer to exactly the same data.
static AudioFileReader AudioFileReader::fromWeak | ( | Weak const & | weak | ) | throw () [inline, static] |
Get a weakly linked copy of this object.
This will return a blank/empty/null object of this type if the original has already been deleted.
int AudioFileReader::getBitsPerSample | ( | ) | const throw () [inline] |
Get the number of bits used per sample in the file.
int AudioFileReader::getBytesPerFrame | ( | ) | const throw () [inline] |
Get the number of bytes in each frame of the file.
int AudioFileReader::getBytesPerSample | ( | ) | const throw () [inline] |
Get the number of bytes in each sample of the file.
int AudioFileReader::getDefaultNumChannels | ( | ) | const throw () [inline] |
Get the default number of channels in the file.
AudioFile::Encoding AudioFileReader::getEncoding | ( | ) | const throw () [inline] |
Get the encoding of the audio file.
i.e., PCM (integer), floating point, whether big or little endian See AudioFile::Encoding the available types.
AudioFile::Format AudioFileReader::getFormat | ( | ) | const throw () [inline] |
Get the format of the audio file.
i.e., WAV, AIFF etc See AudioFile::Format the available types.
LongLong AudioFileReader::getFramePosition | ( | ) | const throw () [inline] |
Get the current frame position.
int AudioFileReader::getNumChannels | ( | ) | const throw () [inline] |
Get the number of channels in the file.
LongLong AudioFileReader::getNumFrames | ( | ) | const throw () [inline] |
Get the total number of frames in the file.
SignalBase<SampleType> AudioFileReader::getOtherSignal | ( | ) | throw () [inline] |
Reads all the frames in the file and returns them in Signal object.
double AudioFileReader::getSampleRate | ( | ) | const throw () [inline] |
Get the sample rate of the file.
AudioFile::SampleType AudioFileReader::getSampleType | ( | ) | const throw () [inline] |
Get the sample type of the audio file.
i.e., Char (8-bit), Short (16-bit) etc See AudioFile::SampleType the available types.
SignalBase<PLONK_TYPE_DEFAULT> AudioFileReader::getSignal | ( | ) | throw () [inline] |
Reads all the frames in the file and returns them in Signal object.
void AudioFileReader::initSignal | ( | SignalBase< SampleType > & | signal, |
const int | numFrames = 0 |
||
) | const throw () [inline] |
Initialises a Signal object in the appropriate format for the audio in the file.
signal | The Signal object to initialise. |
numFrames | The number of frames the Signal should store. |
bool AudioFileReader::isReady | ( | ) | const throw () [inline] |
Determines whether the audio data is ready to be read.
This should return true if the file open and header read operations succeeded.
AudioFileReader::operator NumericalArray< SampleType > | ( | ) | throw () [inline] |
Reads all the frames in the file and returns them in an interleaved array.
AudioFileReader::operator SignalBase< SampleType > | ( | ) | throw () [inline] |
Reads all the frames in the file and returns them in Signal object.
AudioFileReader& AudioFileReader::operator= | ( | AudioFileReader const & | other | ) | throw () [inline] |
Assignment operator.
NumericalArray<SampleType> AudioFileReader::readAllFrames | ( | const bool | applyScaling | ) | throw () [inline] |
Reads all the frames in the file and returns them in an interleaved array.
Here the samples can be automatically scaled depending on the destination data type.
applyScaling |
void AudioFileReader::readFrames | ( | NumericalArray< SampleType > & | data, |
IntVariable & | numLoops | ||
) | throw () [inline] |
Read frames into a pre-allocated NumericalArray and apply scaling.
Here the samples are automatically scaled depending on the destination data type of the NumericalArray.
data | The NumericalArray object to read interleaved frames into. |
numLoops | How many loops to read, 0 means infinite loops. |
void AudioFileReader::readFramesDirect | ( | NumericalArray< SampleType > & | data, |
IntVariable & | numLoops | ||
) | throw () [inline] |
Read frames into a pre-allocated NumericalArray without scaling.
data | The NumericalArray object to read interleaved frames into. |
numLoops | How many loops to read, 0 means infinite loops. |
true
if the array was resized as fewer samples were available, otherwise false
. void AudioFileReader::readSignal | ( | SignalBase< SampleType > & | signal | ) | throw () [inline] |
Read frames into a pre-allocated Signal object and apply scaling.
The Signal object MUST be an interleaved type. Here the samples are automatically scaled depending on the destination data type of the Signal.
signal | The Signal object to read frames into. |
void AudioFileReader::readSignalDirect | ( | SignalBase< SampleType > & | signal | ) | throw () [inline] |
Read frames into a pre-allocated Signal object without scaling.
The Signal object MUST be an interleaved type.
signal | The Signal object to read frames into. |
void AudioFileReader::resetFramePosition | ( | ) | throw () [inline] |
Resets the frame position back to the start of the frames.
void AudioFileReader::setDefaultNumChannels | ( | const int | numChannels | ) | throw () [inline] |
Set the default number of channels in the file.
This can be used to suggest a maximum number of channels especially where this file is a multi-audiofile.
void AudioFileReader::setFramePosition | ( | const LongLong | position | ) | throw () [inline] |
Set the frame position to a particular frame.
This is not thread safe, use setFramePositionOnNextRead() to call this from another thread (e.g., a GUI) while playing a file (e.g., in real time).
void AudioFileReader::setFramePositionOnNextRead | ( | const LongLong | position | ) | throw () [inline] |
Set the frame position to a particular frame just before the next read operation.
This is thread safe.