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 <control_protocol/control_protocol.h>
27 using namespace ARDOUR;
30 sigc::signal<void> ControlProtocol::ZoomToSession;
31 sigc::signal<void> ControlProtocol::ZoomOut;
32 sigc::signal<void> ControlProtocol::ZoomIn;
33 sigc::signal<void> ControlProtocol::Enter;
34 sigc::signal<void,float> ControlProtocol::ScrollTimeline;
36 ControlProtocol::ControlProtocol (Session& s, string str)
41 session->RouteAdded.connect (mem_fun(*this, &ControlProtocol::add_strip));
44 ControlProtocol::~ControlProtocol ()
49 ControlProtocol::add_strip (std::list<boost::shared_ptr<ARDOUR::Route> >)
55 ControlProtocol::next_track (uint32_t initial_id)
57 uint32_t limit = session->nroutes();
58 boost::shared_ptr<Route> cr = route_table[0];
62 id = cr->remote_control_id ();
74 if ((cr = session->route_by_remote_id (id)) != 0) {
82 while (id != initial_id) {
83 if ((cr = session->route_by_remote_id (id)) != 0) {
94 ControlProtocol::prev_track (uint32_t initial_id)
96 uint32_t limit = session->nroutes() - 1;
97 boost::shared_ptr<Route> cr = route_table[0];
101 id = cr->remote_control_id ();
107 id = session->nroutes() - 1;
113 if ((cr = session->route_by_remote_id (id)) != 0) {
121 while (id > initial_id) {
122 if ((cr = session->route_by_remote_id (id)) != 0) {
134 ControlProtocol::set_route_table_size (uint32_t size)
136 while (route_table.size() < size) {
137 route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
142 ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
144 if (table_index >= route_table.size()) {
148 route_table[table_index] = r;
150 // XXX SHAREDPTR need to handle r->GoingAway
154 ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
156 boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
162 set_route_table (table_index, r);
168 ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
170 if (table_index > route_table.size()) {
174 boost::shared_ptr<Route> r = route_table[table_index];
176 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
179 at->set_record_enable (yn, this);
184 ControlProtocol::route_get_rec_enable (uint32_t table_index)
186 if (table_index > route_table.size()) {
190 boost::shared_ptr<Route> r = route_table[table_index];
192 boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
195 return at->record_enabled ();
203 ControlProtocol::route_get_gain (uint32_t table_index)
205 if (table_index > route_table.size()) {
209 boost::shared_ptr<Route> r = route_table[table_index];
219 ControlProtocol::route_set_gain (uint32_t table_index, float gain)
221 if (table_index > route_table.size()) {
225 boost::shared_ptr<Route> r = route_table[table_index];
228 r->set_gain (gain, this);
233 ControlProtocol::route_get_effective_gain (uint32_t table_index)
235 if (table_index > route_table.size()) {
239 boost::shared_ptr<Route> r = route_table[table_index];
245 return r->effective_gain ();
250 ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
252 if (table_index > route_table.size()) {
256 boost::shared_ptr<Route> r = route_table[table_index];
262 return r->peak_meter().peak_power (which_input);
267 ControlProtocol::route_get_muted (uint32_t table_index)
269 if (table_index > route_table.size()) {
273 boost::shared_ptr<Route> r = route_table[table_index];
283 ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
285 if (table_index > route_table.size()) {
289 boost::shared_ptr<Route> r = route_table[table_index];
292 r->set_mute (yn, this);
298 ControlProtocol::route_get_soloed (uint32_t table_index)
300 if (table_index > route_table.size()) {
304 boost::shared_ptr<Route> r = route_table[table_index];
314 ControlProtocol::route_set_soloed (uint32_t table_index, bool yn)
316 if (table_index > route_table.size()) {
320 boost::shared_ptr<Route> r = route_table[table_index];
323 r->set_solo (yn, this);
328 ControlProtocol:: route_get_name (uint32_t table_index)
330 if (table_index > route_table.size()) {
334 boost::shared_ptr<Route> r = route_table[table_index];