Merge big changes (mostly Controllable) from trunk
[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     $Id$
20 */
21
22 #ifndef ardour_control_protocols_h
23 #define ardour_control_protocols_h
24
25 #include <string>
26 #include <vector>
27 #include <list>
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 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         sigc::signal<void> ActiveChanged;
48
49         /* signals that a control protocol can emit and other (presumably graphical)
50            user interfaces can respond to
51         */
52
53         static sigc::signal<void> ZoomToSession;
54         static sigc::signal<void> ZoomIn;
55         static sigc::signal<void> ZoomOut;
56         static sigc::signal<void> Enter;
57         static sigc::signal<void,float> ScrollTimeline;
58
59         /* the model here is as follows:
60
61            we imagine most control surfaces being able to control
62            from 1 to N tracks at a time, with a session that may
63            contain 1 to M tracks, where M may be smaller, larger or
64            equal to N. 
65
66            the control surface has a fixed set of physical controllers
67            which can potentially be mapped onto different tracks/busses
68            via some mechanism.
69
70            therefore, the control protocol object maintains
71            a table that reflects the current mapping between
72            the controls and route object.
73         */
74
75         void set_route_table_size (uint32_t size);
76         void set_route_table (uint32_t table_index, ARDOUR::Route*);
77         bool set_route_table (uint32_t table_index, uint32_t remote_control_id);
78
79         void route_set_rec_enable (uint32_t table_index, bool yn);
80         bool route_get_rec_enable (uint32_t table_index);
81
82         float route_get_gain (uint32_t table_index);
83         void route_set_gain (uint32_t table_index, float);
84         float route_get_effective_gain (uint32_t table_index);
85
86         float route_get_peak_input_power (uint32_t table_index, uint32_t which_input);
87
88         bool route_get_muted (uint32_t table_index);
89         void route_set_muted (uint32_t table_index, bool);
90
91         bool route_get_soloed (uint32_t table_index);
92         void route_set_soloed (uint32_t table_index, bool);
93
94         std::string route_get_name (uint32_t table_index);
95
96   protected:
97         std::vector<ARDOUR::Route*> route_table;
98         std::string _name;
99         bool _active;
100
101         void next_track (uint32_t initial_id);
102         void prev_track (uint32_t initial_id);
103 };
104
105 extern "C" {
106         struct ControlProtocolDescriptor {
107             const char* name;      /* descriptive */
108             const char* id;        /* unique and version-specific */
109             void*       ptr;       /* protocol can store a value here */
110             void*       module;    /* not for public access */
111             int         mandatory; /* if non-zero, always load and do not make optional */
112             bool             (*probe)(ControlProtocolDescriptor*);
113             ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
114             void             (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);
115             
116         };
117 }
118
119 }
120
121 #endif // ardour_control_protocols_h