Better tag interface, starting bpsk
This commit is contained in:
@ -9,6 +9,7 @@ use oxydsp_flowgraph::io::In;
|
||||
use oxydsp_flowgraph::io::Out;
|
||||
use oxydsp_flowgraph::sync_block;
|
||||
use oxydsp_flowgraph::tag::Tag;
|
||||
use oxydsp_flowgraph::tag::TagKey;
|
||||
|
||||
use crate::filtering::fir::Fir;
|
||||
use crate::filtering::fir::FirFilter;
|
||||
@ -37,13 +38,20 @@ pub struct EarlyLateGate<T: Float + Send + Sync + Sum + Clone + NumCast + 'stati
|
||||
// a symbol center (hopefully)
|
||||
next_sample: f32,
|
||||
loop_filter: FirFilter<T, T, T>,
|
||||
|
||||
symbol_tag_key: TagKey<T>,
|
||||
}
|
||||
|
||||
impl<T> EarlyLateGate<T>
|
||||
where
|
||||
T: Float + Sum + Clone + 'static + Send + Sync + NumCast,
|
||||
{
|
||||
pub fn new(input: In<T>, loop_filter: Fir<T>, symbol_length: usize) -> (Self, In<T>)
|
||||
pub fn new(
|
||||
input: In<T>,
|
||||
loop_filter: Fir<T>,
|
||||
symbol_length: usize,
|
||||
symbol_tag_key: TagKey<T>,
|
||||
) -> (Self, In<T>)
|
||||
{
|
||||
let (output, samples) = oxydsp_flowgraph::io::stream();
|
||||
(
|
||||
@ -57,6 +65,7 @@ where
|
||||
next_sample: symbol_length as f32, // We assume that the first symbol is 1.5 windows into
|
||||
// the stream
|
||||
loop_filter: FirFilter::new(loop_filter),
|
||||
symbol_tag_key,
|
||||
},
|
||||
samples,
|
||||
)
|
||||
@ -102,9 +111,7 @@ where
|
||||
*state.next_sample -= *state.window_location as f32;
|
||||
*state.window_location = 0;
|
||||
|
||||
let new_tag = Tag::default();
|
||||
new_tag.tag("elg_symbol", error);
|
||||
tag = Some(new_tag);
|
||||
tag = Some(Tag::with_entry(state.symbol_tag_key.clone(), error));
|
||||
}
|
||||
|
||||
Some((sample, tag).into())
|
||||
|
||||
@ -3,12 +3,11 @@ use std::iter::Peekable;
|
||||
use oxydsp_flowgraph::BlockIO;
|
||||
use oxydsp_flowgraph::block::Block;
|
||||
use oxydsp_flowgraph::block::BlockResult;
|
||||
use oxydsp_flowgraph::block::SyncBlock;
|
||||
use oxydsp_flowgraph::io::In;
|
||||
use oxydsp_flowgraph::io::Out;
|
||||
use oxydsp_flowgraph::io::stream;
|
||||
use oxydsp_flowgraph::sync_block;
|
||||
use oxydsp_flowgraph::tag::Tag;
|
||||
use oxydsp_flowgraph::tag::TagKey;
|
||||
|
||||
#[derive(BlockIO)]
|
||||
pub struct IterSource<I: Iterator>
|
||||
@ -16,6 +15,7 @@ where
|
||||
I::Item: 'static,
|
||||
{
|
||||
iter: Peekable<I>,
|
||||
finished_tag: Option<TagKey<()>>,
|
||||
|
||||
#[output]
|
||||
output: Out<I::Item>,
|
||||
@ -32,11 +32,17 @@ where
|
||||
(
|
||||
Self {
|
||||
iter: iter.peekable(),
|
||||
finished_tag: None,
|
||||
output,
|
||||
},
|
||||
items,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn tag_last_with(&mut self, finished_tag: TagKey<()>)
|
||||
{
|
||||
self.finished_tag = Some(finished_tag);
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> Block for IterSource<I>
|
||||
@ -53,11 +59,10 @@ where
|
||||
if let Some(element) = self.iter.next()
|
||||
{
|
||||
let mut tag = None;
|
||||
if self.iter.peek().is_none()
|
||||
if let Some(tag_key) = &self.finished_tag
|
||||
&& self.iter.peek().is_none()
|
||||
{
|
||||
let new_tag = Tag::default();
|
||||
new_tag.tag("itersource_finished", ());
|
||||
tag = Some(new_tag);
|
||||
tag = Some(Tag::with_entry(tag_key.clone(), ()));
|
||||
}
|
||||
let _ = writer.push((element, tag).into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user