pub struct FilterProcessor<SampleType: Pow<SampleType, Output = SampleType> + Debug + Float + FloatConst> { /* private fields */ }
Expand description

An [AudioProcessor] which holds a Filter. Easy to use DSP filter.

After setting the filter type with FilterProcessor::set_filter_type, use the filter with the [AudioProcessor::prepare] and [AudioProcessor::process] methods.

use audio_processor_traits::{AudioBuffer, AudioProcessor, AudioProcessorSettings, AudioContext};
use audio_processor_traits::simple_processor::MultiChannel;
use augmented_dsp_filters::rbj::{FilterProcessor, FilterType};

let mut audio_buffer = AudioBuffer::empty();
audio_buffer.resize(2, 1 * 44100);
let settings = AudioProcessorSettings {
    sample_rate: 44100.0,
    ..AudioProcessorSettings::default()
};
let mut context = AudioContext::from(settings.clone());

let build_filter = || {
    let mut filter_processor: FilterProcessor<f32> = FilterProcessor::new(FilterType::LowPass);
    filter_processor.set_cutoff(880.0);
    filter_processor.set_q(1.0);
    filter_processor
};

let mut filter_processor = MultiChannel::new(build_filter);
filter_processor.prepare(&mut context);
filter_processor.process(&mut context, &mut audio_buffer);

Implementations§

source§

impl<SampleType> FilterProcessor<SampleType>
where SampleType: Pow<SampleType, Output = SampleType> + Debug + Float + FloatConst + Sum,

source

pub fn new(filter_type: FilterType) -> Self

Create a new FilterProcessor with the FilterType and an initial state.

Sample-rate, cut-off, q, gain and slope will be set to defaults, but should be changed.

source

pub fn set_filter_type(&mut self, filter_type: FilterType)

Change the filter-type

source

pub fn set_cutoff(&mut self, cutoff: SampleType)

Change the cut-off

source

pub fn set_q(&mut self, q: SampleType)

Change the q

source

pub fn set_band_width(&mut self, band_width: SampleType)

Change the bandwidth

source

pub fn set_center_frequency(&mut self, center_frequency: SampleType)

Change the center-frequency

source

pub fn set_slope(&mut self, slope: SampleType)

Change the slope

source

pub fn set_gain_db(&mut self, gain_db: SampleType)

Change the gain

source

pub fn set_sample_rate(&mut self, sample_rate: SampleType)

Set the sample-rate

source

pub fn setup(&mut self)

Set-up the filter for playback

Trait Implementations§

source§

impl<SampleType> AudioProcessorHandleProvider for FilterProcessor<SampleType>
where SampleType: Pow<SampleType, Output = SampleType> + Debug + Float + FloatConst,

source§

impl Default for FilterProcessor<f32>

source§

fn default() -> Self

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

impl<SampleType> MonoAudioProcessor for FilterProcessor<SampleType>
where SampleType: Pow<SampleType, Output = SampleType> + Debug + Float + FloatConst + Send + Sync + Sum<SampleType>,

§

type SampleType = SampleType

source§

fn m_prepare(&mut self, context: &mut AudioContext)

source§

fn m_process( &mut self, _context: &mut AudioContext, sample: Self::SampleType ) -> Self::SampleType

Auto Trait Implementations§

§

impl<SampleType> RefUnwindSafe for FilterProcessor<SampleType>
where SampleType: RefUnwindSafe,

§

impl<SampleType> Send for FilterProcessor<SampleType>
where SampleType: Send,

§

impl<SampleType> Sync for FilterProcessor<SampleType>
where SampleType: Sync,

§

impl<SampleType> Unpin for FilterProcessor<SampleType>
where SampleType: Unpin,

§

impl<SampleType> UnwindSafe for FilterProcessor<SampleType>
where SampleType: 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>,

§

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

§

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.