most of the 2.X->3.0 commit (up to rev 4299) except for gtk2_ardour/editor_canvas...
[ardour.git] / libs / ardour / ardour / automation_control.h
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: Dave Robillard
4
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.
9
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.
14
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.
18
19 */
20
21 #ifndef __ardour_automation_control_h__
22 #define __ardour_automation_control_h__
23
24 #include <boost/shared_ptr.hpp>
25 #include <pbd/controllable.h>
26 #include <evoral/Control.hpp>
27 #include <ardour/automation_list.h>
28
29 namespace ARDOUR {
30
31 class AutomationList;
32 class Session;
33 class Automatable;
34
35
36 /** A PBD::Controllable with associated automation data (AutomationList)
37  */
38 class AutomationControl : public PBD::Controllable, public Evoral::Control
39 {
40 public:
41         AutomationControl(ARDOUR::Session&,
42                         const Evoral::Parameter& parameter,
43                         boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
44                         const string& name="");
45         
46         boost::shared_ptr<AutomationList> alist() const { return boost::dynamic_pointer_cast<AutomationList>(_list); }
47
48         void set_list(boost::shared_ptr<Evoral::ControlList>);
49
50         inline bool automation_playback() const {
51                 return ((ARDOUR::AutomationList*)_list.get())->automation_playback();
52         }
53         
54         inline bool automation_write() const {
55                 return ((ARDOUR::AutomationList*)_list.get())->automation_write();
56         }
57         
58         inline AutoState automation_state() const {
59                 return ((ARDOUR::AutomationList*)_list.get())->automation_state();
60         }
61         
62         inline void set_automation_state(AutoState as) {
63                 return ((ARDOUR::AutomationList*)_list.get())->set_automation_state(as);
64         }
65         
66         inline void start_touch() {
67                 return ((ARDOUR::AutomationList*)_list.get())->start_touch();
68         }
69         
70         inline void stop_touch() {
71                 return ((ARDOUR::AutomationList*)_list.get())->stop_touch();
72         }
73
74         /** Set the value and do the right thing based on automation state
75          * (e.g. record if necessary, etc.)
76          */
77         void set_value(float val);
78
79         /** Get the current effective value based on automation state.
80          */
81         float get_value() const;
82
83 protected:
84         ARDOUR::Session& _session;
85 };
86
87
88 } // namespace ARDOUR
89
90 #endif /* __ardour_automation_control_h__ */