Commit Graph

133 Commits

Author SHA1 Message Date
Ben Loftis 912f9e5ea3 provide functions for both linear and ramped tempo-twists 2023-05-04 09:22:28 -05:00
Paul Davis b936fd12cd temporal: reset the tempo map in sections bounded by BBT markers (if any)
This avoids total SNAFUs caused by the impossibility of globally ordering
by BBT time.
2023-05-03 21:55:23 -06:00
Paul Davis faac648502 temporal: add TempoMap::{next,previous_}meter() 2023-05-03 21:55:23 -06:00
Paul Davis 0ddacb8ea2 when abort()-ing due to a failed assert in tempo map code, dump the map 2023-04-28 15:57:42 -06:00
Paul Davis e7f4c9dcb5 temporal: fix removal (and thus moving) MusicTimePoints 2023-04-27 19:54:14 -06:00
Paul Davis d66f3e7c9d temporal: factor out twist iteration, add debug output 2023-04-16 10:33:37 -06:00
Paul Davis f17a516cef temporal: fix comment explaining when/how TempoMap::set() can be used 2023-04-10 09:18:44 -06:00
Robin Gareus 295dbd8e1e
Make RCU reader return a const pointer (omnibus commit) 2023-04-08 00:15:37 +02:00
Paul Davis e9f71824a1 temporal: change API for TempoMap::stretch_tempo()
This will likely be modified because it is actually impossible to do
what this code is attempting to do.
2023-04-07 12:56:57 -06:00
John Emmas c771eccd0e 'Temporal::DomainSwapInformation' needs to be exportable 2023-03-25 12:29:17 +00:00
Paul Davis 7040ad1b74 temporal: API changes and implementation to support new twist operation
this includes using two different omega members for tempo objects,
a change that likely will not persist beyond the merge back to master.
2023-03-24 14:19:16 -06:00
Paul Davis d513653912 API development for time domain flipping 2023-03-24 14:19:15 -06:00
Paul Davis b35518e212 switch from boost::{shared,weak}_ptr to std::{shared,weak}_ptr
This is mostly a simple lexical search+replace but the absence of operator< for
std::weak_ptr<T> leads to some complications, particularly with Evoral::Sequence
and ExportPortChannel.
2023-03-24 14:19:15 -06:00
Paul Davis 73bc7e6cb7 temporal: fix ::get_tempo_and_meter() for BBT arguments 2023-03-19 10:13:06 -06:00
Paul Davis 6f095b91ce tempo map: add data structure and methods for (fast?) lookup tables
As of this commit, none of the data structures are used.
2023-02-15 16:02:56 -07:00
Paul Davis 92bd8461ca tempomap: provide improved reftime() method for TempoMetric
This now looks backwards in time for a BBT_Marker or the start of the
tempo map, whichever comes first.
2023-02-15 16:02:56 -07:00
Paul Davis 259499fc5f require use of BBT_Argument as both parameter and return type from most methods (libs edition) 2023-02-15 16:02:56 -07:00
Paul Davis f033b5717d tempo map: fix lookup of tempo/meter for a BBT time
Find the first point/tempo/meter after the reference time of the BBT argument
2023-02-15 16:02:56 -07:00
Paul Davis 43c8fae709 initial addition and use of BBT_Argument
Currently this is interchangeable with BBT_Time, but soon will
be handled differently
2023-02-15 16:02:56 -07:00
Paul Davis 818c30a98d temporal: add optional with_reset arg to all map ::remove_*() methods 2022-12-20 21:54:05 -07:00
Paul Davis ae36f8e445 temporal: provide TempoMap::replace_tempo() 2022-12-20 21:31:02 -07:00
Paul Davis d77db816de temporal: reimplement and tweak API of TempoMap::get_grid()
There were many logical errors in the previous implementation. This one is
simpler to read, and appears to work much better.

It also allows the caller to specify the quarter-note subdivision to use when
generating the grid, rather than choosing only between some bar modulo or
quarter notes.
2022-11-29 10:09:39 -07:00
Paul Davis 8299778d26 temporal: slightly change internal API for omega (ramp) computation 2022-11-29 10:09:39 -07:00
Paul Davis d9ed0f0d2e temporal: use muldiv_round to avoid overflow in TempoMetric::superclocks_per_grid() 2022-11-29 10:09:39 -07:00
Paul Davis 883527ba3e temporal: add Meter::round_to_beat() 2022-11-29 10:09:39 -07:00
David Robillard bdacfb8724 Fix invalid use of Doxygen "@param" command
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.
2022-10-30 20:44:28 -04:00
Robin Gareus 30ec62a953 This is clearly broken
Partially revert previous commit. Otherwise snap to bar/beat
clocks-displays display rounded down X|Y|1919 instead of X|Y+1|0
2022-10-22 03:09:32 +02:00
Robin Gareus 14da117bc8 Add explicit round/floor integer multiply/divide
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".
2022-10-22 02:10:05 +02:00
Robin Gareus c8ddfd5637 Fix C++ memory layout for the TempoMap
Usually C++ class instance has the same mem address as its first parent.
LuaBridge uses this to for derived classes. A TemopPoint instance has
the same address as its parent Tempo. However due to virtual inheritance
this was not the case due to a lack of virtual d'tor.

