fm demod
This commit is contained in:
@ -94,7 +94,7 @@ 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 sample) => Some(Ok(self.process_sample(sample))),
|
Ok(sample) => Some(Ok(self.process_sample(sample))),
|
||||||
Err(e) => Some(Err(e)),
|
Err(e) => Some(Err(e)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use crate::iq_reader::IqSample;
|
use crate::iq_reader::IqSample;
|
||||||
|
|
||||||
pub type Phase = f32;
|
pub type Sample = f32;
|
||||||
|
|
||||||
pub struct FmDemod<I> {
|
pub struct FmDemod<I> {
|
||||||
pub inner: I,
|
pub inner: I,
|
||||||
@ -15,7 +15,7 @@ impl<I> FmDemod<I> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_sample(&mut self, sample: IqSample) -> Phase {
|
pub fn process_sample(&mut self, sample: IqSample) -> Sample {
|
||||||
let phase_diff = sample * self.prev_sample.conj();
|
let phase_diff = sample * self.prev_sample.conj();
|
||||||
self.prev_sample = sample;
|
self.prev_sample = sample;
|
||||||
phase_diff.arg()
|
phase_diff.arg()
|
||||||
@ -26,7 +26,7 @@ impl<I, E> Iterator for FmDemod<I>
|
|||||||
where
|
where
|
||||||
I: Iterator<Item = Result<IqSample, E>>,
|
I: Iterator<Item = Result<IqSample, E>>,
|
||||||
{
|
{
|
||||||
type Item = Result<Phase, E>;
|
type Item = Result<Sample, E>;
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
match self.inner.next()? {
|
match self.inner.next()? {
|
||||||
|
|||||||
@ -22,7 +22,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
for phase_r in pipeline {
|
for phase_r in pipeline {
|
||||||
let phase = phase_r?;
|
let phase = phase_r?;
|
||||||
println!("phase : {}", phase);
|
// println!("phase : {}", phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user