Struct augmented_dsp_filters::rbj::FilterProcessor
source · 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>
impl<SampleType> FilterProcessor<SampleType>
sourcepub fn new(filter_type: FilterType) -> Self
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.
sourcepub fn set_filter_type(&mut self, filter_type: FilterType)
pub fn set_filter_type(&mut self, filter_type: FilterType)
Change the filter-type
sourcepub fn set_cutoff(&mut self, cutoff: SampleType)
pub fn set_cutoff(&mut self, cutoff: SampleType)
Change the cut-off
sourcepub fn set_band_width(&mut self, band_width: SampleType)
pub fn set_band_width(&mut self, band_width: SampleType)
Change the bandwidth
sourcepub fn set_center_frequency(&mut self, center_frequency: SampleType)
pub fn set_center_frequency(&mut self, center_frequency: SampleType)
Change the center-frequency
sourcepub fn set_gain_db(&mut self, gain_db: SampleType)
pub fn set_gain_db(&mut self, gain_db: SampleType)
Change the gain
sourcepub fn set_sample_rate(&mut self, sample_rate: SampleType)
pub fn set_sample_rate(&mut self, sample_rate: SampleType)
Set the sample-rate
Trait Implementations§
source§impl<SampleType> AudioProcessorHandleProvider for FilterProcessor<SampleType>
impl<SampleType> AudioProcessorHandleProvider for FilterProcessor<SampleType>
fn generic_handle(&self) -> AudioProcessorHandleRef
source§impl Default for FilterProcessor<f32>
impl Default for FilterProcessor<f32>
source§impl<SampleType> MonoAudioProcessor for FilterProcessor<SampleType>
impl<SampleType> MonoAudioProcessor for FilterProcessor<SampleType>
type SampleType = SampleType
fn m_prepare(&mut self, context: &mut AudioContext)
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> 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