From 663d0e17431e0f841b4a5cde320323d78852a3b2 Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 27 Feb 2017 03:03:55 +1100 Subject: [PATCH] add right-click 'Ramp to Next' tempo marker menu item. --- gtk2_ardour/editor.h | 1 + gtk2_ardour/editor_markers.cc | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 72ee92ed17..c70ca4ae5f 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -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 ramp_to_next_tempo (); void toggle_marker_menu_lock (); void toggle_marker_menu_glue (); void marker_menu_hide (); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 1e8074c7f3..38a84543ca 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -995,6 +995,10 @@ Editor::build_tempo_marker_menu (TempoMarker* loc, bool can_remove) items.push_back (MenuElem (_("Set Constant"), sigc::mem_fun(*this, &Editor::toggle_tempo_type))); } + if (_session->tempo_map().next_tempo_section (&loc->tempo())) { + items.push_back (MenuElem (_("Ramp to Next"), sigc::mem_fun(*this, &Editor::ramp_to_next_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) { @@ -1455,6 +1459,37 @@ Editor::toggle_tempo_type () } } +void +Editor::ramp_to_next_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* next_ts = tmap.next_tempo_section (&tm->tempo()); + if (next_ts) { + const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type(), next_ts->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 (_("ramp to next 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(_session->tempo_map(), &before, &after)); + commit_reversible_command (); + } + //const Tempo tempo (tsp->note_types_per_minute(), tsp->note_type()); + + } +} + void Editor::toggle_marker_menu_lock () {