18 #ifndef RAUL_TIME_SLICE_HPP
19 #define RAUL_TIME_SLICE_HPP
23 #include <boost/utility.hpp>
24 #include <raul/TimeStamp.hpp>
54 , _beat_rate(60.0/bpm)
56 , _length_ticks(
TimeUnit(TimeUnit::FRAMES, rate), 0, 0)
57 , _start_beats(
TimeUnit(TimeUnit::BEATS, LV2_EVENT_PPQN), 0, 0)
58 , _length_beats(
TimeUnit(TimeUnit::BEATS, LV2_EVENT_PPQN), 0, 0)
59 , _offset_ticks(
TimeUnit(TimeUnit::FRAMES, rate), 0, 0)
70 _length_ticks = length;
74 void set_start(
TimeStamp time) { _start_ticks = time; update_beat_time(); }
76 void set_length(TimeDuration length) { _length_ticks = length; update_beat_time(); }
78 bool contains(TimeStamp time) {
82 double tick_rate() {
return _tick_rate; }
83 double beat_rate() {
return _beat_rate; }
84 double bpm() {
return 60/_beat_rate; }
86 void set_tick_rate(
double tick_rate) {
87 _tick_rate = tick_rate;
91 void set_bpm(
double bpm) {
92 _beat_rate = 60.0/bpm;
98 inline TimeStamp beats_to_seconds(TimeStamp beats)
const {
103 inline TimeStamp beats_to_ticks(TimeStamp beats)
const {
108 inline TimeStamp ticks_to_seconds(TimeStamp ticks)
const {
113 inline TimeStamp ticks_to_beats(TimeStamp ticks)
const {
138 inline void update_beat_time() {
139 _start_beats = ticks_to_beats(_start_ticks);
140 _length_beats = ticks_to_beats(_length_ticks);
148 TimeStamp _start_ticks;
149 TimeDuration _length_ticks;
150 TimeStamp _start_beats;
151 TimeDuration _length_beats;
153 TimeDuration _offset_ticks;
159 #endif // RAUL_TIME_SLICE_HPP
TimeStamp start_ticks() const
Start of current sub-cycle in ticks.
Definition: TimeSlice.hpp:119
TimeDuration offset_ticks() const
Offset relative to external (e.g Jack) time.
Definition: TimeSlice.hpp:134
TimeDuration length_beats() const
Length of current sub-cycle in beats.
Definition: TimeSlice.hpp:128
TimeStamp start_beats() const
Start of current sub-cycle in beats.
Definition: TimeSlice.hpp:125
TimeDuration length_ticks() const
Length of current sub-cycle in ticks.
Definition: TimeSlice.hpp:122
A type of time stamp.
Definition: TimeStamp.hpp:32
This header defines the code portion of the LV2 events extension with URI http://lv2plug.in/ns/ext/event ('lv2ev').
A real-time time stamp (possible units: frame, absolute (s), or beat).
Definition: TimeStamp.hpp:78
void set_window(TimeStamp start, TimeDuration length)
Set the start and length of the slice.
Definition: TimeSlice.hpp:68
A duration of time, with conversion between tick time and beat time.
Definition: TimeSlice.hpp:50
void set_offset(TimeDuration offset)
Set the offset between real-time and timeslice-time.
Definition: TimeSlice.hpp:131