convert rec-enable control for a Track from PBD::COntrollable to ARDOUR::AutomatioNCo...
[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 "pbd/controllable.h"
26 #include "evoral/Control.hpp"
27 #include "ardour/automation_list.h"
28
29 namespace ARDOUR {
30
31 class Session;
32 class Automatable;
33
34
35 /** A PBD::Controllable with associated automation data (AutomationList)
36  */
37 class AutomationControl : public PBD::Controllable, public Evoral::Control
38 {
39 public:
40         AutomationControl(ARDOUR::Session&,
41                           const Evoral::Parameter& parameter,
42                           boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
43                           const std::string& name="");
44
45         boost::shared_ptr<AutomationList> alist() const {
46                 return boost::dynamic_pointer_cast<AutomationList>(_list);
47         }
48
49         void set_list(boost::shared_ptr<Evoral::ControlList>);
50
51         inline bool automation_playback() const {
52                 return ((ARDOUR::AutomationList*)_list.get())->automation_playback();
53         }
54
55         inline bool automation_write() const {
56                 return ((ARDOUR::AutomationList*)_list.get())->automation_write();
57         }
58
59         inline AutoState automation_state() const {
60                 return ((ARDOUR::AutomationList*)_list.get())->automation_state();
61         }
62
63         inline void set_automation_state(AutoState as) {
64                 return ((ARDOUR::AutomationList*)_list.get())->set_automation_state(as);
65         }
66
67         inline void start_touch(double when) {
68                 set_touching (true);
69                 return ((ARDOUR::AutomationList*)_list.get())->start_touch(when);
70         }
71
72         inline void stop_touch(bool mark, double when) {
73                 set_touching (false);
74                 return ((ARDOUR::AutomationList*)_list.get())->stop_touch(mark, when);
75         }
76
77         void set_value (double);
78         double get_value () const;
79
80         virtual double internal_to_interface (double v) const {
81                 return v;
82         }
83         
84         virtual double interface_to_internal (double v) const {
85                 return v;
86         }
87
88         virtual double internal_to_user (double v) const {
89                 return v;
90         }
91
92         double lower() const { return parameter().min(); }
93         double upper() const { return parameter().max(); }
94         double normal() const { return parameter().normal(); }
95         bool toggled() const { return parameter().toggled(); }
96
97         const ARDOUR::Session& session() const { return _session; }
98
99 protected:
100
101         ARDOUR::Session& _session;
102 };
103
104
105 } // namespace ARDOUR
106
107 #endif /* __ardour_automation_control_h__ */