MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
FIR.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Filter.hpp"
4
6
7/**
8 * @class FIR
9 * @brief Finite Impulse Response filter implementation
10 *
11 * The FIR filter implements a non-recursive digital filter where the output
12 * depends only on the current and past input values, with no feedback path.
13 * This creates a filter with guaranteed stability and linear phase response
14 * when coefficients are symmetric.
15 *
16 * FIR filters are characterized by the difference equation:
17 * y[n] = b₀x[n] + b₁x[n-1] + ... + bₘx[n-m]
18 *
19 * Key properties of FIR filters:
20 * - Always stable (no feedback means no potential for instability)
21 * - Can have perfectly linear phase (when coefficients are symmetric)
22 * - Typically require more coefficients than IIR for similar magnitude response
23 * - No feedback means no resonance or self-oscillation
24 *
25 * Common applications include:
26 * - Low/high/band-pass filtering with predictable phase response
27 * - Time-domain transformations and delay-based effects
28 * - Convolution-based processing (impulse responses, simulations)
29 * - Windowed-sinc filters for precise frequency response
30 * - Hilbert transformers and other specialized signal processors
31 * - Data smoothing and noise reduction in sensor data
32 * - Feature extraction in pattern recognition
33 */
34class MAYAFLUX_API FIR : public Filter {
35public:
36 /**
37 * @brief Creates an FIR filter with specified coefficients
38 * @param input Source node providing input samples
39 * @param coeffs Vector of filter coefficients
40 *
41 * Creates an FIR filter with the specified input node and coefficients.
42 * The coefficients directly define the filter's impulse response and
43 * frequency response characteristics.
44 */
45 FIR(const std::shared_ptr<Node>& input, const std::vector<double>& coeffs);
46
47 /**
48 * @brief Creates an FIR filter with specified coefficients (no input node)
49 * @param coeffs Vector of filter coefficients
50 *
51 * Creates an FIR filter with the specified coefficients but no input node.
52 * This can be used in scenarios where the filter operates on external data
53 * or is part of a larger processing chain.
54 */
55 FIR(const std::vector<double>& coeffs);
56
57 /**
58 * @brief Processes a single sample through the FIR filter
59 * @param input The input sample
60 * @return The filtered output sample
61 *
62 * Implements the FIR filtering algorithm, computing the weighted sum
63 * of the current input and previous inputs according to the filter
64 * coefficients. This is the core processing method called for each sample.
65 */
66 double process_sample(double input = 0.) override;
67
68 void save_state() override;
69 void restore_state() override;
70};
71
72}
Core::GlobalInputConfig input
Definition Config.cpp:36
Finite Impulse Response filter implementation.
Definition FIR.hpp:34
Base class for computational signal transformers implementing difference equations.
Definition Filter.hpp:139