arduino-audio-tools
Loading...
Searching...
No Matches
SimpleChorus< effectsuite_t > Class Template Reference

Simple Chorus effect with a single delay voice and mono output Chorus is effective between 15 and 20 miliseconds delay of original audio. Requires the sample rate when initialising. More...

#include <AudioEffectsSuite.h>

Inheritance diagram for SimpleChorus< effectsuite_t >:
DelayEffectBase< effectsuite_t_default > ModulationBaseClass< effectsuite_t_default > SimpleLPF< effectsuite_t_default > FilterEffectBase< effectsuite_t_default > EffectSuiteBase< effectsuite_t_default > AudioEffect

Public Member Functions

 SimpleChorus (int extSampleRate=44100)
 SimpleChorus (SimpleChorus &copy)=default
 ~SimpleChorus ()=default
virtual bool active ()
 determines if the effect is active
virtual bool active ()
 determines if the effect is active
virtual effectsuite_t_default applyFilter (effectsuite_t_default sampVal)
void clipWave (effectsuite_t_default amp)
SimpleChorus * clone () override
effectsuite_t_default envelope (effectsuite_t_default sample)
int id ()
 Allows to identify an effect.
int id ()
 Allows to identify an effect.
bool isNoise ()
void printInterpTable ()
virtual effect_t process (effect_t inputSample) override
 see applyFilter
virtual effectsuite_t_default processFloat (effectsuite_t_default inputSample) override
virtual effectsuite_t processFloat (effectsuite_t inputSample) override
effectsuite_t_default readNoise ()
effectsuite_t_default readTable (effectsuite_t_default freq)
virtual void setActive (bool value)
 sets the effect active/inactive
virtual void setActive (bool value)
 sets the effect active/inactive
void setBase (effectsuite_t baseAmount)
bool setChebyICoefficients (effectsuite_t_default cutFreqIn, bool shelfType, effectsuite_t_default rippleIn)
void setDC ()
void setId (int id)
 Allows to identify an effect.
void setId (int id)
 Allows to identify an effect.
bool setInterpTable ()
void setNoise ()
void setOffSine ()
void setRamp ()
void setSawtooth ()
void setSine ()
void setSquare ()
void setSwing (effectsuite_t swingAmount)
void setTriangle ()
void setupChorus (effectsuite_t extSampleRate)
void setupDelayEffectBase (const int bufferSizeSamples)
void setupModulationBaseClass (effectsuite_t_default extSampRate)
 setup the class with a given sample rate. Basically reperforming the constructor

Public Attributes

int sampleRate
effectsuite_t_default tableIndex
effectsuite_t_default timeStep
effectsuite_t_default * waveTable

Protected Member Functions

void allocateBufferMemory ()
bool allocateMemory ()
bool changeChebyICoefficients (effectsuite_t_default cutFreq, bool shelfType, effectsuite_t_default ripple, int poles)
void clearMemory ()
int16_t clip (int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)
 generic clipping method
int16_t clip (int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)
 generic clipping method
void copyParent (AudioEffect *copy)
void copyParent (AudioEffect *copy)
void delaySample (effectsuite_t_default inputSample)
effectsuite_t_default getInterpolatedOut (effectsuite_t_default bufferIndex)
effectsuite_t_default getInterpOut (effectsuite_t_default bufferIndex)
effectsuite_t getModSignal ()
effectsuite_t_default getSplineOut (effectsuite_t_default bufferIndex, int freq)
void incBufferIndex ()
void incDelayBuffReadIndex (effectsuite_t_default indexInc)
void incDelayBuffWriteIndex ()
effectsuite_t_default rms (effectsuite_t_default sample)
bool setDelayBuffer (int bufferSizeSamples)
void setDelayBuffReadIndex (effectsuite_t_default index)
void setRandLfo ()
bool setSimpleLpf (int order)
void storeSample (effectsuite_t_default inputSample)

Static Protected Member Functions

static effectsuite_t_default ** setInterpolationTable ()

Protected Attributes

