#parser #audio #midi

midly

A pure-rust fast and flexible MIDI parser and writer

10 releases

new 0.4.1 Oct 28, 2020
0.4.0 Feb 1, 2020
0.3.0 Dec 6, 2019
0.2.2 Dec 6, 2019
0.1.3 Feb 2, 2018

#64 in Audio

Download history 14/week @ 2020-07-07 26/week @ 2020-07-14 12/week @ 2020-07-21 14/week @ 2020-07-28 1/week @ 2020-08-04 50/week @ 2020-08-11 59/week @ 2020-08-18 44/week @ 2020-08-25 54/week @ 2020-09-01 29/week @ 2020-09-08 28/week @ 2020-09-15 21/week @ 2020-09-22 35/week @ 2020-09-29 31/week @ 2020-10-06 42/week @ 2020-10-13 41/week @ 2020-10-20

151 downloads per month
Used in 2 crates

Unlicense

70KB
1.5K SLoC

Midly

Midly is a Standard Midi File parser and writer designed to be as efficient as possible, making as few allocations as possible and using multiple threads to parse and write MIDI tracks in parallel.

The behaviour of the parser is also configurable through crate features. See the crate-level documentation for the available features and no_std support.

Getting started

First add the following line to your Cargo.toml file, under the [dependencies] section:

midly = "0.4"

Then use the Smf type in the crate root:

use std::fs;
use midly::Smf;

// Load bytes first
let data = fs::read("Pi.mid").unwrap();

// Parse the raw bytes
let mut smf = Smf::parse(&data).unwrap();

// Use the information
println!("midi file has {} tracks!", smf.tracks.len());

// Modify the file
smf.header.format = midly::Format::Sequential;

// Save it back
smf.save("PiRewritten.mid").unwrap();

Most types to be imported are on the crate root and are documented in-place. Check the crate documentation for more information.

Dependencies

~0.5–1.3MB
~29K SLoC