Skip to main content

truce_params/
info.rs

1use crate::range::ParamRange;
2
3/// Metadata for a single parameter, used by format wrappers.
4#[derive(Clone, Debug)]
5pub struct ParamInfo {
6    pub id: u32,
7    pub name: &'static str,
8    pub short_name: &'static str,
9    pub group: &'static str,
10    pub range: ParamRange,
11    pub default_plain: f64,
12    pub flags: ParamFlags,
13    pub unit: ParamUnit,
14}
15
16bitflags::bitflags! {
17    #[derive(Clone, Copy, Debug, PartialEq, Eq)]
18    pub struct ParamFlags: u32 {
19        const AUTOMATABLE = 0b0001;
20        const HIDDEN      = 0b0010;
21        const READONLY    = 0b0100;
22        const IS_BYPASS   = 0b1000;
23    }
24}
25
26#[derive(Clone, Copy, Debug, PartialEq, Eq)]
27pub enum ParamUnit {
28    None,
29    Db,
30    Hz,
31    Milliseconds,
32    Seconds,
33    Percent,
34    Semitones,
35    Pan,
36}
37
38impl ParamUnit {
39    /// Format-agnostic unit string for host display.
40    pub fn as_str(&self) -> &'static str {
41        match self {
42            Self::Db => "dB",
43            Self::Hz => "Hz",
44            Self::Milliseconds => "ms",
45            Self::Seconds => "s",
46            Self::Percent => "%",
47            Self::Semitones => "st",
48            Self::Pan | Self::None => "",
49        }
50    }
51}