fm demod
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
use crate::iq_reader::{IqChunk, IqSample};
|
||||
use crate::iq_reader::IqSample;
|
||||
|
||||
pub type Phase = f32;
|
||||
|
||||
pub struct FmDemod<I> {
|
||||
pub inner: I,
|
||||
@ -13,9 +15,10 @@ impl<I> FmDemod<I> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn process_sample(&mut self, sample: IqSample) -> IqSample {
|
||||
// TODO: FM Demodulation
|
||||
todo!();
|
||||
pub fn process_sample(&mut self, sample: IqSample) -> Phase {
|
||||
let phase_diff = sample * self.prev_sample.conj();
|
||||
self.prev_sample = sample;
|
||||
phase_diff.arg()
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +26,7 @@ impl<I, E> Iterator for FmDemod<I>
|
||||
where
|
||||
I: Iterator<Item = Result<IqSample, E>>,
|
||||
{
|
||||
type Item = Result<IqSample, E>;
|
||||
type Item = Result<Phase, E>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
match self.inner.next()? {
|
||||
|
||||
Reference in New Issue
Block a user