bool active_flag
bool active_flag
effectsuite_t base
int bufferIndex
effectsuite_t_default currentDelayReadIndex
int currentDelayWriteIndex
effectsuite_t_default * delayBuffer
int delayTimeSamples
bool error
int filterOrder
float * firBuffer
float * firCoefficients
float * firTemp
int id_value
int id_value
float * iirBuffer
float * iirCoefficients
float * iirTemp
effectsuite_t_default interpTable [order][res]
bool is_noise
int maxDelayBufferSize
effectsuite_t modMax = .5
effectsuite_t modMin = .5
effectsuite_t modNorm = 1 / (modMax - modMin)
const effectsuite_t readSpeed = ((this->readNoise() + 1) * .5) * .0005
effectsuite_t_default * rmsBuffer
int rmsBufferIndex
const int rmsWindowSize
int samplingRate
effectsuite_t swing

Static Protected Attributes

static effectsuite_t_default ** interpolationTable
 Table of interpolation values as a 2D array indexed by interpolationTable[pointIndex][alphaIndex]. One instance per DelayEffectBase<effectsuite_t> instantiation (previously a single namespace-scope global shared – and type-mismatched – across every effectsuite_t choice).
static const int interpOrder
static const int interpResolution
static const int order
static const int res

Detailed Description

template<typename effectsuite_t = effectsuite_t_default>
class audio_tools::SimpleChorus< effectsuite_t >

Simple Chorus effect with a single delay voice and mono output Chorus is effective between 15 and 20 miliseconds delay of original audio. Requires the sample rate when initialising.

Author
Matthew Hamilton

Constructor & Destructor Documentation

◆ SimpleChorus() [1/2]

template<typename effectsuite_t = effectsuite_t_default>
SimpleChorus ( int extSampleRate = 44100)
inline

Constructor: initialises the effect parameters Since the class inherits DelayEffectBase it must set a delay buffer size when initialisi.

◆ SimpleChorus() [2/2]

template<typename effectsuite_t = effectsuite_t_default>
SimpleChorus ( SimpleChorus< effectsuite_t > & copy)
default

◆ ~SimpleChorus()

template<typename effectsuite_t = effectsuite_t_default>
~SimpleChorus ( )
default

Member Function Documentation

◆ active() [1/2]

virtual bool active ( )
inlinevirtualinherited

determines if the effect is active

◆ active() [2/2]

virtual bool active ( )
inlinevirtualinherited

determines if the effect is active

◆ allocateBufferMemory()

void allocateBufferMemory ( )
inlineprotectedinherited

will allocate memory to a buffer given the current filter order and set all values == 0.00

◆ allocateMemory()

bool allocateMemory ( )
inlineprotectedinherited

allocate memory to internal wave table based on sample rate

Returns
returns true on success or false on failure

◆ applyFilter()

virtual effectsuite_t_default applyFilter ( effectsuite_t_default sampVal)
inlinevirtualinherited

with the current filter coefficients this method filters a sample then stores it the sample Buffer and increments the index

Parameters
sampValis the sample to be processed
Returns
filtered audio sample

◆ changeChebyICoefficients()

bool changeChebyICoefficients ( effectsuite_t_default cutFreq,
bool shelfType,
effectsuite_t_default ripple,
int poles )
inlineprotectedinherited

set firCoefficients and iirCoefficients for required chebyshev type I filter sampleBuffer memory is also set @params cutFreq normalised cutoff frequency (0 < x < .5) @params shelfType bool filter shelf type, false = low pass, true = high pass @params ripple percentage ripple (<.2929) @params poles number of poles

Returns
boolean false on error and true on success

◆ clearMemory()

void clearMemory ( )
inlineprotectedinherited

checks internal memory storage of filter coeffcients and deletes if required

◆ clip() [1/2]

int16_t clip ( int32_t in,
int16_t clipLimit = 32767,
int16_t resultLimit = 32767 )
inlineprotectedinherited

generic clipping method

◆ clip() [2/2]

int16_t clip ( int32_t in,
int16_t clipLimit = 32767,
int16_t resultLimit = 32767 )
inlineprotectedinherited

generic clipping method

