use gmt_dos_actors::{actorscript, prelude::*, system::Sys}; use gmt_dos_clients::{Logging, Signal, Signals}; use tweeter::ResHiFi; use woofer::{AddLoFi, AddResLoFi}; mod tweeter; mod woofer; // use crate::sys::*; #[tokio::main] async fn main() -> anyhow::Result<()> { env_logger::init(); let sampling_frequency_hz = 1_000.; let lofi: Signals = Signals::new(1, 4_000).channels( Signal::Sinusoid { amplitude: 1., sampling_frequency_hz, frequency_hz: 1., phase_s: 0., } + Signal::Sinusoid { amplitude: 0.25, sampling_frequency_hz, frequency_hz: 10., phase_s: 0., }, ); let woofer = Sys::new(woofer::Woofer::new()).build()?; let tweeter = Sys::new(tweeter::Tweeter::new()).build()?; actorscript! { #[model(state = running)] 1: lofi[AddLoFi]~ -> {woofer}[AddResLoFi] -> {tweeter}[ResHiFi]~ } Ok(()) } #[test] fn test_main() -> anyhow::Result<()> { let sampling_frequency_hz = 1_000.; let lofi: Signals = Signals::new(1, 4_000).channels( Signal::Sinusoid { amplitude: 1., sampling_frequency_hz, frequency_hz: 1., phase_s: 0., } + Signal::Sinusoid { amplitude: 0.25, sampling_frequency_hz, frequency_hz: 10., phase_s: 0., }, ); let mut woofer = Sys::new(woofer::Woofer::new()).build()?; let mut tweeter = Sys::new(tweeter::Tweeter::new()).build()?; let mut alofi: Initiator<_> = lofi.into(); let mut logger: Terminator<_> = Logging::new(1).into(); alofi .add_output() .build::() .into_input(&mut woofer)?; woofer .add_output() .build::() .into_input(&mut tweeter)?; tweeter .add_output() .build::() .into_input(&mut logger)?; model!(alofi, woofer, tweeter, logger).check()?.flowchart(); Ok(()) } /* G 764265725185495747 Signals 11232177092631395957 764265725185495747->11232177092631395957 7219006743340403785 WOOFER 4257120465144094172 7219006743340403785->4257120465144094172 1512659184026690350 Logging<f64> 11232177092631395957->7219006743340403785 AddLoFi 4257120465144094172->1512659184026690350 AddResLoFi */