Skip to content

Commit

Permalink
ndk: Make examples in ndk::midi compilable
Browse files Browse the repository at this point in the history
  • Loading branch information
paxbun committed Aug 17, 2023
1 parent 83fe4b2 commit 8c64160
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ndk/src/midi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,17 @@ pub enum MidiOpcode {
/// The length of the received message. The caller should limit the passed `buffer` slice to
/// this length after [`MidiOutputPort::receive()`] returns.
/// ```no_run
/// let output_port: MidiOutputPort = ...;
/// use ndk::midi::{MidiOutputPort, MidiOpcode};
///
/// let output_port: MidiOutputPort = todo!();
/// let mut buffer = [0u8; 128];
/// if let Ok(MidiOpcode::Data { length, .. }) = output_port.receive(&mut buffer) {
/// let buffer = &buffer[..length];
/// ...
/// // process message
/// if let [message, key, velocity] = &buffer[..length] {
/// if message & 0xF0 == 0x90 { /* Note On message */ }
/// else if message & 0xF0 == 0x80 { /* Note Off message */ }
/// else { /* */ }
/// }
/// }
/// ```
length: usize,
Expand Down

0 comments on commit 8c64160

Please sign in to comment.