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.
This commit is contained in:
Mads Kiilerich 2022-10-05 20:05:28 +02:00 committed by Paul Davis
parent 80ffa58c81
commit 622876c8ab
1 changed files with 2 additions and 0 deletions

View File

@ -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);;