arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
audio_tools::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 audio_tools::ModulationBaseClass:
audio_tools::SimpleChorus

Public Member Functions

 ModulationBaseClass ()
 
 ModulationBaseClass (effectsuite_t extSampRate)
 
 ModulationBaseClass (ModulationBaseClass &copy)=default
 
 ~ModulationBaseClass ()=default
 
void clipWave (effectsuite_t amp)
 
void printInterpTable ()
 
effectsuite_t readNoise ()
 
effectsuite_t readTable (effectsuite_t freq)
 
void setDC ()
 
bool setInterpTable ()
 
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]
 

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()

audio_tools::ModulationBaseClass::ModulationBaseClass ( )
inline

Constructor

◆ ~ModulationBaseClass()

audio_tools::ModulationBaseClass::~ModulationBaseClass ( )
default

Destructor

Member Function Documentation

◆ allocateMemory()

bool audio_tools::ModulationBaseClass::allocateMemory ( )
inlineprotected

allocate memory to internal wave table based on sample rate

Returns
returns true on success or false on failure

◆ clipWave()

void audio_tools::ModulationBaseClass::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 audio_tools::ModulationBaseClass::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 audio_tools::ModulationBaseClass::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 audio_tools::ModulationBaseClass::readNoise ( )
inline

reads out white noise

Returns
random number between -1 and 1

◆ readTable()

effectsuite_t audio_tools::ModulationBaseClass::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 audio_tools::ModulationBaseClass::setDC ( )
inline

sets wavetable to DC one

◆ setInterpTable()

bool audio_tools::ModulationBaseClass::setInterpTable ( )
inline

populates the internal interpolation table

Returns
return tru on success, else false

◆ setOffSine()

void audio_tools::ModulationBaseClass::setOffSine ( )
inline

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

◆ setRamp()

void audio_tools::ModulationBaseClass::setRamp ( )
inline

set wave table to be a ramp from 0 to 1

◆ setSawtooth()

void audio_tools::ModulationBaseClass::setSawtooth ( )
inline

sets wavetable to one period of a sawtooth wave

◆ setSine()

void audio_tools::ModulationBaseClass::setSine ( )
inline

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

◆ setSquare()

void audio_tools::ModulationBaseClass::setSquare ( )
inline

sets wavetable to one period of a square wave

◆ setTriangle()

void audio_tools::ModulationBaseClass::setTriangle ( )
inline

sets wavetable to one period of a triangle wave

◆ setupModulationBaseClass()

void audio_tools::ModulationBaseClass::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 audio_tools::ModulationBaseClass::sampleRate

Internal Sample Rate

◆ tableIndex

effectsuite_t audio_tools::ModulationBaseClass::tableIndex = 0

current table read index

◆ timeStep

effectsuite_t audio_tools::ModulationBaseClass::timeStep

time between samples: 1/sampRate

◆ waveTable

effectsuite_t* audio_tools::ModulationBaseClass::waveTable

store modulation signal as


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