Update plugin classification
[ardour.git] / libs / ardour / ardour / automation_control.h
index d84f0a091fc8573af4922fc99c06faee074b5290..8de0ec6ec093fe1892de26b50f01e1b00888180c 100644 (file)
 #include "evoral/types.hpp"
 #include "evoral/Control.hpp"
 
-#include "ardour/libardour_visibility.h"
 #include "ardour/automation_list.h"
+#include "ardour/control_group_member.h"
 #include "ardour/parameter_descriptor.h"
+#include "ardour/session_handle.h"
+
+#include "ardour/libardour_visibility.h"
 
 namespace ARDOUR {
 
@@ -49,15 +52,19 @@ class LIBARDOUR_API AutomationControl
        : public PBD::Controllable
        , public Evoral::Control
        , public boost::enable_shared_from_this<AutomationControl>
+       , public ControlGroupMember
+       , public SessionHandleRef
 {
-    public:
+public:
        AutomationControl(ARDOUR::Session&,
                          const Evoral::Parameter&                  parameter,
                          const ParameterDescriptor&                desc,
                          boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
-                         const std::string&                        name="");
+                         const std::string&                        name="",
+                         PBD::Controllable::Flag                   flags=PBD::Controllable::Flag (0)
+               );
 
-       ~AutomationControl ();
+       virtual ~AutomationControl ();
 
        boost::shared_ptr<AutomationList> alist() const {
                return boost::dynamic_pointer_cast<AutomationList>(_list);
@@ -77,18 +84,14 @@ class LIBARDOUR_API AutomationControl
                return alist() ? alist()->automation_state() : Off;
        }
 
-       inline AutoStyle automation_style() const {
-               return alist() ? alist()->automation_style() : Absolute;
-       }
-
        void set_automation_state(AutoState as);
-       void set_automation_style(AutoStyle as);
        void start_touch(double when);
-       void stop_touch(bool mark, double when);
+       void stop_touch(double when);
+
+       /* inherited from PBD::Controllable. */
+       virtual double get_value () const;
+       virtual double get_save_value () const;
 
-       /* inherited from PBD::Controllable.
-        */
-       double get_value () const;
        /* inherited from PBD::Controllable.
         * Derived classes MUST call ::writable() to verify
         * that writing to the parameter is legal at that time.
@@ -103,6 +106,8 @@ class LIBARDOUR_API AutomationControl
                actually_set_value (val, PBD::Controllable::NoGroup);
        }
 
+       virtual void automation_run (samplepos_t start, pframes_t nframes);
+
        double lower()   const { return _desc.lower; }
        double upper()   const { return _desc.upper; }
        double normal()  const { return _desc.normal; }
@@ -111,15 +116,16 @@ class LIBARDOUR_API AutomationControl
        double internal_to_interface (double i) const;
        double interface_to_internal (double i) const;
 
+       virtual std::string get_user_string() const;
+
        const ParameterDescriptor& desc() const { return _desc; }
 
        const ARDOUR::Session& session() const { return _session; }
        void commit_transaction (bool did_write);
 
-       void set_group (boost::shared_ptr<ControlGroup>);
+       ControlList grouped_controls () const;
 
-  protected:
-       ARDOUR::Session& _session;
+protected:
        boost::shared_ptr<ControlGroup> _group;
 
        const ParameterDescriptor _desc;
@@ -132,61 +138,27 @@ class LIBARDOUR_API AutomationControl
        */
 
        virtual void actually_set_value (double value, PBD::Controllable::GroupControlDisposition);
-};
-
-class SlavableAutomationControl : public AutomationControl
-{
-    public:
-       SlavableAutomationControl(ARDOUR::Session&,
-                         const Evoral::Parameter&                  parameter,
-                         const ParameterDescriptor&                desc,
-                         boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
-                         const std::string&                        name="");
-
-       ~SlavableAutomationControl ();
-
-       double get_value () const;
-
-       void add_master (boost::shared_ptr<AutomationControl>);
-       void remove_master (boost::shared_ptr<AutomationControl>);
-       void clear_masters ();
-       bool slaved_to (boost::shared_ptr<AutomationControl>) const;
-       bool slaved () const;
-       std::vector<PBD::ID> masters () const;
-
-       PBD::Signal0<void> MasterStatusChange;
-
-    protected:
-
-       class MasterRecord {
-          public:
-               MasterRecord (boost::shared_ptr<AutomationControl> gc, double r)
-                       : _master (gc)
-                       , _ratio (r)
-               {}
-
-               boost::shared_ptr<AutomationControl> master() const { return _master; }
-               double ratio () const { return _ratio; }
-               void reset_ratio (double r) { _ratio = r; }
-
-               PBD::ScopedConnection connection;
-
-         private:
-               boost::shared_ptr<AutomationControl> _master;
-               double _ratio;
-
-       };
-
-       mutable Glib::Threads::RWLock master_lock;
-       typedef std::map<PBD::ID,MasterRecord> Masters;
-       Masters _masters;
-       PBD::ScopedConnectionList masters_connections;
-       virtual void master_changed (bool from_self, GroupControlDisposition gcd);
-       void master_going_away (boost::weak_ptr<AutomationControl>);
-       virtual void recompute_masters_ratios (double val) { /* do nothing by default */}
-       virtual double get_masters_value_locked () const;
-       double get_value_locked() const;
 
+       /* Session needs to call this method before it queues up the real
+          change for execution in a realtime context. C++ access control sucks.
+       */
+       friend class Session;
+       /* this is what the session invokes */
+       void pre_realtime_queue_stuff (double new_value, PBD::Controllable::GroupControlDisposition);
+       /* this will be invoked in turn on behalf of the group or the control by itself */
+       virtual void do_pre_realtime_queue_stuff (double new_value) {}
+
+       void session_going_away ();
+
+private:
+       /* I am unclear on why we have to make ControlGroup a friend in order
+          to get access to the ::set_group() method when it is already
+          declared to be a friend in ControlGroupMember. Oh well.
+       */
+       friend class ControlGroup;
+       void set_group (boost::shared_ptr<ControlGroup>);
+       PBD::ScopedConnection _state_changed_connection;
+       bool _no_session;
 };