13
0
Commit Graph

603 Commits

Author SHA1 Message Date
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
62d4e0789a tempo map: fix error in TempoMap::copy_points() that fails to reset _map ptr
This left the _map ptr of all points in a copy of a map pointing
to an old/dead TempoMap.
2023-02-14 10:14:55 -07:00
Marijn Kruisselbrink
b0f5fea53a
Fix minor errors in temporal/wscript 2023-01-12 20:58:24 +01:00
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
34e12a5d78
Fix grid when tempo marker is not on a mod_bar/beat_div
Previously the current iterator bbt was moved to p->bbt().

From then on, no grid line is reached if the point p is not on
a bar and mod_bar != 0 or the point is not on an expected beat_div.

e.g. when using bbt += mod_bar, and a tempo-change is at 5|2|0.
iterations continues 6|2|0 7|2|0  is_bar() is always false
and no more grid-lines were added.

Rather than trying
   bbt = round-up-to-next-grid-mod-div
and then finding the metric for that position, this
approach only does the latter using the already incremented
BBT position.
2023-01-11 00:25:23 +01:00
b0a679a1af
Fix grid after last tempo-marker when showing bars
This is a copy/paste bug, compare to d77db816de
2023-01-11 00:06:43 +01:00
ac30964d67 remove debug output 2022-12-26 14:03:32 -06:00
b2a6fb70b4 remove debug output 2022-12-20 22:01:41 -07:00
818c30a98d temporal: add optional with_reset arg to all map ::remove_*() methods 2022-12-20 21:54:05 -07:00
0ee0226776 temporal: no stretching a tempo that is the last one or precedes a BBT marker 2022-12-20 21:33:13 -07:00
d3dd865093 temporal: NOOP - add helpful comment 2022-12-20 21:31:31 -07:00
ae36f8e445 temporal: provide TempoMap::replace_tempo() 2022-12-20 21:31:02 -07:00
033b4c5152 temporal: fix implementation of TempoMap::copy_points()
This could re-order the map in the presence of BBT markers
2022-12-20 21:29:44 -07:00
39c324b620 temporal: fix ::get_grid() crash condition
We cannot call TempoMetric::superclock_at (BBT_Time) if the BBT time is beyond
the range of the current TempoMetric. We must discover that *before* we make
that call, not as part of the test to see if we've exceeded the range.
2022-12-10 22:59:58 -07:00
db3e87a7e4 do nothing gracefully if asked to remove only tempo 2022-12-10 14:14:12 -07:00
4beca98e28 temporal: fix various incorrect uses of ::samples() in audio time arithmetic
It is a wonder that this has not caused more visible issues since 7.0
2022-12-07 11:13:49 -07:00
c505024a4b temporal: when resetting the map, position BBT markers in beat time (and stop reset there) 2022-12-05 10:01:49 -07:00
12b672492e tempomap: fix and improve efficiency and readability in ::get_grid() 2022-12-05 10:01:49 -07:00
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
a124062fa2 temporal: move_tempo() must use beats (timesig dependent) not quarters 2022-11-29 10:09:39 -07:00
1f4717d93b temporal: reset map requires a BBT-sorted map, not audio time 2022-11-29 10:09:39 -07:00
a817142676 NO-OP: extend debug trace output in superclock_at (BBT_Time) 2022-11-29 10:09:39 -07:00
8299778d26 temporal: slightly change internal API for omega (ramp) computation 2022-11-29 10:09:39 -07:00
d9ed0f0d2e temporal: use muldiv_round to avoid overflow in TempoMetric::superclocks_per_grid() 2022-11-29 10:09:39 -07:00
883527ba3e temporal: add Meter::round_to_beat() 2022-11-29 10:09:39 -07:00
d0fb7ae18a avoid duplicate BBT points in grid 2022-11-22 18:09:46 -07:00
fe386e51b1 incomplete comments - just say no 2022-11-21 18:34:13 -07:00
c7cf4d96e0 confusing comments - just say no 2022-11-21 18:33:17 -07:00
a84d3e04c4 tests: add new test to check that tempo map reset changes beat time correctly 2022-11-21 18:18:21 -07:00
f5887b978d tempo map: when resetting, set beat/quarter positions as well as audio positions
introducing a new time signature that uses non-quarter notes as the denominator
will move the beat position a given BBT time (since the middle "B" of BBT
refers to "beats" given by the denominator, not quarters).
2022-11-21 18:18:21 -07:00
Gon Solo
bb27b24596
Fix warning about integer division.
bugprone-integer-division: Result of integer division used in a floating
point context; possible loss of precision.
2022-11-01 15:56:55 +01:00
62540fb5af tempo map: grid generation, fix use of barmod to insert bar points into return 2022-10-31 17:05:55 -06:00
9c2c08973d tempo map: fix incorrect computation of ::bbt_at() (#9049)
This caused problems with TempoMap::get_grid() ("gone backwards").
2022-10-30 19:35:58 -06:00
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
96bab3ce46
NO-OP: doxygenize timepos_t::distance 2022-10-31 00:22:21 +01:00
b195a04281 fix loading 6.x sessions with initial meter not at sample zero 2022-10-27 15:02:12 -06:00
33770d0777 remove stacktrace() from TempoMap::dump() 2022-10-27 11:58:39 -06:00
0ff2c746f7 prevent crash if tempo or meter are dragged back to zero 2022-10-25 12:52:30 -06:00
3efb488629 when moving tempo markers, do nothing unless the marker is moved at least 1 beat
Since tempo markers are always on-beat, this enforces a minumum distance of 1 beat while remaining on-beat.
2022-10-25 11:10:36 -06:00
b5d7754a26
Fix MIDI Clock generator
MIDI clock start at the next beat (round_up_to_beat), so
here we have to round the current tick, rather than fall
back to a tick that is not yet complete, as 14da117bc8 does.

Reproduced with the Session from #9027
Start loop at bar 40 with MClk generator enabled.

```
#3  in __GI___assert_fail (assertion=0x7fedd86c4fd5 "clk_pos >= pos", file=0x7fedd86c38b7 "../libs/temporal/tempo.cc", line=3336, function=0x7fedd86c4f60 "void Temporal::TempoMap::midi_clock_beat_at_or_after(Temporal::samplepos_t, Temporal::samplepos_t&, uint32_t&) const") at assert.c:101
#4  in Temporal::TempoMap::midi_clock_beat_at_or_after(long, long&, unsigned int&) const (this= 0x560187e92c00, pos=20691033, clk_pos=@0x7fedc02178b8: 20691032, clk_beat=@0x7fedc02178c4: 11472) at ../libs/temporal/tempo.cc:3336
#5  in ARDOUR::MidiClockTicker::tick(long, long, unsigned int, long) (this=0x56018eed6db0, start_sample=20691033, end_sample=20692057, n_samples=1024, pre_roll=0) at ../libs/ardour/ticker.cc:170
#6  in ARDOUR::Session::send_mclk_for_cycle(long, long, unsigned int, long) (this=0x56018a216340, start_sample=20691033, end_sample=20692057, n_samples=1024, pre_roll=0) at ../libs/ardour/session.cc:7495
#7  in ARDOUR::AudioEngine::process_callback(unsigned int) (this=0x5601881a4f20, nframes=1024) at ../libs/ardour/audioengine.cc:563
```
2022-10-24 06:18:30 +02:00
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
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
23010a910d
Be liberal about what to accept
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
```
2022-10-16 22:30:35 +02:00
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
a7a8783bb4 increase superclock_ticks_per_second to provide integer handling for NTSC (following Facebook "flicks") 2022-10-13 18:05:49 -06:00
88396347e6 increment/decrement name changes ... out with old in with the new (libs 2022-10-07 17:30:35 -06:00
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
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
617a517a60 temporal: add timecnt_t::increment() and Range::extent() (length+1) 2022-10-07 16:16:14 -06:00
7a0da94ba3 fix RangeTest to account for Range now using exclusive ends, not inclusive 2022-10-05 17:30:45 -06:00
04647d5ae5 More unit-tests updates
* move RangeTest to libtemporal tests
* remove BeatsTest,  already converted from
  Evoral to temporal/BeatTest.cc
2022-10-01 16:57:12 +02:00
2d6e5d4638 Fix building unit-tests on macOS 2022-09-28 23:05:56 +02:00
8b84a0c36f
Add explicit BBT_Offset print function (like timeline.h has) 2022-09-28 18:46:58 +02:00
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
28d11df6f6
operator% is a const operation 2022-09-27 13:04:49 +02:00
36aa661a1d
Add explicit BBT/Beat print functions (like timeline.h has)
This is in preparation for Lua bindings to allow print()ing
the value. We cannot use PBD::to_string() here.
2022-09-27 02:23:11 +02:00
f79f3ee301
Remove unused API 2022-09-27 00:40:35 +02:00
0b0f49412d remove some debug output 2022-09-21 09:13:26 -06:00
025dfa6062 tempo map: fix logic error in ::reset_starting_at() relating to tempo/bbt markers 2022-08-17 16:40:14 -06:00
luz paz
47c525315d Fix various typos
Found via `codespell -q 3 -S *.po,./.git,./share/patchfiles,./libs,./msvc_extra_headers,./share/web_surfaces,*.patch  -L ba,buss,busses,discreet,doubleclick,hsi,ontop,ro,scrollin,seh,siz,sord,sur,te,trough,ue`
2022-08-03 12:10:01 -06:00
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
2de84c97d0
Fix Temporal::Range::squish reduced to samples
Loop Location start="a1665678660" end="b145920"
Loop-end (at 122BPM) is a2109859636
at 48kHz this is sample 1794098.32

Now play the loop and play sample 1794098 = a2109859248
Range::squish start: a1665678660 end: a2109859636 squish: a2109859248

squish() does nothing, since there are still 388 superclock-ticks
until the end of the loop.

However, DiskReader::get_midi_playback convertes the value back
to samples(), this leads to effective_start == loop_end;
resulting in an endless loop.

Thanks to MikeLupe to provide a session to reproduce this issue.
2022-07-15 19:54:21 +02:00
0d70be3a05 miscellaneous fixes for warnings from -Wconversion 2022-07-04 22:01:48 -06:00
1f6abbb756
Comment-out unused timepos_t modulo operator which is not implemented 2022-06-30 01:47:42 +02:00
3bcf75a35a
Remove Range::squish debug information, used fixed modulo operation 2022-06-30 01:07:32 +02:00
2c1f36201c
Fix timecnt_t modulo operation when mixing time-domains 2022-06-30 01:07:32 +02:00
ee350362d3
Debug loop range squishing
When the loop-range is defined in BeatTime, the disk-reader encounters
rounding issues due to time-domain mismatches.

With a simple session fixed BPM at 120,  48kHz.
looping 1 bar exactly 2 sec at the start of the session:
```
 Range::squish start: b0 end: b7680 squish: a113554560
 Range::squish using modulo:       b45 = a661500
 Range::squish using modulo in TD: a5760
 Range::squish using earlier():    a658560
```
The correct answer is a113554560 - 2 * 56448000 [SC/sec] = a658560

Calculating the modulo iteratively is not great, however usually
only one iteration is required.
2022-06-28 03:01:41 +02:00
046cdf1295 fix unused variable warning by removing it. 2022-06-22 13:31:08 -06:00
e2ef135161 remove unused warning 2022-06-21 17:30:59 -06:00
f679da4e1e simplify implementation of Beats::operator%= (Beats) 2022-06-21 14:46:20 -06:00
5d81535588 remember to use muldiv() when doing a*b/c; also no need to call to_ticks(), just use _ticks 2022-06-21 14:46:20 -06:00
1be136adbd allow construction of Beats with a beat count that exceeds INT32_MAX 2022-06-21 14:46:20 -06:00
d6d9792dcb fix construction of Beats from an int64_t that exceeds INT32_MAX 2022-06-21 14:46:20 -06:00
696e05c3e5 convert internal implementation of Temporal::Beats to just use a 64 bit tick value
This expands significantly the maximum number of Beats that can be represented, which is a good
thing in itself. It slightly speeds up some Beats::operator methods, and slightly slows down
::get_beats() and ::get_ticks().

One minor change in an API user was required, and several tweaks to the unit tests due to the
macros being used by cppunit creating possible type confusion.

Units test pass
2022-06-21 12:26:54 -06:00
4dbdaf7fe9 fix possible negative return from TempoPoint::quarters_at_superclock() 2022-06-21 11:39:10 -06:00
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
32096afc90 temporal: remve debug output 2022-06-16 10:36:02 -06:00
2cfc013b0c temporal: fix loading tempo map from XML
We need to clear out all 4 intrusive lists before we start, not just the 3 typed ones
2022-06-16 10:18:37 -06:00
477b136e97 temporal: if requested via -Dtemporalmap, dump tempo map after any update 2022-06-16 10:18:37 -06:00
637971a7df
Fix Beat duration calculation
bbt_duration_at() calls bbtwalk_to_quarters() which already
subtracts the origin's position. Previously `pos` was subtracted twice.
2022-06-04 04:33:48 +02:00
88a035b000 temporal: changes in API to better support BBT markers 2022-06-03 13:19:56 -06:00
531db75a27 temporal: when dragging tempo/meter, move in points list as well
We spliced the point back into the tempo and meter lists correctly, but failed
to do the same thing for the same object's position in the points list.
2022-06-03 10:53:01 -06:00
7dadb1407b temporal: when copying points between TempoMaps do not double-count MusicTimePoints
They were counted as tempos, and meters, and bartimes individually, which
generated new tempo and meter points in the map, which is incorrect.
2022-06-03 10:53:01 -06:00
1b904285be temporal: improve utility of TempoMap::dump() output 2022-06-03 10:53:01 -06:00
2d24bcdf4a temporal: add operator== and operator!= for ratio_t 2022-05-31 12:36:54 -06:00
192b2fd839 temporal: fixes for TempoMap::move_meter() 2022-05-30 21:14:57 -06:00
710cca9ccf change logic for memory management when adding tempo,meter,bartime points
Because a bartime point IS-A tempo point and IS-A meter point, we cannot just delete the tempo
point passed into core_add_tempo() if the new point replaces an existing one. Ditto for meter.

So, leave that logic up to the caller
2022-05-29 15:01:54 -06:00
cca3e6e061 temporal: fix bug introduced in 48f4f9bf9c
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.
2022-05-28 12:59:35 -06:00
03649dc32a temporal: fix bug in TempoMap::get_grid() when next point (eg. BBT) is not on grid 2022-05-27 18:46:06 -06:00
48f4f9bf9c temporal: remove some arithmetic operators and rewrite others to use muldiv() 2022-05-27 12:47:44 -06:00
5175260af4 temporal: remove dangerous muldiv methods and use explicit method name not cast 2022-05-27 12:47:44 -06:00
30c073f669 temporal: fix double negative causing semantic confusing and crashing 2022-05-25 21:53:27 -06:00
60e5b84d78 temporal: alternative solution to overflow in timeline operator*()
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.
2022-05-24 21:46:10 -06:00
540a15efa0 temporal: remove debug output 2022-05-24 18:08:31 -06:00
a7ee848f70 temporal: improve accuracy of a comment/XXX item 2022-05-24 17:21:18 -06:00
Mads Kiilerich
2f5f917df2 libs/temporal: clarify superclocks-per-second usage comment 2022-05-24 17:15:37 -06:00
Mads Kiilerich
aadd24a4e5 libs/temporal/temporal/types.h: fix confusing indentation 2022-05-24 17:15:37 -06:00
25dc926f24 temporal: improve handling of MusicTimePoints and related matters 2022-05-24 17:10:25 -06:00
d48ee3df0e temporal: improve debug output when ::superclock_at() returns < 0 2022-05-24 17:10:25 -06:00
8ee7dc35f4 temporal: improve operator<< for MusicTimePoint 2022-05-24 17:10:25 -06:00
735835dff3 temporal: improve output of TempoMap::dump() 2022-05-24 17:10:25 -06:00
c48430f502 temporal: refactor methods to add tempo/meter points 2022-05-24 17:10:25 -06:00
ef1f814837 temporal: remove commented constructor 2022-05-24 17:10:25 -06:00
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
7f5a576f66 temporal: fix continuing tempo section's tempo after end-stretch 2022-05-24 17:10:25 -06:00
e7e467264f temporal: add TempoMap::set_continuing() and make it and set_ramped return bool 2022-05-24 17:10:25 -06:00
f2a596669e temporal: set speed *and* tempo when setting tempo 2022-05-24 17:10:25 -06:00
20d7313e13 temporal: change "clamped" terminology to "continuing" (since that's what the GUI calls it) 2022-05-23 08:07:08 -06:00
1179b022da temporal: fix error in TempoMap::previous_tempo() 2022-05-21 18:58:41 -06:00
8de52a74bb temporal: better fix for tempo ramp setting during ::reset_starting_at() 2022-05-21 17:28:38 -06:00
5c8b7519c1 remove debug-only direct-to-output debug info that duplicates a DEBUG_TRACE msg 2022-05-21 16:38:36 -06:00
c4844b00e3 temporal: when calling TempoMap::reset_starting_at(), fix ramps
Even if we start at time T, if the tempo point before T is ramped, we need to
adjust it's omega value based on the beat time of the following tempo point. If
we don't do this, then using that tempo to compute ::superclock_at() for
subsequent points will be incorrect.

Note: there may be an ordering issue here with Tempo/Meter points. We might
need to pass over all tempo points first, then process meters etc. Something
like that.
2022-05-21 16:35:00 -06:00
029ef88059 temporal: wrap some calls to TempoMap::dump() in appropriate DEBUG stuff 2022-05-21 16:35:00 -06:00
5476a20fc4 temporal: fix conditional when deciding which log expression to use inside ::superclock_at() 2022-05-20 11:20:39 -06:00
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
7c2cb31b63 temporal: use boost::intrusive ::iterator_to to improve efficiency of ::next/previous_tempo() 2022-05-15 17:49:09 -06:00
be5c64f737 temporal: NOOP - add blank line 2022-05-13 19:05:13 -06:00
1ccda17504 temporal: add a new version of tempo twist based on pre-nutempo code 2022-05-13 19:05:13 -06:00
60159acd33 temporal: slightly change const positioning in definition of ::stretch_tempo() 2022-05-13 19:05:13 -06:00
b0ff612572 temporal: add DEBUG_TRACE message 2022-05-13 19:05:13 -06:00
4defa3ae8f temporal: fix logic bug in TempoMap::reset_starting_at() 2022-05-13 19:05:13 -06:00
c9b7f012e4 temporal: helpful comment for future readers 2022-05-13 19:05:13 -06:00
f0f8f15cce temporal: missing change from 072a7b17a22f 2022-05-13 19:05:13 -06:00
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
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
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
43b3ec005f temporal: use new debug bit for debug output in reset_starting_at() 2022-05-13 19:05:13 -06:00
5d22e522d1 temporal: add new debug bit for debug tracing just TempoMap::reset_starting_at() 2022-05-13 19:05:13 -06:00
45de3694cc temporal: add reimplemented version of 6.x's TempoMap::gui_stretch_tempo() 2022-05-13 19:05:13 -06:00
db9cc04230 temporal: remove debug output from TempoMap::reset_starting_at() 2022-05-13 19:05:13 -06:00
a57f4fbce6 temporal: after changing a tempo point, reset the map starting at that point 2022-05-10 09:46:08 -06:00
46117303da
Fix some potentially uninitialized variables 2022-05-07 04:19:09 +02:00
John Emmas
2554302281 Export a variable which can't be accessed via a 'get()' function
Temporal::most_recent_engine_sample_rate is used in performance-critical code so shouldn't be accessed via a 'get()' function. But (via the TEMPORAL_SAMPLE_RATE #define) it does get accessed outside of libtemporal and therefore needs to get exported.
2022-05-04 16:09:34 +01: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
b5487415ec editing: a partiaally implemented version of TempoTwistDrag, to be completed. 2022-05-02 16:47:23 -06:00
86e7a1b259 temporal: no reason for Point::set() to be virtual 2022-05-02 16:45:33 -06:00
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
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
Mads Kiilerich
06f8936a73 wscript: remove trailing whitespace 2022-04-09 12:16:37 +02:00
7fd8544e31 temporal: fix copy-n-paste error in TempoCommand cosntructor 2022-04-08 11:58:04 -06:00
e466736e2d temporal: remove MementoBinder API for tempo map undo/redo 2022-04-08 11:58:04 -06:00
a806ede94d temporal: add TempoCommand, a Command-derived structure for managing undo/redo w.r.t TempoMap 2022-04-08 11:58:04 -06:00
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
7bf89ce109 Constification: make Stateful::get_state() const, with all other required const-ness added (libs) 2022-04-06 21:56:59 -06:00
1d10408bd1 temporal: add some relatively useless code to one of the timeline test functions 2022-04-05 20:52:10 -06:00
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
dae649d79c temporal: add namespace to macro definition to make it usable everywhere 2022-04-05 20:52:09 -06:00
bf2618e97b temporal: fix crash during reset_starting_at() 2022-03-23 18:03:42 -06:00
857856431e temporal: remove debug output and stacktrace 2022-03-23 17:42:52 -06:00
74a4678c04 temporal: NOOP add explanatory comment 2022-03-23 17:42:52 -06:00
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
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
d29c70a2a2 temporal: add new variant of TempoMap::bbtwalk_to_quarters() 2022-03-19 15:25:14 -06:00
8ebd097df9 move #includes so that they are only used if needed 2022-03-17 17:43:43 -06:00
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
e603b2e12d
Remove debug messages (1/2) 2022-03-16 17:08:14 +01:00
10dc09fcd4 temporal: extend TempoMap thread local ptr API a little
This allows checking to see if the map has changed compared with the thread's
current local pointer.
2022-03-14 14:03:07 -06:00
da95a0a0ee replace sample rate callback used for superclock<=>sample conversion
Now using a globally-scoped static variable which is updated by the
AudioEngine whenever an SR change occurs. Defaults to 48kHz and can
be used even before there is a backend.
2022-03-14 14:03:07 -06:00
2c769e9f23
Fix Beats::rount_to.. Bar rounding 2022-03-04 19:41:25 +01:00
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
92d82866e0 temporal: add some basic BBT time tests
Some of the subtraction tests may need revising because it is not immediately clear that the
current answers are correct.
2022-02-21 11:55:44 -07:00
c5d7883538 temporal: add skeleton for Timeline (timepos_t/timecnt_t) tests 2022-02-12 22:25:17 -07:00
baaf332a94 temporal: add skeleton for TempoMap tests 2022-02-12 22:25:17 -07:00
14ac8fd36b skeleton for temporal/BBT testing (empty for now) 2022-02-12 17:51:30 -07:00
f641a0559f temporal: missing test source 2022-02-12 15:18:19 -07:00
04bd9187e4 temporal: add (back) first set of unit tests
This just uses the old Evoral BeatTest. Some of the tests needed amending
because temporal uses rint() to convert between float and int, not just
a cast.
2022-02-12 15:12:35 -07:00
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
c6a31250ba alter Source::_length from timecnt_t to timepos_t
THe length of a Source(File) is always measured from its start. In this sense,
the length is like a position on the timeline, which is a duration with an
implicit origin, or a Region start, also a duration with an implicit origin (in
that case the start of the Source). There is no good reason for using
a timecnt_t for this value, because the position component of a timecnt_t
(the origin for the duration) is implicit and always zero. So we make
this property into a timepos_t, and include a number of asserts() to check
for common possible coding errors related to the time domain
2022-01-28 15:52:27 -07:00
b7769a8f4b possible fix for a valgrind reported illegal read 2022-01-24 16:42:12 -07:00
Mads Kiilerich
8bb91099c5 wscript: drop configure statements already present in the top level wscript
Avoid repeated pointless configure messages like:
Checking for 'g++' (C++ compiler!)                   : /usr/lib64/ccache/g++
Checking for 'gcc' (C compiler)                      : /usr/lib64/ccache/gcc
2022-01-22 22:19:03 +01:00
dbefba9904 temporal: have tempo map expose it's separate (intrusive) lists of tempo, meter and bbt points 2022-01-18 19:47:20 -07:00
d8c90decf3 triggerbox: use follow length when quantizing re-start of Again-selected trigger
This also changes the virtual method from ::startup() to ::_startup() so that we can
safely have a default argument in ::startup().
2022-01-13 12:09:23 -07:00
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