Skip to main content

rodecaster_protocol/names/
player.rs

1//! [`PlayerParam`]: the singleton `PLAYER`-node parameter family.
2
3// The eleven properties a real Pro II / Duo fullSync carries on the single
4// PLAYER node (confirmed from capture, firmware 1.7.3): the long-form audio
5// player's transport, the loaded file, and the in/out + fade envelope.
6wire_param_enum! {
7    /// A player parameter: one of the flat properties the device carries on the
8    /// single `PLAYER` node. There is exactly one long-form player, so this
9    /// family takes no addressing key. Covers transport (state, speed,
10    /// position/progress), the loaded file (path, size), the jump-to-sample
11    /// command, and the in/out + fade envelope (`playerEnv*`).
12    PlayerParam {
13    // Transport.
14    State => "playerState",
15    Speed => "playerSpeed",
16    Progress => "playerProgress",
17    CurrentPositionTime => "playerCurrentPositionTime",
18    JumpToSample => "playerJumpToSample",
19    // Loaded file.
20    FilePath => "playerFilePath",
21    FileSize => "playerFileSize",
22    // In/out + fade envelope.
23    EnvStart => "playerEnvStart",
24    EnvStop => "playerEnvStop",
25    EnvFadeIn => "playerEnvFadeIn",
26    EnvFadeOut => "playerEnvFadeOut",
27    }
28}
29
30#[cfg(test)]
31mod tests {
32    use super::*;
33
34    #[test]
35    fn player_param_name_round_trips() {
36        let params = [
37            PlayerParam::State,
38            PlayerParam::Speed,
39            PlayerParam::Progress,
40            PlayerParam::CurrentPositionTime,
41            PlayerParam::JumpToSample,
42            PlayerParam::FilePath,
43            PlayerParam::FileSize,
44            PlayerParam::EnvStart,
45            PlayerParam::EnvStop,
46            PlayerParam::EnvFadeIn,
47            PlayerParam::EnvFadeOut,
48        ];
49        for p in params {
50            assert_eq!(PlayerParam::from_name(p.as_str()), p);
51            assert!(p.is_known());
52            assert_eq!(p.to_string(), p.as_str());
53        }
54    }
55
56    #[test]
57    fn player_param_exact_wire_names() {
58        assert_eq!(PlayerParam::State.as_str(), "playerState");
59        assert_eq!(PlayerParam::EnvFadeOut.as_str(), "playerEnvFadeOut");
60        assert_eq!(PlayerParam::JumpToSample.as_str(), "playerJumpToSample");
61    }
62
63    #[test]
64    fn player_param_unknown_falls_back_to_other() {
65        let p = PlayerParam::from_name("playerMystery");
66        assert_eq!(p, PlayerParam::Other("playerMystery".to_string()));
67        assert!(!p.is_known());
68        assert_eq!(PlayerParam::from_name(p.as_str()), p);
69    }
70}