midi2/channel_voice2/
registered_per_note_controller.rs1use crate::{
2 channel_voice2::{controller, UMP_MESSAGE_TYPE},
3 detail::{common_properties, schema},
4 ux::{u4, u7},
5};
6
7pub(crate) const STATUS: u8 = 0b0000;
8
9#[midi2_proc::generate_message(Via(crate::channel_voice2::ChannelVoice2), FixedSize, MinSizeUmp(2))]
13struct RegisteredPerNoteController {
14 #[property(common_properties::UmpMessageTypeProperty<UMP_MESSAGE_TYPE>)]
15 ump_type: (),
16 #[property(common_properties::ChannelVoiceStatusProperty<STATUS>)]
17 status: (),
18 #[property(common_properties::UmpSchemaProperty<u4, schema::Ump<0x000F_0000, 0x0, 0x0, 0x0>>)]
19 channel: u4,
20 #[property(common_properties::GroupProperty)]
21 group: u4,
22 #[property(common_properties::UmpSchemaProperty<u7, schema::Ump<0x0000_7F00, 0x0, 0x0, 0x0>>)]
23 note_number: u7,
24 #[property(controller::ControllerProperty)]
25 controller: controller::Controller,
26}
27
28#[cfg(test)]
29mod tests {
30 use super::*;
31 use pretty_assertions::assert_eq;
32
33 #[test]
34 fn builder() {
35 use crate::traits::{Channeled, Grouped};
36
37 let mut message = RegisteredPerNoteController::<[u32; 4]>::new();
38 message.set_group(u4::new(0x4));
39 message.set_channel(u4::new(0x5));
40 message.set_note_number(u7::new(0x6C));
41 message.set_controller(controller::Controller::Volume(0xE1E35E92));
42
43 assert_eq!(
44 message,
45 RegisteredPerNoteController([0x4405_6C07, 0xE1E35E92, 0x0, 0x0,]),
46 );
47 }
48
49 #[test]
50 fn note_number() {
51 assert_eq!(
52 RegisteredPerNoteController::try_from(&[0x4405_6C07, 0xE1E35E92][..])
53 .unwrap()
54 .note_number(),
55 u7::new(0x6C),
56 );
57 }
58
59 #[test]
60 fn controller() {
61 assert_eq!(
62 RegisteredPerNoteController::try_from(&[0x4405_6C07, 0xE1E35E92][..])
63 .unwrap()
64 .controller(),
65 controller::Controller::Volume(0xE1E35E92),
66 );
67 }
68}