pub struct FilterNode { /* private fields */ }Expand description
A biquad IIR filter node.
FilterNode provides standard LowPass, HighPass, and BandPass filtering.
It supports dynamic updates of cutoff frequency and Q factor via
ControlMessage::SetParameter.
§Example
use rust_audio_api::nodes::{FilterNode, FilterType, NodeType};
use rust_audio_api::{AudioContext, NodeParameter};
let mut ctx = AudioContext::new().unwrap();
let sample_rate = ctx.sample_rate();
let mut filter_id = None;
let dest_id = ctx.build_graph(|builder| {
let filter = FilterNode::new(FilterType::LowPass, sample_rate, 1000.0, 0.707);
let id = builder.add_node(NodeType::Filter(filter));
filter_id = Some(id);
id
});
// Dynamically sweep the filter cutoff frequency to 2000 Hz
ctx.control_sender().send(
rust_audio_api::graph::ControlMessage::SetParameter(
filter_id.unwrap(),
NodeParameter::Cutoff(2000.0)
)
).unwrap();Implementations§
Source§impl FilterNode
impl FilterNode
Sourcepub fn new(
filter_type: FilterType,
sample_rate: u32,
cutoff_hz: f32,
q: f32,
) -> Self
pub fn new( filter_type: FilterType, sample_rate: u32, cutoff_hz: f32, q: f32, ) -> Self
Creates a new FilterNode.
§Parameters
filter_type: The type of filter (FilterType).sample_rate: Processing sample rate.cutoff_hz: Cutoff frequency in Hz.q: Quality factor (Resonance).
Sourcepub fn set_cutoff(&mut self, cutoff_hz: f32)
pub fn set_cutoff(&mut self, cutoff_hz: f32)
Sets the cutoff frequency (updates coefficients automatically).
Sourcepub fn set_q(&mut self, q: f32)
pub fn set_q(&mut self, q: f32)
Sets the quality factor Q (updates coefficients automatically).
Sourcepub fn set_filter_type(&mut self, filter_type: FilterType)
pub fn set_filter_type(&mut self, filter_type: FilterType)
Sets the filter type (updates coefficients automatically).
pub fn process(&mut self, input: Option<&AudioUnit>, output: &mut AudioUnit)
Auto Trait Implementations§
impl Freeze for FilterNode
impl RefUnwindSafe for FilterNode
impl Send for FilterNode
impl Sync for FilterNode
impl Unpin for FilterNode
impl UnsafeUnpin for FilterNode
impl UnwindSafe for FilterNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more