:)
Loading...
Searching...
No Matches
RustyFilter Class Reference

Variable state IIR Filter. More...

#include <RustyFilter.hpp>

Inheritance diagram for RustyFilter:
RustyProcessor

Public Member Functions

 RustyFilter (RustyFilterType type, float frequency, float q)
 Constructor for RustyFilter.
 
void process (float *sample) override
 Performs DSP on an audio sample.
 
void setModulatorForParameter (std::string parameter, RustyModulator *modulator) override
 Binds a RustyModulator to a RustyProcessor instance parameter.
 
void setParameter (std::string parameter, std::string value) override
 Sets RustyProcessor parameter to new value.
 
std::string getProcessorType () override
 Function to get processor type.
 
std::string getParams () override
 Function to get processor params.
 
- Public Member Functions inherited from RustyProcessor
virtual void process (float *sample)=0
 Performs DSP on an audio sample.
 
virtual void setModulatorForParameter (std::string parameter, RustyModulator *modulator)=0
 Binds a RustyModulator to a RustyProcessor instance parameter.
 
virtual void setParameter (std::string parameter, std::string value)=0
 Sets RustyProcessor parameter to new value.
 
bool isNumeric (const std::string &str)
 Function to test if value contains numeric characters.
 
virtual std::string getProcessorType ()=0
 Function to get processor type.
 
virtual std::string getParams ()=0
 Function to get processor params.
 

Private Member Functions

void calcCoefficients ()
 Biquad variable calculator.
 
float constrain (float val, float min, float max)
 Constrain function between a min and max.
 

Private Attributes

float _a1 = 0
 Biquad variable.
 
float _a2 = 0
 Biquad variable.
 
float _b0 = 1
 Biquad variable.
 
float _b1 = 0
 Biquad variable.
 
float _b2 = 0
 Biquad variable.
 
float _x1
 Current input sample.
 
float _y1
 Previous output sample.
 
float _x2
 Previous input sample.
 
float _y2
 Previous output sample value -1.
 
float _k
 Biquad variable.
 
float _norm
 Biquad variable.
 
float _sum
 Filter output.
 
float _sampleRate
 
float _frequency
 
float _q
 Filter variables.
 
RustyFilterType _type
 Filter type.
 

Additional Inherited Members

- Public Attributes inherited from RustyProcessor
std::map< std::string, RustyModulator * > _modulators
 Map of processors affecting derived RustyProcessor.
 

Detailed Description

Variable state IIR Filter.

2-order IIR filter with four states LOW_PASS, HIGH_PASS, BAND_PASS, NOTCH.

Inherited from RustyProcessor.

Definition at line 19 of file RustyFilter.hpp.

Constructor & Destructor Documentation

◆ RustyFilter()

RustyFilter::RustyFilter ( RustyFilterType  type,
float  frequency,
float  q 
)

Constructor for RustyFilter.


Takes initial parameters for RustyFilter and preps the unit for sample processing.

Parameters
typeRustyFilterType to define filter type.
frequencyFloat of filter cutoff frequency.
ratioFloat of q ratio.

Definition at line 3 of file RustyFilter.cpp.

Member Function Documentation

◆ process()

void RustyFilter::process ( float *  sample)
overridevirtual

Performs DSP on an audio sample.


This pure virtual function performs DSP algorithms on a sample by sample basis. A pointer to a 32bitFloat audio sample is passed as an argument and this will be the value used as the input to the DSP function f(x).

Parameters
samplePointer to a 32bitFloat audio sample value.

Implements RustyProcessor.

Definition at line 11 of file RustyFilter.cpp.

◆ setModulatorForParameter()

void RustyFilter::setModulatorForParameter ( std::string  parameter,
RustyModulator *  modulator 
)
overridevirtual

Binds a RustyModulator to a RustyProcessor instance parameter.


This is pure virtual function assigns modulator manipulation to parameters within the DSP unit. Each RustyProcessor derived DSP unit will check the parameter name against suitable parameters, if there is a match the modulator will affect the parameter.

