add channel+pitch indexing for notes in a Sequence
[ardour.git] / libs / evoral / evoral / ControlList.hpp
index 48050f9e93704ce94758d6a588ec59cfcc17471c..d68b6a3e5f9fe0e273d2cdc3b891266636400a9e 100644 (file)
@@ -1,16 +1,16 @@
 /* This file is part of Evoral.
  * Copyright (C) 2008 Dave Robillard <http://drobilla.net>
  * Copyright (C) 2000-2008 Paul Davis
- * 
+ *
  * Evoral is free software; you can redistribute it and/or modify it under the
  * terms of the GNU General Public License as published by the Free Software
  * Foundation; either version 2 of the License, or (at your option) any later
  * version.
- * 
+ *
  * Evoral is distributed in the hope that it will be useful, but WITHOUT ANY
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for details.
- * 
+ *
  * You should have received a copy of the GNU General Public License along
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #ifndef EVORAL_CONTROL_LIST_HPP
 #define EVORAL_CONTROL_LIST_HPP
 
+#include <cassert>
 #include <list>
 #include <boost/pool/pool.hpp>
 #include <boost/pool/pool_alloc.hpp>
 #include <glibmm/thread.h>
-#include <evoral/types.hpp>
-#include <evoral/Parameter.hpp>
-#include <evoral/Curve.hpp>
+#include "evoral/types.hpp"
+#include "evoral/Parameter.hpp"
 
 namespace Evoral {
 
+class Curve;
 
 /** A single event (time-stamped value) for a control
  */
@@ -37,7 +38,7 @@ struct ControlEvent {
            : when (w), value (v), coeff (0)
        {}
 
-    ControlEvent (const ControlEvent& other) 
+    ControlEvent (const ControlEvent& other)
            : when (other.when), value (other.value), coeff (0)
        {
                if (other.coeff) {
@@ -48,11 +49,11 @@ struct ControlEvent {
        }
 
        ~ControlEvent() { if (coeff) delete[] coeff; }
-       
+
        void create_coeffs() {
                if (!coeff)
                        coeff = new double[4];
-           
+
                coeff[0] = coeff[1] = coeff[2] = coeff[3] = 0.0;
        }
 
@@ -87,14 +88,15 @@ public:
        ControlList (const ControlList&);
        ControlList (const ControlList&, double start, double end);
        virtual ~ControlList();
-       
+
        virtual boost::shared_ptr<ControlList> create(Parameter id);
-       
+
        ControlList& operator= (const ControlList&);
        bool operator== (const ControlList&);
-       
-       void freeze();
-       void thaw ();
+
+       virtual void freeze();
+        virtual void thaw ();
+        bool frozen() const { return _frozen; }
 
        const Parameter& parameter() const                 { return _parameter; }
        void             set_parameter(const Parameter& p) { _parameter = p; }
@@ -120,7 +122,7 @@ public:
        void erase_range (double start, double end);
        void erase (iterator);
        void erase (iterator, iterator);
-       void move_ranges (RangeMoveList const &);
+       void move_ranges (std::list< RangeMove<double> > const &);
        void modify (iterator, double, double);
 
        boost::shared_ptr<ControlList> cut (double, double);
@@ -132,7 +134,7 @@ public:
        void clear (iterator, iterator);
 
        bool paste (ControlList&, double position, float times);
-       
+
        void set_yrange (double min, double max) {
                _min_yval = min;
                _max_yval = max;
@@ -179,7 +181,7 @@ public:
                }
        }
 
-       static inline bool time_comparator (const ControlEvent* a, const ControlEvent* b) { 
+       static inline bool time_comparator (const ControlEvent* a, const ControlEvent* b) {
                return a->when < b->when;
        }
 
@@ -208,7 +210,7 @@ public:
 
        /** Called by locked entry point and various private
         * locations where we already hold the lock.
-        * 
+        *
         * FIXME: Should this be private?  Curve needs it..
         */
        double unlocked_eval (double x) const;
@@ -216,9 +218,12 @@ public:
        bool rt_safe_earliest_event (double start, double end, double& x, double& y, bool start_inclusive=false) const;
        bool rt_safe_earliest_event_unlocked (double start, double end, double& x, double& y, bool start_inclusive=false) const;
 
-       Curve&       curve()       { return *_curve; }
-       const Curve& curve() const { return *_curve; }
-       
+       void create_curve();
+       void destroy_curve();
+
+       Curve&       curve()       { assert(_curve); return *_curve; }
+       const Curve& curve() const { assert(_curve); return *_curve; }
+
        virtual void mark_dirty () const;
 
        enum InterpolationStyle {
@@ -233,7 +238,7 @@ public:
 protected:
 
        /** Called by unlocked_eval() to handle cases of 3 or more control points. */
-       double multipoint_eval (double x) const; 
+       double multipoint_eval (double x) const;
 
        void build_search_cache_if_necessary(double start, double end) const;
 
@@ -244,7 +249,7 @@ protected:
        bool erase_range_internal (double start, double end, EventList &);
 
        virtual void maybe_signal_changed ();
-       
+
        void _x_scale (double factor);
 
        mutable LookupCache _lookup_cache;