pub trait Filter<T>: ParameterizedAlgorithm<T, Params = FilterParams>where
T: Transcendental,{
// Provided methods
fn set_cutoff(&mut self, cutoff: f32) { ... }
fn cutoff(&self) -> f32 { ... }
fn set_q(&mut self, q: f32) { ... }
fn q(&self) -> f32 { ... }
fn set_gain_db(&mut self, gain: f32) { ... }
fn gain_db(&self) -> f32 { ... }
fn filter_type(&self) -> FilterType { ... }
}Expand description
Common trait for all filters
Provides a unified interface for controlling filter parameters.
All concrete filters implement this trait via ParameterizedAlgorithm
with Params = FilterParams.
§Example
use rill_core_dsp::filters::*;
use rill_core::Transcendental;
use rill_core::time::ClockTick;
use rill_core::traits::ActionContext;
fn process_filter<T: Transcendental>(filter: &mut dyn Filter<T>, input: T) -> T {
filter.set_cutoff(1000.0);
filter.set_q(0.707);
let mut output = [T::ZERO];
let tick = ClockTick::default();
let ctx = ActionContext::new(&tick);
filter.process(Some(&[input]), &mut output).unwrap();
output[0]
}Provided Methods§
Sourcefn set_cutoff(&mut self, cutoff: f32)
fn set_cutoff(&mut self, cutoff: f32)
Sourcefn set_gain_db(&mut self, gain: f32)
fn set_gain_db(&mut self, gain: f32)
Sourcefn filter_type(&self) -> FilterType
fn filter_type(&self) -> FilterType
Get filter type
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".