2006-04-04 20:24:57 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2006 Paul Davis
|
|
|
|
|
2006-05-23 15:54:52 -04:00
|
|
|
This program is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU Lesser
|
|
|
|
General Public License as published by the Free Software
|
|
|
|
Foundation; either version 2 of the License, or (at your
|
|
|
|
option) any later version.
|
2006-04-04 20:24:57 -04:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <ardour/route.h>
|
|
|
|
#include <ardour/audio_track.h>
|
2006-08-12 04:20:24 -04:00
|
|
|
#include <ardour/meter.h>
|
2006-06-15 18:31:13 -04:00
|
|
|
#include <control_protocol/control_protocol.h>
|
2006-05-23 15:54:52 -04:00
|
|
|
|
2006-04-04 20:24:57 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
|
|
|
|
2006-04-05 21:52:45 -04:00
|
|
|
sigc::signal<void> ControlProtocol::ZoomToSession;
|
|
|
|
sigc::signal<void> ControlProtocol::ZoomOut;
|
|
|
|
sigc::signal<void> ControlProtocol::ZoomIn;
|
|
|
|
sigc::signal<void> ControlProtocol::Enter;
|
2006-04-06 12:51:27 -04:00
|
|
|
sigc::signal<void,float> ControlProtocol::ScrollTimeline;
|
2006-04-05 21:52:45 -04:00
|
|
|
|
2006-04-04 20:24:57 -04:00
|
|
|
ControlProtocol::ControlProtocol (Session& s, string str)
|
2006-04-24 18:45:19 -04:00
|
|
|
: BasicUI (s),
|
2006-04-04 20:24:57 -04:00
|
|
|
_name (str)
|
|
|
|
{
|
2006-04-24 18:45:19 -04:00
|
|
|
_active = false;
|
2006-04-04 20:24:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ControlProtocol::~ControlProtocol ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
void
|
|
|
|
ControlProtocol::next_track (uint32_t initial_id)
|
|
|
|
{
|
2006-05-18 12:44:07 -04:00
|
|
|
uint32_t limit = session->nroutes();
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> cr = route_table[0];
|
2006-05-17 22:19:27 -04:00
|
|
|
uint32_t id;
|
|
|
|
|
|
|
|
if (cr) {
|
|
|
|
id = cr->remote_control_id ();
|
|
|
|
} else {
|
|
|
|
id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id == limit) {
|
|
|
|
id = 0;
|
|
|
|
} else {
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (id < limit) {
|
2006-05-18 12:44:07 -04:00
|
|
|
if ((cr = session->route_by_remote_id (id)) != 0) {
|
2006-05-17 22:19:27 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id == limit) {
|
|
|
|
id = 0;
|
|
|
|
while (id != initial_id) {
|
2006-05-18 12:44:07 -04:00
|
|
|
if ((cr = session->route_by_remote_id (id)) != 0) {
|
2006-05-17 22:19:27 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
id++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
route_table[0] = cr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::prev_track (uint32_t initial_id)
|
|
|
|
{
|
2006-05-18 12:44:07 -04:00
|
|
|
uint32_t limit = session->nroutes() - 1;
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> cr = route_table[0];
|
2006-05-17 22:19:27 -04:00
|
|
|
uint32_t id;
|
|
|
|
|
|
|
|
if (cr) {
|
|
|
|
id = cr->remote_control_id ();
|
|
|
|
} else {
|
|
|
|
id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id == 0) {
|
2006-05-18 12:44:07 -04:00
|
|
|
id = session->nroutes() - 1;
|
2006-05-17 22:19:27 -04:00
|
|
|
} else {
|
|
|
|
id--;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (id >= 0) {
|
2006-05-18 12:44:07 -04:00
|
|
|
if ((cr = session->route_by_remote_id (id)) != 0) {
|
2006-05-17 22:19:27 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
id--;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (id < 0) {
|
|
|
|
id = limit;
|
|
|
|
while (id > initial_id) {
|
2006-05-18 12:44:07 -04:00
|
|
|
if ((cr = session->route_by_remote_id (id)) != 0) {
|
2006-05-17 22:19:27 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
id--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
route_table[0] = cr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::set_route_table_size (uint32_t size)
|
|
|
|
{
|
|
|
|
while (route_table.size() < size) {
|
2006-07-27 21:08:57 -04:00
|
|
|
route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
|
2006-05-17 22:19:27 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-07-27 21:08:57 -04:00
|
|
|
ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
|
2006-05-17 22:19:27 -04:00
|
|
|
{
|
2006-07-27 21:08:57 -04:00
|
|
|
if (table_index >= route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
route_table[table_index] = r;
|
|
|
|
|
|
|
|
// XXX SHAREDPTR need to handle r->GoingAway
|
2006-05-17 22:19:27 -04:00
|
|
|
}
|
|
|
|
|
2006-05-23 15:54:52 -04:00
|
|
|
bool
|
|
|
|
ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
|
|
|
|
{
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
|
2006-05-23 15:54:52 -04:00
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-07-27 21:08:57 -04:00
|
|
|
|
|
|
|
set_route_table (table_index, r);
|
2006-05-23 15:54:52 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-05-17 22:19:27 -04:00
|
|
|
void
|
|
|
|
ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (at) {
|
|
|
|
at->set_record_enable (yn, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::route_get_rec_enable (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (at) {
|
2006-05-19 16:10:35 -04:00
|
|
|
return at->record_enabled ();
|
2006-05-17 22:19:27 -04:00
|
|
|
}
|
2006-05-19 16:10:35 -04:00
|
|
|
|
|
|
|
return false;
|
2006-05-17 22:19:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
ControlProtocol::route_get_gain (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r->gain ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::route_set_gain (uint32_t table_index, float gain)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r != 0) {
|
|
|
|
r->set_gain (gain, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
ControlProtocol::route_get_effective_gain (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r->effective_gain ();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2006-08-12 04:20:24 -04:00
|
|
|
return r->peak_meter().peak_power (which_input);
|
2006-05-17 22:19:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::route_get_muted (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r->muted ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r != 0) {
|
|
|
|
r->set_mute (yn, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::route_get_soloed (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return r->soloed ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::route_set_soloed (uint32_t table_index, bool yn)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r != 0) {
|
|
|
|
r->set_solo (yn, this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
ControlProtocol:: route_get_name (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2006-05-17 22:19:27 -04:00
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return r->name();
|
|
|
|
}
|
|
|
|
|