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