Skip to main content

wavecraft_dsp/combinators/
mod.rs

1//! Processor combinators for chaining DSP operations.
2
3mod chain;
4
5pub use chain::Chain;
6
7/// Combines processors into a serial chain.
8///
9/// Single processor optimization:
10/// ```rust,no_run
11/// use wavecraft_dsp::builtins::GainDsp;
12/// use wavecraft_dsp::Chain;
13///
14/// type Single = Chain![GainDsp]; // Compiles to just `GainDsp`, no wrapper overhead
15/// ```
16///
17/// Multiple processors:
18/// ```rust,no_run
19/// use wavecraft_dsp::builtins::{GainDsp, PassthroughDsp};
20/// use wavecraft_dsp::Chain;
21///
22/// type Multiple = Chain![GainDsp, PassthroughDsp];
23/// ```
24#[macro_export]
25macro_rules! Chain {
26    // Single processor: no wrapping, zero overhead
27    ($single:ty) => {
28        $single
29    };
30    // Multiple: nest into Chain<A, Chain<B, ...>>
31    ($first:ty, $($rest:ty),+ $(,)?) => {
32        $crate::combinators::Chain<$first, $crate::Chain![$($rest),+]>
33    };
34}