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.
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);
}
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);
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