ofxPDSP
pdsp::SampleBuffer Class Reference

Contains the data loaded from an audio file. More...

#include <SampleBuffer.h>

Public Member Functions

 SampleBuffer (const SampleBuffer &other)
 
SampleBufferoperator= (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
 

Detailed Description

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.

Member Function Documentation

◆ init()

void pdsp::SampleBuffer::init ( int  tableLen,
int  numTables = 1 
)

inits the SampleBuffer with an empty table (all the values set to 0.0f)

Parameters
[in]tableLensize of the table in samples
[in]numTablesnumber of tables to init

◆ load() [1/2]

void pdsp::SampleBuffer::load ( std::string  filePath)

loads the audio data from a file using libsndfile

Parameters
[in]filePathabsolute or relative path to audio file

◆ load() [2/2]

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)

Parameters
[in]interleavedBufferinterleaved buffer to load. Obviously if channels==1 the buffer is not interleaved
[in]sampleRatesample rate of the loaded file
[in]lengthlength of a single channel, NOT the lenght of the full interleaved buffer
[in]channelsnumber of channels interleaved in the buffer, if not specified 1

◆ setMonoChannel()

void pdsp::SampleBuffer::setMonoChannel ( int  monoChannelIndex)

some Units automatically select one channel if more than one are loaded. This set this default channel.

Parameters
[in]monoChannelIndex

◆ setVerbose()

void pdsp::SampleBuffer::setVerbose ( bool  verbose)

activate logging of file loading operations for this SampleBuffer

Parameters
[in]verbose

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