15 releases

0.3.4 Aug 4, 2022
0.3.3 Jun 30, 2022
0.3.1 Feb 13, 2022
0.3.0 May 12, 2021
0.2.5 Nov 5, 2020

#139 in Audio

Download history 18/week @ 2023-08-11 328/week @ 2023-08-18 535/week @ 2023-08-25 30/week @ 2023-09-01 23/week @ 2023-09-08 19/week @ 2023-09-15 5/week @ 2023-09-22 14/week @ 2023-09-29 15/week @ 2023-10-06 30/week @ 2023-10-13 21/week @ 2023-10-20 47/week @ 2023-10-27 19/week @ 2023-11-03 30/week @ 2023-11-10 20/week @ 2023-11-17 49/week @ 2023-11-24

122 downloads per month
Used in floww

GPL-2.0-or-later

99KB
2.5K SLoC

Apres

A MIDI library
Crates.io Crates.io GitHub

Installation

In Cargo.toml

[dependencies]
apres = "^0.2.6"

Usage Examples

Load a Song

use apres::MIDI;
Create a MIDI from a file
let midi = MIDI::from_path("/path/to/file.mid").ok().unwrap();

Create a new MIDI

use apres::MIDI;
// Create an empty MIDI file.
let midi = MIDI::new();

Creating a song

use apres::MIDI;
use apres::MIDIEvent::{NoteOn, NoteOff};
// Create an empty MIDI file.
let mut midi = MIDI::new();

// Using channel 0, press midi note 64 (Middle E) on the first track (0) at the first position (0 ticks)
midi.insert_event(0, 0, NoteOn(0, 64, 100));

// Still on channel 0, release midi note 64 (Middle E) on the first track (0) one beat later (120 ticks)
midi.push_event(0, 120, NoteOff(0, 64, 100));

// Save it to a file
midi.save("beep.mid");

No runtime deps