kovaxis / midly

A feature-complete MIDI parser and writer focused on speed.
The Unlicense
138 stars 26 forks source link

Implement absolute event iterator. #15

Closed PieterPenninckx closed 3 years ago

PieterPenninckx commented 3 years ago

Add an iterator that allows to iterate over the events with time relative to the start of the track, rather than to the previous event.

PieterPenninckx commented 3 years ago

This pull request is not really needed since one can do something like the following:

let mut offset = 0;
let iter = track.iter().map(move |e| {
    offset += e.delta.as_int() as u64;
    (offset, e.kind)
});