Commit graph

139 commits

Author SHA1 Message Date
Paul Davis
a57f4fbce6 temporal: after changing a tempo point, reset the map starting at that point 2022-05-10 09:46:08 -06:00
Robin Gareus
46117303da
Fix some potentially uninitialized variables 2022-05-07 04:19:09 +02:00
Paul Davis
b5487415ec editing: a partiaally implemented version of TempoTwistDrag, to be completed. 2022-05-02 16:47:23 -06:00
Paul Davis
55755d5453 temporal: fix TempoMap::reset_starting_at()
We were using a given tempo or meter point as part of the metric used when
recomputing its position. In fact, the metric should be only use the
tempo/meter immediately preceding the given point.
2022-05-02 16:44:15 -06:00
Paul Davis
00b9e3f86a temporal: change return type of TempoMap::next_tempo()
It is more useful to get the actual TempoPoint than just the Tempo
that we discover.

Aside: it would be awesome to understand how to use boost::intrusive to get the
next tempo point directly from the tempo hook.
2022-05-02 11:40:23 -06:00
Paul Davis
7fd8544e31 temporal: fix copy-n-paste error in TempoCommand cosntructor 2022-04-08 11:58:04 -06:00
Paul Davis
e466736e2d temporal: remove MementoBinder API for tempo map undo/redo 2022-04-08 11:58:04 -06:00
Paul Davis
a806ede94d temporal: add TempoCommand, a Command-derived structure for managing undo/redo w.r.t TempoMap 2022-04-08 11:58:04 -06:00
Paul Davis
7c3268d12f temporal: TempoMap::use() returns a const ptr to enforce semantics (library version)
This commit leaves two issues outstanding:

1. unclear/ugly semantics for drag operations that reset the GUI thread's tempo map to the writable copy
2. undo/redo for the tempo map

These will be addressed in future commits
2022-04-08 11:58:04 -06:00
Paul Davis
7bf89ce109 Constification: make Stateful::get_state() const, with all other required const-ness added (libs) 2022-04-06 21:56:59 -06:00
Paul Davis
ae3548c1da temporal: fix location of enum conversion decls
Without these changes, minor changes in include file
ordering or extent elsewhere can cause compiler errors.
2022-04-05 20:52:09 -06:00
Paul Davis
bf2618e97b temporal: fix crash during reset_starting_at() 2022-03-23 18:03:42 -06:00
Paul Davis
857856431e temporal: remove debug output and stacktrace 2022-03-23 17:42:52 -06:00
Paul Davis
74a4678c04 temporal: NOOP add explanatory comment 2022-03-23 17:42:52 -06:00
Paul Davis
214c291e55 temporal: fix ::set_state() for old sessions where initial meter was moved to non-zero location 2022-03-23 17:42:52 -06:00
Paul Davis
b4cf61304c fix meter point removal
std::upper_bound() was not the correct tool to find the existing point,
it should have been std::lower_bound(). For code consistency, this
change doesn't use either but like ::remove_tempo() and similar methods,
just iterates over the whole list
2022-03-21 11:35:34 -06:00
Paul Davis
d29c70a2a2 temporal: add new variant of TempoMap::bbtwalk_to_quarters() 2022-03-19 15:25:14 -06:00
Paul Davis
a803dd0df8 superclock_ticks_per_second: use an (inline) accessor, change value
We do not want a value as large as the previous one, which limits the time
range that can be represented in 62 bits unnecessarily. The new value is
9 times smaller than the previous value, and loses only 384000 as a significant
factor.

This commit also switches to using an (inline) accessor for superclock_ticks_per_second,
making it possible in debug/testing phases to spot early/illegal uses of the value.
2022-03-17 14:15:59 -06:00
Robin Gareus
e603b2e12d
Remove debug messages (1/2) 2022-03-16 17:08:14 +01:00
Robin Gareus
ab3a7dc721
Fix bbt_subtract math
When r.ticks is already negative, add the negative value
(not subtract), likewise handle negative beat offset correctly.
2022-03-04 19:40:30 +01:00
Paul Davis
3553d56f05 tempo map: fix loading 6000-version or earlier tempo maps
Probably a copy-n-paste error meant the reversed logic was used
to decide if we had found an inital tempo and meter
2022-02-11 08:46:49 -07:00
Paul Davis
b7769a8f4b possible fix for a valgrind reported illegal read 2022-01-24 16:42:12 -07:00
Paul Davis
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
Paul Davis
3c9bebda00 remove debug output 2021-11-17 12:16:39 -07:00
Paul Davis
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
Paul Davis
7dbf2445f5 tempo map: NOOP: expand comment to explain more 2021-11-17 12:16:39 -07:00
Paul Davis
a5ccb521e6 tempo map: NOOP helpful comment, perhaps 2021-11-17 12:16:39 -07:00
Paul Davis
c7adea3ec0 tempo map: really no-op code change to provide another useless compiler const hint 2021-11-17 12:16:39 -07:00
Paul Davis
d9b1d2ccc8 temporal: NOOP add helpful comment about bar_mod argument 2021-11-17 12:16:39 -07:00
Paul Davis
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
Paul Davis
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
Paul Davis
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
Paul Davis
7edcda4fc1 temporal: logic fixes for several tempo map modification methods 2021-11-17 12:16:39 -07:00
Paul Davis
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
Paul Davis
4128088b70 temporal: TempoMap::tempo_at() ... templates FTW 2021-11-17 12:16:38 -07:00
Paul Davis
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
Paul Davis
b67965f499 temporal: add the entire _points list to output of TempoMap::dump() 2021-11-17 12:16:38 -07:00
Paul Davis
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
Paul Davis
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
Paul Davis
e7e44351cc temporal: move implementation of quarters_per_minute_at() into .cc file 2021-11-17 12:16:38 -07:00
Paul Davis
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
Paul Davis
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
Paul Davis
89c17dfe7d remove debug output 2021-10-05 14:00:34 -06:00
Paul Davis
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
Robin Gareus
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
Paul Davis
fee4292bde allow negative superclock -> negative beats computation 2021-08-23 11:36:54 -06:00
Paul Davis
38aa2560f3 libtemporal: remove unnecessary initialization 2021-08-13 12:51:35 -06:00
Paul Davis
f61adcd738 temporal: knarly template code to consolidate and rationalize duplicated methods 2021-08-13 12:51:35 -06:00
Paul Davis
585346ce56 libtemporal: fix many different issues with tempo ramps
API changes, ensuring omega is computed, saved, and restored, generic methods to get tempo/meter at a position, and lots more
2021-08-13 12:51:35 -06:00
Paul Davis
f721655916 libtemporal: to quote the matrix, there is no lock 2021-08-13 12:51:35 -06:00