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.
This commit is contained in:
Colin Fletcher 2015-03-08 15:48:27 +00:00
parent 99e15d9402
commit f7a2df1c9a
3 changed files with 29 additions and 2 deletions

View File

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

View File

@ -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);

View File

@ -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