1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::cli::CliDirective;
#[derive(Debug, structopt::StructOpt)]
pub struct GenSingleDirective {
#[structopt(flatten)]
pub note_vec: crate::cli::NoteVecArg,
#[structopt(flatten)]
pub target: crate::cli::TargetArg,
}
impl CliDirective for GenSingleDirective {
fn run(self) {
let note_vec = self.note_vec.into();
let target: std::path::PathBuf = self.target.into();
println!("::: INFO: Generating MIDI file from pitch sequence");
let mfile = libatm::MIDIFile::new(note_vec, libatm::MIDIFormat::Format0, 1, 1);
println!("::: INFO: Attempting to write MIDI file to {:?}", target);
match mfile.write_file(&target) {
Err(err) => println!("::: ERROR: Failed to write MIDI file to path {:?} ({})", &target, err),
_ => println!("::: INFO: Successfully wrote MIDI file"),
}
}
}