pub struct Svf<F: Float> { /* private fields */ }
Expand description
A State Variable Filter that is copied from Andrew Simper (Cytomic) https://cytomic.com/files/dsp/SvfLinearTrapOptimised2.pdf
Implementations§
Source§impl<F: Float + Default> Svf<F>
impl<F: Float + Default> Svf<F>
Sourcepub fn new(
filter_type: FilterType,
sample_rate: F,
cutoff: F,
q: F,
gain: F,
) -> Result<Self, SvfError>
pub fn new( filter_type: FilterType, sample_rate: F, cutoff: F, q: F, gain: F, ) -> Result<Self, SvfError>
sets the filter to an inital response
use Svf::default
otherwise
Parameters:
- filter_type: choose one of the filter types, like peak, lowpass or highpass
- sample_rate: the sample_rate of the audio buffer that the filter should be applied on
- frequency: the frequency in Hz where the cutoff of the filter should be
- q: the steepness of the filter
- gain: the gain boost or decrease of the filter
Sourcepub fn process(&mut self, input: &[F], output: &mut [F])
pub fn process(&mut self, input: &[F], output: &mut [F])
process helper function that calls Svf::tick
on each sample
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset state of filter. Can be used when the audio callback is restarted.
Sourcepub fn set(
&mut self,
filter_type: FilterType,
sample_rate: F,
cutoff: F,
q: F,
gain: F,
) -> Result<(), SvfError>
pub fn set( &mut self, filter_type: FilterType, sample_rate: F, cutoff: F, q: F, gain: F, ) -> Result<(), SvfError>
The set function is setting the current parameters of the filter. Don’t call from a different thread than tick. Parameters:
- filter_type: choose one of the filter types, like peak, lowpass or highpass
- sample_rate: the sample_rate of the audio buffer that the filter should be applied on
- frequency: the frequency in Hz where the cutoff of the filter should be
- q: the steepness of the filter
- gain: the gain boost or decrease of the filter
Sourcepub fn set_coeffs(&mut self, coefficients: SvfCoefficients<F>)
pub fn set_coeffs(&mut self, coefficients: SvfCoefficients<F>)
Set new filter parameters from coefficients struct
Sourcepub fn tick(&mut self, input: F) -> F
pub fn tick(&mut self, input: F) -> F
The process that is applying the filter on a sample by sample basis
process
is a utility function to call tick on a full frame
Sourcepub fn coefficients(&self) -> &SvfCoefficients<F>
pub fn coefficients(&self) -> &SvfCoefficients<F>
get a reference to the coefficients can be used to clone it to the UI thread, to plot the response
Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for Svf<F>where
F: Freeze,
impl<F> RefUnwindSafe for Svf<F>where
F: RefUnwindSafe,
impl<F> Send for Svf<F>where
F: Send,
impl<F> Sync for Svf<F>where
F: Sync,
impl<F> Unpin for Svf<F>where
F: Unpin,
impl<F> UnwindSafe for Svf<F>where
F: UnwindSafe,
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