A duration of time, with conversion between tick time and beat time. More...
#include <TimeSlice.hpp>
Public Member Functions | |
TimeSlice (uint32_t rate, uint32_t ppqn, double bpm) | |
void | set_slice (TimeStamp start, TimeDuration length) |
Set the start and length of the slice. | |
void | set_length (TimeDuration length) |
bool | contains (TimeStamp time) const |
double | tick_rate () const |
double | beat_rate () const |
double | bpm () const |
void | set_tick_rate (double tick_rate) |
void | set_bpm (double bpm) |
TimeStamp | beats_to_seconds (TimeStamp beats) const |
TimeStamp | beats_to_ticks (TimeStamp beats) const |
TimeStamp | ticks_to_seconds (TimeStamp ticks) const |
TimeStamp | ticks_to_beats (TimeStamp ticks) const |
TimeStamp | start_ticks () const |
Start of current sub-cycle in ticks. | |
TimeDuration | length_ticks () const |
Length of current sub-cycle in ticks. | |
TimeStamp | start_beats () const |
Start of current sub-cycle in beats. | |
TimeDuration | length_beats () const |
Length of current sub-cycle in beats. | |
void | set_offset (TimeDuration offset) |
Set the offset between real-time and timeslice-time. | |
TimeDuration | offset_ticks () const |
Offset relative to external (e.g Jack) time. | |
TimeUnit | beats_unit () const |
TimeUnit | ticks_unit () const |
TimeUnit | real_unit () const |
A duration of time, with conversion between tick time and beat time.
This is a slice along a single timeline (ie t=0 in ticks and t=0 in beats are equal). Relation to an external time base (e.g. Jack frame time) is represented by frame_offset (the idea is that this holds all the information necessary for passing to run() methods so they know the current state of things WRT time).
This class handles conversion between two units of time: musical (beat) time, and real (tick) time. Real time is discrete, the smallest unit of time is the 'tick' (usually audio frames or MIDI ticks). Beat time is stored as a double (to be independent of any rates or timer precision).
This caches as many values as possible to make calls less expensive, pass it around by reference, not value.
void Raul::TimeSlice::set_slice | ( | TimeStamp | start, | |
TimeDuration | length | |||
) | [inline] |
Set the start and length of the slice.
Note that external offset is not affected by this, don't forget to reset the offset each cycle!
void Raul::TimeSlice::set_offset | ( | TimeDuration | offset | ) | [inline] |
Set the offset between real-time and timeslice-time.