make automation thinning factor controllable at run time
authorPaul Davis <paul@linuxaudiosystems.com>
Thu, 5 Apr 2012 11:16:04 +0000 (11:16 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Thu, 5 Apr 2012 11:16:04 +0000 (11:16 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11795 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/evoral/evoral/ControlList.hpp
libs/evoral/src/ControlList.cpp

index 368717bb1f642fd5adf527bbb93d61637eec5bb6..01e0f8c1fb57a1b514566a2df289ccd6d3f3d97a 100644 (file)
@@ -246,6 +246,9 @@ public:
        /** Emitted when our interpolation style changes */
        PBD::Signal1<void, InterpolationStyle> InterpolationChanged;
 
+        static void set_thinning_factor (double d);
+        static double thinning_factor() { return _thinning_factor; }
+
 protected:
 
        /** Called by unlocked_eval() to handle cases of 3 or more control points. */
@@ -288,6 +291,7 @@ protected:
        };
 
        std::list<NascentInfo*> nascent;
+        static double _thinning_factor;
 };
 
 } // namespace Evoral
index 59792f732f8e51d820121de1dd2e808f769288eb..7bdb500d3165e83424219dd531cbbdd53038f6ce 100644 (file)
@@ -33,6 +33,21 @@ inline bool event_time_less_than (ControlEvent* a, ControlEvent* b)
        return a->when < b->when;
 }
 
+/* this has no units but corresponds to the area of a rectangle
+   computed between three points in the list. If the area is
+   large, it indicates significant non-linearity between the
+   points. 
+
+   during automation recording we thin the recorded points
+   using this value. if a point is sufficiently co-linear 
+   with its neighbours (as defined by the area of the rectangle
+   formed by three of them), we will not include it in the
+   ControlList. a smaller value will exclude less points,
+   a larger value will exclude more points, so it effectively
+   measures the amount of thinning to be done.
+*/
+
+double ControlList::_thinning_factor = 20.0; 
 
 ControlList::ControlList (const Parameter& id)
        : _parameter(id)
@@ -420,17 +435,11 @@ ControlList::thin ()
 
                if (counter > 2) {
                        
-                       double area = fabs (0.5 * 
-                                           (prevprev->when * (prev->value - cur->value)) + 
+                       double area = fabs ((prevprev->when * (prev->value - cur->value)) + 
                                            (prev->when * (cur->value - prevprev->value)) + 
                                            (cur->when * (prevprev->value - prev->value)));
                        
-                       /* the number 10.0 is an arbitrary value that needs to
-                        * be controlled by some user-controllable
-                        * configuration utility.
-                        */
-
-                       if (area < 10.0) {
+                       if (area < _thinning_factor) {
                                iterator tmp = pprev;
 
                                /* pprev will change to current
@@ -1540,5 +1549,11 @@ ControlList::set_interpolation (InterpolationStyle s)
        InterpolationChanged (s); /* EMIT SIGNAL */
 }
 
+void
+ControlList::set_thinning_factor (double v)
+{
+       _thinning_factor = v;
+}
+
 } // namespace Evoral