d73b2fc8224815f9260d1c48739136b3e6534906
[ardour.git] / libs / ardour / ardour / automation_control.h
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: David 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 <boost/enable_shared_from_this.hpp>
26
27 #include "evoral/types.hpp"
28 #include "pbd/controllable.h"
29 #include "evoral/Control.hpp"
30
31 #include "ardour/libardour_visibility.h"
32 #include "ardour/automation_list.h"
33 #include "ardour/parameter_descriptor.h"
34
35 namespace ARDOUR {
36
37 class Session;
38 class Automatable;
39
40
41 /** A PBD::Controllable with associated automation data (AutomationList)
42  */
43 class LIBARDOUR_API AutomationControl : public PBD::Controllable, public Evoral::Control, public boost::enable_shared_from_this<AutomationControl>
44 {
45 public:
46         AutomationControl(ARDOUR::Session&,
47                           const Evoral::Parameter&                  parameter,
48                           const ParameterDescriptor&                desc,
49                           boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
50                           const std::string&                        name="");
51
52         ~AutomationControl ();
53
54         boost::shared_ptr<AutomationList> alist() const {
55                 return boost::dynamic_pointer_cast<AutomationList>(_list);
56         }
57
58         void set_list (boost::shared_ptr<Evoral::ControlList>);
59
60         inline bool automation_playback() const {
61                 return alist()->automation_playback();
62         }
63
64         inline bool automation_write() const {
65                 return alist()->automation_write();
66         }
67
68         inline AutoState automation_state() const {
69                 return alist()->automation_state();
70         }
71
72         inline AutoStyle automation_style() const {
73                 return alist()->automation_style();
74         }
75
76         void set_automation_state(AutoState as);
77         void set_automation_style(AutoStyle as);
78         void start_touch (double when);
79         void stop_touch (bool mark, double when);
80
81         void set_value (double);
82         double get_value () const;
83
84         double lower()   const { return _desc.lower; }
85         double upper()   const { return _desc.upper; }
86         double normal()  const { return _desc.normal; }
87         bool   toggled() const { return _desc.toggled; }
88
89         const ParameterDescriptor& desc() const { return _desc; }
90
91         const ARDOUR::Session& session() const { return _session; }
92
93 protected:
94
95         ARDOUR::Session& _session;
96
97         const ParameterDescriptor _desc;
98 };
99
100
101 } // namespace ARDOUR
102
103 #endif /* __ardour_automation_control_h__ */