diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-01-04 18:48:32 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-01-04 18:48:32 +0000 |
commit | f61a0d892cfba3ada195a8d597292d383f089037 (patch) | |
tree | f58efe22a9482ca1d6e589127187d5e5538bf258 /libs/ardour/tempo.cc | |
parent | 2858b0474e4bedf3ab67a539a7f0d12380ac7bda (diff) |
fix error in framepos_{plus,minus}_bbt() which miscounted beats while stepping through bars - stops dragged MIDI notes from ending up in the wrong place, and more
git-svn-id: svn://localhost/ardour2/branches/3.0@11159 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r-- | libs/ardour/tempo.cc | 40 |
1 files changed, 30 insertions, 10 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc index e8f894c1b4..5d02746210 100644 --- a/libs/ardour/tempo.cc +++ b/libs/ardour/tempo.cc @@ -1655,6 +1655,7 @@ TempoMap::framepos_minus_bbt (framepos_t pos, BBT_Time op) Glib::RWLock::ReaderLock lm (map_lock); BBTPointList::const_iterator i; framecnt_t extra_frames = 0; + bool had_bars = (op.bars != 0); /* start from the bar|beat right before (or at) pos */ @@ -1667,11 +1668,19 @@ TempoMap::framepos_minus_bbt (framepos_t pos, BBT_Time op) while (i != _map->begin() && (op.bars || op.beats)) { --i; - if ((*i).is_bar()) { - if (op.bars) { - op.bars--; + + if (had_bars) { + if ((*i).is_bar()) { + if (op.bars) { + op.bars--; + } } - } else { + } + + if ((had_bars && op.bars == 0) || !had_bars) { + /* finished counting bars, or none to count, + so decrement beat count + */ if (op.beats) { op.beats--; } @@ -1703,23 +1712,34 @@ TempoMap::framepos_plus_bbt (framepos_t pos, BBT_Time op) int additional_minutes = 1; BBTPointList::const_iterator i; framecnt_t backup_frames = 0; - + bool had_bars = (op.bars != 0); + while (true) { i = bbt_before_or_at (pos); - + op = op_copy; /* we know that (*i).frame is before or equal to pos */ backup_frames = pos - (*i).frame; while (i != _map->end() && (op.bars || op.beats)) { + ++i; - if ((*i).is_bar()) { - if (op.bars) { - op.bars--; + + if (had_bars) { + if ((*i).is_bar()) { + if (op.bars) { + op.bars--; + } } - } else { + } + + if ((had_bars && op.bars == 0) || !had_bars) { + /* finished counting bars, or none to count, + so decrement beat count + */ + if (op.beats) { op.beats--; } |