conformal_component

Macro pzip

Source
macro_rules! pzip {
    ($params:ident[$($kind:ident $path:literal),+]) => { ... };
}
Expand description

Utility to get a per-sample iterator including the state of multiple parameters.

This is a convenient way to consume a BufferStates object if you intend to track the per-sample state of multiple parameters.

This macro indexes into a BufferStates object with a list of parameter ids and their types. See the examples below for usage.

ยงExamples

let params = ConstantBufferStates::new_defaults(
  vec![
    StaticInfoRef {
      title: "Numeric",
      short_title: "Numeric",
      unique_id: "gain",
      flags: Default::default(),
      type_specific: TypeSpecificInfoRef::Numeric {
        default: 0.0,
        valid_range: 0.0..=1.0,
        units: None,
      },
    },
    StaticInfoRef {
      title: "Enum",
      short_title: "Enum",
      unique_id: "letter",
      flags: Default::default(),
      type_specific: TypeSpecificInfoRef::Enum {
        default: 1,
        values: &["A", "B", "C"],
      },
    },
    StaticInfoRef {
      title: "Switch",
      short_title: "Switch",
      unique_id: "my special switch",
      flags: Default::default(),
      type_specific: TypeSpecificInfoRef::Switch {
        default: false,
      },
    },
  ],
);

let samples: Vec<_> = pzip!(params[
  numeric "gain",
  enum "letter",
  switch "my special switch"
]).take(2).collect();

assert_eq!(samples, vec![(0.0, 1, false), (0.0, 1, false)]);