use midia::{ pitch::Pitch, track::MidiTrack, typ::{InstrumentType, Tonality, TrackType}, MidiWriter, }; fn main() { let mut writer = MidiWriter::new(TrackType::Single, 1, 120); let mut track = MidiTrack::new(); track .set_bpm(120) .set_tonality(Tonality::G) .change_instrument(InstrumentType::AcousticGrandPiano) .note(0.5, Pitch::A4, 90) .note(0.5, Pitch::B4, 90) .note(2., Pitch::C5, 90) .note(0.5, Pitch::B4, 90) .note(1., Pitch::C5, 90) .note(1., Pitch::E5, 90) .note(3., Pitch::B4, 90) .note(1., Pitch::E4, 90) .note(1.5, Pitch::A4, 90) .note(0.5, Pitch::G4, 90) .note(1., Pitch::A4, 90) .note(1., Pitch::C5, 90) .note(3., Pitch::G4, 90) .note(1., Pitch::E4, 90) .note(1.5, Pitch::F4, 90) .note(0.5, Pitch::E4, 90) .note(1., Pitch::F4, 90) .note(1., Pitch::C5, 90) .note(2., Pitch::E4, 90) .note(0.5, Pitch::E4, 0) .note(0.5, Pitch::C5, 90) .note(0.5, Pitch::C5, 90) .note(0.5, Pitch::C5, 90) .note(1.5, Pitch::B4, 90) .note(0.5, Pitch::Fs4, 90) .note(1., Pitch::F4, 90) .note(1., Pitch::B4, 90) .note(3., Pitch::B4, 90) .note(0.5, Pitch::A4, 90) .note(0.5, Pitch::B4, 90) .note(1.5, Pitch::C5, 90) .note(0.5, Pitch::B4, 90) .note(1., Pitch::C5, 90) .note(1., Pitch::E5, 90) .note(3., Pitch::B4, 90) .note(1., Pitch::E4, 90) .note(1.5, Pitch::A4, 90) .note(0.5, Pitch::G4, 90) .note(1., Pitch::A4, 90) .note(1., Pitch::C5, 90) .note(3., Pitch::G4, 90) .note(1., Pitch::E4, 90) .note(1., Pitch::F4, 90) .note(0.5, Pitch::C5, 90) .note(1.5, Pitch::B4, 90) .note(1., Pitch::C5, 90) .note(1., Pitch::D5, 90) .note(0.5, Pitch::E5, 90) .note(2.5, Pitch::C5, 90) .note(0.5, Pitch::C5, 90) .note(0.5, Pitch::B4, 90) .note(1., Pitch::A4, 90) .note(1., Pitch::B4, 90) .note(1., Pitch::Gs4, 90) .note(3., Pitch::A4, 90) .note(0.5, Pitch::C5, 90) .note(0.5, Pitch::D5, 90) .note(1.5, Pitch::E5, 90) .note(0.5, Pitch::D5, 90) .note(1., Pitch::E5, 90) .note(1., Pitch::G5, 90) .note(3., Pitch::D5, 90) .note(1., Pitch::G5, 90) .note(1.5, Pitch::C5, 90) .note(0.5, Pitch::B4, 90) .note(1., Pitch::C5, 90) .note(1., Pitch::E5, 90) .note(4., Pitch::E5, 90) .note(0.5, Pitch::A4, 90) .note(0.5, Pitch::B4, 90) .note(1., Pitch::C5, 90) .note(0.5, Pitch::B4, 90) .note(0.5, Pitch::C5, 90) .note(1., Pitch::D5, 90) .note(1., Pitch::C5, 90) .note(1., Pitch::G4, 90) .note(2., Pitch::G4, 90) .note(1., Pitch::F5, 90) .note(1., Pitch::E5, 90) .note(1., Pitch::D5, 90) .note(1., Pitch::C5, 90) .repeat(5); writer.add_track(track); writer.write("./examples/single_track.mid"); }