Implement additional ControlList interpolation methods.
[ardour.git] / libs / evoral / evoral / ControlList.hpp
index 7d6b294a984a69f2ebb40f6fa7805c8d12c5aa88..c4051193b8b6edb68ffbd340d7c9fb95ae8e84c1 100644 (file)
@@ -90,11 +90,11 @@ public:
 
        virtual boost::shared_ptr<ControlList> create(const Parameter& id, const ParameterDescriptor& desc);
 
-        void dump (std::ostream&);
+       void dump (std::ostream&);
 
        ControlList& operator= (const ControlList&);
        bool operator== (const ControlList&);
-        void copy_events (const ControlList&);
+       void copy_events (const ControlList&);
 
        virtual void freeze();
        virtual void thaw ();
@@ -107,22 +107,21 @@ public:
        void                       set_descriptor(const ParameterDescriptor& d) { _desc = d; }
 
        EventList::size_type size() const { return _events.size(); }
-        double length() const {
+       double length() const {
                Glib::Threads::RWLock::ReaderLock lm (_lock);
                return _events.empty() ? 0.0 : _events.back()->when;
        }
        bool empty() const { return _events.empty(); }
 
-       void reset_default (double val) {
-               _default_value = val;
-       }
-
        void clear ();
        void x_scale (double factor);
        bool extend_to (double);
        void slide (iterator before, double distance);
        void shift (double before, double distance);
 
+       void y_transform (boost::function<double(double)> callback);
+       void list_merge (ControlList const& other, boost::function<double(double, double)> callback);
+
        /** add automation events
         * @param when absolute time in samples
         * @param value parameter value
@@ -172,15 +171,7 @@ public:
         */
        void clear (double start, double end);
 
-       bool paste (const ControlList&, double position, float times);
-
-       void set_yrange (double min, double max) {
-               _min_yval = min;
-               _max_yval = max;
-       }
-
-       double get_max_y() const { return _max_yval; }
-       double get_min_y() const { return _min_yval; }
+       bool paste (const ControlList&, double position);
 
        /** truncate the event list after the given time
         * @param last_coordinate last event to include
@@ -215,7 +206,7 @@ public:
         * @param where absolute time in samples
         * @returns parameter value
         */
-       double eval (double where) {
+       double eval (double where) const {
                Glib::Threads::RWLock::ReaderLock lm (_lock);
                return unlocked_eval (where);
        }
@@ -225,7 +216,7 @@ public:
         * @param ok boolean reference if returned value is valid
         * @returns parameter value
         */
-       double rt_safe_eval (double where, bool& ok) {
+       double rt_safe_eval (double where, bool& ok) const {
 
                Glib::Threads::RWLock::ReaderLock lm (_lock, Glib::Threads::TRY_LOCK);
 
@@ -255,7 +246,6 @@ public:
        };
 
        const EventList& events() const { return _events; }
-       double default_value() const { return _default_value; }
 
        // FIXME: const violations for Curve
        Glib::Threads::RWLock& lock()       const { return _lock; }
@@ -285,7 +275,9 @@ public:
        enum InterpolationStyle {
                Discrete,
                Linear,
-               Curved
+               Curved, // spline, used for x-fades
+               Logarithmic,
+               Exponential // fader, gain
        };
 
        /** query interpolation style of the automation data
@@ -293,10 +285,18 @@ public:
         */
        InterpolationStyle interpolation() const { return _interpolation; }
 
-       /** set the interpolation style of the automation data
+       /** query default interpolation for parameter-descriptor */
+       virtual InterpolationStyle default_interpolation() const;
+
+       /** set the interpolation style of the automation data.
+        *
+        * This will fail when asking for Logarithmic scale and min,max crosses 0
+        * or Exponential scale with min != 0.
+        *
         * @param is interpolation style
+        * @returns true if style change was successful
         */
-       void set_interpolation (InterpolationStyle is);
+       bool set_interpolation (InterpolationStyle is);
 
        virtual bool touching() const { return false; }
        virtual bool writing() const { return false; }
@@ -314,7 +314,7 @@ public:
 
        bool operator!= (ControlList const &) const;
 
-        void invalidate_insert_iterator ();
+       void invalidate_insert_iterator ();
 
 protected:
 
@@ -345,21 +345,19 @@ protected:
        EventList             _events;
        int8_t                _frozen;
        bool                  _changed_when_thawed;
-       double                _min_yval;
-       double                _max_yval;
-       double                _default_value;
        bool                  _sort_pending;
 
        Curve* _curve;
 
-  private:
-    iterator   most_recent_insert_iterator;
-    double     insert_position;
-    bool       new_write_pass;
-    bool       did_write_during_pass;
-    bool       _in_write_pass;
-    void unlocked_invalidate_insert_iterator ();
-    void add_guard_point (double when);
+private:
+       iterator   most_recent_insert_iterator;
+       double     insert_position;
+       bool       new_write_pass;
+       bool       did_write_during_pass;
+       bool       _in_write_pass;
+
+       void unlocked_invalidate_insert_iterator ();
+       void add_guard_point (double when);
 };
 
 } // namespace Evoral