Skip to main content

vstkit_params

Macro vstkit_params 

Source
macro_rules! vstkit_params {
    (
        $set_name:ident;
        $(
            $param_name:ident {
                id: $id:expr,
                name: $name:expr,
                short_name: $short_name:expr,
                unit: $unit:expr,
                default: $default:expr,
                min: $min:expr,
                max: $max:expr,
                step: $step:expr $(,)?
            }
        ),* $(,)?
    ) => { ... };
}
Expand description

Define a parameter set with minimal boilerplate.

This macro generates:

  • A parameter ID enum (with #[repr(u32)])
  • A ParamSet implementation
  • Conversion from the ID enum to ParamId

§Syntax

vstkit_params! {
    ParamSetName;

    ParameterName {
        id: 0,
        name: "Display Name",
        short_name: "Short",
        unit: "unit",
        default: 0.0,
        min: -10.0,
        max: 10.0,
        step: 0.1,
    },

    // ... more parameters
}

§Example

use wavecraft_protocol::vstkit_params;

vstkit_params! {
    MyParams;
     
    Volume {
        id: 0,
        name: "Volume",
        short_name: "Vol",
        unit: "dB",
        default: 0.0,
        min: -60.0,
        max: 12.0,
        step: 0.1,
    },
     
    Pan {
        id: 1,
        name: "Pan",
        short_name: "Pan",
        unit: "",
        default: 0.0,
        min: -1.0,
        max: 1.0,
        step: 0.01,
    },
}

// The macro generates:
// - enum MyParamsId { Volume = 0, Pan = 1 }
// - struct MyParams
// - impl ParamSet for MyParams
// - impl From<MyParamsId> for ParamId