Crates.io | apres |
lib.rs | apres |
version | 0.3.4 |
source | src |
created_at | 2020-10-25 20:49:57.557831 |
updated_at | 2022-08-04 18:59:00.604395 |
description | MIDI Library |
homepage | https://burnsomni.net/software/apres |
repository | https://burnsomni.net/git/apres |
max_upload_size | |
id | 305403 |
size | 116,067 |
In Cargo.toml
[dependencies]
apres = "^0.2.6"
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");