Skip to main content

rodecaster_protocol/names/
master.rs

1//! [`MasterParam`]: the singleton `MASTERCHANNEL`-node parameter family.
2
3// The seven properties a real Pro II / Duo fullSync carries on the single
4// MASTERCHANNEL node (confirmed from capture, firmware 1.7.3): the master-bus
5// Compellor (RODE's compressor/leveller) plus the master delay.
6wire_param_enum! {
7    /// A master-bus parameter: one of the flat properties the device carries on
8    /// the single `MASTERCHANNEL` node. There is exactly one master bus, so this
9    /// family takes no addressing key (unlike [`crate::ChannelParam`], which is
10    /// per-fader). Covers the master Compellor (RODE's compressor/leveller) and
11    /// the master delay.
12    MasterParam {
13    // Compellor (master compressor / leveller).
14    CompellorOn => "masterCompellorOn",
15    CompellorThreshold => "masterCompellorThreshold",
16    CompellorAttack => "masterCompellorAttack",
17    CompellorRelease => "masterCompellorRelease",
18    CompellorGain => "masterCompellorGain",
19    // Master delay.
20    DelayOn => "masterDelayOn",
21    DelaySeconds => "masterDelaySeconds",
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[test]
30    fn master_param_name_round_trips() {
31        // Every typed MASTERCHANNEL param: from_name(as_str(x)) == x.
32        let params = [
33            MasterParam::CompellorOn,
34            MasterParam::CompellorThreshold,
35            MasterParam::CompellorAttack,
36            MasterParam::CompellorRelease,
37            MasterParam::CompellorGain,
38            MasterParam::DelayOn,
39            MasterParam::DelaySeconds,
40        ];
41        for p in params {
42            assert_eq!(MasterParam::from_name(p.as_str()), p);
43            assert!(p.is_known());
44            assert_eq!(p.to_string(), p.as_str());
45        }
46    }
47
48    #[test]
49    fn master_param_exact_wire_names() {
50        // The master* prefix and Compellor casing must match the firmware.
51        assert_eq!(MasterParam::CompellorOn.as_str(), "masterCompellorOn");
52        assert_eq!(MasterParam::DelaySeconds.as_str(), "masterDelaySeconds");
53    }
54
55    #[test]
56    fn master_param_unknown_falls_back_to_other() {
57        let p = MasterParam::from_name("masterMysteryFlag");
58        assert_eq!(p, MasterParam::Other("masterMysteryFlag".to_string()));
59        assert!(!p.is_known());
60        assert_eq!(MasterParam::from_name(p.as_str()), p);
61    }
62}