◆ clipWave()

void clipWave ( effectsuite_t_default amp)
inlineinherited

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

◆ clone()

template<typename effectsuite_t = effectsuite_t_default>
SimpleChorus * clone ( )
inlineoverridevirtual

Implements AudioEffect.

◆ copyParent() [1/2]

void copyParent ( AudioEffect * copy)
inlineprotectedinherited

◆ copyParent() [2/2]

void copyParent ( AudioEffect * copy)
inlineprotectedinherited

◆ delaySample()

void delaySample ( effectsuite_t_default inputSample)
inlineprotectedinherited

store input sample into the delay buffer and increment currentDelayWriteIndex for tracking when to loop back to start of buffer

Parameters
inputSamplesample to be stored for delay (effectsuite_t)

◆ envelope()

detect the envelop of an incoming signal

Parameters
samplethe incoming signal sample value
Returns
returns envelope dection signal sample value

◆ getInterpolatedOut()

effectsuite_t_default getInterpolatedOut ( effectsuite_t_default bufferIndex)
inlineprotectedinherited

get the value of the requested buffer index by interpolating other points

Parameters
bufferIndexThe required buffer index
Returns
interpolated output

◆ getInterpOut()

effectsuite_t_default getInterpOut ( effectsuite_t_default bufferIndex)
inlineprotectedinherited

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

◆ getModSignal()

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t getModSignal ( )
inlineprotected

modulation signal scaling equation: ((n - modMin)*modNorm*swing) + base modulates a random white noise signal by lowpass filtering then scaling to a range between 15 to 25 miliseconds of delay.

◆ getSplineOut()

effectsuite_t_default getSplineOut ( effectsuite_t_default bufferIndex,
int freq )
inlineprotectedinherited

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

◆ id() [1/2]

int id ( )
inlineinherited

Allows to identify an effect.

◆ id() [2/2]

int id ( )
inlineinherited

Allows to identify an effect.

◆ incBufferIndex()

void incBufferIndex ( )
inlineprotectedinherited

increment the buffer index and wrap it to the filter order

◆ incDelayBuffReadIndex()

void incDelayBuffReadIndex ( effectsuite_t_default indexInc)
inlineprotectedinherited

Increments the currentDelayBufferReadIndex by indexInc

Parameters
indexIncThe amount to increment the delay buffer index

◆ incDelayBuffWriteIndex()

void incDelayBuffWriteIndex ( )
inlineprotectedinherited

Increments the currentDelayWriteBufferIndex by 1

◆ isNoise()

bool isNoise ( )
inlineinherited

◆ printInterpTable()

void printInterpTable ( )
inlineinherited

◆ process()

virtual effect_t process ( effect_t inputSample)
inlineoverridevirtualinherited

see applyFilter

Reimplemented from EffectSuiteBase< effectsuite_t_default >.

Reimplemented in FilteredDelay< effectsuite_t >.

◆ processFloat() [1/2]

virtual effectsuite_t_default processFloat ( effectsuite_t_default inputSample)
inlineoverridevirtualinherited

◆ processFloat() [2/2]

template<typename effectsuite_t = effectsuite_t_default>
virtual effectsuite_t processFloat ( effectsuite_t inputSample)
inlineoverridevirtual

apply chorus effect to audio sample

Parameters
inputSampleinput audio sample
Returns
processed audio sample

◆ readNoise()

effectsuite_t_default readNoise ( )
inlineinherited

reads out white noise

Returns
random number between -1 and 1

◆ readTable()

effectsuite_t_default readTable ( effectsuite_t_default freq)
inlineinherited

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

◆ rms()

effectsuite_t_default rms ( effectsuite_t_default sample)
inlineprotectedinherited

root mean square of signal over a specific sample window

◆ setActive() [1/2]

virtual void setActive ( bool value)
inlinevirtualinherited

sets the effect active/inactive

◆ setActive() [2/2]

virtual void setActive ( bool value)
inlinevirtualinherited

sets the effect active/inactive

◆ setBase()

template<typename effectsuite_t = effectsuite_t_default>
void setBase ( effectsuite_t baseAmount)
inline

