Skip to content

Commit

Permalink
updated FIR and IIR filter doc
Browse files Browse the repository at this point in the history
Signed-off-by: Ralph J. Steinhagen <[email protected]>
  • Loading branch information
RalphSteinhagen authored and wirew0rm committed Sep 3, 2023
1 parent ff0a9ea commit 4ee8f88
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions test/blocklib/core/filter/time_domain_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ namespace gr::blocks::filter {

using namespace fair::graph;

/**
* @brief Finite Impulse Response (FIR) filter class
*
* The transfer function of an FIR filter is given by:
* H(z) = b[0] + b[1]*z^-1 + b[2]*z^-2 + ... + b[N]*z^-N
*
*/
template<typename T>
requires std::floating_point<T>
struct fir_filter : node<fir_filter<T>> {
struct fir_filter : node<fir_filter<T>, Doc<R""(
@brief Finite Impulse Response (FIR) filter class
The transfer function of an FIR filter is given by:
H(z) = b[0] + b[1]*z^-1 + b[2]*z^-2 + ... + b[N]*z^-N
)"">> {
IN<T> in;
OUT<T> out;
std::vector<T> b{}; // feedforward coefficients
Expand All @@ -45,19 +43,17 @@ enum class IIRForm {
DF_II_TRANSPOSED
};

/**
* @brief Infinite Impulse Response (IIR) filter class
*
* b are the feed-forward coefficients (N.B. b[0] denoting the newest and n[-1] the previous sample)
* a are the feedback coefficients
*
*/
template<typename T, IIRForm form = std::is_floating_point_v<T> ? IIRForm::DF_II : IIRForm::DF_I>
requires std::floating_point<T>
struct iir_filter : node<iir_filter<T, form>> {
struct iir_filter : node<iir_filter<T, form>, Doc<R""(
@brief Infinite Impulse Response (IIR) filter class
b are the feed-forward coefficients (N.B. b[0] denoting the newest and n[-1] the previous sample)
a are the feedback coefficients
)"">> {
IN<T> in;
OUT<T> out;
std::vector<T> b{ 1 }; // feedforward coefficients
std::vector<T> b{ 1 }; // feed-forward coefficients
std::vector<T> a{ 1 }; // feedback coefficients
history_buffer<T> inputHistory{ 32 };
history_buffer<T> outputHistory{ 32 };
Expand Down

0 comments on commit 4ee8f88

Please sign in to comment.