pub struct USysExDecoder<'a>(/* private fields */);Expand description
Universal SysEx decoder.
Implementations§
Source§impl USysExDecoder<'_>
impl USysExDecoder<'_>
Sourcepub fn decode(msg: &MidiMessage) -> Option<USysExDecoder<'_>>
pub fn decode(msg: &MidiMessage) -> Option<USysExDecoder<'_>>
Creates a new decoder for the message.
§Error
Returns None if the message isn’t a Universal System Exclusive
Examples found in repository?
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 is_non_realtime(&self) -> bool
pub fn is_non_realtime(&self) -> bool
Tell if message is non realtime
Examples found in repository?
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 target_device(&self) -> u8
pub fn target_device(&self) -> u8
Returns the target device
§Panic
If the message isn’t a Universal System Exclusive it will panic. The decode() function is supposed to check for it.
Examples found in repository?
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 subid(&self) -> [u8; 2]
pub fn subid(&self) -> [u8; 2]
Returns the subid for the Universel System Exclusive message.
§Panic
If the message isn’t a Universal System Exclusive it will panic. The decode() function is supposed to check for it.
Sourcepub fn general_info_reply_manufacturer_id(&self) -> Option<ManufacturerId>
pub fn general_info_reply_manufacturer_id(&self) -> Option<ManufacturerId>
Return the manufacturer ID from the General Info reply Check that the SysEx message is the right one.
§Error
Returns None if the message isn’t the right one.
Examples found in repository?
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 general_info_reply_family(&self) -> Option<([u8; 2], [u8; 2])>
pub fn general_info_reply_family(&self) -> Option<([u8; 2], [u8; 2])>
Return the device family from the General Info reply Check that the SysEx message is the right one.
§Error
Returns None if the message isn’t the right one.
Examples found in repository?
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}