Mirror of Ardour Source Code
Find a file
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
doc Fix various typos 2022-04-08 19:51:02 +02:00
gtk2_ardour gtk2_ardour/editor_drag.cc: fix confusing newline 2022-05-24 17:15:37 -06:00
headless wscript: consistently have at most one empty separator line 2022-04-09 12:16:40 +02:00
libs evoral: fix ControlList::_x_scale to avoid ratio overflow when adjusting fade length 2022-05-24 17:15:37 -06:00
luasession wscript: drop unnecessary trailing ";" 2022-04-09 12:16:41 +02:00
msvc_extra_headers Fix various typos 2022-04-08 19:51:02 +02:00
MSVCardour3 Add/remove source(s) in our MSVC project (libardour and gtk2_ardour) 2021-07-19 11:27:02 +01:00
MSVCMixbus3 Initial changes needed for building Mixbus (with MSVC) as version 5 2018-09-10 07:14:59 +01:00
MSVCvst_scan Add/remove source(s) in our MSVC project (vst2_scanner) 2021-07-05 10:25:35 +01:00
nutemp Fix various typos 2022-04-08 19:51:02 +02:00
session_utils Revert "Small tool to test event-loop and x-thread signals " 2022-05-02 00:31:33 +02:00
share plugin tags: add tags for some Apple, x42, and Harrison plugins 2022-04-26 12:09:36 -05:00
tools Add readme for udev files 2022-05-17 03:52:36 +02:00
.dir-locals.el
.gitattributes Add a Readme pertaining to GH release tarballs 2017-04-22 16:04:35 +02:00
.gitignore Ignore generaed translation files 2020-10-18 17:45:32 +02:00
ardour.1 Update man-page 2020-07-06 21:36:12 +02:00
COPYING
instant.xml.sae
msvc32-fixup.pl Build 'ardour-vst3-scanner.exe' with MSVC 2020-09-22 12:15:09 +01:00
nutempo-todo todo list text for nutempo-related tasks 2021-08-16 13:41:49 -06:00
PACKAGER_README
README Directly use HTTPS 2021-03-23 23:27:45 +01:00
README-GITHUB.txt Add a Readme pertaining to GH release tarballs 2017-04-22 16:04:35 +02:00
system_config Empty system_config (pre-seed XML nodes, use built-in settings) 2017-03-02 19:37:36 +01:00
testfile.flac
testfile.ogg
TRANSLATORS add text to TRANSLATORS file explaining how contextual translation msgids work and should be translated 2020-05-20 14:40:10 -06:00
waf Update waf binary, using doc/updating_waf.txt 2022-01-09 18:46:24 +01:00
wscript Fix waf dist (create stored version file, set global vars) 2022-05-19 02:45:28 +02:00

Please see the Ardour web site at https://ardour.org/ for all documentation..

For information on building ardour: 
      
     https://ardour.org/development.html