File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -28,11 +28,17 @@ pub enum MidiOpcode {
28
28
/// The length of the received message. The caller should limit the passed `buffer` slice to
29
29
/// this length after [`MidiOutputPort::receive()`] returns.
30
30
/// ```no_run
31
- /// let output_port: MidiOutputPort = ...;
31
+ /// use ndk::midi::{MidiOutputPort, MidiOpcode};
32
+ ///
33
+ /// let output_port: MidiOutputPort = todo!();
32
34
/// let mut buffer = [0u8; 128];
33
35
/// if let Ok(MidiOpcode::Data { length, .. }) = output_port.receive(&mut buffer) {
34
- /// let buffer = &buffer[..length];
35
- /// ...
36
+ /// // process message
37
+ /// if let [message, key, velocity] = &buffer[..length] {
38
+ /// if message & 0xF0 == 0x90 { /* Note On message */ }
39
+ /// else if message & 0xF0 == 0x80 { /* Note Off message */ }
40
+ /// else { /* */ }
41
+ /// }
36
42
/// }
37
43
/// ```
38
44
length : usize ,
You can’t perform that action at this time.
0 commit comments