arduino-audio-tools
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ModulationBaseClass Class Reference

Class provides a wave table that can be populated with a number of preallocated waveforms. These can be used to generate audio in themselves or to modulate The parameters of another effect. Class initialised with sample rate. More...

#include <AudioEffectsSuite.h>

Inheritance diagram for ModulationBaseClass:
SimpleChorus

Public Member Functions

 ModulationBaseClass ()
 
 ModulationBaseClass (effectsuite_t extSampRate)
 
 ModulationBaseClass (ModulationBaseClass &copy)=default
 
 ~ModulationBaseClass ()=default
 
void clipWave (effectsuite_t amp)
 
bool isNoise ()
 
void printInterpTable ()
 
effectsuite_t readNoise ()
 
effectsuite_t readTable (effectsuite_t freq)
 
void setDC ()
 
bool setInterpTable ()
 
void setNoise ()
 
void setOffSine ()
 
void setRamp ()
 
void setSawtooth ()
 
void setSine ()
 
void setSquare ()
 
void setTriangle ()
 
void setupModulationBaseClass (effectsuite_t extSampRate)
 setup the class with a given sample rate. Basically reperforming the constructor More...
 

Public Attributes

int sampleRate
 
effectsuite_t tableIndex = 0
 
effectsuite_t timeStep
 
effectsuite_t * waveTable
 

Protected Member Functions

bool allocateMemory ()
 
effectsuite_t getInterpOut (effectsuite_t bufferIndex)
 
effectsuite_t getSplineOut (effectsuite_t bufferIndex, int freq)
 

Protected Attributes

effectsuite_t interpTable [order][res]
 
bool is_noise = false
 

Static Protected Attributes

static const int order = 4
 
static const int res = 100
 

Detailed Description

Class provides a wave table that can be populated with a number of preallocated waveforms. These can be used to generate audio in themselves or to modulate The parameters of another effect. Class initialised with sample rate.

Author
Matthew Hamilton

Constructor & Destructor Documentation

◆ ModulationBaseClass()

ModulationBaseClass ( )
inline

Constructor

◆ ~ModulationBaseClass()

~ModulationBaseClass ( )
default

Destructor

Member Function Documentation

◆ allocateMemory()

bool allocateMemory ( )
inlineprotected

allocate memory to internal wave table based on sample rate

Returns
returns true on success or false on failure

◆ clipWave()

void clipWave ( effectsuite_t  amp)
inline

clip wave table values with a tanh function. Effect change with a variable amp to control intensity.

Parameters
ampamount to multiply signal before being fed through a tanh function

◆ getInterpOut()

effectsuite_t getInterpOut ( effectsuite_t  bufferIndex)
inlineprotected

get the interpolated output of the waveTable from the given buffer index

Parameters
bufferIndexbuffer index as effectsuite_t
Returns
returns interpolated value from surrounding wavtable indices

◆ getSplineOut()

effectsuite_t getSplineOut ( effectsuite_t  bufferIndex,
int  freq 
)
inlineprotected

get a cubic spline interpolated out from the wave table

Derived from code by Alec Wright at repository: https://github.com/Alec-Wright/Chorus

Authors
Matthew Hamilton, Alec Wright
Parameters
bufferIndexthe required buffer index
freq(speed) that the table is being read through
Returns
returns interpolated value as effectsuite_t

◆ readNoise()

effectsuite_t readNoise ( )
inline

reads out white noise

Returns
random number between -1 and 1

◆ readTable()

effectsuite_t readTable ( effectsuite_t  freq)
inline

Read through values in waveTable as a given frequency

Parameters
freqread speed in Hz: essentially the number of samples jumped between reads
Returns
value from table as effectsuite_t

◆ setDC()

void setDC ( )
inline

sets wavetable to DC one

◆ setInterpTable()

bool setInterpTable ( )
inline

populates the internal interpolation table

Returns
return tru on success, else false

◆ setOffSine()

void setOffSine ( )
inline

sets wavetable to one period of a sine wave oscillating between 0 and 1

◆ setRamp()

void setRamp ( )
inline

set wave table to be a ramp from 0 to 1

◆ setSawtooth()

void setSawtooth ( )
inline

sets wavetable to one period of a sawtooth wave

◆ setSine()

void setSine ( )
inline

sets wavetable to one period of a sine wave oscillating between -1 and 1

◆ setSquare()

void setSquare ( )
inline

sets wavetable to one period of a square wave

◆ setTriangle()

void setTriangle ( )
inline

sets wavetable to one period of a triangle wave

◆ setupModulationBaseClass()

void setupModulationBaseClass ( effectsuite_t  extSampRate)
inline

setup the class with a given sample rate. Basically reperforming the constructor

Parameters
extSampRateExternal sample rate

Member Data Documentation

◆ sampleRate

int sampleRate

Internal Sample Rate

◆ tableIndex

effectsuite_t tableIndex = 0

current table read index

◆ timeStep

effectsuite_t timeStep

time between samples: 1/sampRate

◆ waveTable

effectsuite_t* waveTable

store modulation signal as


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