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 "ardour/session.h"
22 #include "ardour/route.h"
23 #include "ardour/audio_track.h"
24 #include "ardour/meter.h"
25 #include "ardour/amp.h"
26 #include "control_protocol/control_protocol.h"
28 using namespace ARDOUR;
31 PBD::Signal0<void> ControlProtocol::ZoomToSession;
32 PBD::Signal0<void> ControlProtocol::ZoomOut;
33 PBD::Signal0<void> ControlProtocol::ZoomIn;
34 PBD::Signal0<void> ControlProtocol::Enter;
35 PBD::Signal1<void,float> ControlProtocol::ScrollTimeline;
37 ControlProtocol::ControlProtocol (Session& s, string str)
42 session->RouteAdded.connect (*this, boost::bind (&ControlProtocol::add_strip, this, _1));
45 ControlProtocol::~ControlProtocol ()
50 ControlProtocol::add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >)
56 ControlProtocol::next_track (uint32_t initial_id)
58 uint32_t limit = session->nroutes();
59 boost::shared_ptr<Route> cr = route_table[0];
63 id = cr->remote_control_id ();
75 if ((cr = session->route_by_remote_id (id)) != 0) {
83 while (id != initial_id) {
84 if ((cr = session->route_by_remote_id (id)) != 0) {
95 ControlProtocol::prev_track (uint32_t initial_id)
97 uint32_t limit = session->nroutes();
98 boost::shared_ptr<Route> cr = route_table[0];
102 id = cr->remote_control_id ();
114 if ((cr = session->route_by_remote_id (id)) != 0) {
122 while (i > initial_id) {
123 if ((cr = session->route_by_remote_id (i)) != 0) {
135 ControlProtocol::set_route_table_size (uint32_t size)
137 while (route_table.size() < size) {
138 route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
143 ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
145 if (table_index >= route_table.size()) {
149 route_table[table_index] = r;
151 // XXX SHAREDPTR need to handle r->GoingAway
155 ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
157 boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
163 set_route_table (table_index, r);
169 ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
171 if (table_index > route_table.size()) {
175 boost::shared_ptr<Route> r = route_table[table_index];
177 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
180 at->set_record_enable (yn, this);
185 ControlProtocol::route_get_rec_enable (uint32_t table_index)
187 if (table_index > route_table.size()) {
191 boost::shared_ptr<Route> r = route_table[table_index];
193 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
196 return at->record_enabled ();
204 ControlProtocol::route_get_gain (uint32_t table_index)
206 if (table_index > route_table.size()) {
210 boost::shared_ptr<Route> r = route_table[table_index];
216 return r->amp()->gain ();
220 ControlProtocol::route_set_gain (uint32_t table_index, float gain)
222 if (table_index > route_table.size()) {
226 boost::shared_ptr<Route> r = route_table[table_index];
229 r->set_gain (gain, this);
234 ControlProtocol::route_get_effective_gain (uint32_t table_index)
236 if (table_index > route_table.size()) {
240 boost::shared_ptr<Route> r = route_table[table_index];
246 return r->amp()->gain_control()->get_value();
251 ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
253 if (table_index > route_table.size()) {
257 boost::shared_ptr<Route> r = route_table[table_index];
263 return r->peak_meter().peak_power (which_input);
268 ControlProtocol::route_get_muted (uint32_t table_index)
270 if (table_index > route_table.size()) {
274 boost::shared_ptr<Route> r = route_table[table_index];
284 ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
286 if (table_index > route_table.size()) {
290 boost::shared_ptr<Route> r = route_table[table_index];
293 r->set_mute (yn, this);
299 ControlProtocol::route_get_soloed (uint32_t table_index)
301 if (table_index > route_table.size()) {
305 boost::shared_ptr<Route> r = route_table[table_index];
315 ControlProtocol::route_set_soloed (uint32_t table_index, bool yn)
317 if (table_index > route_table.size()) {
321 boost::shared_ptr<Route> r = route_table[table_index];
324 r->set_solo (yn, this);
329 ControlProtocol:: route_get_name (uint32_t table_index)
331 if (table_index > route_table.size()) {
335 boost::shared_ptr<Route> r = route_table[table_index];