Skip to main content

rodecaster_protocol/names/
channel.rs

1//! [`ChannelParam`]: the per-fader `CHANNEL`-node parameter family.
2
3wire_param_enum! {
4    /// A per-channel-strip parameter: one of the flat properties the device
5    /// carries on a `CHANNEL` node (the EQ, dynamics, HPF, aphex, pan and tone
6    /// controls for one fader).
7    ///
8    /// The preamp controls (gain, 48V, mic type) are **not** here: a source
9    /// exists independently of which fader it is assigned to, so they live on
10    /// the separate `INPUTSOURCE` node and are typed as [`crate::InputSourceParam`].
11    /// `CHANNEL` only references its source via `channelInputSource`.
12    ChannelParam {
13    // EQ (3-band parametric).
14    EqOn => "eqOn",
15    EqLowOn => "eqLowOn",
16    EqLowGain => "eqLowGain",
17    EqLowQ => "eqLowQ",
18    EqLowShelf => "eqLowShelf",
19    EqMidOn => "eqMidOn",
20    EqMidGain => "eqMidGain",
21    EqMidQ => "eqMidQ",
22    EqMidBell => "eqMidBell",
23    EqHighOn => "eqHighOn",
24    EqHighGain => "eqHighGain",
25    EqHighQ => "eqHighQ",
26    EqHighBell => "eqHighBell",
27    // NOTE: eqParamMode{Low,Mid,High} are intentionally NOT here. A real
28    // fullSync shows them on the `GUI` node (which EQ band the touchscreen is
29    // editing), not on `CHANNEL`. They are UI state, not a per-strip parameter.
30    // Compressor.
31    CompressorOn => "compressorOn",
32    CompressorThreshold => "compressorThreshold",
33    CompressorRatio => "compressorRatio",
34    CompressorAttack => "compressorAttack",
35    CompressorRelease => "compressorRelease",
36    CompressorGain => "compressorGain",
37    // De-esser.
38    DeesserOn => "deesserOn",
39    DeesserThreshold => "deesserThreshold",
40    DeesserRatio => "deesserRatio",
41    DeesserAttack => "deesserAttack",
42    DeesserRelease => "deesserRelease",
43    DeesserGain => "deesserGain",
44    DeesserFrequency => "deesserFrequency",
45    // Noise gate.
46    NoiseGateOn => "noiseGateOn",
47    NoiseGateThreshold => "noiseGateThreshold",
48    NoiseGateRange => "noiseGateRange",
49    NoiseGateAttack => "noiseGateAttack",
50    NoiseGateHold => "noiseGateHold",
51    NoiseGateRelease => "noiseGateRelease",
52    NoiseGateHysteresis => "noiseGateHysteresis",
53    // High-pass filter.
54    HpfOn => "hpfOn",
55    HpfFrequency => "hpfFrequency",
56    HpfSlope => "hpfSlope",
57    HpfLowerOn => "hpfLowerOn",
58    HpfHigherOn => "hpfHigherOn",
59    // Aphex (Aural Exciter + Big Bottom).
60    AphexOn => "aphexOn",
61    AphexAeMix => "aphexAEMix",
62    AphexAeTune => "aphexAETune",
63    AphexBbDrive => "aphexBBDrive",
64    AphexBbTune => "aphexBBTune",
65    // Pan.
66    PanOn => "channelPanOn",
67    Pan => "channelPan",
68    PanL => "channelPanL",
69    PanR => "channelPanR",
70    PanMode => "channelPanMode",
71    // RODE voice tone (the "Big / Bright" sliders).
72    Depth => "channelDepth",
73    Sparkle => "channelSparkle",
74    Punch => "channelPunch",
75    // NOTE: the input* preamp params (inputType, inputPower, inputMicrophoneGain,
76    // inputColour, ...) are intentionally NOT here. A real fullSync proves they
77    // live on the separate `INPUTSOURCE` node (one per source), not on `CHANNEL`.
78    // CHANNEL only references a source via `channelInputSource`. The preamp
79    // controls are typed as `InputSourceParam` and addressed by `Source`.
80    // Channel-level flags.
81    AdvancedProcessing => "channelAdvancedProcessing",
82    BypassProcessing => "channelBypassProcessing",
83    CurrentFxPreset => "channelCurrentFxPreset",
84    ListenSource => "channelListenSource",
85    TalkbackEnable => "channelTalkbackEnable",
86    WirelessMute => "channelWirelessMute",
87    ChannelIndex => "channelIndex",
88    }
89}
90
91#[cfg(test)]
92mod tests {
93    use super::*;
94
95    #[test]
96    fn channel_param_name_round_trips() {
97        // A representative slice of every family: from_name(as_str(x)) == x.
98        let params = [
99            ChannelParam::EqHighGain,
100            ChannelParam::CompressorThreshold,
101            ChannelParam::DeesserFrequency,
102            ChannelParam::NoiseGateOn,
103            ChannelParam::HpfSlope,
104            ChannelParam::AphexAeMix,
105            ChannelParam::PanMode,
106            ChannelParam::Depth,
107            ChannelParam::ListenSource,
108            ChannelParam::WirelessMute,
109        ];
110        for p in params {
111            assert_eq!(ChannelParam::from_name(p.as_str()), p);
112            assert!(p.is_known());
113            // Display matches the wire name.
114            assert_eq!(p.to_string(), p.as_str());
115        }
116    }
117
118    #[test]
119    fn channel_param_exact_wire_names() {
120        // Variant spelling differs from the wire name for acronym cases; pin a
121        // few exact wire strings so a rename can't silently change the protocol.
122        assert_eq!(ChannelParam::AphexAeMix.as_str(), "aphexAEMix");
123        assert_eq!(ChannelParam::AphexBbDrive.as_str(), "aphexBBDrive");
124        assert_eq!(ChannelParam::Pan.as_str(), "channelPan");
125        assert_eq!(ChannelParam::Depth.as_str(), "channelDepth");
126    }
127
128    #[test]
129    fn channel_param_unknown_falls_back_to_other() {
130        let p = ChannelParam::from_name("channelMysteryKnob");
131        assert_eq!(p, ChannelParam::Other("channelMysteryKnob".to_string()));
132        assert!(!p.is_known());
133        // Other round-trips its raw name through as_str/from_name too.
134        assert_eq!(p.as_str(), "channelMysteryKnob");
135        assert_eq!(ChannelParam::from_name(p.as_str()), p);
136    }
137}