Skip to main content

rodecaster_protocol/names/
pad.rs

1//! [`PadParam`]: the per-pad `PAD`-node parameter family (nested under `SOUNDPADS`).
2
3// The forty-eight properties a real Pro II / Duo fullSync carries on each `PAD`
4// node (confirmed from capture, firmware 1.7.3). The `PAD` nodes are nested
5// children of the single root `SOUNDPADS` node (one per sound pad), with `padIdx`
6// equal to the child ordinal, so a pad is addressed by its index on a two-level
7// path (like `FADER` under `PHYSICALINTERFACE`). These cover the whole sound-pad
8// surface: the loaded sample + playback envelope, the per-pad mixer routing
9// (back-channel sends), the trigger/MIDI mapping, the SIP/phone-book binding, and
10// the effects input.
11wire_param_enum! {
12    /// A sound-pad parameter: one of the flat properties the device carries on
13    /// one `PAD` node (nested under the single root `SOUNDPADS` node, one per
14    /// pad). Pads are addressed by index; `padIdx` echoes that index. Covers the
15    /// loaded sample + playback envelope, per-pad mixer routing (the
16    /// `padMixerBackChannel*` sends), the trigger / MIDI mapping
17    /// (`padTrigger*`), the SIP / phone-book binding (`padSIP*`), gain, colour
18    /// and the effects input.
19    ///
20    /// `padProgressRequestSignal` is a request/command pulse (a JUCE binary blob),
21    /// not a scalar; it rides byte-faithfully like any other value.
22    PadParam {
23    // Identity / appearance.
24    Idx => "padIdx",
25    ColourIndex => "padColourIndex",
26    Name => "padName",
27    Type => "padType",
28    IsInternal => "padIsInternal",
29    RcvSyncPadType => "padRCVSyncPadType",
30    // Loaded sample + transport.
31    FilePath => "padFilePath",
32    Active => "padActive",
33    Loop => "padLoop",
34    Replay => "padReplay",
35    PlayMode => "padPlayMode",
36    Progress => "padProgress",
37    ProgressRequestSignal => "padProgressRequestSignal",
38    Gain => "padGain",
39    // Playback envelope (in/out + fades).
40    EnvStart => "padEnvStart",
41    EnvStop => "padEnvStop",
42    EnvFadeIn => "padEnvFadeIn",
43    EnvFadeOut => "padEnvFadeOut",
44    // Per-pad mixer mode + censor + fades.
45    MixerMode => "padMixerMode",
46    MixerTriggerMode => "padMixerTriggerMode",
47    MixerCensorCustom => "padMixerCensorCustom",
48    MixerCensorFilePath => "padMixerCensorFilePath",
49    MixerFadeInSeconds => "padMixerFadeInSeconds",
50    MixerFadeOutSeconds => "padMixerFadeOutSeconds",
51    MixerFadeExcludeHost => "padMixerFadeExcludeHost",
52    // Per-pad mixer back-channel sends.
53    MixerBackChannelMic2 => "padMixerBackChannelMic2",
54    MixerBackChannelMic3 => "padMixerBackChannelMic3",
55    MixerBackChannelMic4 => "padMixerBackChannelMic4",
56    MixerBackChannelUsb1Comms => "padMixerBackChannelUsb1Comms",
57    MixerBackChannelUsb2Main => "padMixerBackChannelUsb2Main",
58    MixerBackChannelBluetooth => "padMixerBackChannelBluetooth",
59    MixerBackChannelCallMe1 => "padMixerBackChannelCallMe1",
60    MixerBackChannelCallMe2 => "padMixerBackChannelCallMe2",
61    MixerBackChannelCallMe3 => "padMixerBackChannelCallMe3",
62    // Effects input.
63    EffectInput => "padEffectInput",
64    EffectTriggerMode => "padEffectTriggerMode",
65    // SIP / phone-book binding.
66    SipPhoneBookEntry => "padSIPPhoneBookEntry",
67    SipCallSlot => "padSIPCallSlot",
68    SipFlashState => "padSIPFlashState",
69    SipQdLock => "padSIPQdLock",
70    // Trigger / MIDI mapping.
71    TriggerMode => "padTriggerMode",
72    TriggerSend => "padTriggerSend",
73    TriggerType => "padTriggerType",
74    TriggerCustom => "padTriggerCustom",
75    TriggerControl => "padTriggerControl",
76    TriggerChannel => "padTriggerChannel",
77    TriggerOn => "padTriggerOn",
78    TriggerOff => "padTriggerOff",
79    }
80}
81
82#[cfg(test)]
83mod tests {
84    use super::*;
85
86    #[test]
87    fn pad_param_round_trips_and_exact_wire_names() {
88        for p in [
89            PadParam::Idx,
90            PadParam::ColourIndex,
91            PadParam::Name,
92            PadParam::Type,
93            PadParam::FilePath,
94            PadParam::Active,
95            PadParam::Loop,
96            PadParam::PlayMode,
97            PadParam::Gain,
98            PadParam::MixerMode,
99            PadParam::EffectInput,
100            PadParam::SipPhoneBookEntry,
101            PadParam::TriggerMode,
102        ] {
103            assert_eq!(PadParam::from_name(p.as_str()), p);
104            assert!(p.is_known());
105            assert_eq!(p.to_string(), p.as_str());
106        }
107        // Spot-check the casing that camel-casing the variant name would get wrong.
108        assert_eq!(PadParam::RcvSyncPadType.as_str(), "padRCVSyncPadType");
109        assert_eq!(
110            PadParam::MixerBackChannelUsb1Comms.as_str(),
111            "padMixerBackChannelUsb1Comms"
112        );
113        assert_eq!(PadParam::SipPhoneBookEntry.as_str(), "padSIPPhoneBookEntry");
114        assert_eq!(PadParam::SipQdLock.as_str(), "padSIPQdLock");
115    }
116
117    #[test]
118    fn pad_param_unknown_falls_back_to_other() {
119        let p = PadParam::from_name("padMysteryFlag");
120        assert_eq!(p, PadParam::Other("padMysteryFlag".to_string()));
121        assert!(!p.is_known());
122        assert_eq!(PadParam::from_name(p.as_str()), p);
123    }
124}