augmented-midi
Implements a MIDI (file) parser/serializer using nom and cookie-factory combinators.
Thanks to the combinators this library requires no allocation for serialization/de-serialization into/from the MIDI types provided.
(This is part of augmented-audio)
Specification
Based on MIDI 1.0 specification. MIDI 1.0
License notes
There's a Bach MIDI file used from piano-midi.de linked here. This file is licensed as described
in http://www.piano-midi.de/copy.htm. Name: Bernd Krueger
The distribution or public playback of the files is only allowed under identical license conditions.
The scores are open source.
Parsing a single message
We can parse a single MIDI message as follows.
use ;
// Initialize parser state. This is here to support rolling status on MIDI files
let mut state = default;
// We'll parse this &[u8] buffer. This could be a vec
let input_buffer = ;
// We parse a message borrowing from the input buffer. We could use `MIDIMessage<Vec<u8>>` to
// allocate owned messages.
//
// This is only relevant for variable size messages like SysEx.
//
// Parsing is otherwise only using the stack.
let parse_result: =
parse_midi_event;
let = parse_result.unwrap;
assert_eq!;
Serializing messages
use ;
let mut writer = ; // This could be a vec.
let message: = control_change; // CC#55 127 - channel 0
let _ = serialize_message.unwrap;
assert_eq!;
License: MIT