Skip to main content

sim_lib_audio_graph_core/
cookbook.rs

1//! Deterministic cookbook builders for audio-graph core recipes.
2
3use crate::{Patch, PatchNode};
4
5use sim_kernel::Expr;
6
7/// Build the modeled copy-node patch descriptor used by the cookbook recipe.
8pub fn copy_node_demo() -> Expr {
9    Patch {
10        nodes: vec![PatchNode {
11            id: "copy".to_owned(),
12            in_channels: 1,
13            out_channels: 1,
14        }],
15        cables: Vec::new(),
16    }
17    .to_expr()
18}
19
20#[cfg(test)]
21mod tests {
22    use super::*;
23    use crate::Patch;
24
25    #[test]
26    fn copy_node_demo_round_trips_as_patch() {
27        let expr = copy_node_demo();
28        let patch = Patch::from_expr(&expr).expect("copy node patch decodes");
29        assert_eq!(patch.nodes.len(), 1);
30        assert_eq!(patch.nodes[0].id, "copy");
31    }
32}