Commit Graph

8 Commits

Author SHA1 Message Date
Mads Kiilerich
622876c8ab 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.
2023-09-20 12:30:53 -06:00
Mads Kiilerich
80ffa58c81 temporal: introduce Temporal::reset() with TempoMap initialization
Ardour uses some global variables and singletons. These global variables
can be initialized with a value prior to program execution (especially
if they are const), but some of the static variables are modified, and
it is crucial that they always are reset when switching to another
session. To keep things simple and explicit and consistent, we thus
introduce Temporal::reset() to reset TempoMap (and later on also the
superclock rate). This is somewhat similar to Temporal::init(), which
usually only is invoked once (on program start) to initialize singletons
(such as the TempoMap).

9964f20c added TempoMap initialization to Session::create() ... but only
when not using a template. This create method is mainly preparing the
filesystem for a new session, and TempoMap initialization doesn't seem
like a perfect fit for it. It also seemed odd that it only initialized
TempoMap for clean new sessions, while existing sessions and templates
initialized it elsewhere.

Instead, invoke the TempoMap initialization early in the Session
creation process. This might introduce an extra and unnecessary TempoMap
initialization when loading an existing session or using a template, but
that will be cheap and do no harm, while providing a guarantee that we
always use the same default value.
2023-09-20 12:30:53 -06:00
8a371bcaa2
Fix tempo-map backward compatibility
Moving forward tempo-type is saved without `Tempo::`
prefix again.
2023-07-17 00:35:05 +02:00
78233b343f libtemporal: add operator<<() for ratio_t 2021-08-13 12:51:32 -06:00
5bef968069 Temporal: replace thread_local sample rate with callback to get sample rate 2021-08-13 12:51:31 -06:00
8dbbc1df54 library changes to get libtemporal setup at application startup 2021-08-13 12:51:30 -06:00
5150e856b0 add to enums list for libtemporal 2021-08-13 12:51:29 -06:00
bca8e2e8cc libtemporal: changes derived from converting libardour 2021-08-13 12:51:28 -06:00