2008-06-02 17:41:35 -04:00
|
|
|
/*
|
2015-10-04 14:51:05 -04:00
|
|
|
Copyright (C) 2006 Paul Davis
|
2008-06-02 17:41:35 -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.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
#include "pbd/error.h"
|
|
|
|
|
2016-01-12 22:04:18 -05:00
|
|
|
#include "ardour/gain_control.h"
|
2009-06-09 16:21:19 -04:00
|
|
|
#include "ardour/session.h"
|
2016-05-27 16:11:55 -04:00
|
|
|
#include "ardour/record_enable_control.h"
|
2009-06-09 16:21:19 -04:00
|
|
|
#include "ardour/route.h"
|
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/meter.h"
|
|
|
|
#include "ardour/amp.h"
|
|
|
|
#include "control_protocol/control_protocol.h"
|
2008-06-02 17:41:35 -04:00
|
|
|
|
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace std;
|
2009-12-21 13:23:07 -05:00
|
|
|
using namespace PBD;
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2009-12-21 13:23:07 -05:00
|
|
|
Signal0<void> ControlProtocol::ZoomToSession;
|
|
|
|
Signal0<void> ControlProtocol::ZoomOut;
|
|
|
|
Signal0<void> ControlProtocol::ZoomIn;
|
|
|
|
Signal0<void> ControlProtocol::Enter;
|
2012-04-09 11:50:38 -04:00
|
|
|
Signal0<void> ControlProtocol::Undo;
|
|
|
|
Signal0<void> ControlProtocol::Redo;
|
2009-12-21 13:23:07 -05:00
|
|
|
Signal1<void,float> ControlProtocol::ScrollTimeline;
|
2012-04-09 14:53:51 -04:00
|
|
|
Signal1<void,uint32_t> ControlProtocol::GotoView;
|
|
|
|
Signal0<void> ControlProtocol::CloseDialog;
|
|
|
|
PBD::Signal0<void> ControlProtocol::VerticalZoomInAll;
|
|
|
|
PBD::Signal0<void> ControlProtocol::VerticalZoomOutAll;
|
|
|
|
PBD::Signal0<void> ControlProtocol::VerticalZoomInSelected;
|
|
|
|
PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
|
2016-05-16 16:36:01 -04:00
|
|
|
PBD::Signal0<void> ControlProtocol::StepTracksDown;
|
|
|
|
PBD::Signal0<void> ControlProtocol::StepTracksUp;
|
|
|
|
|
|
|
|
PBD::Signal1<void,StripableNotificationListPtr> ControlProtocol::StripableSelectionChanged;
|
2016-06-10 13:47:41 -04:00
|
|
|
PBD::Signal1<void,uint64_t> ControlProtocol::AddStripableSelection;
|
2016-05-16 16:36:01 -04:00
|
|
|
PBD::Signal1<void,uint64_t> ControlProtocol::SetStripableSelection;
|
|
|
|
PBD::Signal1<void,uint64_t> ControlProtocol::ToggleStripableSelection;
|
|
|
|
PBD::Signal0<void> ControlProtocol::ClearStripableSelection;
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
|
2013-12-21 15:27:57 -05:00
|
|
|
const std::string ControlProtocol::state_node_name ("Protocol");
|
|
|
|
|
2012-04-23 06:54:34 -04:00
|
|
|
ControlProtocol::ControlProtocol (Session& s, string str)
|
|
|
|
: BasicUI (s)
|
|
|
|
, _name (str)
|
|
|
|
, _active (false)
|
2008-06-02 17:41:35 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ControlProtocol::~ControlProtocol ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-12-21 15:27:57 -05:00
|
|
|
int
|
|
|
|
ControlProtocol::set_active (bool yn)
|
|
|
|
{
|
|
|
|
_active = yn;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
void
|
|
|
|
ControlProtocol::next_track (uint32_t initial_id)
|
|
|
|
{
|
2016-05-16 07:30:28 -04:00
|
|
|
// STRIPABLE route_table[0] = _session->get_nth_stripable (++initial_id, RemoteControlID::Route);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::prev_track (uint32_t initial_id)
|
|
|
|
{
|
2016-05-16 07:30:28 -04:00
|
|
|
if (!initial_id) {
|
|
|
|
return;
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
2016-05-16 07:30:28 -04:00
|
|
|
// STRIPABLE route_table[0] = _session->get_nth_stripable (--initial_id, RemoteControlID::Route);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::set_route_table_size (uint32_t size)
|
|
|
|
{
|
|
|
|
while (route_table.size() < size) {
|
|
|
|
route_table.push_back (boost::shared_ptr<Route> ((Route*) 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::set_route_table (uint32_t table_index, boost::shared_ptr<ARDOUR::Route> r)
|
|
|
|
{
|
|
|
|
if (table_index >= route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
route_table[table_index] = r;
|
|
|
|
|
|
|
|
// XXX SHAREDPTR need to handle r->GoingAway
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::set_route_table (uint32_t table_index, uint32_t remote_control_id)
|
|
|
|
{
|
2016-05-16 07:30:28 -04:00
|
|
|
#if 0 // STRIPABLE
|
2008-06-02 17:41:35 -04:00
|
|
|
boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
|
|
|
|
|
|
|
|
if (!r) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_route_table (table_index, r);
|
2016-05-16 07:30:28 -04:00
|
|
|
#endif
|
2008-06-02 17:41:35 -04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::route_set_rec_enable (uint32_t table_index, bool yn)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
|
|
|
|
|
|
|
|
if (at) {
|
2016-04-08 16:49:47 -04:00
|
|
|
at->rec_enable_control()->set_value (1.0, Controllable::UseGroup);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::route_get_rec_enable (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
|
|
|
|
|
|
|
|
if (at) {
|
2016-04-08 16:49:47 -04:00
|
|
|
return at->rec_enable_control()->get_value();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
ControlProtocol::route_get_gain (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2016-01-25 11:48:43 -05:00
|
|
|
return r->gain_control()->get_value();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::route_set_gain (uint32_t table_index, float gain)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
2015-10-05 10:17:49 -04:00
|
|
|
|
2008-06-02 17:41:35 -04:00
|
|
|
if (r != 0) {
|
2016-04-08 16:49:47 -04:00
|
|
|
r->gain_control()->set_value (gain, Controllable::UseGroup);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
float
|
|
|
|
ControlProtocol::route_get_effective_gain (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2009-06-09 16:21:19 -04:00
|
|
|
return r->amp()->gain_control()->get_value();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float
|
|
|
|
ControlProtocol::route_get_peak_input_power (uint32_t table_index, uint32_t which_input)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return 0.0f;
|
|
|
|
}
|
|
|
|
|
2016-03-07 15:00:17 -05:00
|
|
|
return r->peak_meter()->meter_level (which_input, MeterPeak);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::route_get_muted (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-04-08 16:49:47 -04:00
|
|
|
return r->mute_control()->muted ();
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ControlProtocol::route_set_muted (uint32_t table_index, bool yn)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r != 0) {
|
2016-04-08 16:49:47 -04:00
|
|
|
r->mute_control()->set_value (yn ? 1.0 : 0.0, Controllable::UseGroup);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
ControlProtocol::route_get_soloed (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r != 0) {
|
2016-04-08 16:49:47 -04:00
|
|
|
r->solo_control()->set_value (yn ? 1.0 : 0.0, Controllable::UseGroup);
|
2008-06-02 17:41:35 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string
|
|
|
|
ControlProtocol:: route_get_name (uint32_t table_index)
|
|
|
|
{
|
|
|
|
if (table_index > route_table.size()) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
boost::shared_ptr<Route> r = route_table[table_index];
|
|
|
|
|
|
|
|
if (r == 0) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return r->name();
|
|
|
|
}
|
|
|
|
|
2010-07-29 22:09:39 -04:00
|
|
|
list<boost::shared_ptr<Bundle> >
|
|
|
|
ControlProtocol::bundles ()
|
|
|
|
{
|
2013-12-21 15:27:57 -05:00
|
|
|
return list<boost::shared_ptr<Bundle> > ();
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLNode&
|
|
|
|
ControlProtocol::get_state ()
|
|
|
|
{
|
|
|
|
XMLNode* node = new XMLNode (state_node_name);
|
|
|
|
|
|
|
|
node->add_property ("name", _name);
|
2015-06-24 13:46:07 -04:00
|
|
|
node->add_property ("feedback", get_feedback() ? "yes" : "no");
|
2013-12-21 15:27:57 -05:00
|
|
|
|
|
|
|
return *node;
|
2010-07-29 22:09:39 -04:00
|
|
|
}
|
2015-06-24 13:46:07 -04:00
|
|
|
|
|
|
|
int
|
|
|
|
ControlProtocol::set_state (XMLNode const & node, int /* version */)
|
|
|
|
{
|
|
|
|
const XMLProperty* prop;
|
|
|
|
|
|
|
|
if ((prop = node.property ("feedback")) != 0) {
|
|
|
|
set_feedback (string_is_affirmative (prop->value()));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|