allow continuation of tempo via right-click 'Continue' where appropriate.
- this is the opposite of 'Ramp to Next'. it removes discontinuities between the last end tempo and the current by altering the current one.
This commit is contained in:
@@ -1688,6 +1688,7 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
|
||||
void rename_marker (ArdourMarker *marker);
|
||||
void toggle_marker_lock_style ();
|
||||
void toggle_tempo_type ();
|
||||
void continue_previous_tempo ();
|
||||
void ramp_to_next_tempo ();
|
||||
void toggle_marker_menu_lock ();
|
||||
void toggle_marker_menu_glue ();
|
||||
|
||||
@@ -1000,6 +1000,11 @@ Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove)
|
||||
items.push_back (MenuElem (_("Ramp to Next"), sigc::mem_fun(*this, &Editor::ramp_to_next_tempo)));
|
||||
}
|
||||
|
||||
TempoSection* prev_ts = _session->tempo_map().previous_tempo_section (&loc->tempo());
|
||||
if (prev_ts && prev_ts->end_note_types_per_minute() != loc->tempo().note_types_per_minute()) {
|
||||
items.push_back (MenuElem (_("Continue"), sigc::mem_fun(*this, &Editor::continue_previous_tempo)));
|
||||
}
|
||||
|
||||
if (loc->tempo().position_lock_style() == AudioTime && can_remove) {
|
||||
items.push_back (MenuElem (_("Lock to Music"), sigc::mem_fun(*this, &Editor::toggle_marker_lock_style)));
|
||||
} else if (can_remove) {
|
||||
@@ -1460,6 +1465,35 @@ Editor::toggle_tempo_type ()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::continue_previous_tempo ()
|
||||
{
|
||||
TempoMarker* tm;
|
||||
MeterMarker* mm;
|
||||
dynamic_cast_marker_object (marker_menu_item->get_data ("marker"), &mm, &tm);
|
||||
|
||||
if (tm) {
|
||||
TempoMap& tmap (_session->tempo_map());
|
||||
TempoSection* tsp = &tm->tempo();
|
||||
TempoSection* prev_ts = tmap.previous_tempo_section (&tm->tempo());
|
||||
if (prev_ts) {
|
||||
const Tempo tempo (prev_ts->end_note_types_per_minute(), tsp->note_type(), tsp->end_note_types_per_minute());
|
||||
const double pulse = tsp->pulse();
|
||||
const framepos_t frame = tsp->frame();
|
||||
const PositionLockStyle pls = tsp->position_lock_style();
|
||||
|
||||
begin_reversible_command (_("continue previous tempo"));
|
||||
XMLNode &before = _session->tempo_map().get_state();
|
||||
|
||||
tmap.replace_tempo (*tsp, tempo, pulse, frame, pls);
|
||||
|
||||
XMLNode &after = _session->tempo_map().get_state();
|
||||
_session->add_command(new MementoCommand<TempoMap>(_session->tempo_map(), &before, &after));
|
||||
commit_reversible_command ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Editor::ramp_to_next_tempo ()
|
||||
{
|
||||
|
||||
@@ -367,6 +367,7 @@ class LIBARDOUR_API TempoMap : public PBD::StatefulDestructible
|
||||
const MeterSection& meter_section_at_frame (framepos_t frame) const;
|
||||
const MeterSection& meter_section_at_beat (double beat) const;
|
||||
|
||||
TempoSection* previous_tempo_section (TempoSection*) const;
|
||||
TempoSection* next_tempo_section (TempoSection*) const;
|
||||
|
||||
/** add a tempo section locked to pls. ignored values will be set in recompute_tempi()
|
||||
|
||||
@@ -4285,6 +4285,43 @@ TempoMap::tempo_section_at_beat_locked (const Metrics& metrics, const double& be
|
||||
return *prev_t;
|
||||
}
|
||||
|
||||
TempoSection*
|
||||
TempoMap::previous_tempo_section (TempoSection* ts) const
|
||||
{
|
||||
if (!ts) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Glib::Threads::RWLock::ReaderLock lm (lock);
|
||||
|
||||
TempoSection* prev = 0;
|
||||
|
||||
for (Metrics::const_iterator i = _metrics.begin(); i != _metrics.end(); ++i) {
|
||||
|
||||
if ((*i)->is_tempo()) {
|
||||
TempoSection* t = static_cast<TempoSection*> (*i);
|
||||
|
||||
if (!t->active()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev && t == ts) {
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
prev = t;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev == 0) {
|
||||
fatal << endmsg;
|
||||
abort(); /*NOTREACHED*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TempoSection*
|
||||
TempoMap::next_tempo_section (TempoSection* ts) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user