parens were in the wrong place - we need to add the ::magnitude() of
the tick-based duration AFTER conversion of audio-time position to beats, not
before.
This is never for inline references to parameters, only for starting parameter
documentation blocks. The "@p" command is for this, although unfortunately
Doxygen doesn't actually do anything with it and it's just an alias for code
text.
This fixes various rounding issues. Notably superclock to sample
conversion must always round down when playing forward.
`::process (start, end, speed = 1)` uses exclusive end.
Processing begins at `start` and end ends just before `end`.
Next cycle will begin with the current end.
One example where this failed:
- New session at 48kHz
- Change tempo to 130 BPM
- Enable snap to 1/8 note
- Snap playhead to 1|3|0
- Enable Metronome
- Play
`assert (superclock_to_samples ((*i).sclock(), sample_rate()) < end);`
end = 177231 samples == superclock 1042118280
A grid point is found at superclock 1042116920 (that is < 1042118280).
However converting it back to samples rounded it to sample 177231 == end,
while actual location is 1360 super-clock ticks before end.
The metronome click has to be started this cycle, since the same
position will not be found at the beginning of the next cycle, with
start = 177232.
Similarly a samplecnt_t t, converted to music-time and back must not be
later than the given sample.
```
timepos_t tsc (t);
assert (timepos_t::from_ticks (tsc.ticks ()).samples () <= t);
```
IOW. When playing forward, all super-clock time between 1|1|0 and 1|1|1
should round down to 1|1|0. "We have not yet reached the first tick".
This addressee a bug where ardour 6 was able to write negative
duration `length="-1"` `length-beats="-3.3650500597559585e-05"`
Ideally timecnt_t::string_to should check for invalid,
negative, duration. But this also catches a more generic case.
```
exception at str.substr (1)
#3 Temporal::timepos_t::string_to (this=0x7fffffff7bb0, str="") at libs/temporal/timeline.cc:904
#4 Temporal::timecnt_t::string_to (this=0x7fffffff7ba0, str="-2") at libs/temporal/timeline.cc:294
#5 PBD::string_to<Temporal::timecnt_t> (str="-2") at libs/ardour/ardour/types_convert.h:131
```
timecnt_t and timepos_t constructors with the initial argument as an int64_t
are assumed to be using samples. We need to use the explicit factory methods
instead.
This uses boost::multiprecision::int512_t when multiplying and dividing by the numerator
and denominator of a ratio_t. 128 bits would be sufficient but for some reason, the boost
docs show the 512 bit variant being very slightly faster.
This is a better solution than using a double, which although it will prevent overflow
has fairly limited resolution.
max_samplepos and max_samplecnt and both INT64_MAX which is (a) too large to fit into a signed 62 bit
integer and (b) definitely too large to be represented in a signed 62 bit superclock value.
Move the constructors that use samplepos_t into the .cc file, and treat these two values as special
cases that mean "as large/late/huge/long as possible".
If time domains differ, it is necessary to first convert the argument duration into a duration
at the position of "this", in the correct time domain. Then we recursively call the operator
again, but this time we will use the fast path that just adds two timepos_t values.
pbd/i18n.h MUST NEVER be included from header files and always be
the last include. This is because `_` is declared other headers
notably boost and some apple headers.
leading to issues like
../libs/pbd/gettext.h:58:27: error: expected unqualified-id before ‘const’
58 | # define gettext(Msgid) ((const char *) (Msgid))
superclock_t and samplepos_t have the same underlying C++ type, so methods that accept one or the
other as an argument need to be named to make it clear which type they accept. We do not need
the superclock_t variant publically, but it turns out to be useful within TempoMap.
This allows us to differentiate between superclock_t and samplepos_t (and related types) which are all typedef'ed to the
same underlying primitive C++ type. Without this, it would be impossible for the compiler or someone reading the code
to know whether a scalar passed to a constructor for a timeline type is in units of samples or superclocks