Commit graph

263 commits

Author SHA1 Message Date
Paul Davis
f5f87f86d4 temporal: adjust cut buffer API to better deal with start/end "guard points" 2023-06-05 17:27:12 -06:00
Ben Loftis
c452a4816c tempo mapping: Re-implement tempo-twist with constant and ramped varieties (lib part) 2023-05-22 13:32:53 -05:00
Paul Davis
7c07a9964a temporal: add operator<<(ostream&) for BBT_Argument 2023-05-05 18:55:27 -06:00
Paul Davis
fafc891ca6 add ripple option API for TempoMap::cut() 2023-05-04 18:49:06 -06:00
Paul Davis
b3a127d318 temporal: TempoMap::paste(), TempoMapCutBuffer::dump() and cut/copy fixes 2023-05-04 17:09:19 -06:00
Paul Davis
a8424e8617 temporal: implement (maybe) cut-copy for tempo map 2023-05-04 15:45:09 -06:00
Paul Davis
f7ba9af6b2 temporal: stub API for tempo map cut/copy/paste 2023-05-04 15:10:56 -06:00
Paul Davis
b3040a31fc temporal: a basic data structure to hold the result of a TempoMap cut/copy operation 2023-05-04 15:10:56 -06:00
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
Robin Gareus
ef7b7f4c89
Fix timecnt_t less-than-equal operator 2023-03-30 00:37:23 +02:00
John Emmas
c771eccd0e 'Temporal::DomainSwapInformation' needs to be exportable 2023-03-25 12:29:17 +00:00
Paul Davis
5dbbac0bc2 temporal: operator<< for Range and RangeList 2023-03-24 14:19:16 -06: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
6cde958480 BBT_Time: provide conversion to/from integer format
This is not guaranteed to be lossless, but with 44 bits for bars,
256 beats per bar and up to 4095 ticks per beat, it should be fine.
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
Robin Gareus
6407ca51cd
Fix region-fade, time-stretch and other scaling operations (#9057)
This resolves an ambiguity between abs(int) and std::abs(T) which
depends on context and compiler version and optimization.

In context of #9057, (gcc-6.3 -O3) math.h `abs(int)` was used. This
truncated the superclock value to 31 bit in ControlList::extend_to.
2023-01-12 16:17:39 +01: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
96bab3ce46
NO-OP: doxygenize timepos_t::distance 2022-10-31 00:22:21 +01: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
8240875379
Prevent overflow for huge time values (fix 99h clock limit @96kHz)
The default clock-limit is 99:59:59:00, just under 360000 seconds
(see ARDOUR_UI::parameter_changed, clock-display-limit).

AudioClock calculates this limit pos as
`timepos_t (limit_sec * _session->sample_rate())`

This caused an overflow leading to a negative value:
```
   timepos_t (359999 * 96000)
   samples_to_superclock (359999 * 96000, 96000)
   int_div_round (359999 * 96000 * 282240000, 96000)
```

Ideally this will be optimized, here the sample-rate cancels out,
so we could use a c'tor usin seconds.
In other cases we could cache the pre-calculated sc_per_sample:
`superclock_ticks_per_second() / superclock_t (sr)` which is an
integer for all commonly used sample-rates.
2022-10-16 18:46:36 +02:00
Paul Davis
a7a8783bb4 increase superclock_ticks_per_second to provide integer handling for NTSC (following Facebook "flicks") 2022-10-13 18:05:49 -06:00
Paul Davis
88396347e6 increment/decrement name changes ... out with old in with the new (libs 2022-10-07 17:30:35 -06:00
Paul Davis
27d5843f7a temporal: replace Range::extent() with Range::length()
We want to encourage/enforce the use of exclusive-end conventions
everywhere in the libraries that make up ardour
2022-10-07 16:16:14 -06:00
Paul Davis
c4d737dd87 temporal: provide ::decrement_by_domain() methods for time{pos,cnt}_t
audio time nominally uses superclocks as its canonical unit. However
many things at a higher level only understand samples. If we
increment or decrement a superclock value by 1, the vast majority of
the time we will still get the same sample value after
conversion. Thus to correctly alter an audio time by an amount
that will manifest as 1 sample's difference, we have to use
samples_to_superclock(1)
2022-10-07 16:16:14 -06:00
Paul Davis
617a517a60 temporal: add timecnt_t::increment() and Range::extent() (length+1) 2022-10-07 16:16:14 -06:00
Robin Gareus
8b84a0c36f
Add explicit BBT_Offset print function (like timeline.h has) 2022-09-28 18:46:58 +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
Robin Gareus
28d11df6f6
operator% is a const operation 2022-09-27 13:04:49 +02:00