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

Simple Delay effect consiting of a single tap delay with Effect Gain and feed back controls Constructor requires internal delay in samples. More...

#include <AudioEffectsSuite.h>

Inheritance diagram for SimpleDelay< effectsuite_t >:
DelayEffectBase< effectsuite_t_default > EffectSuiteBase< effectsuite_t_default > AudioEffect

Public Member Functions

 SimpleDelay (int maxDelayInSamples=8810, int samplingRate=44100)
 SimpleDelay (SimpleDelay &copy)=default
 ~SimpleDelay ()=default
virtual bool active ()
 determines if the effect is active
SimpleDelay * clone () override
int id ()
 Allows to identify an effect.
effect_t process (effect_t inputSample) override
effectsuite_t processFloat (effectsuite_t inputSample) override
virtual void setActive (bool value)
 sets the effect active/inactive
void setDelayGain (effectsuite_t gain)
void setDelayTime (effectsuite_t delayInSamples)
void setDelayTransitionTime (effectsuite_t seconds)
void setFeedbackGain (effectsuite_t gain)
void setId (int id)
 Allows to identify an effect.
void setupDelayEffectBase (const int bufferSizeSamples)
void setupSimpleDelay (int delayInSamples)

Protected Member Functions

void capGain (effectsuite_t &gain)
int16_t clip (int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)
 generic clipping method
void copyParent (AudioEffect *copy)
void delaySample (effectsuite_t_default inputSample)
effectsuite_t_default getInterpolatedOut (effectsuite_t_default bufferIndex)
effectsuite_t getSplineOut (effectsuite_t bufferIndex)
void incDelayBuffReadIndex (effectsuite_t_default indexInc)
void incDelayBuffWriteIndex ()
bool setDelayBuffer (int bufferSizeSamples)
void setDelayBuffReadIndex (effectsuite_t_default index)
void storeSample (effectsuite_t_default inputSample)

Static Protected Member Functions

static effectsuite_t_default ** setInterpolationTable ()

Protected Attributes

bool active_flag
int count = 0
effectsuite_t_default currentDelayReadIndex
effectsuite_t currentDelaySamples
int currentDelayWriteIndex
effectsuite_t_default * delayBuffer
effectsuite_t delayGain = .707
effectsuite_t delayIncrement
bool delayTimeChanged = false
int delayTimeSamples
effectsuite_t delayTransitionTime
effectsuite_t delayTransitionTimeInSamples
bool error
effectsuite_t feedbackGain = 0.
int id_value
effectsuite_t invDelayIncrement
int maxDelayBufferSize
effectsuite_t readHeadIndex
int sampleRate
effectsuite_t targetDelaySamples
unsigned int writeHeadIndex

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

Detailed Description

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

Simple Delay effect consiting of a single tap delay with Effect Gain and feed back controls Constructor requires internal delay in samples.

See also
process
Author
Matthew Hamilton

Constructor & Destructor Documentation

◆ SimpleDelay() [1/2]

template<typename effectsuite_t = effectsuite_t_default>
SimpleDelay ( int maxDelayInSamples = 8810,
int samplingRate = 44100 )
inline

Constructor: DigitalEffect Base Must Be initialised

Parameters
delayInSamplesSet the amount of delay in samples
See also
DelayEffectBase constructor

◆ SimpleDelay() [2/2]

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

◆ ~SimpleDelay()

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

Destructor.

Member Function Documentation

◆ active()

virtual bool active ( )
inlinevirtualinherited

determines if the effect is active

◆ capGain()

template<typename effectsuite_t = effectsuite_t_default>
void capGain ( effectsuite_t & gain)
inlineprotected

capGain: caps gain to a range of 1 and -1;

Parameters
gainaddress of gain value

◆ clip()

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

generic clipping method

◆ clone()

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

Implements AudioEffect.

◆ copyParent()

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)

◆ 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

◆ getSplineOut()

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t getSplineOut ( effectsuite_t bufferIndex)
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
Returns
returns interpolated value as effectsuite_t

◆ id()

int id ( )
inlineinherited

Allows to identify an effect.

◆ 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

◆ process()

template<typename effectsuite_t = effectsuite_t_default>
effect_t process ( effect_t inputSample)
inlineoverridevirtual

Main process block for applying audio effect

