Struct rimd::SMFWriter [] [src]

pub struct SMFWriter {
    // some fields omitted
}

An SMFWriter is used to write an SMF to a file. It can be either constructed empty and have tracks added, or created from an existing rimd::SMF.

Writing an existing SMF to a file

use rimd::{SMF,SMFWriter};
// Create smf
let writer = SMFWriter::from_smf(smf);
let result = writer.write_to_file(Path::new("/path/to/file.smf"));
// handle result

Methods

impl SMFWriter

fn new_with_division(ticks: i16) -> SMFWriter

Create a new SMFWriter with the given number of units per beat. The SMFWriter will initially have no tracks.

fn new_with_division_and_format(format: SMFFormat, ticks: i16) -> SMFWriter

Create a new SMFWriter with the given format and number of units per beat. The SMFWriter will initially have no tracks.

fn from_smf(smf: SMF) -> SMFWriter

Create a writer that has all the tracks from the given SMF already added

fn vtime_to_vec(val: u64) -> Vec<u8>

fn write_vtime(val: u64, writer: &mut Write) -> Result<u32, Error>

fn add_track<'a, I>(&mut self, track: I) where I: Iterator<Item=&'a AbsoluteEvent>

Add any sequence of AbsoluteEvents as a track to this writer

fn add_track_with_name<'a, I>(&mut self, track: I, name: Option<String>) where I: Iterator<Item=&'a AbsoluteEvent>

Add any sequence of AbsoluteEvents as a track to this writer. A meta event with the given name will be added at the start of the track

fn write_all(self, writer: &mut Write) -> Result<(), Error>

Write out all the tracks that have been added to this SMFWriter to the passed writer

fn write_to_file(self, path: &Path) -> Result<(), Error>

Write out the result of the tracks that have been added to a file. Warning: This will overwrite an existing file