rodecaster_protocol/names/audio.rs
1//! [`AudioParam`]: the singleton `AUDIO`-node parameter family.
2
3// The nine properties a real Pro II / Duo fullSync carries on the single
4// AUDIO node (confirmed from capture, firmware 1.7.3): global audio-engine
5// state: buffer size, sample rate, input/output channel counts, in/out
6// latency, plus the currently-active StreamerX mix preset selector and the
7// two rcSync channel-assignment / swap flags.
8wire_param_enum! {
9 /// A device-wide audio-engine parameter: one of the flat properties the
10 /// device carries on the singleton `AUDIO` node. Covers the audio engine
11 /// (buffer, sample rate, channel counts, latencies), the active
12 /// StreamerX mix-preset selector, and the two rcSync channel controls.
13 /// Un-typed properties arrive as [`AudioParam::Other`] for forward-compat.
14 ///
15 /// Firmware casing quirk preserved verbatim: `audioOuputLatency` is
16 /// misspelled on the wire (missing `t` in "Output"). Consumers matching
17 /// against the wire name must use this spelling.
18 AudioParam {
19 // StreamerX preset selector.
20 ActiveStreamerXMixPreset => "activeStreamerXMixPreset",
21 // Audio engine settings.
22 BufferSize => "audioBufferSize",
23 SampleRate => "audioSampleRate",
24 InputChannels => "audioInputChannels",
25 OutputChannels => "audioOutputChannels",
26 InputLatency => "audioInputLatency",
27 // Firmware wire name is misspelled ("Ouput" not "Output"); preserved.
28 OuputLatency => "audioOuputLatency",
29 // rcSync channel controls.
30 RcSyncChannelAssign => "rcSyncChannelAssign",
31 RcSyncChannelSwap => "rcSyncChannelSwap",
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn audio_param_name_round_trips() {
41 let params = [
42 AudioParam::ActiveStreamerXMixPreset,
43 AudioParam::BufferSize,
44 AudioParam::SampleRate,
45 AudioParam::InputChannels,
46 AudioParam::OutputChannels,
47 AudioParam::InputLatency,
48 AudioParam::OuputLatency,
49 AudioParam::RcSyncChannelAssign,
50 AudioParam::RcSyncChannelSwap,
51 ];
52 for p in params {
53 assert_eq!(AudioParam::from_name(p.as_str()), p);
54 assert!(p.is_known());
55 }
56 }
57
58 #[test]
59 fn audio_param_preserves_firmware_typo() {
60 // The wire misspells "Output" as "Ouput"; the crate matches it verbatim.
61 assert_eq!(AudioParam::OuputLatency.as_str(), "audioOuputLatency");
62 assert_ne!(
63 AudioParam::from_name("audioOutputLatency"),
64 AudioParam::OuputLatency
65 );
66 }
67}