RAUL  0.5.1
Public Member Functions | List of all members
Raul::TimeSlice Class Reference

A duration of time, with conversion between tick time and beat time. More...

#include <TimeSlice.hpp>

Public Member Functions

 TimeSlice (uint32_t rate, double bpm)
 
void set_window (TimeStamp start, TimeDuration length)
 Set the start and length of the slice. More...
 
void set_start (TimeStamp time)
 
void set_length (TimeDuration length)
 
bool contains (TimeStamp time)
 
double tick_rate ()
 
double beat_rate ()
 
double bpm ()
 
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. More...
 
TimeDuration offset_ticks () const
 Offset relative to external (e.g Jack) time.
 

Detailed Description

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.

Member Function Documentation

void Raul::TimeSlice::set_window ( 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.


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