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) {
|
||||
for iq in chunk.samples.iter_mut() {
|
||||
pub fn process_chunk(&mut self, chunk: &IqChunk) -> IqChunk {
|
||||
let mut chunk_out = IqChunk::new();
|
||||
|
||||
for iq in chunk.samples.iter() {
|
||||
self.history.push(*iq);
|
||||
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];
|
||||
|
||||
// Decimation
|
||||
if self.decimation_index.is_multiple_of(self.decimation_factor) {
|
||||
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> {
|
||||
match self.inner.next()? {
|
||||
Ok(mut chunk) => {
|
||||
self.process_chunk(&mut chunk);
|
||||
Some(Ok(chunk))
|
||||
Ok(chunk) => {
|
||||
// self.process_chunk(&mut chunk);
|
||||
// Some(Ok(chunk))
|
||||
Some(Ok(self.process_chunk(&chunk)))
|
||||
}
|
||||
Err(e) => Some(Err(e)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user