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>
|
| static effectsuite_t ** | interpolationTable = nullptr |
| | 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 = 4 |
| |
| static const int | interpResolution = 1000 |
| |
| static const int | order = 4 |
| |
| static const int | res = 100 |
| |
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
- Copyright
- MIT License
◆ SimpleChorus() [1/2]
template<typename effectsuite_t = effectsuite_t_default>
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()
template<typename effectsuite_t = effectsuite_t_default>
◆ active()
determines if the effect is active
◆ allocateBufferMemory()
template<typename effectsuite_t = effectsuite_t_default>
| void allocateBufferMemory |
( |
| ) |
|
|
inlineprotectedinherited |
will allocate memory to a buffer given the current filter order and set all values == 0.00
◆ allocateMemory()
template<typename effectsuite_t = effectsuite_t_default>
allocate memory to internal wave table based on sample rate
- Returns
- returns true on success or false on failure
◆ applyFilter()
template<typename effectsuite_t = effectsuite_t_default>
| virtual effectsuite_t applyFilter |
( |
effectsuite_t |
sampVal | ) |
|
|
inlinevirtualinherited |
with the current filter coefficients this method filters a sample then stores it the sample Buffer and increments the index
- Parameters
-
| sampVal | is the sample to be processed |
- Returns
- filtered audio sample
◆ changeChebyICoefficients()
template<typename effectsuite_t = effectsuite_t_default>
| bool changeChebyICoefficients |
( |
effectsuite_t |
cutFreq, |
|
|
bool |
shelfType, |
|
|
effectsuite_t |
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()
template<typename effectsuite_t = effectsuite_t_default>
checks internal memory storage of filter coeffcients and deletes if required
◆ clip()
| int16_t clip |
( |
int32_t |
in, |
|
|
int16_t |
clipLimit = 32767, |
|
|
int16_t |
resultLimit = 32767 |
|
) |
| |
|
inlineprotectedinherited |
◆ clipWave()
template<typename effectsuite_t = effectsuite_t_default>
| void clipWave |
( |
effectsuite_t |
amp | ) |
|
|
inlineinherited |
clip wave table values with a tanh function. Effect change with a variable amp to control intensity.
- Parameters
-
| amp | amount to multiply signal before being fed through a tanh function |
◆ clone()
template<typename effectsuite_t = effectsuite_t_default>
◆ copyParent()
◆ delaySample()
template<typename effectsuite_t = effectsuite_t_default>
| void delaySample |
( |
effectsuite_t |
inputSample | ) |
|
|
inlineprotectedinherited |
store input sample into the delay buffer and increment currentDelayWriteIndex for tracking when to loop back to start of buffer
- Parameters
-
| inputSample | sample to be stored for delay (effectsuite_t) |
◆ envelope()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t envelope |
( |
effectsuite_t |
sample | ) |
|
|
inlineinherited |
detect the envelop of an incoming signal
- Parameters
-
| sample | the incoming signal sample value |
- Returns
- returns envelope dection signal sample value
◆ getInterpolatedOut()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t getInterpolatedOut |
( |
effectsuite_t |
bufferIndex | ) |
|
|
inlineprotectedinherited |
get the value of the requested buffer index by interpolating other points
- Parameters
-
| bufferIndex | The required buffer index |
- Returns
- interpolated output
◆ getInterpOut()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t getInterpOut |
( |
effectsuite_t |
bufferIndex | ) |
|
|
inlineprotectedinherited |
get the interpolated output of the waveTable from the given buffer index
- Parameters
-
| bufferIndex | buffer 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()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t getSplineOut |
( |
effectsuite_t |
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
-
| bufferIndex | the required buffer index |
| freq | (speed) that the table is being read through |
- Returns
- returns interpolated value as effectsuite_t
◆ id()
Allows to identify an effect.
◆ incBufferIndex()
template<typename effectsuite_t = effectsuite_t_default>
increment the buffer index and wrap it to the filter order
◆ incDelayBuffReadIndex()
template<typename effectsuite_t = effectsuite_t_default>
| void incDelayBuffReadIndex |
( |
effectsuite_t |
indexInc | ) |
|
|
inlineprotectedinherited |
Increments the currentDelayBufferReadIndex by indexInc
- Parameters
-
| indexInc | The amount to increment the delay buffer index |
◆ incDelayBuffWriteIndex()
template<typename effectsuite_t = effectsuite_t_default>
| void incDelayBuffWriteIndex |
( |
| ) |
|
|
inlineprotectedinherited |
Increments the currentDelayWriteBufferIndex by 1
◆ isNoise()
template<typename effectsuite_t = effectsuite_t_default>
◆ printInterpTable()
template<typename effectsuite_t = effectsuite_t_default>
| void printInterpTable |
( |
| ) |
|
|
inlineinherited |
◆ process()
template<typename effectsuite_t = effectsuite_t_default>
|
|
inlineoverridevirtualinherited |
◆ processFloat()
template<typename effectsuite_t = effectsuite_t_default>
| virtual effectsuite_t processFloat |
( |
effectsuite_t |
inputSample | ) |
|
|
inlineoverridevirtual |
◆ readNoise()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t readNoise |
( |
| ) |
|
|
inlineinherited |
reads out white noise
- Returns
- random number between -1 and 1
◆ readTable()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t readTable |
( |
effectsuite_t |
freq | ) |
|
|
inlineinherited |
Read through values in waveTable as a given frequency
- Parameters
-
| freq | read speed in Hz: essentially the number of samples jumped between reads |
- Returns
- value from table as effectsuite_t
◆ rms()
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t rms |
( |
effectsuite_t |
sample | ) |
|
|
inlineprotectedinherited |
root mean square of signal over a specific sample window
◆ setActive()
| 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()
template<typename effectsuite_t = effectsuite_t_default>
| bool setChebyICoefficients |
( |
effectsuite_t |
cutFreqIn, |
|
|
bool |
shelfType, |
|
|
effectsuite_t |
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()
template<typename effectsuite_t = effectsuite_t_default>
◆ setDelayBuffer()
template<typename effectsuite_t = effectsuite_t_default>
| bool setDelayBuffer |
( |
int |
bufferSizeSamples | ) |
|
|
inlineprotectedinherited |
Allocates memory for delay buffer and initialises all elements to 0
- Parameters
-
| bufferSizeSamples | the 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()
template<typename effectsuite_t = effectsuite_t_default>
| void setDelayBuffReadIndex |
( |
effectsuite_t |
index | ) |
|
|
inlineprotectedinherited |
sets the currentDelayBufferReadIndex by indexInc (Currently no wrapping)
- Parameters
-
| index | the read index index required |
◆ setId()
Allows to identify an effect.
◆ setInterpolationTable()
template<typename effectsuite_t = effectsuite_t_default>
| static effectsuite_t ** 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()
template<typename effectsuite_t = effectsuite_t_default>
populates the internal interpolation table
- Returns
- return tru on success, else false
◆ setNoise()
template<typename effectsuite_t = effectsuite_t_default>
◆ setOffSine()
template<typename effectsuite_t = effectsuite_t_default>
sets wavetable to one period of a sine wave oscillating between 0 and 1
◆ setRamp()
template<typename effectsuite_t = effectsuite_t_default>
set wave table to be a ramp from 0 to 1
◆ setRandLfo()
template<typename effectsuite_t = effectsuite_t_default>
◆ setSawtooth()
template<typename effectsuite_t = effectsuite_t_default>
sets wavetable to one period of a sawtooth wave
◆ setSimpleLpf()
template<typename effectsuite_t = effectsuite_t_default>
| bool setSimpleLpf |
( |
int |
order | ) |
|
|
inlineprotectedinherited |
a simple normalised fir low pass filter @params order number of delay coefficients
◆ setSine()
template<typename effectsuite_t = effectsuite_t_default>
sets wavetable to one period of a sine wave oscillating between -1 and 1
◆ setSquare()
template<typename effectsuite_t = effectsuite_t_default>
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()
template<typename effectsuite_t = effectsuite_t_default>
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
-
| extSampleRate | external sample rate |
◆ setupDelayEffectBase()
template<typename effectsuite_t = effectsuite_t_default>
| void setupDelayEffectBase |
( |
const int |
bufferSizeSamples | ) |
|
|
inlineinherited |
<Description#>
- Parameters
-
| bufferSizeSamples | <#bufferSizeSamples description#> |
◆ setupModulationBaseClass()
template<typename effectsuite_t = effectsuite_t_default>
| void setupModulationBaseClass |
( |
effectsuite_t |
extSampRate | ) |
|
|
inlineinherited |
setup the class with a given sample rate. Basically reperforming the constructor
- Parameters
-
| extSampRate | External sample rate |
◆ storeSample()
template<typename effectsuite_t = effectsuite_t_default>
| void storeSample |
( |
effectsuite_t |
inputSample | ) |
|
|
inlineprotectedinherited |
store input sample into the delay buffer
- Parameters
-
| inputSample | sample to be stored for delay (effectsuite_t) |
◆ active_flag
◆ base
template<typename effectsuite_t = effectsuite_t_default>
minimum delay in samples. Typically 10 milliseconds
◆ bufferIndex
template<typename effectsuite_t = effectsuite_t_default>
◆ currentDelayReadIndex
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t currentDelayReadIndex = 0 |
|
protectedinherited |
◆ currentDelayWriteIndex
template<typename effectsuite_t = effectsuite_t_default>
| int currentDelayWriteIndex = 0 |
|
protectedinherited |
◆ delayBuffer
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t* delayBuffer = 0 |
|
protectedinherited |
buffer to stored audio buffer for delay effects
◆ delayTimeSamples
template<typename effectsuite_t = effectsuite_t_default>
| int delayTimeSamples = 44100 |
|
protectedinherited |
the delay time of signal in samples
◆ error
template<typename effectsuite_t = effectsuite_t_default>
internal class error boolean
◆ filterOrder
template<typename effectsuite_t = effectsuite_t_default>
order of delay filter including the zero delay coefficients
◆ firBuffer
template<typename effectsuite_t = effectsuite_t_default>
buffer to hold forward delay sample data
◆ firCoefficients
template<typename effectsuite_t = effectsuite_t_default>
| float* firCoefficients = 0 |
|
protectedinherited |
Numerator coefficients in delay filter firCoefficients[0] z^0 coeffcieint firCoefficients[1] z^-1 coefficient
◆ firTemp
template<typename effectsuite_t = effectsuite_t_default>
hold temporary values for fir coeffcient buffer
◆ id_value
◆ iirBuffer
template<typename effectsuite_t = effectsuite_t_default>
buffer to hold backward delay sample data
◆ iirCoefficients
template<typename effectsuite_t = effectsuite_t_default>
| float* iirCoefficients = 0 |
|
protectedinherited |
◆ iirTemp
template<typename effectsuite_t = effectsuite_t_default>
hold temporary values for iir coeffcient buffer
◆ interpolationTable
template<typename effectsuite_t >
| effectsuite_t ** interpolationTable = nullptr |
|
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
template<typename effectsuite_t = effectsuite_t_default>
| const int interpOrder = 4 |
|
staticprotectedinherited |
◆ interpResolution
template<typename effectsuite_t = effectsuite_t_default>
| const int interpResolution = 1000 |
|
staticprotectedinherited |
◆ interpTable
template<typename effectsuite_t = effectsuite_t_default>
◆ is_noise
template<typename effectsuite_t = effectsuite_t_default>
◆ maxDelayBufferSize
template<typename effectsuite_t = effectsuite_t_default>
| int maxDelayBufferSize = 441000 |
|
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>
the normalising factor of the random delay signal
◆ order
template<typename effectsuite_t = effectsuite_t_default>
◆ readSpeed
template<typename effectsuite_t = effectsuite_t_default>
| const effectsuite_t readSpeed = ((this->readNoise() + 1) * .5) * .0005 |
|
protected |
◆ res
template<typename effectsuite_t = effectsuite_t_default>
◆ rmsBuffer
template<typename effectsuite_t = effectsuite_t_default>
◆ rmsBufferIndex
template<typename effectsuite_t = effectsuite_t_default>
current write index of rmsBuffer
◆ rmsWindowSize
template<typename effectsuite_t = effectsuite_t_default>
| const int rmsWindowSize = 128 |
|
protectedinherited |
window size in samples of rms window
◆ sampleRate
template<typename effectsuite_t = effectsuite_t_default>
◆ samplingRate
template<typename effectsuite_t = effectsuite_t_default>
◆ swing
template<typename effectsuite_t = effectsuite_t_default>
swing range of delayed audio index in samples typical maximum swing would be 15 milliseconds (i.e. 0.015*sampleRate)
◆ tableIndex
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t tableIndex = 0 |
|
inherited |
◆ timeStep
template<typename effectsuite_t = effectsuite_t_default>
time between samples: 1/sampRate
◆ waveTable
template<typename effectsuite_t = effectsuite_t_default>
| effectsuite_t* waveTable = nullptr |
|
inherited |
store modulation signal as
The documentation for this class was generated from the following file: