ofxPDSP
pdsp::WaveTable Class Reference

Utility class for storing and loading buffers of waveforms. More...

#include <WaveTable.h>

Public Member Functions

void setEmpty (int index)
 clears the table at the given index. More...
 
void setSample (int index, std::string path)
 sets the table at the given index to a sine waveform a waveform from a sample file located at path More...
 
void setAdditiveWave (int index, std::initializer_list< float > partials, bool harmonicScale=false)
 generate a waveform from an inlined list of partials. This function is not thread safe, avoid access to the given index while you set wave, More...
 
void setAdditiveWave (int index, const std::vector< float > &partials, bool harmonicScale=false)
 sets the table at the given index to a waveform from a given vector of partials. This function is not thread safe, avoid access to the given index while you set wave, More...
 
void setSawWave (int index, int partials)
 sets the table at the given index to a sine waveform a sawtooth waveform with the given number of of partials. This function is not thread safe, avoid access to the given index while you set wave, More...
 
void setSquareWave (int index, int partials)
 sets the table at the given index to a sine waveform a square waveform with the given number of of partials. This function is not thread safe, avoid access to the given index while you set wave, More...
 
void setTriangleWave (int index, int partials)
 sets the table at the given index to a sine waveform a triangle waveform with the given number of of partials. This function is not thread safe, avoid access to the given index while you set wave, More...
 
void setSineWave (int index)
 sets the table at the given index to a sine waveform. This function is not thread safe, avoid access to the given index while you set wave, More...
 
void addEmpty (int numberOfWavesToAdd=1)
 adds an empty waveform. This function reallocate all the internal pointers, never access the wavetable while you call it. More...
 
void addSample (std::string path)
 add a waveform from a sample file located at a given path. This function reallocate all the internal pointers, never access the wavetable while you call it. More...
 
void addAdditiveWave (std::initializer_list< float > partials, bool harmonicScale=false)
 generate a waveform from an inlined list of partials. This function reallocate all the internal pointers, never access the wavetable while you call it. More...
 
void addAdditiveWave (const std::vector< float > &partials, bool harmonicScale=false)
 generate a waveform from a given vector of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it. More...
 
void addSawWave (int partials)
 generate a sawtooth waveform with the given number of of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it. More...
 
void addSquareWave (int partials)
 generate a square waveform with the given number of of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it. More...
 
void addTriangleWave (int partials)
 generate a triangle waveform with the given number of of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it. More...
 
void addSineWave ()
 generate a sine waveform. This function reallocate all the internal pointers, NEVER access the wavetable while you call it.
 
float * table (int index)
 returns an handle to the buffer of the wave at the given index, avoid accessing the given index while you modify the wave values. More...
 
int tableLength () const
 returns the lenght of each wave buffer
 
void setup (int len, int maxPartials=64)
 sets the table length, and the maximum number of partial. More...
 
void initLength (int len)
 
int size () const
 returns the size of the wavetable
 
void setVerbose (bool verbose)
 enables logs for file loading
 

Friends

class WaveTableOsc
 

Detailed Description

Utility class for storing and loading buffers of waveforms.

Member Function Documentation

◆ addAdditiveWave() [1/2]

void pdsp::WaveTable::addAdditiveWave ( std::initializer_list< float >  partials,
bool  harmonicScale = false 
)

generate a waveform from an inlined list of partials. This function reallocate all the internal pointers, never access the wavetable while you call it.

Parameters
[in]partialsinlined array of partials
[in]harmonicScaleif true each value is multiplied by a saw wave corresponding partial

◆ addAdditiveWave() [2/2]

void pdsp::WaveTable::addAdditiveWave ( const std::vector< float > &  partials,
bool  harmonicScale = false 
)

generate a waveform from a given vector of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it.

Parameters
[in]harmonicScaleif true each value is multiplied by a saw wave corresponding partial

◆ addEmpty()

void pdsp::WaveTable::addEmpty ( int  numberOfWavesToAdd = 1)

adds an empty waveform. This function reallocate all the internal pointers, never access the wavetable while you call it.

Parameters
[in]numberOfWavesToAddnumber of empty waveforms to add. 1 if not given.

