use std::{path::PathBuf, thread, time::Duration};
use maudio::{
audio::sample_rate::SampleRate,
engine::{
node_graph::{
nodes::{filters::lpf::LpfNodeBuilder, NodeOps},
NodeGraphOps,
},
Engine, EngineOps,
},
MaResult,
};
fn main() -> MaResult<()> {
let engine = Engine::new()?;
let path = PathBuf::from(concat!(
env!("CARGO_MANIFEST_DIR"),
"/../maudio-sys/native/miniaudio/data/16-44100-stereo.flac"
));
let node_graph = engine.as_node_graph().unwrap();
let mut lpf = LpfNodeBuilder::new(&node_graph, 2, SampleRate::Sr48000, 800.0, 1).build()?;
let mut end_node = node_graph.endpoint().unwrap();
let mut source = engine.new_sound_from_file(&path)?;
let mut source_node = source.as_node();
source_node.detach_all_outputs()?;
source_node.attach_output_bus(0, &mut lpf, 0)?;
lpf.attach_output_bus(0, &mut end_node, 0)?;
source.play_sound()?;
println!("Stopping in 5 seconds...");
thread::sleep(Duration::from_secs(5));
source.stop_sound()?;
Ok(())
}