Struct Svf

Source
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>

Source

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
Source

pub fn process(&mut self, input: &[F], output: &mut [F])

process helper function that calls Svf::tick on each sample

Source

pub fn reset(&mut self)

Reset state of filter. Can be used when the audio callback is restarted.

Source

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
Source

pub fn set_coeffs(&mut self, coefficients: SvfCoefficients<F>)

Set new filter parameters from coefficients struct

Source

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

Source

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

Source

pub fn get_response(&self, frequency: f64) -> Result<Complex64, SvfError>

utility method to get the response should not be called from another thread than the set methods

Trait Implementations§

Source§

impl<F: Default + Float> Default for Svf<F>

Source§

fn default() -> Svf<F>

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.