2 Copyright (C) 2007 Paul Davis
3 Author: David Robillard
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_automation_control_h__
22 #define __ardour_automation_control_h__
24 #include <boost/shared_ptr.hpp>
25 #include <boost/enable_shared_from_this.hpp>
27 #include "evoral/types.hpp"
28 #include "pbd/controllable.h"
29 #include "evoral/Control.hpp"
31 #include "ardour/libardour_visibility.h"
32 #include "ardour/automation_list.h"
33 #include "ardour/parameter_descriptor.h"
41 /** A PBD::Controllable with associated automation data (AutomationList)
43 class LIBARDOUR_API AutomationControl
44 : public PBD::Controllable
45 , public Evoral::Control
46 , public boost::enable_shared_from_this<AutomationControl>
49 AutomationControl(ARDOUR::Session&,
50 const Evoral::Parameter& parameter,
51 const ParameterDescriptor& desc,
52 boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
53 const std::string& name="");
55 ~AutomationControl ();
57 boost::shared_ptr<AutomationList> alist() const {
58 return boost::dynamic_pointer_cast<AutomationList>(_list);
61 void set_list (boost::shared_ptr<Evoral::ControlList>);
63 inline bool automation_playback() const {
64 return alist() ? alist()->automation_playback() : false;
67 inline bool automation_write() const {
68 return alist() ? alist()->automation_write() : false;
71 inline AutoState automation_state() const {
72 return alist() ? alist()->automation_state() : Off;
75 inline AutoStyle automation_style() const {
76 return alist() ? alist()->automation_style() : Absolute;
79 void set_automation_state(AutoState as);
80 void set_automation_style(AutoStyle as);
81 void start_touch(double when);
82 void stop_touch(bool mark, double when);
84 /* inherited from PBD::Controllable.
85 * Derived classes MUST call ::writable() to verify
86 * that writing to the parameter is legal at that time.
88 double get_value () const;
89 /* inherited from PBD::Controllable.
90 * Derived classes MUST call ::writable() to verify
91 * that writing to the parameter is legal at that time.
93 void set_value (double value, PBD::Controllable::GroupControlDisposition group_override);
94 /* automation related value setting */
95 virtual bool writable () const;
96 /* Call to ::set_value() with no test for writable() because
97 * this is only used by automation playback. We would like
98 * to make it pure virtual
100 virtual void set_value_unchecked (double val) {}
102 double lower() const { return _desc.lower; }
103 double upper() const { return _desc.upper; }
104 double normal() const { return _desc.normal; }
105 bool toggled() const { return _desc.toggled; }
107 double internal_to_interface (double i) const;
108 double interface_to_internal (double i) const;
110 const ParameterDescriptor& desc() const { return _desc; }
112 const ARDOUR::Session& session() const { return _session; }
113 void commit_transaction (bool did_write);
116 ARDOUR::Session& _session;
118 const ParameterDescriptor _desc;
122 } // namespace ARDOUR
124 #endif /* __ardour_automation_control_h__ */