Loading...
Searching...
No Matches
mtk::midi_clock::timeline_clock Struct Reference

Detailed Description

Clocks locked to the score's timeline, as the audio thread sends them with sample-accurate timestamps.

The clock at timeline time T is sent at T + offset. A negative offset sends clocks ahead of the timeline by extrapolating the current tempo: a tempo change is followed from the next clock on, and the clocks already sent are not taken back.

Clocks the timeline jumps over (seek, transport) are skipped. Clocks that a smaller offset moves before the current tick, including at the first tick with a negative offset, are sent at the start of the tick instead, so that a receiver counting clocks keeps its position.

After a locate, the first clock is the one of the receiver's 16th note the Song Position names: at once when the timeline is located on it, as at its start, with Start or Continue as the free clock does.

Public Member Functions

int64_t locate (double time, double quarters, double tempo, double rate) noexcept
 
template<typename Emit >
void process (double current_time, double frame_duration, int64_t frames, double tempo, double factor, double offset, Emit &&emit)
 factor: nudge times clock rate; offset in seconds.
 

Public Attributes

double last_clock_time = 0.0
 
uint32_t clock_tick_count = 0
 
double previous_offset = 0.0
 
bool clock_at_locate = false
 The clock at last_clock_time is still to send.
 

Member Function Documentation

◆ locate()

int64_t mtk::midi_clock::timeline_clock::locate ( double  time,
double  quarters,
double  tempo,
double  rate 
)
inlinenoexcept

Puts the clock back on the timeline at a new position, as at the start. A receiver resumes from a Song Position, which counts its 16th notes, on the next clock: the next clock is the first of the receiver's 16ths at or after quarters, and nothing is sent before it. time is the timeline time of quarters, in seconds; rate the clock rate factor, which sets how many of the receiver's quarters a score quarter is.

Returns the Song Position of that 16th.


The documentation for this struct was generated from the following file: