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
impl Filter
Sourcepub fn new(coeff: Vec<f32>) -> Self
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, ... ].
Sourcepub fn filter_windowed(&self, signal: &Vec<f32>) -> Vec<f32>
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.
Sourcepub fn create_moving_average(size: usize) -> Self
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.
Sourcepub fn create_srrc(n_half: usize, b: f32, m: usize) -> Self
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)