pub struct SysExEvent {
pub type: SysExType,
pub data: Vec<u8>,
}Expand description
SysEx message
Fields§
§type: SysExTypeType of SysEx message
data: Vec<u8>The raw data for the sysex. This include the terminating byte.
Implementations§
Source§impl SysExEvent
impl SysExEvent
Sourcepub fn new_manufacturer(manufacturer: ManufacturerId, data: &[u8]) -> SysExEvent
pub fn new_manufacturer(manufacturer: ManufacturerId, data: &[u8]) -> SysExEvent
Create a new SysEx message with a manufacturer ID
- data is the data in the message, including the EOX
Sourcepub fn new_non_realtime(device: u8, subids: [u8; 2], data: &[u8]) -> SysExEvent
pub fn new_non_realtime(device: u8, subids: [u8; 2], data: &[u8]) -> SysExEvent
Create a non realtime Universal System Exclusive message
- device is the device. Use consts::usysex::ALL_CALL if you want all device to listen
- subids is the two bytes for the message type.
- data incude the rest of the data including EOX
Examples found in repository?
examples/arturia-blink.rs (lines 92-96)
60fn main() {
61 let midi_input = midir::MidiInput::new("MIDITest").unwrap();
62
63 let device_port = find_port(&midi_input);
64 if device_port.is_none() {
65 println!("Input device not found!");
66 return;
67 }
68
69 let (sender, receiver) = channel::<MidiMessage>();
70
71 let device_port = device_port.unwrap();
72 let _connect_in = midi_input.connect(
73 &device_port,
74 ARTURIA_DEVICE,
75 move |_timestamp, data, sender| {
76 let msg = MidiMessage::from(data);
77 // println!("{}: received {:?} => {:?}", timestamp, data, msg);
78 print_on_err!(sender.send(msg));
79 },
80 sender,
81 );
82
83 let midi_output = midir::MidiOutput::new("MIDITest").unwrap();
84 let device_port = find_port(&midi_output);
85 if device_port.is_none() {
86 println!("Output device not found!");
87 return;
88 }
89
90 let device_port = device_port.unwrap();
91 if let Ok(mut connect_out) = midi_output.connect(&device_port, ARTURIA_DEVICE) {
92 let msg = MidiMessage::SysEx(SysExEvent::new_non_realtime(
93 consts::usysex::ALL_CALL,
94 [0x06, 0x01],
95 &[0xf7],
96 ));
97 print_on_err!(connect_out.send_message(msg));
98 println!("Press Control-C at anytime to stop the demo");
99
100 let hundred_millis = time::Duration::from_millis(100);
101 loop {
102 if let Ok(msg) = receiver.recv() {
103 if let Some(decoder) = USysExDecoder::decode(&msg) {
104 if decoder.is_non_realtime()
105 && decoder.target_device() == 0
106 && decoder.general_info_reply_manufacturer_id()
107 == Some(arturia::EXTENDED_ID_VALUE)
108 {
109 if decoder.general_info_reply_family() != Some(([2, 0], [4, 2])) {
110 println!("Your device isn't supported by this demo");
111 println!("Only the Arturia minilab MkII is supported");
112 } else {
113 run_demo(&mut connect_out);
114 }
115 }
116 }
117 }
118 thread::sleep(hundred_millis);
119 }
120 }
121}Sourcepub fn new_realtime(device: u8, subids: [u8; 2], data: &[u8]) -> SysExEvent
pub fn new_realtime(device: u8, subids: [u8; 2], data: &[u8]) -> SysExEvent
Create a realtime Universal System Exclusive message
- device is the device. Use consts::usysex::ALL_CALL if you want all device to listen
- subids is the two bytes for the message type.
- data incude the rest of the data including EOX