rill_core/macros/
ports.rs1#[macro_export]
5macro_rules! audio_node {
6 (
7 $(#[$meta:meta])*
8 source $name:ident<$T:ident: $crate::math::Transcendental, const $BUF:ident: usize>
9 $(where $($bounds:tt)*)?
10 { $($tt:tt)* }
11 ) => {
12 $crate::source_node! {
13 $(#[$meta])*
14 pub $name<$T, $BUF>
15 $(where $($bounds)*)?
16 { $($tt)* }
17 }
18 };
19
20 (
21 $(#[$meta:meta])*
22 processor $name:ident<$T:ident: $crate::math::Transcendental, const $BUF:ident: usize>
23 $(where $($bounds:tt)*)?
24 { $($tt:tt)* }
25 ) => {
26 $crate::processor_node! {
27 $(#[$meta])*
28 pub $name<$T, $BUF>
29 $(where $($bounds)*)?
30 { $($tt)* }
31 }
32 };
33
34 (
35 $(#[$meta:meta])*
36 sink $name:ident<$T:ident: $crate::math::Transcendental, const $BUF:ident: usize>
37 $(where $($bounds:tt)*)?
38 { $($tt:tt)* }
39 ) => {
40 $crate::sink_node! {
41 $(#[$meta])*
42 pub $name<$T, $BUF>
43 $(where $($bounds)*)?
44 { $($tt)* }
45 }
46 };
47}
48
49#[macro_export]
51macro_rules! with_parameters {
52 (
53 $node:expr,
54 $($name:ident: $value:expr),* $(,)?
55 ) => {
56 {
57 let mut node = $node;
58 $(
59 let param_id = match $crate::ParameterId::new(stringify!($name)) {
61 Ok(id) => id,
62 Err(e) => panic!("Invalid parameter name '{}': {:?}", stringify!($name), e),
63 };
64 let param_value: $crate::ParamValue = $value.into();
66 match node.set_parameter(¶m_id, param_value) {
67 Ok(()) => {},
68 Err(e) => panic!("Failed to set parameter '{}': {:?}", stringify!($name), e),
69 }
70 )*
71 node
72 }
73 };
74}