summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2015-06-25 17:24:20 +0100
committerColin Fletcher <colin.m.fletcher@googlemail.com>2015-06-25 17:24:20 +0100
commit0613a02e10189c46a32ba67b23b83fc212dce51a (patch)
tree6357ba9e934da9fa714d68210a1b192a3973784c /libs/ardour/tempo.cc
parent94e4e2f55f79fc025dad17a72dcd7217869a3d91 (diff)
Try to avoid coincident tempo/meter markers when removing time
If a tempo or meter marker exists immediately after the range being removed by a 'remove time' operation, don't try to move the last marker within the range being removed to the same position. Ideally, TempoMap::remove_time() should do the same stuff as insert_time() to make sure that meter changes only occur on bar lines, but that's for another time.
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r--libs/ardour/tempo.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index c7e46ba327..82520c19ea 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1911,6 +1911,8 @@ TempoMap::remove_time (framepos_t where, framecnt_t amount)
TempoSection* last_tempo = NULL;
MeterSection* last_meter = NULL;
+ bool tempo_after = false; // is there a tempo marker at the first sample after the removed range?
+ bool meter_after = false; // is there a meter marker likewise?
{
Glib::Threads::RWLock::WriterLock lm (lock);
for (Metrics::iterator i = metrics.begin(); i != metrics.end(); ++i) {
@@ -1924,18 +1926,24 @@ TempoMap::remove_time (framepos_t where, framecnt_t amount)
last_meter = lm;
}
else if ((*i)->frame() >= where) {
+ // TODO: make sure that moved tempo/meter markers are rounded to beat/bar boundaries
(*i)->set_frame ((*i)->frame() - amount);
+ if ((*i)->frame() == where) {
+ // marker was immediately after end of range
+ tempo_after = dynamic_cast<TempoSection*> (*i);
+ meter_after = dynamic_cast<MeterSection*> (*i);
+ }
moved = true;
}
}
//find the last TEMPO and METER metric (if any) and move it to the cut point so future stuff is correct
- if (last_tempo) {
+ if (last_tempo && !tempo_after) {
metric_kill_list.remove(last_tempo);
last_tempo->set_frame(where);
moved = true;
}
- if (last_meter) {
+ if (last_meter && !meter_after) {
metric_kill_list.remove(last_meter);
last_meter->set_frame(where);
moved = true;