13
0
Commit Graph

281 Commits

Author SHA1 Message Date
9b5e910717 temporal: add additional required string_to/to_string functions for BBT_Offset & BBT_Time 2021-12-18 14:11:25 -07:00
506bc3a6f6
Disambiguate zero(bool) constructor and is_zero() comparison
This is mainly for the benefit of Lua bindings, but also increases
overall API naming consistency with functions and methods
`is_XYZ()` being used elsewhere.

This API change breaks builds!
2021-12-11 14:33:45 +01:00
940d8844e3 temporal: fix implementation of Beats::snap_to(), and add variants
::snap_to() was intended to round a Beats value to the nearest multiple
of another Beats value. It did not do that, but instead rounded down.
Worse, it used Beats::operator/ which in turn uses int_div_round(),
which is incorrect for a situation where we need integer truncation.

The changes fix the actual arithmetic and add 2 variant functions so that the
API includes round down, round up and round to nearest.
2021-11-29 21:50:29 -07:00
878393e68b temporal: fix construction of timepos_t and timecnt_t with max_sample{pos,cnt}
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".
2021-11-22 10:35:52 -07:00
d71b3100d8 temporal: handle negative positional values that somehow appear in older sessions 2021-11-22 10:28:13 -07:00
6e404ea7bf tempomap: reimplement TempoMap::bbt_walk()
This still needs work to deal correctly with negative (backwards/earlier)
walks.
2021-11-17 15:59:03 -07:00
b1b5553d1d tempomap: allow access to TempoMap::bbt_at () variant 2021-11-17 15:58:33 -07:00
2aefb472e2 temporal: change API of TempoMap::sample_at() to not require an explicit sample rate
We have a mechanism to get the engine sample rate and use that widely. We
should use it here also.
2021-11-17 15:56:06 -07:00
3c9bebda00 remove debug output 2021-11-17 12:16:39 -07:00
180c1d7759 tempo map: slight reorganization of ::get_grid
This avoids resetting beats based on superclocks in case where we
already do the opposite.
2021-11-17 12:16:39 -07:00
7dbf2445f5 tempo map: NOOP: expand comment to explain more 2021-11-17 12:16:39 -07:00
a5ccb521e6 tempo map: NOOP helpful comment, perhaps 2021-11-17 12:16:39 -07:00
73c87064a5 tempo map: NOOP correct comment text 2021-11-17 12:16:39 -07:00
c7adea3ec0 tempo map: really no-op code change to provide another useless compiler const hint 2021-11-17 12:16:39 -07:00
d9b1d2ccc8 temporal: NOOP add helpful comment about bar_mod argument 2021-11-17 12:16:39 -07:00
b3451f4055 tempo map: fix computation of superclocks_per_note_type_at()
Code used position as an absolute, rather than offset from the point
that defines tempo. It worked if the point was at zero, but not
otherwise.
2021-11-17 12:16:39 -07:00
a417cbae4b tempo map: fix a potential bug (not seen in the wild) when generating the grid
the "p" variable could point to _points.end(), so we cannot indirect and use
p->sclock() value unconditionally.
2021-11-17 12:16:39 -07:00
1ba2e28d6f tempo map: fix grid generation with ramped tempos
The old code used the instantaneous tempo at T0 to compute where the next
quarter note would be. This is incorrect, since the tempo is
changing (continuously, for now) during the time represented by that quarter
note. Instead, we need to add a quarter note (or technically, whatever the
tempo note type is) to get a new position in beats, then compute the superclock
time at that location (which will use our equations for tempo, including the
use of omega, the ramp factor).
2021-11-17 12:16:39 -07:00
8972ed1517 temporal: add Tempo::note_type_as_beats() 2021-11-17 12:16:39 -07:00
7edcda4fc1 temporal: logic fixes for several tempo map modification methods 2021-11-17 12:16:39 -07:00
1532ebb38f temporal: truncate ::to_string() method for timeline types to ::str() for easier use in debugger 2021-11-17 12:16:38 -07:00
7a12458244 temporal: improve implementation of TempoMap::meter_at() and more templating
Needed to move template defns around to ensure that required instances are defined
2021-11-17 12:16:38 -07:00
4128088b70 temporal: TempoMap::tempo_at() ... templates FTW 2021-11-17 12:16:38 -07:00
fb2281129a temporal: add clarifying comments to TempoMap::remove_*()
These comments should correct an impression left in the commit message for
6e9e28343bc3695d that there may be some sort of problem with synchronization
of TempoMap changes. The actual problem is that TempoMap edits are done using
RCU, so the modifications are performaned using a copy of the map, but with
map elements taken from the pre-copy version.
2021-11-17 12:16:38 -07:00
b67965f499 temporal: add the entire _points list to output of TempoMap::dump() 2021-11-17 12:16:38 -07:00
8a59f3fe8e temporal: fix issue with removal of tempo, meter and bartime points
The correct algorithm is to traverse the type-specific list of points,
find the point (if any) whose time matches that of the argument (because
we do not allow multiple points of the same type at the same time), and
then use that discovered point from the _points list.