sets the 'base' of the chorus: the minimum delay in the signal.

Parameters
baseAmount<#baseAmount description#>

◆ setChebyICoefficients()

bool setChebyICoefficients ( effectsuite_t_default cutFreqIn,
bool shelfType,
effectsuite_t_default rippleIn )
inlineinherited

changes the current Chebyshev type 1 coefficients without altering the filter order. This allows for use in an audio process thread as it avoids dynamic allocation of memory. Filter sample and coefficient buffers are unaltered for initialising a chebyshev type 1 filter

See also
setChebyICoefficients @params cutFreq normalised cutoff frequency (0 < x < .5) @params shelfType bool Filters shelf type, false = low pass, true = high pass @params ripple percentage ripple (<.2929)
Returns
boolean false on error and true on success

◆ setDC()

void setDC ( )
inlineinherited

sets wavetable to DC one

◆ setDelayBuffer()

bool setDelayBuffer ( int bufferSizeSamples)
inlineprotectedinherited

Allocates memory for delay buffer and initialises all elements to 0

Parameters
bufferSizeSamplesthe size of delay buffer to be used
Returns
false and error description if there's a problem, or sets the internal delay buffer and returns true

◆ setDelayBuffReadIndex()

void setDelayBuffReadIndex ( effectsuite_t_default index)
inlineprotectedinherited

sets the currentDelayBufferReadIndex by indexInc (Currently no wrapping)

Parameters
indexthe read index index required

◆ setId() [1/2]

void setId ( int id)
inlineinherited

Allows to identify an effect.

◆ setId() [2/2]

void setId ( int id)
inlineinherited

Allows to identify an effect.

◆ setInterpolationTable()

effectsuite_t_default ** setInterpolationTable ( )
inlinestaticprotectedinherited

Sets the internal lagrange interpolation table. Ideally it should be shared amongst all

Returns
false and an error description if there's a problem, or sets the interpolation lookup table and returns true

◆ setInterpTable()

bool setInterpTable ( )
inlineinherited

populates the internal interpolation table

Returns
return tru on success, else false

◆ setNoise()

void setNoise ( )
inlineinherited

◆ setOffSine()

void setOffSine ( )
inlineinherited

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

◆ setRamp()

void setRamp ( )
inlineinherited

set wave table to be a ramp from 0 to 1

◆ setRandLfo()

template<typename effectsuite_t = effectsuite_t_default>
void setRandLfo ( )
inlineprotected

◆ setSawtooth()

void setSawtooth ( )
inlineinherited

sets wavetable to one period of a sawtooth wave

◆ setSimpleLpf()

bool setSimpleLpf ( int order)
inlineprotectedinherited

a simple normalised fir low pass filter @params order number of delay coefficients

◆ setSine()

void setSine ( )
inlineinherited

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

◆ setSquare()

void setSquare ( )
inlineinherited

sets wavetable to one period of a square wave

◆ setSwing()

template<typename effectsuite_t = effectsuite_t_default>
void setSwing ( effectsuite_t swingAmount)
inline

set the 'swing' of the chorus: The amount intensity of vibrato in the delay signal

Parameters
swingAmount<#swingAmount description#>

◆ setTriangle()

void setTriangle ( )
inlineinherited

sets wavetable to one period of a triangle wave

◆ setupChorus()

template<typename effectsuite_t = effectsuite_t_default>
void setupChorus ( effectsuite_t extSampleRate)
inline

set parameters and internal sample rate

Parameters
extSampleRateexternal sample rate

◆ setupDelayEffectBase()

void setupDelayEffectBase ( const int bufferSizeSamples)
inlineinherited

<Description#>

Parameters
bufferSizeSamples<#bufferSizeSamples description#>

◆ setupModulationBaseClass()

void setupModulationBaseClass ( effectsuite_t_default extSampRate)
inlineinherited

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

Parameters
extSampRateExternal sample rate

◆ storeSample()

void storeSample ( effectsuite_t_default inputSample)
inlineprotectedinherited

