summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Fletcher <colin.m.fletcher@googlemail.com>2015-03-08 15:48:27 +0000
committerColin Fletcher <colin.m.fletcher@googlemail.com>2015-03-09 19:17:53 +0000
commitf7a2df1c9a8c540f7e5778561c8527c525874b84 (patch)
treeeb7b15cc2056b492f002317d0da5cca251087245
parent99e15d94025b7ce9046b3e8d4c4e7b2e1635df7a (diff)
Make editing of meter work at the current position
Add a function TempoMap::meter_section_at(), similar to TempoMap::tempo_section_at() but returning the meter section at the given position, and use this to make editing meter changes from the main clock work on the meter that's in effect at the current position.
-rw-r--r--gtk2_ardour/main_clock.cc3
-rw-r--r--libs/ardour/ardour/tempo.h1
-rw-r--r--libs/ardour/tempo.cc27
3 files changed, 29 insertions, 2 deletions
diff --git a/gtk2_ardour/main_clock.cc b/gtk2_ardour/main_clock.cc
index f90599de13..26d780ea8a 100644
--- a/gtk2_ardour/main_clock.cc
+++ b/gtk2_ardour/main_clock.cc
@@ -99,8 +99,7 @@ MainClock::edit_current_tempo ()
void
MainClock::edit_current_meter ()
{
- ARDOUR::Meter m = PublicEditor::instance().session()->tempo_map().meter_at (absolute_time());
- ARDOUR::MeterSection ms (absolute_time(), m.divisions_per_bar(), m.note_divisor());
+ ARDOUR::MeterSection ms = PublicEditor::instance().session()->tempo_map().meter_section_at (absolute_time());
PublicEditor::instance().edit_meter_section (&ms);
}
diff --git a/libs/ardour/ardour/tempo.h b/libs/ardour/ardour/tempo.h
index f2d314651d..29f1f25643 100644
--- a/libs/ardour/ardour/tempo.h
+++ b/libs/ardour/ardour/tempo.h
@@ -287,6 +287,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
const Meter& meter_at (framepos_t) const;
const TempoSection& tempo_section_at (framepos_t) const;
+ const MeterSection& meter_section_at (framepos_t) const;
void add_tempo (const Tempo&, Timecode::BBT_Time where);
void add_meter (const Meter&, Timecode::BBT_Time where);
diff --git a/libs/ardour/tempo.cc b/libs/ardour/tempo.cc
index ff6553e820..8c4011cefd 100644
--- a/libs/ardour/tempo.cc
+++ b/libs/ardour/tempo.cc
@@ -1583,6 +1583,33 @@ TempoMap::tempo_at (framepos_t frame) const
return m.tempo();
}
+const MeterSection&
+TempoMap::meter_section_at (framepos_t frame) const
+{
+ Glib::Threads::RWLock::ReaderLock lm (lock);
+ Metrics::const_iterator i;
+ MeterSection* prev = 0;
+
+ for (i = metrics.begin(); i != metrics.end(); ++i) {
+ MeterSection* t;
+
+ if ((t = dynamic_cast<MeterSection*> (*i)) != 0) {
+
+ if ((*i)->frame() > frame) {
+ break;
+ }
+
+ prev = t;
+ }
+ }
+
+ if (prev == 0) {
+ fatal << endmsg;
+ abort(); /*NOTREACHED*/
+ }
+
+ return *prev;
+}
const Meter&
TempoMap::meter_at (framepos_t frame) const