From 2aad1ac5f5709f85cbeca6f2d8486d57ade57beb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 19 Aug 2025 10:46:37 -0600 Subject: [PATCH] temporal: fix TempoMap::paste() to pass unit test the BBT times of the newly inserted points during paste() are meaningless until we recompute them using ::reset_starting_at(). So don't try to compute some sort of likely value, just use the value from the cut buffer, and call reset_starting_at() after every point inserted. --- libs/temporal/tempo.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libs/temporal/tempo.cc b/libs/temporal/tempo.cc index 3cd120d3b4..130b9c3ffb 100644 --- a/libs/temporal/tempo.cc +++ b/libs/temporal/tempo.cc @@ -1096,10 +1096,11 @@ TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool core_add_meter (mtp, ignored); core_add_point (mtp); } + + reset_starting_at (position.superclocks()); } MeterPoint const * current_meter = &meter_at (position); - BBT_Offset bbt_offset = BBT_Offset (cb.points().front().bbt()) - BBT_Offset (pos_bbt); for (auto const & p : cb.points()) { TempoPoint const * tp; @@ -1134,21 +1135,21 @@ TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool } else { if ((tp = dynamic_cast (&p))) { - bb = current_meter->bbt_add (p.bbt(), bbt_offset); - TempoPoint *ntp = new TempoPoint (*this, *tp, s, b, bb); + TempoPoint *ntp = new TempoPoint (*this, *tp, s, b, p.bbt()); core_add_tempo (ntp, replaced); if (!replaced) { core_add_point (ntp); } } else if ((mp = dynamic_cast (&p))) { - bb = current_meter->bbt_add (p.bbt(), bbt_offset); - MeterPoint *ntp = new MeterPoint (*this, *mp, s, b, bb); + MeterPoint *ntp = new MeterPoint (*this, *mp, s, b, p.bbt()); current_meter = core_add_meter (ntp, replaced); if (!replaced) { core_add_point (ntp); } } } + + reset_starting_at (s); } pos_bbt = bbt_at (end_position); @@ -1169,9 +1170,9 @@ TempoMap::paste (TempoMapCutBuffer const & cb, timepos_t const & position, bool core_add_meter (mtp, ignored); core_add_point (mtp); } - } - reset_starting_at (s); + reset_starting_at (s); + } } void