decimation
This commit is contained in:
32
src/fir.rs
32
src/fir.rs
@ -27,18 +27,27 @@ impl<I, const N: usize> Fir<I, N> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_chunk(&mut self, chunk: &mut IqChunk) {
|
pub fn process_chunk(&mut self, chunk: &IqChunk) -> IqChunk {
|
||||||
for iq in chunk.samples.iter_mut() {
|
let mut chunk_out = IqChunk::new();
|
||||||
|
|
||||||
|
for iq in chunk.samples.iter() {
|
||||||
self.history.push(*iq);
|
self.history.push(*iq);
|
||||||
let mut y_n = IqSample::default();
|
|
||||||
for k in 0..N {
|
// Decimation
|
||||||
if let Some(sample) = self.history.read_at(k) {
|
if self.decimation_index.is_multiple_of(self.decimation_factor) {
|
||||||
y_n += *sample * self.taps[k];
|
let mut y_n = IqSample::default();
|
||||||
|
for k in 0..N {
|
||||||
|
if let Some(sample) = self.history.read_at(k) {
|
||||||
|
y_n += *sample * self.taps[k];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chunk_out.samples.push(y_n);
|
||||||
}
|
}
|
||||||
*iq = y_n
|
|
||||||
|
self.decimation_index += 1;
|
||||||
}
|
}
|
||||||
// TODO: Decimation
|
chunk_out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,9 +59,10 @@ where
|
|||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
match self.inner.next()? {
|
match self.inner.next()? {
|
||||||
Ok(mut chunk) => {
|
Ok(chunk) => {
|
||||||
self.process_chunk(&mut chunk);
|
// self.process_chunk(&mut chunk);
|
||||||
Some(Ok(chunk))
|
// Some(Ok(chunk))
|
||||||
|
Some(Ok(self.process_chunk(&chunk)))
|
||||||
}
|
}
|
||||||
Err(e) => Some(Err(e)),
|
Err(e) => Some(Err(e)),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,6 +11,14 @@ pub struct IqChunk {
|
|||||||
pub samples: Vec<IqSample>,
|
pub samples: Vec<IqSample>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IqChunk {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
IqChunk {
|
||||||
|
samples: Vec::<IqSample>::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct FileSource {
|
pub struct FileSource {
|
||||||
// Buffer
|
// Buffer
|
||||||
pub reader: BufReader<File>,
|
pub reader: BufReader<File>,
|
||||||
|
|||||||
@ -12,14 +12,15 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
let source = FileSource::new("test.iq", 32769)?;
|
let source = FileSource::new("test.iq", 32769)?;
|
||||||
|
|
||||||
// Fir coefs
|
// Fir coefs
|
||||||
let taps = [1.0; 64];
|
let taps = [0.5; 64];
|
||||||
|
|
||||||
let pipeline = source
|
let pipeline = source
|
||||||
.agc(20_000_000.0, 1.0, 0.001, 100.0)
|
.agc(20_000_000.0, 1.0, 0.001, 100.0)
|
||||||
.fir::<64>(taps, 4);
|
.fir::<64>(taps, 4);
|
||||||
|
|
||||||
for chunk_r in pipeline {
|
for chunk_r in pipeline {
|
||||||
let _chunk = chunk_r?;
|
let chunk = chunk_r?;
|
||||||
|
println!("size : {}", chunk.samples.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user