pub struct MidiTempoMap { /* private fields */ }Expand description
A piecewise-constant MIDI tempo map at one ticks-per-quarter resolution.
Construction consumes already ordered MIDI events, applies the standard
120-BPM default before the first tempo meta event, and lets the last tempo
meta event at a tick win. Wall-time conversion delegates to the generic
exact chart in sim-lib-stream-clock.
Implementations§
Source§impl MidiTempoMap
impl MidiTempoMap
Sourcepub fn from_ordered_events<'a>(
tpq: u32,
events: impl IntoIterator<Item = &'a MidiEvent>,
) -> Result<Self, MidiError>
pub fn from_ordered_events<'a>( tpq: u32, events: impl IntoIterator<Item = &'a MidiEvent>, ) -> Result<Self, MidiError>
Builds a tempo map from an ordered event stream.
Every event must be non-negative, exactly expressible at tpq, and
monotonic. Non-tempo events participate in the ordering check but do not
create segments.
Sourcepub fn segments(&self) -> &[TempoSegment]
pub fn segments(&self) -> &[TempoSegment]
Returns the ordered constant-tempo segments.
Sourcepub fn beat_for_tick(&self, tick: TickTime) -> Result<MidiBeat, MidiError>
pub fn beat_for_tick(&self, tick: TickTime) -> Result<MidiBeat, MidiError>
Converts a tick position to an exact quarter-note beat.
Sourcepub fn tick_for_beat(&self, beat: MidiBeat) -> Result<TickTime, MidiError>
pub fn tick_for_beat(&self, beat: MidiBeat) -> Result<TickTime, MidiError>
Converts an exact quarter-note beat to an integer tick.
Returns MidiError::InexactTempoTick when the beat lies between tick
boundaries at this map’s resolution.
Sourcepub fn wall_time_for_tick(&self, tick: TickTime) -> Result<Instant, MidiError>
pub fn wall_time_for_tick(&self, tick: TickTime) -> Result<Instant, MidiError>
Converts a tick position to exact non-negative wall time in seconds.
Sourcepub fn tick_for_wall_time(
&self,
wall_time: Instant,
) -> Result<TickTime, MidiError>
pub fn tick_for_wall_time( &self, wall_time: Instant, ) -> Result<TickTime, MidiError>
Converts exact wall time to an integer tick.
Returns MidiError::InexactTempoTick instead of rounding when the
instant lies between MIDI tick boundaries.
Trait Implementations§
Source§impl Clone for MidiTempoMap
impl Clone for MidiTempoMap
Source§fn clone(&self) -> MidiTempoMap
fn clone(&self) -> MidiTempoMap
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more