pub struct SmfFile {
pub format: SmfFormat,
pub division: SmfDivision,
pub tracks: Vec<SmfTrack>,
}Expand description
A parsed Standard MIDI File: its format, time division, and tracks.
Fields§
§format: SmfFormatHeader format field.
division: SmfDivisionLossless metrical or SMPTE time division.
tracks: Vec<SmfTrack>Tracks in file order.
Implementations§
Source§impl SmfFile
impl SmfFile
Sourcepub const fn ticks_per_quarter(&self) -> Option<u32>
pub const fn ticks_per_quarter(&self) -> Option<u32>
Returns this file’s metrical ticks per quarter note, or None when its
division is SMPTE.
Sourcepub fn tempo_maps(&self) -> Result<SmfTempoMaps, MidiError>
pub fn tempo_maps(&self) -> Result<SmfTempoMaps, MidiError>
Builds exact tempo maps from the file’s ordered tempo meta events.
Metrical formats 0 and 1 produce one shared map. Format 2 produces one
map per independent track. SMPTE divisions have a direct timecode chart
rather than a tempo map and return MidiError::MetricalTempoRequired.
Sourcepub fn canonicalize(&mut self)
pub fn canonicalize(&mut self)
Sorts every track into canonical order and ensures each ends with an end-of-track meta event.
Sourcepub fn merge_cursor(&self) -> Result<SmfMergeCursor<'_>, SmfError>
pub fn merge_cursor(&self) -> Result<SmfMergeCursor<'_>, SmfError>
Returns a cursor that merges tracks sharing one timeline.
Format-2 tracks are independent patterns, so merging them would invent a relationship between their local time origins and is rejected.
Sourcepub fn merged_events(&self) -> Result<Vec<TrackedMidiEvent>, SmfError>
pub fn merged_events(&self) -> Result<Vec<TrackedMidiEvent>, SmfError>
Collects every track’s events into a single time-ordered, track-tagged vector.
Format-2 files return SmfError::IndependentPatternsCannotMerge;
callers must choose and process a track as an independent pattern.