MCP: F1-7 jump to a given view; F8 closes any currently open dialog; in zoom mode...
[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 "pbd/stateful.h"
29 #include "pbd/signals.h"
30 #include "control_protocol/basic_ui.h"
31
32 namespace ARDOUR {
33
34 class Route;
35 class Session;
36 class Bundle;
37
38 class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI {
39   public:
40         ControlProtocol (Session&, std::string name, PBD::EventLoop* event_loop);
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         virtual void route_list_changed () {}
52
53         PBD::Signal0<void> ActiveChanged;
54
55         /* signals that a control protocol can emit and other (presumably graphical)
56            user interfaces can respond to
57         */
58
59         static PBD::Signal0<void> ZoomToSession;
60         static PBD::Signal0<void> ZoomIn;
61         static PBD::Signal0<void> ZoomOut;
62         static PBD::Signal0<void> Enter;
63         static PBD::Signal0<void> Undo;
64         static PBD::Signal0<void> Redo;
65         static PBD::Signal1<void,float> ScrollTimeline;
66         static PBD::Signal1<void,uint32_t> SelectByRID;
67         static PBD::Signal0<void> UnselectTrack;
68         static PBD::Signal1<void,uint32_t> GotoView;
69         static PBD::Signal0<void> CloseDialog;
70         static PBD::Signal0<void> VerticalZoomInAll;
71         static PBD::Signal0<void> VerticalZoomOutAll;
72         static PBD::Signal0<void> VerticalZoomInSelected;
73         static PBD::Signal0<void> VerticalZoomOutSelected;
74
75         /* the model here is as follows:
76
77            we imagine most control surfaces being able to control
78            from 1 to N tracks at a time, with a session that may
79            contain 1 to M tracks, where M may be smaller, larger or
80            equal to N. 
81
82            the control surface has a fixed set of physical controllers
83            which can potentially be mapped onto different tracks/busses
84            via some mechanism.
85
86            therefore, the control protocol object maintains
87            a table that reflects the current mapping between
88            the controls and route object.
89         */
90
91         void set_route_table_size (uint32_t size);
92         void set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route>);
93         bool set_route_table (uint32_t table_index, uint32_t remote_control_id);
94
95         void route_set_rec_enable (uint32_t table_index, bool yn);
96         bool route_get_rec_enable (uint32_t table_index);
97
98         float route_get_gain (uint32_t table_index);
99         void route_set_gain (uint32_t table_index, float);
100         float route_get_effective_gain (uint32_t table_index);
101
102         float route_get_peak_input_power (uint32_t table_index, uint32_t which_input);
103
104         bool route_get_muted (uint32_t table_index);
105         void route_set_muted (uint32_t table_index, bool);
106
107         bool route_get_soloed (uint32_t table_index);
108         void route_set_soloed (uint32_t table_index, bool);
109
110         std::string route_get_name (uint32_t table_index);
111
112         virtual std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
113
114         virtual bool  has_editor () const { return false; }
115         virtual void* get_gui() const { return 0; }
116         virtual void  tear_down_gui() { }
117
118   protected:
119         PBD::EventLoop* _event_loop;
120         bool _own_event_loop;
121         std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
122         std::string _name;
123         bool _active;
124
125         void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >&);
126
127         void next_track (uint32_t initial_id);
128         void prev_track (uint32_t initial_id);
129
130   private:
131         ControlProtocol (const ControlProtocol&); /* noncopyable */
132 };
133
134 extern "C" {
135         struct ControlProtocolDescriptor {
136             const char* name;      /* descriptive */
137             const char* id;        /* unique and version-specific */
138             void*       ptr;       /* protocol can store a value here */
139             void*       module;    /* not for public access */
140             int         mandatory; /* if non-zero, always load and do not make optional */
141             bool        supports_feedback; /* if true, protocol has toggleable feedback mechanism */
142             bool             (*probe)(ControlProtocolDescriptor*);
143             ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
144             void             (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);
145             
146         };
147 }
148
149 }
150
151 #endif // ardour_control_protocols_h