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/gain_control.h"
24 #include "ardour/session.h"
25 #include "ardour/route.h"
26 #include "ardour/audio_track.h"
27 #include "ardour/meter.h"
28 #include "ardour/amp.h"
29 #include "control_protocol/control_protocol.h"
31 using namespace ARDOUR;
35 Signal0<void> ControlProtocol::ZoomToSession;
36 Signal0<void> ControlProtocol::ZoomOut;
37 Signal0<void> ControlProtocol::ZoomIn;
38 Signal0<void> ControlProtocol::Enter;
39 Signal0<void> ControlProtocol::Undo;
40 Signal0<void> ControlProtocol::Redo;
41 Signal1<void,float> ControlProtocol::ScrollTimeline;
42 Signal1<void,uint32_t> ControlProtocol::GotoView;
43 Signal0<void> ControlProtocol::CloseDialog;
44 PBD::Signal0<void> ControlProtocol::VerticalZoomInAll;
45 PBD::Signal0<void> ControlProtocol::VerticalZoomOutAll;
46 PBD::Signal0<void> ControlProtocol::VerticalZoomInSelected;
47 PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
48 PBD::Signal1<void,RouteNotificationListPtr> ControlProtocol::TrackSelectionChanged;
49 PBD::Signal1<void,uint64_t> ControlProtocol::AddRouteToSelection;
50 PBD::Signal1<void,uint64_t> ControlProtocol::SetRouteSelection;
51 PBD::Signal1<void,uint64_t> ControlProtocol::ToggleRouteSelection;
52 PBD::Signal1<void,uint64_t> ControlProtocol::RemoveRouteFromSelection;
53 PBD::Signal0<void> ControlProtocol::ClearRouteSelection;
54 PBD::Signal0<void> ControlProtocol::StepTracksDown;
55 PBD::Signal0<void> ControlProtocol::StepTracksUp;
57 const std::string ControlProtocol::state_node_name ("Protocol");
59 ControlProtocol::ControlProtocol (Session& s, string str)
66 ControlProtocol::~ControlProtocol ()
71 ControlProtocol::set_active (bool yn)
78 ControlProtocol::next_track (uint32_t initial_id)
80 // STRIPABLE route_table[0] = _session->get_nth_stripable (++initial_id, RemoteControlID::Route);
84 ControlProtocol::prev_track (uint32_t initial_id)
89 // STRIPABLE route_table[0] = _session->get_nth_stripable (--initial_id, RemoteControlID::Route);
93 ControlProtocol::set_route_table_size (uint32_t size)
95 while (route_table.size() < size) {
96 route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
101 ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
103 if (table_index >= route_table.size()) {
107 route_table[table_index] = r;
109 // XXX SHAREDPTR need to handle r->GoingAway
113 ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
116 boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
122 set_route_table (table_index, r);
128 ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
130 if (table_index > route_table.size()) {
134 boost::shared_ptr<Route> r = route_table[table_index];
136 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
139 at->rec_enable_control()->set_value (1.0, Controllable::UseGroup);
144 ControlProtocol::route_get_rec_enable (uint32_t table_index)
146 if (table_index > route_table.size()) {
150 boost::shared_ptr<Route> r = route_table[table_index];
152 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
155 return at->rec_enable_control()->get_value();
163 ControlProtocol::route_get_gain (uint32_t table_index)
165 if (table_index > route_table.size()) {
169 boost::shared_ptr<Route> r = route_table[table_index];
175 return r->gain_control()->get_value();
179 ControlProtocol::route_set_gain (uint32_t table_index, float gain)
181 if (table_index > route_table.size()) {
185 boost::shared_ptr<Route> r = route_table[table_index];
188 r->gain_control()->set_value (gain, Controllable::UseGroup);
193 ControlProtocol::route_get_effective_gain (uint32_t table_index)
195 if (table_index > route_table.size()) {
199 boost::shared_ptr<Route> r = route_table[table_index];
205 return r->amp()->gain_control()->get_value();
210 ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
212 if (table_index > route_table.size()) {
216 boost::shared_ptr<Route> r = route_table[table_index];
222 return r->peak_meter()->meter_level (which_input, MeterPeak);
226 ControlProtocol::route_get_muted (uint32_t table_index)
228 if (table_index > route_table.size()) {
232 boost::shared_ptr<Route> r = route_table[table_index];
238 return r->mute_control()->muted ();
242 ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
244 if (table_index > route_table.size()) {
248 boost::shared_ptr<Route> r = route_table[table_index];
251 r->mute_control()->set_value (yn ? 1.0 : 0.0, Controllable::UseGroup);
257 ControlProtocol::route_get_soloed (uint32_t table_index)
259 if (table_index > route_table.size()) {
263 boost::shared_ptr<Route> r = route_table[table_index];
273 ControlProtocol::route_set_soloed (uint32_t table_index, bool yn)
275 if (table_index > route_table.size()) {
279 boost::shared_ptr<Route> r = route_table[table_index];
282 r->solo_control()->set_value (yn ? 1.0 : 0.0, Controllable::UseGroup);
287 ControlProtocol:: route_get_name (uint32_t table_index)
289 if (table_index > route_table.size()) {
293 boost::shared_ptr<Route> r = route_table[table_index];
302 list<boost::shared_ptr<Bundle> >
303 ControlProtocol::bundles ()
305 return list<boost::shared_ptr<Bundle> > ();
309 ControlProtocol::get_state ()
311 XMLNode* node = new XMLNode (state_node_name);
313 node->add_property ("name", _name);
314 node->add_property ("feedback", get_feedback() ? "yes" : "no");
320 ControlProtocol::set_state (XMLNode const & node, int /* version */)
322 const XMLProperty* prop;
324 if ((prop = node.property ("feedback")) != 0) {
325 set_feedback (string_is_affirmative (prop->value()));