store input sample into the delay buffer

Parameters
inputSamplesample to be stored for delay (effectsuite_t)

Member Data Documentation

◆ active_flag [1/2]

bool active_flag
protectedinherited

◆ active_flag [2/2]

bool active_flag
protectedinherited

◆ base

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t base
protected

minimum delay in samples. Typically 10 milliseconds

◆ bufferIndex

int bufferIndex
protectedinherited

current buffer index

◆ currentDelayReadIndex

effectsuite_t_default currentDelayReadIndex
protectedinherited

◆ currentDelayWriteIndex

int currentDelayWriteIndex
protectedinherited

◆ delayBuffer

effectsuite_t_default* delayBuffer
protectedinherited

buffer to stored audio buffer for delay effects

◆ delayTimeSamples

int delayTimeSamples
protectedinherited

the delay time of signal in samples

◆ error

bool error
protectedinherited

internal class error boolean

◆ filterOrder

int filterOrder
protectedinherited

order of delay filter including the zero delay coefficients

◆ firBuffer

float* firBuffer
protectedinherited

buffer to hold forward delay sample data

◆ firCoefficients

float* firCoefficients
protectedinherited

Numerator coefficients in delay filter firCoefficients[0] z^0 coeffcieint firCoefficients[1] z^-1 coefficient

◆ firTemp

float* firTemp
protectedinherited

hold temporary values for fir coeffcient buffer

◆ id_value [1/2]

int id_value
protectedinherited

◆ id_value [2/2]

int id_value
protectedinherited

◆ iirBuffer

float* iirBuffer
protectedinherited

buffer to hold backward delay sample data

◆ iirCoefficients

float* iirCoefficients
protectedinherited

Denomiator coefficients in delay filter

See also
firCoefficients

◆ iirTemp

float* iirTemp
protectedinherited

hold temporary values for iir coeffcient buffer

◆ interpolationTable

effectsuite_t_default** interpolationTable
staticprotectedinherited

Table of interpolation values as a 2D array indexed by interpolationTable[pointIndex][alphaIndex]. One instance per DelayEffectBase<effectsuite_t> instantiation (previously a single namespace-scope global shared – and type-mismatched – across every effectsuite_t choice).

◆ interpOrder

const int interpOrder
staticprotectedinherited

◆ interpResolution

const int interpResolution
staticprotectedinherited

◆ interpTable

effectsuite_t_default interpTable[order][res]
protectedinherited

◆ is_noise

bool is_noise
protectedinherited

◆ maxDelayBufferSize

int maxDelayBufferSize
protectedinherited

Maximum number of samples that can be stored in delayBuffer

◆ modMax

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t modMax = .5
protected

the maximum value of the lowpassed random modulation signal

◆ modMin

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t modMin = .5
protected

the minimum value of the lowpassed random modulation signal

◆ modNorm

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t modNorm = 1 / (modMax - modMin)
protected

the normalising factor of the random delay signal

◆ order

const int order
staticprotectedinherited

◆ readSpeed

template<typename effectsuite_t = effectsuite_t_default>
const effectsuite_t readSpeed = ((this->readNoise() + 1) * .5) * .0005
protected

◆ res

const int res
staticprotectedinherited

◆ rmsBuffer

effectsuite_t_default* rmsBuffer
protectedinherited

RMS window buffer

◆ rmsBufferIndex

int rmsBufferIndex
protectedinherited

current write index of rmsBuffer

◆ rmsWindowSize

const int rmsWindowSize
protectedinherited

window size in samples of rms window

◆ sampleRate

int sampleRate
inherited

Internal Sample Rate

◆ samplingRate

int samplingRate
protectedinherited

◆ swing

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t swing
protected

swing range of delayed audio index in samples typical maximum swing would be 15 milliseconds (i.e. 0.015*sampleRate)

◆ tableIndex

effectsuite_t_default tableIndex
inherited

current table read index

◆ timeStep

effectsuite_t_default timeStep
inherited

time between samples: 1/sampRate

◆ waveTable

effectsuite_t_default* waveTable
inherited

store modulation signal as


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