Commit Graph

620 Commits

Author SHA1 Message Date
Paul Davis 16c9d91641 temporal: remove impossible get_tempo_and_meter (..., bbt, ...) method 2023-06-30 12:10:50 -06:00
Paul Davis a591fb64a3 temporal: rework ::get_grid() to avoid get_tempo_and_meter (..., bbt, ...) 2023-06-30 12:10:50 -06:00
Paul Davis 3513debba8 temporal: NO-OP (tiny variable rename) 2023-06-30 12:10:50 -06:00
Paul Davis bb97ade440 temporal: special case editing of the initial tempo (#9339) 2023-06-12 16:46:13 -06:00
Paul Davis 50232a23a7 temporal: hide superclock_t variant of TempoMap::metric_at()
This fixes several callsites that were passing samplepos_t to get a TempoMetric,
some of them somewhat significant (e.g. VST plugins that want tempo information).

Bad API design on my part, apologies.

This commit combines libs/ and gtk2_ardour because the new private status
of the ::metric_at() call would be a blocking point for git bisect
2023-06-12 12:36:16 -06:00
Paul Davis 733d59c65b temporal: unit testing more like unit testing
But still not really.
2023-06-08 14:01:17 -06:00
Paul Davis 01b8187cd3 temporal: add rudimentary paste test 2023-06-08 14:01:17 -06:00
Paul Davis 1cf4f9293c temporal: paste needs to add to _points 2023-06-08 14:01:17 -06:00
Paul Davis 24f6c51de6 temporal: more nuances for ::cut_copy() 2023-06-08 14:01:17 -06:00
Paul Davis a09a37049b temporal: get guard point values before altering the tempo map 2023-06-08 14:01:17 -06:00
Paul Davis 6039cea3dc temporal: improve cut buffer slightly by using different meters 2023-06-08 14:01:17 -06:00
Paul Davis d761ccb59b temporal: the second variant of shift() (untested) 2023-06-07 11:25:44 -06:00
Paul Davis e6b6340f3e temporal: more nuances for shift() 2023-06-07 11:25:44 -06:00
Paul Davis ad45778edc temporal: shift() with BBT must allow negative motion 2023-06-07 11:25:44 -06:00
Paul Davis a456a10cdf temporal: first guess at a TempoMap::shift() implementation 2023-06-07 11:25:44 -06:00
Paul Davis 9d3ae4fc8d temporal: fix position of end guard points during map paste 2023-06-06 09:52:29 -06:00
Paul Davis 9e4b1d59a7 temporal: do something when pasting the cut buffer guard points
Don't think this is quite right yet - we get guard points even when
they are not really necessary
2023-06-06 09:04:34 -06:00
Paul Davis f5f87f86d4 temporal: adjust cut buffer API to better deal with start/end "guard points" 2023-06-05 17:27:12 -06:00
Paul Davis 7789df5b1c temporal: get cut/copy/paste test code slightly more useful 2023-06-05 16:35:17 -06:00
Robin Gareus 11157d9bd9
Fix some Wunused-variable 2023-05-22 21:26:26 +02: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
Ben Loftis 54969d8aab fix thinko resulting in duplicate bar-names after a tempo-mapping op 2023-05-14 09:05:08 -05:00
Paul Davis b9e5621e03 during map reset, force meter to bars, and tempo to beats 2023-05-05 20:53:23 -06:00
Paul Davis 32a3591018 remove #warning 2023-05-05 18:57:16 -06:00
Paul Davis 9e8eed8a03 temporal: various tweaks to get TempoMap::get_grid() to be more correct/robust 2023-05-05 18:56:01 -06: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 7f977bf3e4 add skeleton unit test for tempo map cut buffer 2023-05-04 18:48:50 -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 907d3f82a7 temporal: fix grid generation in the presence of MusicTimePoints 2023-04-27 19:54:44 -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 f29557348e remove debug output 2023-04-13 17:47:32 -06:00
Paul Davis b362d2b6ba temporal: don't abort() for illegal omega value, just leave it as it was 2023-04-13 10:57:12 -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 151fceea54
Add missing include
This fixes "error: ‘isfinite’ was not declared in this scope"
2023-03-30 01:10:23 +02: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 393929a55b tempo twisting: various fixes and improvements to core logic 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 b36a0493df tempomap: use muldiv_round() not int_div_round to avoid errors 2023-03-24 14:19:16 -06:00
Paul Davis 45490bf43f more functional tempo mapping 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 27205c7639 midi clock: provide option to quantize incoming BPM values 2023-02-23 12:15:26 -07:00
Robin Gareus c1c913be9d
Fix MClk generator position 2023-02-19 18:08:58 +01:00
Paul Davis 5b6bc3f358 Revert "tempo map: use lookup tables to speed up time conversions"
This reverts commit 644ebe37a8.

Adding entries to the lookup table is (a) not thread safe (b) not appropriate
from RT context.
2023-02-16 18:25:23 -07:00
Paul Davis 31a3c3c6f3 temporal: fix bad escape sequence in test source code 2023-02-15 18:36:23 -07:00
Paul Davis a59059c15e temporal: map used for ::reftime() must be the one pointed at by TempoMetric 2023-02-15 18:36:23 -07:00
Paul Davis ee64390c48 fix libtemporal tests after API changes to the library 2023-02-15 17:51:28 -07:00
Paul Davis 644ebe37a8 tempo map: use lookup tables to speed up time conversions 2023-02-15 16:02:56 -07: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
Paul Davis 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
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
Robin Gareus 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
Robin Gareus 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
Ben Loftis ac30964d67 remove debug output 2022-12-26 14:03:32 -06:00
Paul Davis b2a6fb70b4 remove debug output 2022-12-20 22:01:41 -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 0ee0226776 temporal: no stretching a tempo that is the last one or precedes a BBT marker 2022-12-20 21:33:13 -07:00
Paul Davis d3dd865093 temporal: NOOP - add helpful comment 2022-12-20 21:31:31 -07:00
Paul Davis ae36f8e445 temporal: provide TempoMap::replace_tempo() 2022-12-20 21:31:02 -07:00
Paul Davis 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
Paul Davis 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
Paul Davis db3e87a7e4 do nothing gracefully if asked to remove only tempo 2022-12-10 14:14:12 -07:00
Paul Davis 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
Paul Davis c505024a4b temporal: when resetting the map, position BBT markers in beat time (and stop reset there) 2022-12-05 10:01:49 -07:00
Paul Davis 12b672492e tempomap: fix and improve efficiency and readability in ::get_grid() 2022-12-05 10:01:49 -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 a124062fa2 temporal: move_tempo() must use beats (timesig dependent) not quarters 2022-11-29 10:09:39 -07:00
Paul Davis 1f4717d93b temporal: reset map requires a BBT-sorted map, not audio time 2022-11-29 10:09:39 -07:00
Paul Davis a817142676 NO-OP: extend debug trace output in superclock_at (BBT_Time) 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
Paul Davis d0fb7ae18a avoid duplicate BBT points in grid 2022-11-22 18:09:46 -07:00
Paul Davis fe386e51b1 incomplete comments - just say no 2022-11-21 18:34:13 -07:00
Paul Davis c7cf4d96e0 confusing comments - just say no 2022-11-21 18:33:17 -07:00
Paul Davis a84d3e04c4 tests: add new test to check that tempo map reset changes beat time correctly 2022-11-21 18:18:21 -07:00
Paul Davis 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
Paul Davis 62540fb5af tempo map: grid generation, fix use of barmod to insert bar points into return 2022-10-31 17:05:55 -06:00
Paul Davis 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
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
Paul Davis b195a04281 fix loading 6.x sessions with initial meter not at sample zero 2022-10-27 15:02:12 -06:00
Paul Davis 33770d0777 remove stacktrace() from TempoMap::dump() 2022-10-27 11:58:39 -06:00
Paul Davis 0ff2c746f7 prevent crash if tempo or meter are dragged back to zero 2022-10-25 12:52:30 -06:00
Paul Davis 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
Robin Gareus 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
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 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
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
Paul Davis 7a0da94ba3 fix RangeTest to account for Range now using exclusive ends, not inclusive 2022-10-05 17:30:45 -06:00
Robin Gareus 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
Robin Gareus 2d6e5d4638 Fix building unit-tests on macOS 2022-09-28 23:05:56 +02: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
Robin Gareus 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
Robin Gareus f79f3ee301
Remove unused API 2022-09-27 00:40:35 +02:00
Paul Davis 0b0f49412d remove some debug output 2022-09-21 09:13:26 -06:00
Paul Davis 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
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
Robin Gareus 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
Paul Davis 0d70be3a05 miscellaneous fixes for warnings from -Wconversion 2022-07-04 22:01:48 -06:00
Robin Gareus 1f6abbb756
Comment-out unused timepos_t modulo operator which is not implemented 2022-06-30 01:47:42 +02:00
Robin Gareus 3bcf75a35a
Remove Range::squish debug information, used fixed modulo operation 2022-06-30 01:07:32 +02:00
Robin Gareus 2c1f36201c
Fix timecnt_t modulo operation when mixing time-domains 2022-06-30 01:07:32 +02:00
Robin Gareus 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
Paul Davis 046cdf1295 fix unused variable warning by removing it. 2022-06-22 13:31:08 -06:00
Paul Davis e2ef135161 remove unused warning 2022-06-21 17:30:59 -06:00
Paul Davis f679da4e1e simplify implementation of Beats::operator%= (Beats) 2022-06-21 14:46:20 -06:00
Paul Davis 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
Paul Davis 1be136adbd allow construction of Beats with a beat count that exceeds INT32_MAX 2022-06-21 14:46:20 -06:00
Paul Davis d6d9792dcb fix construction of Beats from an int64_t that exceeds INT32_MAX 2022-06-21 14:46:20 -06:00
Paul Davis 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
Paul Davis 4dbdaf7fe9 fix possible negative return from TempoPoint::quarters_at_superclock() 2022-06-21 11:39:10 -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 32096afc90 temporal: remve debug output 2022-06-16 10:36:02 -06:00
Paul Davis 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
Paul Davis 477b136e97 temporal: if requested via -Dtemporalmap, dump tempo map after any update 2022-06-16 10:18:37 -06:00
Robin Gareus 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
Paul Davis 88a035b000 temporal: changes in API to better support BBT markers 2022-06-03 13:19:56 -06:00
Paul Davis 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
Paul Davis 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