MayaFlux
0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
IIR.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Filter.hpp
"
4
5
namespace
MayaFlux::Nodes::Filters
{
6
7
/**
8
* @class IIR
9
* @brief Infinite Impulse Response filter implementation
10
*
11
* The IIR filter implements a recursive digital filter where the output
12
* depends on both current/past input values and past output values through
13
* a feedback path. This creates a filter that can achieve complex frequency
14
* responses with fewer coefficients than FIR filters.
15
*
16
* IIR filters are characterized by the difference equation:
17
* y[n] = (b₀x[n] + b₁x[n-1] + ... + bₘx[n-m]) - (a₁y[n-1] + ... + aₙy[n-n])
18
*
19
* Key properties of IIR filters:
20
* - Can become unstable if coefficients are improperly designed
21
* - Non-linear phase response (phase distortion)
22
* - Require fewer coefficients than FIR for similar magnitude response
23
* - Feedback path enables resonance and self-reinforcing behaviors
24
* - Can model analog system responses (Butterworth, Chebyshev, etc.)
25
*
26
* Common applications include:
27
* - Efficient low/high/band-pass filtering
28
* - Resonant systems for dynamic modeling
29
* - Spectral shaping and frequency-domain transformations
30
* - Physical modeling components (resonators, feedback systems)
31
* - Adaptive filters and dynamic response systems
32
* - Control systems and feedback loops
33
* - Predictive modeling in time-series data
34
* - Simulation of natural and mechanical systems
35
*/
36
class
MAYAFLUX_API
IIR
:
public
Filter
{
37
public
:
38
/**
39
* @brief Creates an IIR filter with specified coefficients
40
* @param input Source node providing input samples
41
* @param a_coef Feedback (denominator) coefficients
42
* @param b_coef Feedforward (numerator) coefficients
43
*
44
* Creates an IIR filter with the specified input node and coefficient vectors.
45
* The a_coef vector contains feedback coefficients (denominator of transfer function),
46
* while b_coef contains feedforward coefficients (numerator of transfer function).
47
*
48
* Note: a[0] is typically normalized to 1.0, and the remaining a coefficients
49
* are negated compared to the standard transfer function representation.
50
*/
51
IIR
(
const
std::shared_ptr<Node>&
input
,
const
std::vector<double>& a_coef,
const
std::vector<double>& b_coef);
52
53
/**
54
* @brief Creates an IIR filter with specified coefficients (no input node)
55
* @param a_coef Feedback (denominator) coefficients
56
* @param b_coef Feedforward (numerator) coefficients
57
*
58
* Creates an IIR filter with the specified coefficient vectors but no input node.
59
* This can be used in scenarios where the input will be set later or through
60
* other means.
61
*/
62
IIR
(
const
std::vector<double>& a_coef,
const
std::vector<double>& b_coef);
63
64
/**
65
* @brief Processes a single sample through the IIR filter
66
* @param input The input sample
67
* @return The filtered output sample
68
*
69
* Implements the IIR filtering algorithm, computing the weighted sum
70
* of the current input, previous inputs, and previous outputs according
71
* to the filter coefficients. This is the core processing method called
72
* for each sample.
73
*/
74
double
process_sample(
double
input
= 0.)
override
;
75
76
void
save_state()
override
;
77
void
restore_state()
override
;
78
};
79
80
}
input
Core::GlobalInputConfig input
Definition
Config.cpp:36
Filter.hpp
MayaFlux::Nodes::Filters::Filter
Base class for computational signal transformers implementing difference equations.
Definition
Filter.hpp:139
MayaFlux::Nodes::Filters::IIR
Infinite Impulse Response filter implementation.
Definition
IIR.hpp:36
MayaFlux::Nodes::Filters
Definition
Registry.hpp:16
src
MayaFlux
Nodes
Filters
IIR.hpp
Generated by
1.9.8