diff --git a/src/fm_demod.rs b/src/fm_demod.rs new file mode 100644 index 0000000..c2f5f9f --- /dev/null +++ b/src/fm_demod.rs @@ -0,0 +1,39 @@ +use std::{os::unix::process, slice::Chunks}; + +use crate::iq_reader::{IqChunk, IqSample}; + +pub struct FmDemod { + pub inner: I, + pub prev_sample: IqSample, +} + +impl FmDemod { + pub fn new(inner: I) -> Self { + Self { + inner, + prev_sample: IqSample::new(1.0, 0.0), + } + } + + pub fn process_chunk(&mut self, chunk: &mut IqChunk) { + // TODO: FM Demodulation + todo!(); + } +} + +impl Iterator for FmDemod +where + I: Iterator>, +{ + type Item = Result; + + fn next(&mut self) -> Option { + match self.inner.next()? { + Ok(mut chunk) => { + self.process_chunk(&mut chunk); + Some(Ok(chunk)) + } + Err(e) => Some(Err(e)), + } + } +} diff --git a/src/main.rs b/src/main.rs index 48b77ca..fdc9380 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use std::error::Error; mod agc; mod fir; +mod fm_demod; mod iq_reader; mod pipeline; mod utils;