11#ifndef MARVIN_BIQUAD_H
12#define MARVIN_BIQUAD_H
14#include "marvin/library/marvin_Literals.h"
48 template <FloatType SampleType,
size_t NumStages>
57 m_coeffs[stage] = coeffs;
65 [[nodiscard]] SampleType
operator()(SampleType x)
noexcept {
66 for (
auto stage = 0_sz; stage < NumStages; ++stage) {
74 const auto [a0, a1, a2, b0, b1, b2] = m_coeffs[stage];
75 auto& delay = m_delays[stage];
76 const auto y =
static_cast<SampleType
>(1.0) / b0 * ((a0 * x) + (a1 * delay.x_z1) + (a2 * delay.x_z2) - (b1 * delay.y_z1) - (b2 * delay.y_z2));
87 for (
auto& d : m_delays) {
93 struct BiquadDelay final {
94 SampleType x_z1{
static_cast<SampleType
>(0.0) }, x_z2{
static_cast<SampleType
>(0.0) };
95 SampleType y_z1{
static_cast<SampleType
>(0.0) }, y_z2{
static_cast<SampleType
>(0.0) };
97 void operator()(SampleType x, SampleType y)
noexcept {
104 void reset() noexcept {
105 x_z1 = x_z2 = y_z1 = y_z2 =
static_cast<SampleType
>(0.0);
108 std::array<BiquadDelay, NumStages> m_delays;
109 std::array<BiquadCoefficients<SampleType>, NumStages> m_coeffs;
A cascading direct form ii biquad filter.
Definition marvin_Biquad.h:49
void reset() noexcept
Definition marvin_Biquad.h:86
SampleType operator()(SampleType x) noexcept
Definition marvin_Biquad.h:65
void setCoeffs(size_t stage, BiquadCoefficients< SampleType > coeffs) noexcept
Definition marvin_Biquad.h:56
Digital filter functions and classes.
Definition marvin_SVF.h:15
A POD type for use with the Biquad class, and the SmoothedBiquadCoefficients class.
Definition marvin_BiquadCoefficients.h:22