From 622876c8abc958b117c2080a0e5fdc21d617dd6b Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Wed, 5 Oct 2022 20:05:28 +0200 Subject: [PATCH] temporal: reset global superclock rate when creating a new session The superclock rate is variable and is stored in session files since 7.0 . It is set globally when reading from a session file, and it really should be reset to a known state whenever a new blank session is created from an existing one. Currently, that doesn't happen. We fix that by resetting it in Temporal::reset(). For now, we are duplicating the default superclock rate 282240000 from superclock.h , but we can drop that when all code paths that use superclock also use Temporal::reset(). This will provide an (extra) guarantee that set_superclock_ticks_per_second() always is invoked before creating TempoMap or using superclock_ticks_per_second() in other ways. The DEBUG_EARLY_SCTS_USE in superclock.h is thus closer to passing. --- libs/temporal/enums.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libs/temporal/enums.cc b/libs/temporal/enums.cc index e61bbd7e42..5b2d976cc1 100644 --- a/libs/temporal/enums.cc +++ b/libs/temporal/enums.cc @@ -78,6 +78,8 @@ void Temporal::init () void Temporal::reset () { + set_superclock_ticks_per_second (282240000); /* 2^10 * 3^2 * 5^4 * 7^2 */ + (void) TempoMap::write_copy(); /* we are going to throw away the return value and replace the map entirely */ TempoMap::WritableSharedPtr new_map (new TempoMap (Tempo (120, 4), Meter (4, 4))); TempoMap::update (new_map);;