Stream rework, qpsk example, splitter/merger
This commit is contained in:
8
examples/simple/Cargo.toml
Normal file
8
examples/simple/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "simple"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
oxydsp-flowgraph = {path = "../../oxydsp-flowgraph/"}
|
||||
oxydsp-dsp = {path = "../../oxydsp-dsp/"}
|
||||
31
examples/simple/src/main.rs
Normal file
31
examples/simple/src/main.rs
Normal file
@ -0,0 +1,31 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use oxydsp_dsp::blocks::utilities::adapters::NullSink;
|
||||
use oxydsp_dsp::blocks::utilities::adapters::Scan;
|
||||
use oxydsp_dsp::blocks::utilities::channels::RxSource;
|
||||
use oxydsp_flowgraph::flowgraph;
|
||||
|
||||
fn main()
|
||||
{
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
let (rx_source, numbers) = RxSource::new(rx);
|
||||
let (inspect, numbers) = Scan::new(numbers, 0, |state, x: usize| {
|
||||
if x.is_multiple_of(100)
|
||||
{
|
||||
println!("{}", x);
|
||||
}
|
||||
x
|
||||
});
|
||||
let null_sink = NullSink::new(numbers);
|
||||
let graph = flowgraph![rx_source, inspect, null_sink];
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let mut x = 0usize;
|
||||
loop
|
||||
{
|
||||
let _ = tx.send(x);
|
||||
x += 1;
|
||||
}
|
||||
});
|
||||
graph.run(1).join();
|
||||
}
|
||||
Reference in New Issue
Block a user