Parameters
inputSampleThe int16_t input audio sample for the effect to be applied to
Returns
an audio sample as a int16_t with effect applied

Reimplemented from EffectSuiteBase< effectsuite_t_default >.

◆ processFloat()

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t processFloat ( effectsuite_t inputSample)
inlineoverride

Apply delay and return input sample along with delay buffer signal

Parameters
inputSample<#inputSample description#>
Returns
<#return value description#>

◆ setActive()

virtual void setActive ( bool value)
inlinevirtualinherited

sets the effect active/inactive

◆ 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

◆ setDelayGain()

template<typename effectsuite_t = effectsuite_t_default>
void setDelayGain ( effectsuite_t gain)
inline

setDelayGain: sets the delay gain to a value between 1 and -1

Parameters
gainrequired delay gain. Values beyond 1 and -1 are capped to the maximum to avoid idiocy. Negative velus invoke a phase inversion.
See also
setFeedbackGain

◆ setDelayTime()

template<typename effectsuite_t = effectsuite_t_default>
void setDelayTime ( effectsuite_t delayInSamples)
inline

<Description#>

Parameters
delayInSample<#delayInSample description#>

◆ setDelayTransitionTime()

template<typename effectsuite_t = effectsuite_t_default>
void setDelayTransitionTime ( effectsuite_t seconds)
inline

<Description#>

Parameters
seconds<#seconds description#>

◆ setFeedbackGain()

template<typename effectsuite_t = effectsuite_t_default>
void setFeedbackGain ( effectsuite_t gain)
inline

setDelayGain: sets the feedback gain to a value between 1 and -1

Parameters
gainrequired delay gain. Values beyond 1 and -1 are capped to the maximum to avoid idiocy. Negative velus invoke a phase inversion.
See also
setDelayGain

◆ setId()

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

◆ setupDelayEffectBase()

void setupDelayEffectBase ( const int bufferSizeSamples)
inlineinherited

<Description#>

Parameters
bufferSizeSamples<#bufferSizeSamples description#>

◆ setupSimpleDelay()

template<typename effectsuite_t = effectsuite_t_default>
void setupSimpleDelay ( int delayInSamples)
inline

<Description#>

Parameters
delayInSamples<#delayInSamples description#>

◆ 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

bool active_flag
protectedinherited

◆ count

template<typename effectsuite_t = effectsuite_t_default>
int count = 0
protected

◆ currentDelayReadIndex

effectsuite_t_default currentDelayReadIndex
protectedinherited

◆ currentDelaySamples

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t currentDelaySamples
protected

◆ currentDelayWriteIndex

int currentDelayWriteIndex
protectedinherited

◆ delayBuffer

effectsuite_t_default* delayBuffer
protectedinherited

buffer to stored audio buffer for delay effects

◆ delayGain

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t delayGain = .707
protected

◆ delayIncrement

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t delayIncrement
protected

increment when transition from current to target delay per sample set by delayTransitionTime

◆ delayTimeChanged

template<typename effectsuite_t = effectsuite_t_default>
bool delayTimeChanged = false
protected

◆ delayTimeSamples

int delayTimeSamples
protectedinherited

the delay time of signal in samples

◆ delayTransitionTime

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t delayTransitionTime
protected

time in seconds to transition from one delay to another

◆ delayTransitionTimeInSamples

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t delayTransitionTimeInSamples
protected

◆ error

bool error
protectedinherited

internal class error boolean

◆ feedbackGain

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t feedbackGain = 0.
protected

◆ id_value

int id_value
protectedinherited

◆ 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

◆ invDelayIncrement

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t invDelayIncrement
protected

inverse of delay increment: for working out whole number cyles to reach target delay

◆ maxDelayBufferSize

int maxDelayBufferSize
protectedinherited

Maximum number of samples that can be stored in delayBuffer

◆ readHeadIndex

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t readHeadIndex
protected

◆ sampleRate

template<typename effectsuite_t = effectsuite_t_default>
int sampleRate
protected

◆ targetDelaySamples

template<typename effectsuite_t = effectsuite_t_default>
effectsuite_t targetDelaySamples
protected

◆ writeHeadIndex

template<typename effectsuite_t = effectsuite_t_default>
unsigned int writeHeadIndex
protected

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