From cb85a0a521837361ff47d5a213f7220926345593 Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Mon, 16 May 2022 07:09:58 -0500 Subject: [PATCH] fix for automation control point drags: prevent overlapping points in time. * control points that were already closer than one_tick_in_pixels were able to move beyond adjacent points, resulting in out-of-order lines * prior code was using 'one tick' as the smallest spacing between two CPs, but that is larger than the default 'guard point' spacing. this resulted in odd behavior because of the dxt calculation when you moved a point that was created as a 'guard point' For now, use the same 64 samples we use for 'guard points'. And change the 'dxt' calculation logic to more aggressively limit the points from overlapping. TODO: we might decide that 'one tick' should be the minimum automation period throughout ardour. In that case we should change guard-points. --- gtk2_ardour/automation_line.cc | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/gtk2_ardour/automation_line.cc b/gtk2_ardour/automation_line.cc index 8d0326ffe1..4730d7b8b0 100644 --- a/gtk2_ardour/automation_line.cc +++ b/gtk2_ardour/automation_line.cc @@ -503,13 +503,7 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) if (front()->view_index() > 0) { before_x = line.nth (front()->view_index() - 1)->get_x(); - - const samplepos_t pos = e.pixel_to_sample(before_x); - const TempoMetric& metric = map->metric_at (pos); - const samplecnt_t len = ceil (metric.samples_per_bar (pos) / (Temporal::ticks_per_beat * metric.meter().divisions_per_bar())); - const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len); - - before_x += one_tick_in_pixels; + before_x += e.sample_to_pixel_unrounded (64); } /* if our last point has a point after it in the line, @@ -518,13 +512,7 @@ AutomationLine::ContiguousControlPoints::compute_x_bounds (PublicEditor& e) if (back()->view_index() < (line.npoints() - 1)) { after_x = line.nth (back()->view_index() + 1)->get_x(); - - const samplepos_t pos = e.pixel_to_sample(after_x); - const TempoMetric& metric = map->metric_at (pos); - const samplecnt_t len = ceil (metric.samples_per_bar (pos) / (Temporal::ticks_per_beat * metric.meter().divisions_per_bar())); - const double one_tick_in_pixels = e.sample_to_pixel_unrounded (len); - - after_x -= one_tick_in_pixels; + after_x -= e.sample_to_pixel_unrounded (64); } } } @@ -650,10 +638,7 @@ AutomationLine::drag_motion (double const x, float fraction, bool ignore_x, bool if (dx < 0 || ((dx > 0) && !with_push)) { for (vector::iterator ccp = contiguous_points.begin(); ccp != contiguous_points.end(); ++ccp) { - double dxt = (*ccp)->clamp_dx (dx); - if (fabs (dxt) < fabs (dx)) { - dx = dxt; - } + dx = (*ccp)->clamp_dx (dx); } }