Skip to main content

SysExEvent

Struct SysExEvent 

Source
pub struct SysExEvent {
    pub type: SysExType,
    pub data: Vec<u8>,
}
Expand description

SysEx message

Fields§

§type: SysExType

Type of SysEx message

§data: Vec<u8>

The raw data for the sysex. This include the terminating byte.

Implementations§

Source§

impl SysExEvent

Source

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
Source

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}
Source

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
Source

pub fn get_type(&self) -> &SysExType

Get the SysEx type

Source

pub fn get_data(&self) -> &Vec<u8>

Get the data from the SysEx

Trait Implementations§

Source§

impl Debug for SysExEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for SysExEvent

Source§

impl PartialEq for SysExEvent

Source§

fn eq(&self, other: &SysExEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for SysExEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.