ring buffer init
This commit is contained in:
32
src/fir.rs
Normal file
32
src/fir.rs
Normal file
@ -0,0 +1,32 @@
|
||||
// Finite Impulse response + Decimation
|
||||
use num_complex::Complex32;
|
||||
use crate::utils::ring_buffer::RingBuffer;
|
||||
|
||||
pub struct Fir {
|
||||
// Filter coefs
|
||||
pub taps: Vec<f32>,
|
||||
|
||||
// Ring Buffer of samples
|
||||
pub history: RingBuffer<Complex32>,
|
||||
|
||||
decimation_factor: usize,
|
||||
|
||||
// When to keep a sample
|
||||
decimator_counter: usize,
|
||||
}
|
||||
|
||||
impl Fir {
|
||||
fn new(decimation_factor: usize) -> Self {
|
||||
Self {
|
||||
// TODO: precalulate filter coefs + ring buffer
|
||||
taps: vec![],
|
||||
history:
|
||||
decimation_factor,
|
||||
decimator_counter: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn () {
|
||||
|
||||
}
|
||||
}
|
||||
@ -3,7 +3,9 @@ use crate::iq_reader::FileSource;
|
||||
use std::error::Error;
|
||||
|
||||
mod agc;
|
||||
mod fir;
|
||||
mod iq_reader;
|
||||
mod utils;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let source = FileSource::new("test.iq", 32769)?;
|
||||
|
||||
1
src/utils/mod.rs
Normal file
1
src/utils/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod ring_buffer;
|
||||
38
src/utils/ring_buffer.rs
Normal file
38
src/utils/ring_buffer.rs
Normal file
@ -0,0 +1,38 @@
|
||||
pub struct RingBuffer<T> {
|
||||
pub data: Vec<T>,
|
||||
pub head: usize,
|
||||
pub tail: usize,
|
||||
pub len: usize,
|
||||
}
|
||||
|
||||
impl<T> RingBuffer<T> {
|
||||
fn new(capacity: usize) -> Self {
|
||||
// TODO : add capacity to vec
|
||||
Self {
|
||||
data: Vec::new(),
|
||||
head: 0,
|
||||
tail: 0,
|
||||
len: 0,
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&mut self, value: T) {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn pop(&mut self) -> bool {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn is_empty(&self) -> bool {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn is_full(&self) -> bool {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn len(&self) -> usize {
|
||||
self.len
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user