1use std::time::Instant;
2
3use midi_toolkit::{
4 events::{Event, MIDIEventEnum},
5 io::MIDIFile,
6 pipe,
7 sequence::unwrap_items,
8};
9
10pub fn main() {
11 println!("Opening midi...");
12 let file = MIDIFile::open("/run/media/d/Midis/The Quarantine Project.mid", None).unwrap();
13 let now = Instant::now();
14 let mut nc: u64 = 0;
15
16 println!("Creating parsers...");
17 let merged = pipe!(file.iter_all_track_events_merged()|>unwrap_items());
18 println!("Parsing midi...");
19
20 for e in merged {
21 if let Event::NoteOn(_) = e.as_event() {
22 nc += 1;
23 }
24 }
25
26 println!("Finished parsing midi, found {nc} notes");
27 println!("Elapsed {:?}", now.elapsed());
28 println!(
29 "Notes/second {}",
30 (nc as f64 / now.elapsed().as_secs_f64()).round()
31 );
32}