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