Parameters
parameterString of the parameter to affect.
modulatorPointer to instance of RustyModulator.
See also
setParameter()

Implements RustyProcessor.

Definition at line 45 of file RustyFilter.cpp.

◆ setParameter()

void RustyFilter::setParameter ( std::string  parameter,
std::string  value 
)
overridevirtual

Sets RustyProcessor parameter to new value.


This is pure virtual function that assigns a new value to a parameter of RustyProcessor derived DSP units. This function is used at runtime from CLI interaction.

Parameters
parameterString of the parameter to affect.
modulatorPointer to instance of RustyModulator.
See also
setModulatorForParameter()

Implements RustyProcessor.

Definition at line 56 of file RustyFilter.cpp.

◆ getProcessorType()

std::string RustyFilter::getProcessorType ( )
overridevirtual

Function to get processor type.


Simple function allows CLI to test Processor types for user interaction.

Returns
Returns string of RustyProcessor child type.

Implements RustyProcessor.

Definition at line 138 of file RustyFilter.cpp.

◆ getParams()

std::string RustyFilter::getParams ( )
overridevirtual

Function to get processor params.


Simple function allows CLI to get available params for RustyProcessor child.

Returns
Returns string of parameters available for RustyProcessor child.

Implements RustyProcessor.

Definition at line 143 of file RustyFilter.cpp.

◆ calcCoefficients()

void RustyFilter::calcCoefficients ( )
private

Biquad variable calculator.


Calculates filter biquads based on user's input variables or modulator changes.

Definition at line 98 of file RustyFilter.cpp.

◆ constrain()

float RustyFilter::constrain ( float  val,
float  min,
float  max 
)
inlineprivate

Constrain function between a min and max.


Constrains particular variables that would break IIR Filter.

Definition at line 56 of file RustyFilter.hpp.

Member Data Documentation

◆ _a1

float RustyFilter::_a1 = 0
private

Biquad variable.

Definition at line 59 of file RustyFilter.hpp.

◆ _a2

float RustyFilter::_a2 = 0
private

Biquad variable.

Definition at line 60 of file RustyFilter.hpp.

◆ _b0

float RustyFilter::_b0 = 1
private

Biquad variable.

Definition at line 61 of file RustyFilter.hpp.

◆ _b1

float RustyFilter::_b1 = 0
private

Biquad variable.

Definition at line 62 of file RustyFilter.hpp.

◆ _b2

float RustyFilter::_b2 = 0
private

Biquad variable.

Definition at line 63 of file RustyFilter.hpp.

◆ _x1

float RustyFilter::_x1
private

Current input sample.

Definition at line 64 of file RustyFilter.hpp.

◆ _y1

float RustyFilter::_y1
private

Previous output sample.

Definition at line 65 of file RustyFilter.hpp.

◆ _x2

float RustyFilter::_x2
private

Previous input sample.

Definition at line 66 of file RustyFilter.hpp.

◆ _y2

float RustyFilter::_y2
private

Previous output sample value -1.

Definition at line 67 of file RustyFilter.hpp.

◆ _k

float RustyFilter::_k
private

Biquad variable.

Definition at line 68 of file RustyFilter.hpp.

◆ _norm

float RustyFilter::_norm
private

Biquad variable.

Definition at line 69 of file RustyFilter.hpp.

◆ _sum

float RustyFilter::_sum
private

Filter output.

Definition at line 70 of file RustyFilter.hpp.

◆ _sampleRate

float RustyFilter::_sampleRate
private

Definition at line 72 of file RustyFilter.hpp.

◆ _frequency

float RustyFilter::_frequency
private

Definition at line 72 of file RustyFilter.hpp.

◆ _q

float RustyFilter::_q
private

Filter variables.

Definition at line 72 of file RustyFilter.hpp.

◆ _type

RustyFilterType RustyFilter::_type
private

Filter type.

Definition at line 73 of file RustyFilter.hpp.


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