summaryrefslogtreecommitdiff
path: root/libs/ardour/tempo.cc
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2013-10-16 22:25:35 +0100
committerBen Loftis <ben@harrisonconsoles.com>2015-04-21 10:22:27 -0500
commit84f0dceefb2e4079e1f015a17e538f0cd795ba2e (patch)
treecfddf5f6e8c45b1bde5dd8a1884a893f7d71bac1 /libs/ardour/tempo.cc
parent17546f47b6927c21fe50ce5e784f2f4952d69473 (diff)
Port 'Cut time' code from Mixbus
Copy the 'Cut time' code from Mixbus, making a few obvious fixes to work in A3 (e.g. nframes_t => framepos_t / framecnt_t). Seems to work to move & remove markers, tempo & meter markers, and regions on selected tracks. Still TODO: - use existing A3 'Insert time' dialogue - make it respect 'No selection = all tracks' - rename the command to something like 'Remove time' or 'Delete time': 'Cut' sounds to me as if the removed range should end up on the clipboard ready to be pasted somewhere, which of course it doesn't.
Diffstat (limited to 'libs/ardour/tempo.cc')
-rw-r--r--libs/ardour/tempo.cc52
1 files changed, 52 insertions, 0 deletions
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index c5f7272b7e..b9ad1be682 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1900,6 +1900,58 @@ TempoMap::insert_time (framepos_t where, framecnt_t amount)
PropertyChanged (PropertyChange ());
}
+bool
+TempoMap::cut_time (framepos_t where, framecnt_t amount)
+{
+ bool moved = false;
+
+ std::list<MetricSection*> metric_kill_list;
+
+ TempoSection* last_tempo = NULL;
+ MeterSection* last_meter = NULL;
+ {
+ Glib::Threads::RWLock::WriterLock lm (lock);
+ for (Metrics::iterator i = metrics.begin(); i != metrics.end(); ++i) {
+ if ((*i)->frame() >= where && (*i)->frame() < where+amount) {
+ metric_kill_list.push_back(*i);
+ TempoSection *lt = dynamic_cast<TempoSection*> (*i);
+ if (lt)
+ last_tempo = lt;
+ MeterSection *lm = dynamic_cast<MeterSection*> (*i);
+ if (lm)
+ last_meter = lm;
+ }
+ else if ((*i)->frame() >= where) {
+ (*i)->set_frame ((*i)->frame() - amount);
+ 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) {
+ metric_kill_list.remove(last_tempo);
+ last_tempo->set_frame(where);
+ moved = true;
+ }
+ if (last_meter) {
+ metric_kill_list.remove(last_meter);
+ last_meter->set_frame(where);
+ moved = true;
+ }
+
+ //remove all the remaining metrics
+ for (std::list<MetricSection*>::iterator i = metric_kill_list.begin(); i != metric_kill_list.end(); ++i) {
+ metrics.remove(*i);
+ moved = true;
+ }
+
+ if (moved) {
+ recompute_map (true);
+ }
+ }
+ PropertyChanged (PropertyChange ());
+ return moved;
+}
/** Add some (fractional) beats to a session frame position, and return the result in frames.
* pos can be -ve, if required.