◆ addSample()

void pdsp::WaveTable::addSample ( std::string  path)

add a waveform from a sample file located at a given path. This function reallocate all the internal pointers, never access the wavetable while you call it.

Parameters
[in]pathabsolute or relative path to audio file

◆ addSawWave()

void pdsp::WaveTable::addSawWave ( int  partials)

generate a sawtooth waveform with the given number of of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it.

Parameters
[in]partialsnumber of partials

◆ addSquareWave()

void pdsp::WaveTable::addSquareWave ( int  partials)

generate a square waveform with the given number of of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it.

Parameters
[in]partialsnumber of partials

◆ addTriangleWave()

void pdsp::WaveTable::addTriangleWave ( int  partials)

generate a triangle waveform with the given number of of partials. This function reallocate all the internal pointers, NEVER access the wavetable while you call it.

Parameters
[in]partialsnumber of partials

◆ setAdditiveWave() [1/2]

void pdsp::WaveTable::setAdditiveWave ( int  index,
std::initializer_list< float >  partials,
bool  harmonicScale = false 
)

generate a waveform from an inlined list of partials. This function is not thread safe, avoid access to the given index while you set wave,

Parameters
[in]indexindex of the wavetable
[in]partialsinlined array of partials
[in]harmonicScaleif true each value is multiplied by a saw wave corresponding partial

◆ setAdditiveWave() [2/2]

void pdsp::WaveTable::setAdditiveWave ( int  index,
const std::vector< float > &  partials,
bool  harmonicScale = false 
)

sets the table at the given index to a waveform from a given vector of partials. This function is not thread safe, avoid access to the given index while you set wave,

Parameters
[in]indexindex of the wavetable
[in]partialsinlined array of partials
[in]harmonicScaleif true each value is multiplied by a saw wave corresponding partial

◆ setEmpty()

void pdsp::WaveTable::setEmpty ( int  index)

clears the table at the given index.

Parameters
[in]indexindex of the wavetable

◆ setSample()

void pdsp::WaveTable::setSample ( int  index,
std::string  path 
)

sets the table at the given index to a sine waveform a waveform from a sample file located at path

Parameters
[in]indexindex of the wavetable
[in]pathabsolute or relative path to audio file

◆ setSawWave()

void pdsp::WaveTable::setSawWave ( int  index,
int  partials 
)

sets the table at the given index to a sine waveform a sawtooth waveform with the given number of of partials. This function is not thread safe, avoid access to the given index while you set wave,

Parameters
[in]indexindex of the wavetable
[in]partialsnumber of partials

◆ setSineWave()

void pdsp::WaveTable::setSineWave ( int  index)

sets the table at the given index to a sine waveform. This function is not thread safe, avoid access to the given index while you set wave,

Parameters
[in]indexindex of the wavetable

◆ setSquareWave()

void pdsp::WaveTable::setSquareWave ( int  index,
int  partials 
)

sets the table at the given index to a sine waveform a square waveform with the given number of of partials. This function is not thread safe, avoid access to the given index while you set wave,

Parameters
[in]indexindex of the wavetable
[in]partialsnumber of partials

◆ setTriangleWave()

void pdsp::WaveTable::setTriangleWave ( int  index,
int  partials 
)

sets the table at the given index to a sine waveform a triangle waveform with the given number of of partials. This function is not thread safe, avoid access to the given index while you set wave,

Parameters
[in]indexindex of the wavetable
[in]partialsnumber of partials

◆ setup()

void pdsp::WaveTable::setup ( int  len,
int  maxPartials = 64 
)

sets the table length, and the maximum number of partial.

Parameters
[in]lenlength of each wave sample buffer
[in]maxPartialsmax number of partials available for the waves. 64 if not given.

It is called automatically if you add samples as first waves, maxPartial default is 64. Keeping the partial number low will use less memory, 128-256 is enough, the old Waldorf synths sounded good with just 64 partial waves.

◆ table()

float * pdsp::WaveTable::table ( int  index)

returns an handle to the buffer of the wave at the given index, avoid accessing the given index while you modify the wave values.

Parameters
[in]indexindex of the wavetable

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