Commit graph

54 commits

Author SHA1 Message Date
Paul Davis
b5f1c5b0dd Fix potential infinite loop when iterating over ControlLists
If you have the "wrong" kind of MIDI CC, the interpolation for the list is set
to Linear, which causes interpolation to return audio time stamps instead of
beat time.  Because of the asymmetrical transforms, this causes iterators over
the Sequence to go haywire and create an infinite loop.

This fix changes ControlList behavior to always return times in the time domain
of the list.
2025-08-07 12:49:18 -06:00
Paul Davis
4ee709af7b libardour APIs for Sequence::shift (timepos_t const &)
A way to move all MIDI data in a Sequence later in time.

This is likely not finished, and may need a new signal for
notifications
2025-04-05 17:25:03 -06:00
Robin Gareus
74c4ca3e52
Reduce reliance on boost - the hard part
the rest from `tools/convert_boost.sh`.

* replace boost::function, boost::bind with std::function and std::bind.

This required some manual fixes, notably std::placeholders,
some static_casts<>, and boost::function::clear -> = {}.
2024-10-19 03:47:21 +02:00
Robin Gareus
5a647cd84a Fix guard point logic for editor_add_ordered API.
Previously the code was too simple and potentially added points out of
order, leading to automation jumping back in time.
2024-07-12 00:45:37 +02:00
Paul Davis
06e9bf6ca4 domain swaps for MIDI CC and other controls 2023-08-16 09:06:10 -06:00
Paul Davis
f92dcfa068 domain bouncing for Automatable/ControlLists 2023-08-15 08:34:42 -06:00
Paul Davis
3b565693c8 objects don't have a time domain, they have a time domain provider (libs) 2023-08-02 15:22:52 -06:00
Paul Davis
459659d229 ControlList: do not handle mis-ordered OrderedPoints 2023-07-10 14:23:17 -06:00
Paul Davis
9c590c1ed1 syntactic tweak 2023-07-10 14:17:10 -06:00
Paul Davis
64dc7557cf automation drawing: some code cleanup and thinko fixes for ::editor_add_ordered() 2023-07-10 14:05:27 -06:00
Paul Davis
45b02538e6 Evoral: extend ControlList API with ::editor_ordered_points()
Much more efficient than adding points 1 by 1
2023-07-10 11:20:47 -06:00
Robin Gareus
4ba1ccc09b
NO-OP: use Tab to indent 2023-04-01 17:21:32 +02:00
Robin Gareus
a6401763a3
Fix interpolation when iterating over sequence (#9288)
When a control-point is exactly at tick (N * 8), iterating
over the List (Sequence<Time>::const_iterator::operator++)
skipped the point.

Sequence::time_between_interpolated_controller_outputs == 8.
2023-04-01 17:21:04 +02: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
4796a3643d use C++11 auto iterator 2023-02-06 21:04:17 -07:00
Robin Gareus
c24c210cce Use Controllist's time-domain for guard-point delta
This fixes copy/paste of pan automation (amongst other things).
2023-01-23 04:02:08 +01:00
Robin Gareus
ae321721cf
Also thin automation after touch/latch
AutomationList::start_touch must not start a write-pass.
That function is also called when the transport is no rolling.
A write-pass is started via AutomationWatch::add_automation_watch.
2022-12-18 01:45:04 +01:00
Robin Gareus
a5f36bbbbf
Fix thinning (normalize parameter value)
This fixes thinning of MIDI data (range 0..127) and
other parameters with range other than 0..1.
2022-12-18 00:55:12 +01:00
Robin Gareus
30efb2f178
NO-OP: clang-format 2022-12-03 14:46:45 +01:00
Robin Gareus
2338e25d31
Fix automation thinning
For consistency, samples need to be used a unit.
Currently the calculated area is orders of magnitude larger
than the default thinning_factor (20).
2022-12-03 14:46:45 +01: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
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
be9fdd9873 libs: use {de,in}crement_by_domain() instead of {de,in} (libs) 2022-10-07 16:24:46 -06:00
Paul Davis
ffc9239de5 ControlList: replace code use to interpolate MIDI CC curves
Original code is of questionable historical provenance, and
was needlessly (it seems) complexity. New code is relatively
simple arithmetic linear interpolation.
2022-08-17 20:55:17 -06:00
Paul Davis
b03e9b4c10 NOOP: add helpful explanatory comment 2022-08-12 09:21:23 -06:00
Paul Davis
610b5dddbf ControlList: GUARD_POINT_DELTA needs to take time domain into account 2022-08-11 15:26:42 -06:00
Paul Davis
c8feef51ab convert use of operator* for tim::line types with ::scale(ratio_t) 2022-05-27 12:47:44 -06:00
Paul Davis
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
Mads Kiilerich
c1c95f538f evoral: fix ControlList::_x_scale to avoid ratio overflow when adjusting fade length
Region fades would sometimes get in a mode with weird behaviour. They
would be drawn in 2d with crossing lines, mainly moving back and forth
horizontally - not as a function of time. It would sound as it looked.
The fade would sometimes jump around when resizing. It could be worked
around by resetting the fade shape. It turned out the problem could be
reproduced by making minute long fades.

This change fixes or works around the problem.

Back story:

timepos_t (in temporal/timeline.h) uses 62 bit for integer value and the
max value is thus 4611686018427387904 ~ 5e18. timepos_t counts
superclocks, where superclock_ticks_per_second is 56448000 ~ 6e7. It can
thus store up to 8e10 seconds - thousands of years.

ratio_t (in temporal/types.h) can represent fractions as 64 bit (signed)
numerator and denominator. timepos_t avoids floating point operations,
but has operator* with ratio_t. To avoid crazy loss of precision it will
multiply the superclock count with the numerator before dividing with
the denominator.

Audio region fade in and out uses a number of increasing timepos_t
values (in a ControlList) up to the length of fade. When dragging to
resize, these values are (in_x_scale) multiplied with the ratio_t of the
new and old fade length. The problem is that the 62 bits will overflow
if using fades more than sqrt(5e18) ~ 2e9 superclock ticks ~ 38 seconds.
It will overflow into the "beat" flag and (at 58 seconds) into the sign
bit. The timepos_t values in the fade will thus jump and can be negative
or change to count beats.

To work around that problem, this changeset just use floating point
values for scaling the timepos_t values. All scaled values are stored as
integer anyway, so it should not make any actual difference for this use
case. There might however be other uses of ControlList where it matters.

As an implementation detail of this "workaround" of using double, it
could perhaps also be nice to implement timepos_t operator* (or
operator*=) for double. But I'm not sure we want floating point support
in timepos_t.

An alternative (and better) solution would be to convince the fraction
multiplication to use 128 bits. It is essential to avoid overflow -
mainly in static analysis, alternatively as runtime checks or asserts.
2022-05-24 17:15:37 -06:00
Ben Loftis
cd332a2af0 when pasting a Range of automation, first add guard points,
so the automation data before and after this range is retained
2022-05-16 07:16:25 -05:00
Ben Loftis
3a174ff914 add support for 'positive' guard points in ControlList 2022-05-16 07:16:25 -05:00
Ben Loftis
c98561e95c when cutting or clearing an automation range, always add boundary points
* these guard points are necessary to retain the automation that existed
 before and after the selected range is removed
2022-05-16 07:16:24 -05:00
Paul Davis
2b8b9a3a2f const for const-sake 2022-05-01 18:01:35 -06:00
Paul Davis
d218dcb21b evoral: when adding points to a ControlList, coerce the time domain of the new point to the list time domain
This may not be the ideal solution, but for now it appears to be the best approach to preventing
points with different time domains with the same list
2022-05-01 17:50:51 -06:00
Paul Davis
8657eba4c5 evoral: NOOP reorder and edit comments 2022-04-05 20:52:09 -06:00
Paul Davis
8c3fad0133 evoral: fix implementation of rt_safe_earliest_event_linear_unlocked
Code within the method was using @param start_time rather than start, which is a modified
value required to generate the correct results.

This comment also contains some logical reordering, optimization and commenting
on this rather complex method.
2022-04-05 20:52:09 -06:00
Paul Davis
256e6f97a2 evoral: change how we specify a zero min_x_delta to rt_safe_earliest_event_linear_unlocked
See comment in the code for more details.
2022-04-05 20:52:09 -06:00
Robin Gareus
176c41a485
Fix region-gain when region-start is trimmed
Region-gain (unlike other automation) is specific to the
region and independent of the source. Region::start() offset
does not apply. When region-start is trimmed the region's
envelope is modified (not just offset). The event-list is truncated.

Any audio-region envelope does (and must) have a point exactly
at the start and end of the region.

truncate_start() can thus calculate the earliest position of
valid events with the new length relative to the last event.

The mathematical operator for that is subtraction, not distance.
2022-03-17 23:46:55 +01:00
Robin Gareus
60be0c27a1
Use updated temporal API 1/2 2021-12-11 14:42:36 +01:00
Paul Davis
940f3022c1 prevent addition of events to a ControlList whose time-domain does not match the ControlList's own time-domain 2021-08-30 15:15:14 -06:00
Paul Davis
6d154c14b4 libevoral: add a new method to set the time domain that can be used from ::set_state(), when the event list is not (yet) empty 2021-08-13 12:51:34 -06:00
Paul Davis
1a5e2aacff remove another NUTEMPO warning 2021-08-13 12:51:32 -06:00
Paul Davis
779a04b0ce Evoral: alter ControlList::paste() to internally change time domain of pasted events 2021-08-13 12:51:31 -06:00
Paul Davis
bed76798f3 manual fixups after rebase against master (general libs edition) 2021-08-13 12:51:31 -06:00
Paul Davis
18fea5c7a9 changes required by fixing ambiguities in timepos_t/timecnt_t API (evoral edition) 2021-08-13 12:51:31 -06:00
Paul Davis
def35cf043 mark BBT_Offset (double) constructor explicit to avoid implicit conversion in timeline expressions.
Also clean up the mess this had caused.
2021-08-13 12:51:30 -06:00
Paul Davis
ebd8704f9d libevoral: tweaks related to timeline types based on libardour conversion 2021-08-13 12:51:29 -06:00
Paul Davis
6b09642406 changes to compile against libtemporal and use of timepos_t/timecnt_t 2021-08-13 12:51:28 -06:00
Robin Gareus
b9cfb31205
Fix control-list editing (#8384)
This fixes segfaults as well as corrupt listes when copy/pasting
due to invalid iterators.

::mark_dirty() must be called with WriterLock, and
::rt_safe_earliest_event_linear_unlocked() must not be called
while _events is being modified. The Sequence iterator
(only user of that function) does not ensure this. Only the
sequence read-lock is taken.
2020-08-31 07:39:45 +02:00
Robin Gareus
65ecc1b40e
Do not interpolate away explicit MIDI automation points #8362 2020-08-15 01:57:01 +02:00