copy/
copy.rs

1//! Example program that reads the entirety of a MIDI file as raw chunks and writes it to a second
2//! file to test byte writing
3
4use miami::{reader::MidiReadable, writer::MidiWriteable};
5use miami::{Midi, RawMidi};
6use std::fs::File;
7use std::io::Write;
8
9fn main() {
10    let mut output = File::create("test/test_run.mid").expect("Create new output file");
11    let data = "test/run.mid"
12        .get_midi_bytes()
13        .expect("Get `run.midi` file and stream bytes");
14
15    let midi: Midi = RawMidi::try_from_midi_stream(data)
16        .expect("Parse data as a MIDI stream")
17        .check_into_midi()
18        .expect("Sanitize MIDI into formatted MIDI");
19
20    output
21        .write_all(&midi.to_midi_bytes())
22        .expect("Failed to write bytes");
23}