diff options
author | nick_m <mainsbridge@gmail.com> | 2016-11-22 00:29:53 +1100 |
---|---|---|
committer | nick_m <mainsbridge@gmail.com> | 2016-11-22 00:29:53 +1100 |
commit | 66488e1174ad5dbdc724c82418c4bf32f00b1eb9 (patch) | |
tree | 063d168c517f29762b72aaaee65e4a847795b594 /libs/ardour | |
parent | 73f3e479d363ef35bb12a89b61d21609a7428e19 (diff) |
TempoMap::bbt_duration_at() handles an audio-locked meter.
- fixes some odd results when scrolling down/up over the BBT clock display.
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/tempo.cc | 41 |
1 files changed, 32 insertions, 9 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index 0f3766b03c..65299587fe 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -3495,6 +3495,7 @@ TempoMap::bbt_duration_at (framepos_t pos, const BBT_Time& bbt, int dir) 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) { @@ -3511,26 +3512,48 @@ TempoMap::bbt_duration_at (framepos_t pos, const BBT_Time& bbt, int dir) pos_bbt.bars += 1; pos_bbt.beats -= divisions; } + const framecnt_t music_origin = frame_at_minute (minute_at_bbt_locked (_metrics, BBT_Time (1, 1, 0))); + const framecnt_t pos_bbt_frame = frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt)); + + if (pos < music_origin) { + + return pos_bbt_frame - pos; + } else { - return frame_at_minute (minute_at_bbt_locked (_metrics, pos_bbt)) - offset; + return pos_bbt_frame - 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; } |