Now the following Lua code works correctly
```
tm = Temporal.TempoMap.read()
tp = Temporal.timepos_t (0)
print (tm:tempo_at(tp):note_type())
```

Previously the last line failed calling Tempo::note_type()
on a TempoPoint instance, due to memory offset e.g.
TempoPoint: 0x600000ff90e0 Tempo: 0x600000ff90e8
2022-09-28 04:12:11 +02:00
Paul Davis cc6a437faf temporal: fix a bug in BBT_Time::round_up_to_bar()
Also remove Meter:: versions of related methods, because they are not necessary. We
only need metrical information for operations like ::round_to_bar()
2022-08-03 10:59:29 -06:00
Paul Davis 0d70be3a05 miscellaneous fixes for warnings from -Wconversion 2022-07-04 22:01:48 -06:00
Paul Davis f60b35483d temporal: fix major conceptual error managing Point reference to owner map
When TempoMap::copy_points() is called, the new points are intended to belong
to the (nascent) new map. But the copy constructor for the points leaves the
_map member of a Point unchanged, and so the new points reference the old
map (forever!). ::copy_points() must reset each Point to reference the new map.

Refactored the object that has the _map member, so that we could limit access
to its ::set_map() method to TempoMap.
2022-06-16 22:11:56 -06:00
Paul Davis 88a035b000 temporal: changes in API to better support BBT markers 2022-06-03 13:19:56 -06:00
Paul Davis 192b2fd839 temporal: fixes for TempoMap::move_meter() 2022-05-30 21:14:57 -06:00
Paul Davis 25dc926f24 temporal: improve handling of MusicTimePoints and related matters 2022-05-24 17:10:25 -06:00
Paul Davis c48430f502 temporal: refactor methods to add tempo/meter points 2022-05-24 17:10:25 -06:00
Paul Davis ef1f814837 temporal: remove commented constructor 2022-05-24 17:10:25 -06:00
Paul Davis e3501a05f8 temporal: remove the concept of a time domain for the tempo map
TempoPoint and MeterPoint always have their position set in musical time; MusicTimePoint (BBT)
always has a position in audio time. It's that simple
2022-05-24 17:10:25 -06:00
Paul Davis e7e467264f temporal: add TempoMap::set_continuing() and make it and set_ramped return bool 2022-05-24 17:10:25 -06:00
Paul Davis f2a596669e temporal: set speed *and* tempo when setting tempo 2022-05-24 17:10:25 -06:00
Paul Davis 20d7313e13 temporal: change "clamped" terminology to "continuing" (since that's what the GUI calls it) 2022-05-23 08:07:08 -06:00
Paul Davis 9dd4931247 temporal: revert changes that created two different omegas; fix computation of ::superclock_at() for decelerando
changes in tempo can be negative (decelerando/slowing down), and thus so can _omega. We cannot call log() or its
cousins on negative values, so in this scenario use an alternate expression for "t from b" in the tempo.pdf paper
2022-05-20 09:06:25 -06:00
Paul Davis 1ccda17504 temporal: add a new version of tempo twist based on pre-nutempo code 2022-05-13 19:05:13 -06:00
Paul Davis 51980b15cd temporal: split _omega into two values, for each time domain
omega can be computed from Beat or superclock duration. This gives rise to
different units for omega, and we must use the correct value in a given
context.

This commit also changes the way that the audio time omega is computed during
TempoMap::reset_starting_at()
2022-05-13 19:05:13 -06:00
Paul Davis f679cd6eab temporal: remove Rampable, change name of method to set end note types per minute
Rampable only existed to provide exclusive access to ::set_end() for the
TempoMap. More idiomatic C++ but now that _type has also gone away, so has
::set_ramped() and it really was not worth keeping it around.
2022-05-13 19:05:13 -06:00
Paul Davis 8770df611c temporal: remove TempoMap::_type concept
Ramped/Constant is really a function of start/end note_types_per_minute. Having
a separate member is really just caching it and leads to errors or risk thereof.
2022-05-13 19:05:13 -06:00
Paul Davis 45de3694cc temporal: add reimplemented version of 6.x's TempoMap::gui_stretch_tempo() 2022-05-13 19:05:13 -06:00
John Emmas 2245e362b9 TempoMap::twist_tempi() gets used outside of libtemporal so needs to get exported 2022-05-03 11:31:43 +01:00
Paul Davis b5487415ec editing: a partiaally implemented version of TempoTwistDrag, to be completed. 2022-05-02 16:47:23 -06:00
Paul Davis 86e7a1b259 temporal: no reason for Point::set() to be virtual 2022-05-02 16:45:33 -06:00