This approach is required because the actual argument may no longer be
in the tempo map (due to a change made by another thread). The lack of
sync, however, needs investigation.
2021-11-17 12:16:38 -07:00
5b5ca546e0 temporal: fix incorrect implementation of TempoMap::tempo_map()
std::lower_bound() is not appropriate here. We need to find the first
TempoPoint after the given time, then return the one before that.
2021-11-17 12:16:38 -07:00
e7e44351cc temporal: move implementation of quarters_per_minute_at() into .cc file 2021-11-17 12:16:38 -07:00
a0e134e1b3 temporal: update comment on a method that suggest not using it; provide TempoMap::quarters_per_minute_at () 2021-11-17 12:16:38 -07:00
4f3bf37680 temporal: implement a faster method to lookup TempoPoint
There is no reason to build a TempoMetric if you only need the Tempo
2021-11-17 12:16:38 -07:00
8c632c8446 temporal: allow negative timecnt_t to be used when constructing a timepos_t
Negative positions are legal and should be handled by higher level logic
2021-11-14 15:22:53 -07:00
4376185a6b temporal: fix TempoPoint::superclock_at (Beats)
a negative beat position needs to be legal, so the assert was moved and modified. The only check
for a negative value is that the TempoPoint being used is at absolute zero.

This check might turn out to be wrong in the future, but for now we still require a tempo and
meter point at absolute zero
2021-10-29 12:55:14 -06:00
480907d613 add sstream header file, since the header file requires the defn 2021-10-14 13:12:31 -06:00
bb87ba49d9 remove unnecessary boost header (we have our own ratio_t) 2021-10-14 13:12:31 -06:00
89c17dfe7d remove debug output 2021-10-05 14:00:34 -06:00
dadf530243 temporal: change loading of session format 3x tempo maps
We were attempting to add the initial tempo and meter twice, which was unwise
2021-10-05 13:57:10 -06:00
0acc1a3fec temporal: use correct implementation of timepos_t::operator+ (timecnt_t) (and +=)
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.
2021-10-04 17:45:02 -06:00
ed3d374f47
Fix --no-nls compilation 1/2 -- #8802
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))
2021-09-27 16:28:44 +02:00
30a00c5e9f Fix implementation of timecnt_t::operator==() to compare both duration and position 2021-09-25 16:49:51 -06:00
John Emmas
666e62076c Part 2: Complete the changes needed to make 'boost::intrusive::list' work with MSVC
It turned out that 'boost::intrusive::list_base_hook<>' won't compile if its parent class is declared using '__declspec(dllexport)' - so rather than exporting each entire class, let's use the alternative approach and export the various class members individually.
2021-09-18 13:40:22 +01:00
cb81b06a5d
Revert "Fix div/zero, allow switching backends"
This reverts commit 1288262ca7.
2021-09-15 17:52:53 +02:00
John Emmas
840e63e6b2 Prefer tags for 'boost::intrusive::list' rather than list_member_hook<>
list_member_hook<> is very troublesome in MSVC and is known to cause problems in other compilers when used inside a class which has a virtual base class.
2021-09-15 09:28:54 +01:00
1288262ca7
Fix div/zero, allow switching backends
When switching backends, the effective sample-rate is zero.
This only affects the butler thread (the only active thread when
stopped). The actual issue here is the butler calling
"non-realtime-stop" without a backend. However fixing 0/0
generally seems appropriate.
```
#0 in int_div_round<long>(long, long) (x=0, y=0) at ../libs/pbd/pbd/integer_division.h:36
#1 in Temporal::samples_to_superclock(int64_t, int) (samples=0, sr=0) at ../libs/temporal/temporal/superclock.h:39
#2 in Temporal::timepos_t::timepos_t(long) (this=0x7f94bc0a5890, s=0) at ../libs/temporal/temporal/timeline.h:55
#3 in ARDOUR::Automatable::non_realtime_locate(long) (this=0x55a12a980cc8, now=0) at ../libs/ardour/automatable.cc:421
#4 in ARDOUR::Route::non_realtime_locate(long) (this=0x55a12a980ae0, pos=0) at ../libs/ardour/route.cc:5462
#5 in ARDOUR::Session::non_realtime_stop(bool, int, bool&) (this=0x55a12e0cd000, abort=false, on_entry=1, finished=@0x7f94bc0a5e0f: true) at ../libs/ardour/session_transport.cc:1487
#6 in ARDOUR::Session::butler_transport_work(bool) (this=0x55a12e0cd000, have_process_lock=false) at ../libs/ardour/session_transport.cc:1153
#7 in ARDOUR::Butler::thread_work() (this=0x55a12f3b7000) at ../libs/ardour/butler.cc:222
#8 in ARDOUR::Butler::_thread_work(void*) (arg=0x55a12f3b7000) at ../libs/ardour/butler.cc:16
```
2021-09-11 04:54:40 +02:00
1904c4aa29 temporal: fix operator>> for Beats when handling pre-nutempo formats (double) 2021-09-10 12:15:24 -06:00
John Emmas
f6ed73986b A few visibility changes needed for linking to libtemporal (when building with MSVC) 2021-09-04 12:28:15 +01:00
John Emmas
d7d966e02b Adapt 'Temporal::TempoMap::tempo_map_p' to be buildable with MSVC
Whenever a variable gets declared using 'thread_local' MSVC requires that it should not be compiled with DLL linkage (i.e. it mustn't be exportable). So for Temporal::TempoMap we'll need to export the required members individually, rather than exporting the entire class.
2021-09-03 10:02:41 +01:00
7dba843cb4 temporal: fix error in operator>> for BBT_offset 2021-08-31 22:33:33 -06:00
4eda53c8c9 temporal: add to_string() converters for BBT_Offset 2021-08-31 16:45:44 -06:00
Nil Geisweiller
21c94b23f3 Make BBT_Time::print_padded const
As this method does not modify BBT_Time it can be const.  This allows such
method to be called over a const BBT_Time instance.
2021-08-30 02:24:38 +03:00
John Emmas
d3cd621f7a Initial changes needed for building libtemporal with MSVC
Later I'll need to push some extra changes (to support 'tempo_map_p' and 'boost::intrusive::list' etc) but these initial ones (hopefully!) won't cause any issues for the other builds.
2021-08-29 11:03:58 +01:00