update Temporal::Beats to merge master/nutempo versions, notably with private from-double constructor

This is the libraries-only edition. It still features liberal use of Beats::from_double() but this is now
explicit and will be easier to locate the calls and remove them. Several classes that were using
Beats::to_double() have been (temporarily) made friends of Beats to allow them to keep using it,
pending the much more widespread redesigns of several structures. Once this is done, the friend
relationships can (mostly) be removed. It is expected the ARDOUR::Variant will need to continue
as a friend because it is used to pass beat counts to LV2 as doubles
This commit is contained in:
Paul Davis 2020-07-13 18:02:57 -06:00
parent ecf2028c7a
commit 4dc048b28a
16 changed files with 299 additions and 97 deletions

View file

@ -67,7 +67,6 @@ SMFSource::SMFSource (Session& s, const string& path, Source::Flag flags)
, FileSource(s, DataType::MIDI, path, string(), flags)
, Evoral::SMF()
, _open (false)
, _last_ev_time_beats(0.0)
, _last_ev_time_samples(0)
, _smf_last_read_end (0)
, _smf_last_read_time (0)
@ -103,7 +102,6 @@ SMFSource::SMFSource (Session& s, const string& path)
, FileSource(s, DataType::MIDI, path, string(), Source::Flag (0))
, Evoral::SMF()
, _open (false)
, _last_ev_time_beats(0.0)
, _last_ev_time_samples(0)
, _smf_last_read_end (0)
, _smf_last_read_time (0)
@ -135,7 +133,6 @@ SMFSource::SMFSource (Session& s, const XMLNode& node, bool must_exist)
, MidiSource(s, node)
, FileSource(s, node, must_exist)
, _open (false)
, _last_ev_time_beats(0.0)
, _last_ev_time_samples(0)
, _smf_last_read_end (0)
, _smf_last_read_time (0)
@ -419,7 +416,7 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
Temporal::Beats time = ev.time();
if (time < _last_ev_time_beats) {
const Temporal::Beats difference = _last_ev_time_beats - time;
if (difference.to_double() / (double)ppqn() < 1.0) {
if (difference < Temporal::Beats::ticks (ppqn())) {
/* Close enough. This problem occurs because Sequence is not
actually ordered due to fuzzy time comparison. I'm pretty sure
this is inherently a bad idea which causes problems all over the
@ -428,7 +425,7 @@ SMFSource::append_event_beats (const Glib::Threads::Mutex::Lock& lock,
} else {
/* Out of order by more than a tick. */
warning << string_compose(_("Skipping event with unordered beat time %1 < %2 (off by %3 beats, %4 ticks)"),
ev.time(), _last_ev_time_beats, difference, difference.to_double() / (double)ppqn())
ev.time(), _last_ev_time_beats, difference, difference)
<< endmsg;
return;
}