From 5fcc701f27f8e72cac58032be65cbf51d78101ad Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 28 Feb 2025 16:50:18 -0700 Subject: [PATCH] when creating an SMF source, round up the duration to the nearest bar unless the duration was explicit --- libs/ardour/smf_source.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 6061d26963..c78fcc902c 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -841,7 +841,23 @@ SMFSource::load_model_unlocked (bool force_reload) the final true event. */ - _length = file_duration(); + Temporal::Beats fd = file_duration(); + + if (duration_is_explicit()) { + /* SMF provides an explicit duration that differs from the data + duration, use it + */ + _length = fd; + } else { + bool ignored; + std::shared_ptr tmap = tempo_map (ignored); + Temporal::BBT_Time bbt (tmap->bbt_at (fd)); + std::cerr << "SMF file duration " << fd << " = " << bbt << ' '; + bbt = tmap->round_up_to_bar (Temporal::BBT_Argument (bbt)); + _length = tmap->quarters_at (Temporal::BBT_Argument (bbt)); + std::cerr << " rounded up to bar " << bbt << " aka " << _length.beats() << std::endl; + } + _model->set_duration (_length.beats()); // cerr << "----SMF-SRC-----\n";