macro_rules! pgrab {
($params:ident[$($kind:ident $path:tt),+]) => { ... };
($expr_head:ident $(. $expr_part:ident $( ( $($args:tt)* ) )? )+ [$($kind:ident $path:tt),+]) => { ... };
}Expand description
Grab an instantaneous snapshot of parameter values at the start of the buffer.
This has the same syntax as pzip! but instead of returning a per-sample
iterator, it returns the values from the first sample as a tuple.
This is useful for parameters that don’t need to be modulated every sample.
§Examples
let params = ConstantBufferStates::new_defaults(
vec![
StaticInfoRef {
title: "Gain",
short_title: "Gain",
unique_id: "gain",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.5,
valid_range: 0.0..=1.0,
units: None,
},
},
StaticInfoRef {
title: "Switch",
short_title: "Switch",
unique_id: "enabled",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Switch {
default: true,
},
},
],
);
let (gain, enabled) = pgrab!(params[numeric "gain", switch "enabled"]);
assert_eq!(gain, 0.5);
assert_eq!(enabled, true);It also works with a single parameter:
let params = ConstantBufferStates::new_defaults(
vec![
StaticInfoRef {
title: "Gain",
short_title: "Gain",
unique_id: "gain",
flags: Default::default(),
type_specific: TypeSpecificInfoRef::Numeric {
default: 0.75,
valid_range: 0.0..=1.0,
units: None,
},
},
],
);
let gain = pgrab!(params[numeric "gain"]);
assert_eq!(gain, 0.75);