46 lines
1.4 KiB
Rust
46 lines
1.4 KiB
Rust
//! # Filter implemententations for biquads, series of biquads and banks of series of biquads.
|
|
//!
|
|
//! Contains [Biquad], [SeriesBiquad], and [BiquadBank]. These are all constructs that work on
|
|
//! blocks of input data, and apply filters on it. Todo: implement FIR filter.
|
|
#![allow(non_snake_case)]
|
|
pub use super::config::*;
|
|
|
|
mod biquad;
|
|
mod biquadbank;
|
|
mod seriesbiquad;
|
|
|
|
pub use biquad::Biquad;
|
|
pub use biquadbank::BiquadBank;
|
|
pub use seriesbiquad::SeriesBiquad;
|
|
|
|
/// Implementations of this trait are able to DSP-filter input data.
|
|
pub trait Filter: Send {
|
|
//! The filter trait is implemented by Biquad, SeriesBiquad, and BiquadBank
|
|
|
|
/// Filter input to generate output. A vector of output floats is generated with the same
|
|
/// length as input.
|
|
fn filter(&mut self, input: &[Flt]) -> Vd;
|
|
/// Reset the filter state(s). In essence, this makes sure that all memory of the past is
|
|
/// forgotten.
|
|
fn reset(&mut self);
|
|
|
|
/// Required method for cloning a BiquadBank, such that arbitrary filter types can be used as
|
|
/// their 'channels'.
|
|
fn clone_dyn(&self) -> Box<dyn Filter>;
|
|
}
|
|
|
|
/// Implementations are able to generate transfer functions of itself
|
|
|
|
pub trait TransferFunction: Send {
|
|
/// Compute frequency response (i.e. transfer function from input to output)
|
|
///
|
|
/// Args
|
|
fn tf(&self, fs: Flt, freq: VdView) -> Ccol;
|
|
}
|
|
|
|
impl Clone for Box<dyn Filter> {
|
|
fn clone(&self) -> Self {
|
|
self.clone_dyn()
|
|
}
|
|
}
|