2 Copyright (C) 2006 Paul Davis
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.
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.
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.
21 #ifndef ardour_control_protocols_h
22 #define ardour_control_protocols_h
28 #include <boost/shared_ptr.hpp>
30 #include "pbd/stateful.h"
31 #include "pbd/signals.h"
33 #include "control_protocol/basic_ui.h"
34 #include "control_protocol/types.h"
42 class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, public PBD::ScopedConnectionList, public BasicUI {
44 ControlProtocol (Session&, std::string name, PBD::EventLoop* event_loop);
45 virtual ~ControlProtocol();
47 std::string name() const { return _name; }
49 virtual int set_active (bool yn) = 0;
50 bool get_active() const { return _active; }
52 virtual int set_feedback (bool /*yn*/) { return 0; }
53 virtual bool get_feedback () const { return false; }
55 virtual void route_list_changed () {}
57 virtual void midi_connectivity_established () {}
59 PBD::Signal0<void> ActiveChanged;
61 /* signals that a control protocol can emit and other (presumably graphical)
62 user interfaces can respond to
65 static PBD::Signal0<void> ZoomToSession;
66 static PBD::Signal0<void> ZoomIn;
67 static PBD::Signal0<void> ZoomOut;
68 static PBD::Signal0<void> Enter;
69 static PBD::Signal0<void> Undo;
70 static PBD::Signal0<void> Redo;
71 static PBD::Signal1<void,float> ScrollTimeline;
72 static PBD::Signal1<void,uint32_t> GotoView;
73 static PBD::Signal0<void> CloseDialog;
74 static PBD::Signal0<void> VerticalZoomInAll;
75 static PBD::Signal0<void> VerticalZoomOutAll;
76 static PBD::Signal0<void> VerticalZoomInSelected;
77 static PBD::Signal0<void> VerticalZoomOutSelected;
79 static PBD::Signal1<void,uint32_t> AddRouteToSelection;
80 static PBD::Signal1<void,uint32_t> SetRouteSelection;
81 static PBD::Signal1<void,uint32_t> RemoveRouteFromSelection;
82 static PBD::Signal0<void> ClearRouteSelection;
84 /* signals that one UI (e.g. the GUI) can emit to get all other UI's to
85 respond. Typically this will always be GUI->"others" - the GUI pays
86 no attention to these signals.
89 static PBD::Signal1<void,RouteNotificationListPtr> TrackSelectionChanged;
91 /* the model here is as follows:
93 we imagine most control surfaces being able to control
94 from 1 to N tracks at a time, with a session that may
95 contain 1 to M tracks, where M may be smaller, larger or
98 the control surface has a fixed set of physical controllers
99 which can potentially be mapped onto different tracks/busses
102 therefore, the control protocol object maintains
103 a table that reflects the current mapping between
104 the controls and route object.
107 void set_route_table_size (uint32_t size);
108 void set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route>);
109 bool set_route_table (uint32_t table_index, uint32_t remote_control_id);
111 void route_set_rec_enable (uint32_t table_index, bool yn);
112 bool route_get_rec_enable (uint32_t table_index);
114 float route_get_gain (uint32_t table_index);
115 void route_set_gain (uint32_t table_index, float);
116 float route_get_effective_gain (uint32_t table_index);
118 float route_get_peak_input_power (uint32_t table_index, uint32_t which_input);
120 bool route_get_muted (uint32_t table_index);
121 void route_set_muted (uint32_t table_index, bool);
123 bool route_get_soloed (uint32_t table_index);
124 void route_set_soloed (uint32_t table_index, bool);
126 std::string route_get_name (uint32_t table_index);
128 virtual std::list<boost::shared_ptr<ARDOUR::Bundle> > bundles ();
130 virtual bool has_editor () const { return false; }
131 virtual void* get_gui() const { return 0; }
132 virtual void tear_down_gui() { }
135 PBD::EventLoop* _event_loop;
136 bool _own_event_loop;
137 std::vector<boost::shared_ptr<ARDOUR::Route> > route_table;
141 void add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >&);
143 void next_track (uint32_t initial_id);
144 void prev_track (uint32_t initial_id);
147 ControlProtocol (const ControlProtocol&); /* noncopyable */
151 struct ControlProtocolDescriptor {
152 const char* name; /* descriptive */
153 const char* id; /* unique and version-specific */
154 void* ptr; /* protocol can store a value here */
155 void* module; /* not for public access */
156 int mandatory; /* if non-zero, always load and do not make optional */
157 bool supports_feedback; /* if true, protocol has toggleable feedback mechanism */
158 bool (*probe)(ControlProtocolDescriptor*);
159 ControlProtocol* (*initialize)(ControlProtocolDescriptor*,Session*);
160 void (*destroy)(ControlProtocolDescriptor*,ControlProtocol*);
167 #endif // ardour_control_protocols_h