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 #include "pbd/error.h"
23 #include "ardour/session.h"
24 #include "ardour/route.h"
25 #include "ardour/audio_track.h"
26 #include "ardour/meter.h"
27 #include "ardour/amp.h"
28 #include "control_protocol/control_protocol.h"
30 using namespace ARDOUR;
34 Signal0<void> ControlProtocol::ZoomToSession;
35 Signal0<void> ControlProtocol::ZoomOut;
36 Signal0<void> ControlProtocol::ZoomIn;
37 Signal0<void> ControlProtocol::Enter;
38 Signal0<void> ControlProtocol::Undo;
39 Signal0<void> ControlProtocol::Redo;
40 Signal1<void,float> ControlProtocol::ScrollTimeline;
41 Signal1<void,uint32_t> ControlProtocol::GotoView;
42 Signal0<void> ControlProtocol::CloseDialog;
43 PBD::Signal0<void> ControlProtocol::VerticalZoomInAll;
44 PBD::Signal0<void> ControlProtocol::VerticalZoomOutAll;
45 PBD::Signal0<void> ControlProtocol::VerticalZoomInSelected;
46 PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
47 PBD::Signal1<void,RouteNotificationListPtr> ControlProtocol::TrackSelectionChanged;
48 PBD::Signal1<void,uint32_t> ControlProtocol::AddRouteToSelection;
49 PBD::Signal1<void,uint32_t> ControlProtocol::SetRouteSelection;
50 PBD::Signal1<void,uint32_t> ControlProtocol::ToggleRouteSelection;
51 PBD::Signal1<void,uint32_t> ControlProtocol::RemoveRouteFromSelection;
52 PBD::Signal0<void> ControlProtocol::ClearRouteSelection;
53 PBD::Signal0<void> ControlProtocol::StepTracksDown;
54 PBD::Signal0<void> ControlProtocol::StepTracksUp;
56 const std::string ControlProtocol::state_node_name ("Protocol");
58 ControlProtocol::ControlProtocol (Session& s, string str)
65 ControlProtocol::~ControlProtocol ()
70 ControlProtocol::set_active (bool yn)
77 ControlProtocol::next_track (uint32_t initial_id)
79 uint32_t limit = session->nroutes();
80 boost::shared_ptr<Route> cr = route_table[0];
84 id = cr->remote_control_id ();
96 if ((cr = session->route_by_remote_id (id)) != 0) {
104 while (id != initial_id) {
105 if ((cr = session->route_by_remote_id (id)) != 0) {
116 ControlProtocol::prev_track (uint32_t initial_id)
118 uint32_t limit = session->nroutes();
119 boost::shared_ptr<Route> cr = route_table[0];
123 id = cr->remote_control_id ();
135 if ((cr = session->route_by_remote_id (id)) != 0) {
143 while (i > initial_id) {
144 if ((cr = session->route_by_remote_id (i)) != 0) {
156 ControlProtocol::set_route_table_size (uint32_t size)
158 while (route_table.size() < size) {
159 route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
164 ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
166 if (table_index >= route_table.size()) {
170 route_table[table_index] = r;
172 // XXX SHAREDPTR need to handle r->GoingAway
176 ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
178 boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
184 set_route_table (table_index, r);
190 ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
192 if (table_index > route_table.size()) {
196 boost::shared_ptr<Route> r = route_table[table_index];
198 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
201 at->set_record_enabled (yn, this);
206 ControlProtocol::route_get_rec_enable (uint32_t table_index)
208 if (table_index > route_table.size()) {
212 boost::shared_ptr<Route> r = route_table[table_index];
214 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
217 return at->record_enabled ();
225 ControlProtocol::route_get_gain (uint32_t table_index)
227 if (table_index > route_table.size()) {
231 boost::shared_ptr<Route> r = route_table[table_index];
237 return r->amp()->gain ();
241 ControlProtocol::route_set_gain (uint32_t table_index, float gain)
243 if (table_index > route_table.size()) {
247 boost::shared_ptr<Route> r = route_table[table_index];
250 r->set_gain (gain, this);
255 ControlProtocol::route_get_effective_gain (uint32_t table_index)
257 if (table_index > route_table.size()) {
261 boost::shared_ptr<Route> r = route_table[table_index];
267 return r->amp()->gain_control()->get_value();
272 ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
274 if (table_index > route_table.size()) {
278 boost::shared_ptr<Route> r = route_table[table_index];
284 return r->peak_meter().peak_power (which_input);
289 ControlProtocol::route_get_muted (uint32_t table_index)
291 if (table_index > route_table.size()) {
295 boost::shared_ptr<Route> r = route_table[table_index];
305 ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
307 if (table_index > route_table.size()) {
311 boost::shared_ptr<Route> r = route_table[table_index];
314 r->set_mute (yn, this);
320 ControlProtocol::route_get_soloed (uint32_t table_index)
322 if (table_index > route_table.size()) {
326 boost::shared_ptr<Route> r = route_table[table_index];
336 ControlProtocol::route_set_soloed (uint32_t table_index, bool yn)
338 if (table_index > route_table.size()) {
342 boost::shared_ptr<Route> r = route_table[table_index];
345 r->set_solo (yn, this);
350 ControlProtocol:: route_get_name (uint32_t table_index)
352 if (table_index > route_table.size()) {
356 boost::shared_ptr<Route> r = route_table[table_index];
365 list<boost::shared_ptr<Bundle> >
366 ControlProtocol::bundles ()
368 return list<boost::shared_ptr<Bundle> > ();
372 ControlProtocol::get_state ()
374 XMLNode* node = new XMLNode (state_node_name);
376 node->add_property ("name", _name);