FunDSP represents audio network structure at the type level using the AudioNode component system.
Arity and Types
Input and output arities are encoded using types U0, U1, ..., UN (from the typenum crate). These are accessible via the associated types AudioNode::Inputs and AudioNode::Outputs.
The An<X> Wrapper
Preludes use the An<X: AudioNode> wrapper type. This wrapper provides operator overloading (like ^, |, >>, &) and implements the AudioUnit trait.
Type Signatures
When defining functions that return a graph, you can use impl AudioNode for brevity, but the type will be opaque. To allow the node to be used in further combinations, you should declare the full arity in the signature:
use fundsp::prelude64::*;
fn split_quad() -> An<impl AudioNode<Inputs = U1, Outputs = U4>> {
pass() ^ pass() ^ pass() ^ pass()
}
Debugging Opaque Types
Because the compiler reports these types in an opaque form (e.g., An<Bus<Noise, Pipe<Constant<...>, Sine>>>), you can use the provided example utility to unscramble them:
cargo run --example type -- "fundsp::combinator::An<Bus<Noise, Pipe<Constant<typenum::uint::UInt<typenum::uint::UTerm,typenum::bit::B1>>, Sine>>>"