ofxPDSP
|
Contains the data loaded from an audio file. More...
#include <SampleBuffer.h>
Public Member Functions | |
SampleBuffer (const SampleBuffer &other) | |
SampleBuffer & | operator= (const SampleBuffer &other) |
void | load (std::string filePath) |
loads the audio data from a file using libsndfile More... | |
void | load (float *interleavedBuffer, double sampleRate, int length, int channels=1) |
loads the audio data from a given interleaved float array (or from a single non interleaved channel) More... | |
void | unLoad () |
unload the data from the buffer and free the allocated memory | |
bool | loaded () |
returns true if data has been loaded into the SampleBuffer | |
void | init (int tableLen, int numTables=1) |
inits the SampleBuffer with an empty table (all the values set to 0.0f) More... | |
void | normalize () |
scales all the sample values of all the channels so that the absolute maximum value is 1.0f | |
void | setMonoChannel (int monoChannelIndex) |
some Units automatically select one channel if more than one are loaded. This set this default channel. More... | |
void | setVerbose (bool verbose) |
activate logging of file loading operations for this SampleBuffer More... | |
Public Attributes | |
std::string | filePath |
path of loaded file, or contains diagnostic strings if a file is not loaded | |
float ** | buffer |
multidimensional buffer, use it like this: buffer[channel][sample] | |
int | channels |
number of channels | |
int | mono |
index of channel to select for mono operation | |
int | length |
length of each buffer | |
double | fileSampleRate |
sample rate of the loaded channels | |
Contains the data loaded from an audio file.
This is a class that contains data loaded from an audio file (or created in any other way). It is used by units that require samples like Sampler, FDLConvolver or TableOsc. On Windows it uses libsndfile to load audio file from path so if you want to use it you have to link libsndfile to your project, go in flags.h and uncomment #define PDSP_USE_LIBSNDFILE. You also use any method you have on you platform for getting an interleaved or a mono array of floats and load it with load( float* interleavedBuffer, double sampleRate, int length, int channels=1 ). You can also use init() to initialize an empty table and manually fill it with your data.
void pdsp::SampleBuffer::init | ( | int | tableLen, |
int | numTables = 1 |
||
) |
inits the SampleBuffer with an empty table (all the values set to 0.0f)
[in] | tableLen | size of the table in samples |
[in] | numTables | number of tables to init |
void pdsp::SampleBuffer::load | ( | std::string | filePath | ) |
loads the audio data from a file using libsndfile
[in] | filePath | absolute or relative path to audio file |
void pdsp::SampleBuffer::load | ( | float * | interleavedBuffer, |
double | sampleRate, | ||
int | length, | ||
int | channels = 1 |
||
) |
loads the audio data from a given interleaved float array (or from a single non interleaved channel)
[in] | interleavedBuffer | interleaved buffer to load. Obviously if channels==1 the buffer is not interleaved |
[in] | sampleRate | sample rate of the loaded file |
[in] | length | length of a single channel, NOT the lenght of the full interleaved buffer |
[in] | channels | number of channels interleaved in the buffer, if not specified 1 |
void pdsp::SampleBuffer::setMonoChannel | ( | int | monoChannelIndex | ) |
some Units automatically select one channel if more than one are loaded. This set this default channel.
[in] | monoChannelIndex |
void pdsp::SampleBuffer::setVerbose | ( | bool | verbose | ) |
activate logging of file loading operations for this SampleBuffer
[in] | verbose |