midly 0.1.0

A Rusty ultra-fast, safe, easy to use MIDI parsing library designed for multi-MB files
Documentation

Examples

The Smf struct is used to store a parsed Standard Midi File (.mid and .midi files). Notice that it has a lifetime parameter, since it stores references to the raw file bytes. For this reason, the byte buffer must be created separately to the Smf structure:

use midly::{Smf,Event};
//Load bytes into a buffer
let bytes=include_bytes!("../test-asset/Clementi.mid");
//Parse file in a separate step
let smf: Smf<Vec<Event>>=Smf::read(bytes).unwrap();

However, preloading into a buffer and dealing with generics can be tedious. For this purposes, use SmfBuffer instead, which provides several parse_* non-generic methods.

use midly::SmfBuffer;
//Load bytes into a buffer
let smf=SmfBuffer::open("test-asset/Clementi.mid").unwrap();
//Parse bytes in a separate step
//When in doubt, use parse_collect!
let smf=smf.parse_collect().unwrap();

Check the documentation for SmfBuffer for more information on the different parse_* methods.