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