pub trait Timer {
    fn sleep_duration(&self, n_ticks: u32) -> Duration;
    fn change_tempo(&mut self, tempo: u32);

    fn sleep(&self, n_ticks: u32) { ... }
    fn duration(&mut self, moments: &[Moment]) -> Duration { ... }
}
Expand description

Used for timing MIDI playback.

Required Methods

Returns the Duration that should be slept for.

Arguments
  • n_ticks: Number of MIDI ticks to sleep for.

Changes the timers tempo.

Arguments
  • tempo: Represents microseconds per a beat (MIDI quarter note).

Provided Methods

Sleeps given number of ticks. The provided implementation will sleep the thread for self.sleep_duration(n_ticks).

Notes

The provided implementation will not sleep if self.sleep_duration(n_ticks).is_zero().

Calculates the length of a track or a slice of Moments.

Notes

The default implementation modifies self if a tempo event is found.

Implementors