Filter

Struct Filter 

Source
pub struct Filter { /* private fields */ }
Expand description

Create a FIR Filter, which can be applied to signals (simply Vec<f32>).

use pluto_sdr::filter::Filter;
// arbitrary signal
let signal = vec![1., 4., -3., 5., 10., -19., -4., 10., -2., -1.];
// coeff describe a 4 point moving average
let lpf_coefficients = vec![0.25, 0.25, 0.25, 0.25];
// create the low pass filter
let lpf = Filter::new(lpf_coefficients.into());

// filter the signal
let filtered = lpf.filter_windowed(&signal);
println!("{:?}", filtered);

Implementations§

Source§

impl Filter

Source

pub fn new(coeff: Vec<f32>) -> Self

Create a new FIR Filter. coeff is of type Vec<f32> and contains the FIR Filters Coefficients: [b_0, b_1, b_2, ... ].

Source

pub fn len(&self) -> usize

The Filter size is just the size of its coefficients

Source

pub fn filter_windowed(&self, signal: &Vec<f32>) -> Vec<f32>

recall that windowed convolution produces a signal of length N - M + 1 where N is the length of signal 1: signal; and M is the length of signal 2: self.coeff The signal should be longer than the internal filter coefficients.

Source

pub fn create_moving_average(size: usize) -> Self

Creates a moving average filter, where all coefficients are the same value of 1 / N, where the size of the filter is N.

Source

pub fn create_srrc(n_half: usize, b: f32, m: usize) -> Self

Creates a Matched Filter / Square-root raised cosine filter. A Root Raised Cosine / Matched Filter has very low ISI / Inter Symbol Interference. n_half is half the length of the pulse (0,1,2…(n_half*2+1)). -> we want one sample in the middle of the pulse: sinc(0), that is why the length of this filter is always uneven. b is beta / sinc roll-off and m is the oversampling factor. (Ported from Matlab: srrc.m, see Software Receiver Design book)

Trait Implementations§

Source§

impl Debug for Filter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Filter

Source§

fn eq(&self, other: &Filter) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Filter

Auto Trait Implementations§

§

impl Freeze for Filter

§

impl RefUnwindSafe for Filter

§

impl Send for Filter

§

impl Sync for Filter

§

impl Unpin for Filter

§

impl UnwindSafe for Filter

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.