*
*/
double
-TempoMap::quarter_note_at_beat (const double beat)
+TempoMap::quarter_note_at_beat (const double beat) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
*
*/
double
-TempoMap::beat_at_quarter_note (const double quarter_note)
+TempoMap::beat_at_quarter_note (const double quarter_note) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
* This function is sensitive to tempo and meter.
*/
double
-TempoMap::exact_beat_at_frame (const framepos_t& frame, const int32_t sub_num)
+TempoMap::exact_beat_at_frame (const framepos_t& frame, const int32_t sub_num) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
}
double
-TempoMap::exact_beat_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t divisions)
+TempoMap::exact_beat_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t divisions) const
{
return beat_at_pulse_locked (_metrics, exact_qn_at_frame_locked (metrics, frame, divisions) / 4.0);
}
* This function is tempo-sensitive.
*/
double
-TempoMap::exact_qn_at_frame (const framepos_t& frame, const int32_t sub_num)
+TempoMap::exact_qn_at_frame (const framepos_t& frame, const int32_t sub_num) const
{
Glib::Threads::RWLock::ReaderLock lm (lock);
}
double
-TempoMap::exact_qn_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t sub_num)
+TempoMap::exact_qn_at_frame_locked (const Metrics& metrics, const framepos_t& frame, const int32_t sub_num) const
{
double qn = quarter_note_at_minute_locked (metrics, minute_at_frame (frame));
Glib::Threads::RWLock::ReaderLock lm (lock);
BBT_Time pos_bbt = bbt_at_minute_locked (_metrics, minute_at_frame (pos));
- const framecnt_t offset = frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
+
const double divisions = meter_section_at_minute_locked (_metrics, minute_at_frame (pos)).divisions_per_bar();
if (dir > 0) {
pos_bbt.bars += 1;
pos_bbt.beats -= divisions;
}
+ const framecnt_t pos_bbt_frame = frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
+
+ return pos_bbt_frame - pos;
- return frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt)) - offset;
} else {
- pos_bbt.bars -= bbt.bars;
+
+ if (pos_bbt.bars <= bbt.bars) {
+ pos_bbt.bars = 1;
+ } else {
+ pos_bbt.bars -= bbt.bars;
+ }
if (pos_bbt.ticks < bbt.ticks) {
- if (pos_bbt.beats == 1) {
- pos_bbt.bars--;
- pos_bbt.beats = divisions;
+ if (pos_bbt.bars > 1) {
+ if (pos_bbt.beats == 1) {
+ pos_bbt.bars--;
+ pos_bbt.beats = divisions;
+ } else {
+ pos_bbt.beats--;
+ }
+ pos_bbt.ticks = BBT_Time::ticks_per_beat - (bbt.ticks - pos_bbt.ticks);
} else {
- pos_bbt.beats--;
+ pos_bbt.beats = 1;
+ pos_bbt.ticks = 0;
}
- pos_bbt.ticks = BBT_Time::ticks_per_beat - (bbt.ticks - pos_bbt.ticks);
} else {
pos_bbt.ticks -= bbt.ticks;
}
if (pos_bbt.beats <= bbt.beats) {
- pos_bbt.bars--;
- pos_bbt.beats = divisions - (bbt.beats - pos_bbt.beats);
+ if (pos_bbt.bars > 1) {
+ pos_bbt.bars--;
+ pos_bbt.beats = divisions - (bbt.beats - pos_bbt.beats);
+ } else {
+ pos_bbt.beats = 1;
+ }
} else {
pos_bbt.beats -= bbt.beats;
}
- return offset - frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
+ return pos - frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt));
}
return 0;