arduino-audio-tools
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
audio_tools::FilterEffectBase Class Reference

A Base class for filter based effects including methods for simple high, low and band pass filtering. More...

#include <AudioEffectsSuite.h>

Inheritance diagram for audio_tools::FilterEffectBase:
audio_tools::EffectSuiteBase audio_tools::AudioEffect audio_tools::EnvelopeFilter audio_tools::FilteredDelay audio_tools::SimpleLPF audio_tools::SimpleChorus

Public Member Functions

 FilterEffectBase ()
 
 FilterEffectBase (FilterEffectBase &copy)=default
 
 ~FilterEffectBase ()=default
 
virtual effectsuite_t applyFilter (effectsuite_t sampVal)
 
effectsuite_t envelope (effectsuite_t sample)
 
void printBuffers ()
 
void printCoefs ()
 
virtual effect_t process (effect_t inputSample) override
 see applyFilter More...
 
virtual effectsuite_t processDouble (effectsuite_t inputSample) override
 Main process block for applying audio effect. More...
 
bool setChebyICoefficients (effectsuite_t cutFreq, bool shelfType, effectsuite_t ripple)
 
- Public Member Functions inherited from audio_tools::AudioEffect
virtual bool active ()
 determines if the effect is active
 
virtual AudioEffectclone ()=0
 
int id ()
 Allows to identify an effect.
 
virtual effect_t process (effect_t in)=0
 calculates the effect output from the input More...
 
virtual void setActive (bool value)
 sets the effect active/inactive
 
void setId (int id)
 Allows to identify an effect.
 

Protected Member Functions

void allocateBufferMemory ()
 
bool changeChebyICoefficients (effectsuite_t cutFreq, bool shelfType, effectsuite_t ripple, int poles)
 
void clearMemory ()
 
void incBufferIndex ()
 
effectsuite_t rms (effectsuite_t sample)
 
bool setSimpleLpf (int order)
 
- Protected Member Functions inherited from audio_tools::AudioEffect
int16_t clip (int32_t in, int16_t clipLimit=32767, int16_t resultLimit=32767)
 generic clipping method
 
void copyParent (AudioEffect *copy)
 

Protected Attributes

int bufferIndex = 0
 
int filterOrder = 0
 
effectsuite_t * firBuffer = 0
 
effectsuite_t * firCoefficients = 0
 
effectsuite_t * firTemp = 0
 
effectsuite_t * iirBuffer = 0
 
effectsuite_t * iirCoefficients = 0
 
effectsuite_t * iirTemp = 0
 
effectsuite_t * rmsBuffer = new effectsuite_t[rmsWindowSize]
 
int rmsBufferIndex = 0
 
const int rmsWindowSize = 128
 
int samplingRate = 0
 
- Protected Attributes inherited from audio_tools::AudioEffect
bool active_flag = true
 
int id_value = -1
 

Static Protected Attributes

static constexpr const effectsuite_t pi = 3.141592653589793
 

Detailed Description

A Base class for filter based effects including methods for simple high, low and band pass filtering.

See also
FilterEffectBase
Author
Matthew Hamilton

Constructor & Destructor Documentation

◆ FilterEffectBase()

audio_tools::FilterEffectBase::FilterEffectBase ( )
inline

Constructor.

◆ ~FilterEffectBase()

audio_tools::FilterEffectBase::~FilterEffectBase ( )
default

Destructor.

Member Function Documentation

◆ allocateBufferMemory()

void audio_tools::FilterEffectBase::allocateBufferMemory ( )
inlineprotected

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

◆ applyFilter()

virtual effectsuite_t audio_tools::FilterEffectBase::applyFilter ( effectsuite_t  sampVal)
inlinevirtual

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 audio_tools::FilterEffectBase::changeChebyICoefficients ( effectsuite_t  cutFreq,
bool  shelfType,
effectsuite_t  ripple,
int  poles 
)
inlineprotected

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 audio_tools::FilterEffectBase::clearMemory ( )
inlineprotected

checks internal memory storage of filter coeffcients and deletes if required

◆ envelope()

effectsuite_t audio_tools::FilterEffectBase::envelope ( effectsuite_t  sample)
inline

detect the envelop of an incoming signal

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

◆ incBufferIndex()

void audio_tools::FilterEffectBase::incBufferIndex ( )
inlineprotected

increment the buffer index and wrap it to the filter order

◆ process()

virtual effect_t audio_tools::FilterEffectBase::process ( effect_t  inputSample)
inlineoverridevirtual

see applyFilter

Reimplemented from audio_tools::EffectSuiteBase.

Reimplemented in audio_tools::FilteredDelay.

◆ processDouble()

virtual effectsuite_t audio_tools::FilterEffectBase::processDouble ( effectsuite_t  inputSample)
inlineoverridevirtual

Main process block for applying audio effect.

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

Implements audio_tools::EffectSuiteBase.

Reimplemented in audio_tools::SimpleChorus, audio_tools::FilteredDelay, and audio_tools::EnvelopeFilter.

◆ rms()

effectsuite_t audio_tools::FilterEffectBase::rms ( effectsuite_t  sample)
inlineprotected

root mean square of signal over a specific sample window

◆ setChebyICoefficients()

bool audio_tools::FilterEffectBase::setChebyICoefficients ( effectsuite_t  cutFreq,
bool  shelfType,
effectsuite_t  ripple 
)
inline

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

◆ setSimpleLpf()

bool audio_tools::FilterEffectBase::setSimpleLpf ( int  order)
inlineprotected

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

Member Data Documentation

◆ bufferIndex

int audio_tools::FilterEffectBase::bufferIndex = 0
protected

current buffer index

◆ filterOrder

int audio_tools::FilterEffectBase::filterOrder = 0
protected

order of delay filter including the zero delay coefficients

◆ firBuffer

effectsuite_t* audio_tools::FilterEffectBase::firBuffer = 0
protected

buffer to hold forward delay sample data

◆ firCoefficients

effectsuite_t* audio_tools::FilterEffectBase::firCoefficients = 0
protected

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

◆ firTemp

effectsuite_t* audio_tools::FilterEffectBase::firTemp = 0
protected

hold temporary values for fir coeffcient buffer

◆ iirBuffer

effectsuite_t* audio_tools::FilterEffectBase::iirBuffer = 0
protected

buffer to hold backward delay sample data

◆ iirCoefficients

effectsuite_t* audio_tools::FilterEffectBase::iirCoefficients = 0
protected

Denomiator coefficients in delay filter

See also
firCoefficients

◆ iirTemp

effectsuite_t* audio_tools::FilterEffectBase::iirTemp = 0
protected

hold temporary values for iir coeffcient buffer

◆ rmsBuffer

effectsuite_t* audio_tools::FilterEffectBase::rmsBuffer = new effectsuite_t[rmsWindowSize]
protected

RMS window buffer

◆ rmsBufferIndex

int audio_tools::FilterEffectBase::rmsBufferIndex = 0
protected

current write index of rmsBuffer

◆ rmsWindowSize

const int audio_tools::FilterEffectBase::rmsWindowSize = 128
protected

window size in samples of rms window


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