9efb4b299c8a0314ab586c7c4c01ee91f24f98d1
[ardour.git] / libs / surfaces / control_protocol / control_protocol / control_protocol.h
1 /*
2     Copyright (C) 2006 Paul Davis 
3
4     This program is free software; you can redistribute it
5     and/or modify it under the terms of the GNU Lesser
6     General Public License as published by the Free Software
7     Foundation; either version 2 of the License, or (at your
8     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_control_protocols_h
22 #define ardour_control_protocols_h
23
24 #include <string>
25 #include <vector>
26 #include <list>
27 #include <boost/shared_ptr.hpp>
28 #include <sigc++/sigc++.h>
29 #include <pbd/stateful.h>
30 #include <control_protocol/basic_ui.h>
31
32 namespace ARDOUR {
33
34 class Route;
35 class Session;
36
37 class ControlProtocol : public sigc::trackable, public PBD::Stateful, public BasicUI {
38   public:
39         ControlProtocol (Session&, std::string name);
40         virtual ~ControlProtocol();
41
42         std::string name() const { return _name; }
43
44         virtual int set_active (bool yn) = 0;
45         bool get_active() const { return _active; }
46
47         virtual int set_feedback (bool /*yn*/) { return 0; }
48         virtual bool get_feedback () const { return false; }
49
50         virtual void route_list_changed () {}
51
52         sigc::signal<void> ActiveChanged;
53
54         /* signals that a control protocol can emit and other (presumably graphical)
55            user interfaces can respond to
56         */
57
58         static sigc::signal<void> ZoomToSession;
59         static sigc::signal<void> ZoomIn;
60         static sigc::signal<void> ZoomOut;
61         static sigc::signal<void> Enter;
62         static sigc::signal<void,float> ScrollTimeline;
63
64         /* the model here is as follows:
65
66            we imagine most control surfaces being able to control
67            from 1 to N tracks at a time, with a session that may
68            contain 1 to M tracks, where M may be smaller, larger or
69            equal to N. 
70
71            the control surface has a fixed set of physical controllers
72            which can potentially be mapped onto different tracks/busses
73            via some mechanism.
74
75            therefore, the control protocol object maintains
76            a table that reflects the current mapping between
77            the controls and route object.
78         */
79
80         void set_route_table_size (uint32_t size);
81         void set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route>);
82         bool set_route_table (uint32_t table_index, uint32_t remote_control_id);
83
84         void route_set_rec_enable (uint32_t table_index, bool yn);
85         bool route_get_rec_enable (uint32_t table_index);
86
87         float route_get_gain (uint32_t table_index);
88         void route_set_gain (uint32_t table_index, float);
89         float route_get_effective_gain (uint32_t table_index);
90
91         float route_get_peak_input_power (uint32_t table_index, uint32_t which_input);
92
93         bool route_get_muted (uint32_t table_index);
94         void route_set_muted (uint32_t table_index, bool);
95
96         bool route_get_soloed (uint32_t table_index);
97         void route_set_soloed (uint32_t table_index, bool);
98
99         std::string route_get_name (uint32_t table_index);
100
101   protected:
102         std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
103         std::string _name;
104         bool _active;
105
106         void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >);
107
108         void next_track (uint32_t initial_id);
109         void prev_track (uint32_t initial_id);
110 };
111
112 extern "C" {
113         struct ControlProtocolDescriptor {
114             const char* name;      /* descriptive */
115             const char* id;        /* unique and version-specific */
116             void*       ptr;       /* protocol can store a value here */
117             void*       module;    /* not for public access */
118             int         mandatory; /* if non-zero, always load and do not make optional */
119             bool        supports_feedback; /* if true, protocol has toggleable feedback mechanism */
120             bool             (*probe)(ControlProtocolDescriptor*);
121             ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
122             void             (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);
123             
124         };
125 }
126
127 }
128
129 #endif // ardour_control_protocols_h