TransferFunction implemented for series biquad

This commit is contained in:
Anne de Jong 2024-07-03 22:06:33 +02:00
parent 7e9cf734d0
commit 81872c62e1

View File

@ -1,14 +1,11 @@
use super::*; use super::*;
use super::biquad::Biquad; use super::biquad::Biquad;
use anyhow::{bail, Result}; use anyhow::{bail, Result};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[cfg_attr(feature = "python-bindings", pyclass)] #[cfg_attr(feature = "python-bindings", pyclass)]
/// Series of biquads that filter sequentially on an input signal /// Series of biquads that filter sequentially on an input signal
/// ///
/// # Examples /// # Examples
@ -109,7 +106,16 @@ impl Filter for SeriesBiquad {
Box::new(self.clone()) Box::new(self.clone())
} }
} }
impl<'a, T: AsArray<'a, Flt>> TransferFunction<'a, T> for SeriesBiquad {
fn tf(&self, fs: Flt, freq: T) -> Ccol {
let freq = freq.into();
let mut res = self.biqs.first().unwrap().tf(fs, freq);
for i in self.biqs.iter().skip(1) {
res = &res * i.tf(fs, freq);
}
res
}
}
#[cfg(test)] #[cfg(test)]
mod test { mod test {