pub struct TempoMap { /* private fields */ }Expand description
Ordered list of TempoSegments describing how MIDI tempo changes over a
timeline.
A valid map starts with a segment at tick 0 and has strictly increasing
segment ticks, so every tick maps to exactly one tempo. The map drives the
tick <-> Instant conversions for MIDI clocks.
§Examples
use sim_lib_stream_clock::TempoMap;
let map = TempoMap::single(500_000)?;
assert_eq!(map.segments().len(), 1);
assert_eq!(map.segments()[0].start_tick, 0);Implementations§
Source§impl TempoMap
impl TempoMap
Sourcepub fn new(segments: Vec<TempoSegment>) -> Result<Self>
pub fn new(segments: Vec<TempoSegment>) -> Result<Self>
Builds a tempo map from segments.
Returns an error when segments is empty, when the first segment does
not start at tick 0, or when the segment ticks are not strictly
increasing.
Sourcepub fn single(us_per_quarter: u32) -> Result<Self>
pub fn single(us_per_quarter: u32) -> Result<Self>
Builds a single-segment map holding a constant tempo from tick 0.
Returns an error when us_per_quarter is zero.
Sourcepub fn segments(&self) -> &[TempoSegment]
pub fn segments(&self) -> &[TempoSegment]
Returns the map’s segments in tick order.
Trait Implementations§
impl Eq for TempoMap
impl StructuralPartialEq for TempoMap
Auto Trait Implementations§
impl Freeze for TempoMap
impl RefUnwindSafe for TempoMap
impl Send for TempoMap
impl Sync for TempoMap
impl Unpin for TempoMap
impl UnsafeUnpin for TempoMap
impl UnwindSafe for TempoMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more