Skip to content

Commit 49b7993

Browse files
committed
Add MIDIEvent
1 parent 6c46c19 commit 49b7993

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
use serde::{Deserialize, Serialize};
2+
3+
/// A MIDI message event.
4+
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Clone)]
5+
pub struct MIDIEvent {
6+
/// The binary MIDI message.
7+
///
8+
/// The first byte is a status byte (first/most significant bit = 1), the
9+
/// remaining bytes are data bytes (first/most significant bit = 0).
10+
///
11+
/// To give a simple example, pressing C5 on a MIDI keyboard would generate the
12+
/// following message:
13+
///
14+
/// ```plaintext
15+
/// [0x90, 0x48, 0x64]
16+
/// Ch.1 Note 72 Velocity 100
17+
/// NoteOn i.e. C5
18+
/// ```
19+
///
20+
/// The note values can be looked up online:
21+
///
22+
/// - https://www.phys.unsw.edu.au/jw/notes.html
23+
///
24+
/// Same goes for a full description of the packet structure:
25+
///
26+
/// - https://www.w3.org/TR/webmidi/#terminology
27+
/// - http://www.opensound.com/pguide/midi/midi5.html
28+
/// - https://www.songstuff.com/recording/article/midi-message-format/
29+
data: Vec<u8>,
30+
}

lighthouse-protocol/src/input/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ mod input_event;
88
mod key_event;
99
mod key_modifiers;
1010
mod legacy_input_event;
11+
mod midi_event;
1112
mod mouse_button;
1213
mod mouse_event;
1314
mod unknown_event;
@@ -22,6 +23,7 @@ pub use input_event::*;
2223
pub use key_event::*;
2324
pub use key_modifiers::*;
2425
pub use legacy_input_event::*;
26+
pub use midi_event::*;
2527
pub use mouse_button::*;
2628
pub use mouse_event::*;
2729
pub use unknown_event::*;

0 commit comments

Comments
 (0)