From ce236c49ca07c70fa11582fb4052af863571d5cc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 24 Apr 2025 11:58:27 -0600 Subject: [PATCH] when building a tempo map for the Pianoroll, consider using the main tempo map This is only relevant when a Pianoroll is used to edit a timeline region. --- gtk2_ardour/pianoroll.cc | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/gtk2_ardour/pianoroll.cc b/gtk2_ardour/pianoroll.cc index ea8bfe3be5..83ee2c5c89 100644 --- a/gtk2_ardour/pianoroll.cc +++ b/gtk2_ardour/pianoroll.cc @@ -2555,8 +2555,26 @@ Pianoroll::set_region (std::shared_ptr r) } if (!provided) { - /* COPY MAIN SESSION TEMPO MAP? */ - map.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); + Temporal::TempoMap::SharedPtr tmap (Temporal::TempoMap::use()); + + if (with_transport_controls) { + /* clip editing, timeline irrelevant, sort of */ + + if (tmap->n_tempos() == 1 && tmap->n_meters() == 1) { + /* Single entry tempo map, use the values there */ + map.reset (new Temporal::TempoMap (tmap->tempo_at (timepos_t (0)), tmap->meter_at (timepos_t (0)))); + } else { + + map.reset (new Temporal::TempoMap (Temporal::Tempo (120, 4), Temporal::Meter (4, 4))); + } + + } else { + /* COPY MAIN SESSION TEMPO MAP? */ + Meter m (tmap->meter_at (r->source_position())); + Tempo t (tmap->tempo_at (r->source_position())); + + map.reset (new Temporal::TempoMap (t, m)); + } } {