* introduced dependency: libsmf-1.2
[ardour.git] / libs / evoral / src / ControlList.cpp
index 98083f58da044dfab629d262bde9d12b760e6363..db6d6a956275b9492eab55555189f0cdeb9ab3f4 100644 (file)
@@ -758,31 +758,23 @@ ControlList::unlocked_eval (double x) const
        double fraction;
 
        const_iterator length_check_iter = _events.begin();
-       for (npoints = 0; npoints < 4; ++npoints, ++length_check_iter)
-               if (length_check_iter == _events.end())
+       for (npoints = 0; npoints < 4; ++npoints, ++length_check_iter) {
+               if (length_check_iter == _events.end()) {
                        break;
+               }
+       }
 
        switch (npoints) {
        case 0:
                return _default_value;
 
        case 1:
-               if (x >= _events.front()->when) {
-                       return _events.front()->value;
-               } else {
-                       // hansfbaier: v--------- Why commented ??? 
-                       // return _default_value;
-                       return _events.front()->value;
-               } 
+               return _events.front()->value;
                
        case 2:
                if (x >= _events.back()->when) {
                        return _events.back()->value;
-               } else if (x == _events.front()->when) {
-                       return _events.front()->value;
-               } else if (x < _events.front()->when) {
-                       // hansfbaier: v--------- Why commented ??? 
-                       // return _default_value;
+               } else if (x <= _events.front()->when) {
                        return _events.front()->value;
                }
 
@@ -795,30 +787,22 @@ ControlList::unlocked_eval (double x) const
                        return lval;
                }
 
-               /* linear interpolation betweeen the two points
-               */
-
+               /* linear interpolation betweeen the two points */
                fraction = (double) (x - lpos) / (double) (upos - lpos);
                return lval + (fraction * (uval - lval));
 
        default:
-
                if (x >= _events.back()->when) {
                        return _events.back()->value;
-               } else if (x == _events.front()->when) {
-                       return _events.front()->value;
-               } else if (x < _events.front()->when) {
-                       // hansfbaier: v--------- Why commented ??? 
-                       // return _default_value;
+               } else if (x <= _events.front()->when) {
                        return _events.front()->value;
                }
 
                return multipoint_eval (x);
-               break;
        }
 
        /*NOTREACHED*/ /* stupid gcc */
-       return 0.0;
+       return _default_value;
 }
 
 double
@@ -1001,8 +985,6 @@ ControlList::rt_safe_earliest_event_discrete_unlocked (double start, double end,
 
 /** Get the earliest time the line crosses an integer (Linear interpolation).
  *
- * In other words: send out multiple events to interpolate the line
- * defined by its control points
  * If an event is found, \a x and \a y are set to its coordinates.
  *
  * \param inclusive Include events with timestamp exactly equal to \a start
@@ -1303,8 +1285,10 @@ ControlList::paste (ControlList& alist, double pos, float times)
 
 /** Move automation around according to a list of region movements */
 void
-ControlList::move_ranges (RangeMoveList const & movements)
+ControlList::move_ranges (const list< RangeMove<double> >& movements)
 {
+       typedef list< RangeMove<double> > RangeMoveList;
+
        {
                Glib::Mutex::Lock lm (_lock);
 
@@ -1322,8 +1306,8 @@ ControlList::move_ranges (RangeMoveList const & movements)
                /* copy the events into the new list */
                for (RangeMoveList::const_iterator i = movements.begin (); i != movements.end (); ++i) {
                        iterator j = old_events.begin ();
-                       EventTime const limit = i->from + i->length;
-                       EventTime const dx = i->to - i->from;
+                       const double limit = i->from + i->length;
+                       const double dx    = i->to - i->from;
                        while (j != old_events.end () && (*j)->when <= limit) {
                                if ((*j)->when >= i->from) {
                                        ControlEvent* ev = new ControlEvent (**j);