From a523551228830fd932706440a45c8f6af388c989 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 2 Feb 2024 10:32:04 -0700 Subject: [PATCH] use SMF tempo map if available in MidiCueEditor --- gtk2_ardour/midi_cue_editor.cc | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/midi_cue_editor.cc b/gtk2_ardour/midi_cue_editor.cc index 4f2d3d9cf9..d875ddb226 100644 --- a/gtk2_ardour/midi_cue_editor.cc +++ b/gtk2_ardour/midi_cue_editor.cc @@ -17,7 +17,7 @@ */ #include "ardour/midi_region.h" -#include "ardour/midi_source.h" +#include "ardour/smf_source.h" #include "canvas/canvas.h" #include "canvas/container.h" @@ -27,6 +27,7 @@ #include "gtkmm2ext/actions.h" + #include "ardour_ui.h" #include "editor_cursors.h" #include "editor_drag.h" @@ -295,11 +296,19 @@ MidiCueEditor::set_region (std::shared_ptr t, std::shared_ptr /* Compute zoom level to show entire source plus some margin if possible */ - std::shared_ptr map; - Temporal::timecnt_t duration = Temporal::timecnt_t (r->midi_source()->length().beats()); - /* XXX build tempo map from source */ - map.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); + + bool provided = false; + std::shared_ptr map; + std::shared_ptr smf (std::dynamic_pointer_cast (r->midi_source())); + + if (smf) { + map = smf->tempo_map (provided); + } + + if (!provided) { + map.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); + } { EditingContext::TempoMapScope tms (*this, map); @@ -497,12 +506,18 @@ MidiCueEditor::metric_get_bbt (std::vector& marks, sa return; } + bool provided = false; std::shared_ptr tmap; if (view) { - /* XXX MAKE MAP FROM REGION->SOURCE */ - tmap.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); - } else { + std::shared_ptr smf (std::dynamic_pointer_cast (view->midi_region()->midi_source())); + + if (smf) { + tmap = smf->tempo_map (provided); + } + } + + if (!provided) { tmap.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); }