Yet Another Synthesizer Engine
 
Loading...
Searching...
No Matches
yase::IIRFilter Class Reference

#include <iir_filter.hh>

+ Inheritance diagram for yase::IIRFilter:
+ Collaboration diagram for yase::IIRFilter:

Detailed Description

This module implements an Infinite Impulse Response (IIR) filter.

The IIR operates according to the difference equation

  a[0]*y[n] + a[1]*y[n-1] + ... + a[p]*y[n-p] = b[0]*u[n] + b[1]*u[n-1] + ... + b[q]*u[n-q].

The input is u[n] and the output is y[n]. Previous values of u and y are remembered by the module. There are two constructors. One takes integers p and q, specifying the feedforward and feedback orders respectively. A later call to set_coefficients is needed in this case. The other constructor takes a list of the coefficients directly.

For example, a simple averaging filter (which is actually a FIR filter) can be constructed with

  IIRFilter filter({2},{1,1});
Parameters
[in]signal
[out]signal

Public Member Functions

 IIRFilter (int P, int Q)
 
 IIRFilter (vector< double > A, vector< double > B)
 
void init ()
 
void update ()
 
void set_coefficients (vector< double > A, vector< double > B)
 
- Public Member Functions inherited from yase::Module
virtual void init ()=0
 
virtual void update ()=0
 
int add_input (string name)
 
int add_output (string name)
 
int get_input_index (string name) const
 
string get_input_name (int index) const
 
string get_output_name (int index) const
 
int get_output_index (string name) const
 
void set_input (string name, double value)
 
void set_input (int index, double value)
 
double get_input (int index) const
 
double get_input (string name) const
 
double get_output (string name) const
 
double get_output (int index) const
 
void set_output (int index, double value)
 
void copy_inputs (const Module &source)
 
void copy_outputs (Module &destination) const
 
void configure (std::vector< std::tuple< string, double > > assignments)
 
int num_inputs () const
 
int num_outputs () const
 
void emit (Event e)
 
void set_ts (double s)
 
double get_ts ()
 

Constructor & Destructor Documentation

◆ IIRFilter() [1/2]

yase::IIRFilter::IIRFilter ( int  P,
int  Q 
)

Define a new IIR filter with feedforward order P and feedback order Q. Call IIRFilter::set_coefficients to set the value of the coefficents.

Parameters
PFeedforward order
QFeedback order.

◆ IIRFilter() [2/2]

yase::IIRFilter::IIRFilter ( vector< double >  A,
vector< double >  B 
)

Define a new IIR filter feedforward coefficients A and feedback coefficients B.

Parameters
AFeedforward coefficients.
BFeedback coefficients.

Member Function Documentation

◆ init()

void yase::IIRFilter::init ( )
virtual

This method should be overridden by derived classes. It will usually be called once, after all modules and connections objects have been added to a synthesizer, but before the synthesizer starts running.

Implements yase::Module.

Reimplemented in yase::Resonator.

◆ set_coefficients()

void yase::IIRFilter::set_coefficients ( vector< double >  A,
vector< double >  B 
)

Set the coefficients of the filter.

Parameters
AFeedforward coefficients.
BFeedback coefficients.

◆ update()

void yase::IIRFilter::update ( )
virtual

This method should be overridden by derived classes. It will be called repeatedly by a synthesizer at a frequency determined by SAMPLE_RATE.

Implements yase::Module.

Reimplemented in yase::Resonator.


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