use crate::parameter_groups::{GroupId, ROOT_GROUP_ID};
use crate::types::{ParameterId, ParameterValue};
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum ParameterUnit {
#[default]
Generic = 0,
Indexed = 1,
Boolean = 2,
Percent = 3,
Seconds = 4,
SampleFrames = 5,
Phase = 6,
Rate = 7,
Hertz = 8,
Cents = 9,
RelativeSemiTones = 10,
MidiNoteNumber = 11,
MidiController = 12,
Decibels = 13,
LinearGain = 14,
Degrees = 15,
EqualPowerCrossfade = 16,
MixerFaderCurve1 = 17,
Pan = 18,
Meters = 19,
AbsoluteCents = 20,
Octaves = 21,
Bpm = 22,
Beats = 23,
Milliseconds = 24,
Ratio = 25,
CustomUnit = 26,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ParameterFlags {
pub can_automate: bool,
pub is_readonly: bool,
pub is_bypass: bool,
pub is_list: bool,
pub is_hidden: bool,
}
impl Default for ParameterFlags {
fn default() -> Self {
Self {
can_automate: true,
is_readonly: false,
is_bypass: false,
is_list: false,
is_hidden: false,
}
}
}
#[derive(Debug, Clone)]
pub struct ParameterInfo {
pub id: ParameterId,
pub name: &'static str,
pub short_name: &'static str,
pub units: &'static str,
pub unit: ParameterUnit,
pub default_normalized: ParameterValue,
pub step_count: i32,
pub flags: ParameterFlags,
pub group_id: GroupId,
}
impl ParameterInfo {
pub const fn new(id: ParameterId, name: &'static str) -> Self {
Self {
id,
name,
short_name: name,
units: "",
unit: ParameterUnit::Generic,
default_normalized: 0.5,
step_count: 0,
flags: ParameterFlags {
can_automate: true,
is_readonly: false,
is_bypass: false,
is_list: false,
is_hidden: false,
},
group_id: ROOT_GROUP_ID,
}
}
pub const fn with_short_name(mut self, short_name: &'static str) -> Self {
self.short_name = short_name;
self
}
pub const fn with_units(mut self, units: &'static str) -> Self {
self.units = units;
self
}
pub const fn with_default(mut self, default: ParameterValue) -> Self {
self.default_normalized = default;
self
}
pub const fn with_steps(mut self, steps: i32) -> Self {
self.step_count = steps;
self
}
pub const fn with_flags(mut self, flags: ParameterFlags) -> Self {
self.flags = flags;
self
}
pub const fn bypass(id: ParameterId) -> Self {
Self {
id,
name: "Bypass",
short_name: "Byp",
units: "",
unit: ParameterUnit::Boolean,
default_normalized: 0.0,
step_count: 1,
flags: ParameterFlags {
can_automate: true,
is_readonly: false,
is_bypass: true,
is_list: false,
is_hidden: false,
},
group_id: ROOT_GROUP_ID,
}
}
pub const fn with_unit(mut self, unit: ParameterUnit) -> Self {
self.unit = unit;
self
}
pub const fn with_group(mut self, group_id: GroupId) -> Self {
self.group_id = group_id;
self
}
}