/*
- Copyright (C) 2006 Paul Davis
+ Copyright (C) 2006 Paul Davis
This program is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser
#include "pbd/error.h"
+#include "ardour/gain_control.h"
#include "ardour/session.h"
+#include "ardour/record_enable_control.h"
#include "ardour/route.h"
#include "ardour/audio_track.h"
#include "ardour/meter.h"
PBD::Signal0<void> ControlProtocol::VerticalZoomOutAll;
PBD::Signal0<void> ControlProtocol::VerticalZoomInSelected;
PBD::Signal0<void> ControlProtocol::VerticalZoomOutSelected;
-PBD::Signal1<void,RouteNotificationListPtr> ControlProtocol::TrackSelectionChanged;
-PBD::Signal1<void,uint32_t> ControlProtocol::AddRouteToSelection;
-PBD::Signal1<void,uint32_t> ControlProtocol::SetRouteSelection;
-PBD::Signal1<void,uint32_t> ControlProtocol::RemoveRouteFromSelection;
-PBD::Signal0<void> ControlProtocol::ClearRouteSelection;
PBD::Signal0<void> ControlProtocol::StepTracksDown;
PBD::Signal0<void> ControlProtocol::StepTracksUp;
+PBD::Signal1<void,StripableNotificationListPtr> ControlProtocol::StripableSelectionChanged;
+PBD::Signal1<void,uint64_t> ControlProtocol::AddStripableSelection;
+PBD::Signal1<void,uint64_t> ControlProtocol::SetStripableSelection;
+PBD::Signal1<void,uint64_t> ControlProtocol::ToggleStripableSelection;
+PBD::Signal0<void> ControlProtocol::ClearStripableSelection;
+
+
+const std::string ControlProtocol::state_node_name ("Protocol");
+
ControlProtocol::ControlProtocol (Session& s, string str)
: BasicUI (s)
, _name (str)
{
}
+int
+ControlProtocol::set_active (bool yn)
+{
+ _active = yn;
+ return 0;
+}
+
void
ControlProtocol::next_track (uint32_t initial_id)
{
- uint32_t limit = session->nroutes();
- boost::shared_ptr<Route> cr = route_table[0];
- uint32_t id;
-
- if (cr) {
- id = cr->remote_control_id ();
- } else {
- id = 0;
- }
-
- if (id == limit) {
- id = 0;
- } else {
- id++;
- }
-
- while (id <= limit) {
- if ((cr = session->route_by_remote_id (id)) != 0) {
- break;
- }
- id++;
- }
-
- if (id >= limit) {
- id = 0;
- while (id != initial_id) {
- if ((cr = session->route_by_remote_id (id)) != 0) {
- break;
- }
- id++;
- }
- }
-
- route_table[0] = cr;
+ // STRIPABLE route_table[0] = _session->get_nth_stripable (++initial_id, RemoteControlID::Route);
}
void
ControlProtocol::prev_track (uint32_t initial_id)
{
- uint32_t limit = session->nroutes();
- boost::shared_ptr<Route> cr = route_table[0];
- int32_t id;
-
- if (cr) {
- id = cr->remote_control_id ();
- } else {
- id = 0;
- }
-
- if (id == 0) {
- id = limit;
- } else {
- id--;
- }
-
- while (id >= 0) {
- if ((cr = session->route_by_remote_id (id)) != 0) {
- break;
- }
- id--;
- }
-
- if (id < 0) {
- uint32_t i = limit;
- while (i > initial_id) {
- if ((cr = session->route_by_remote_id (i)) != 0) {
- break;
- }
- i--;
- }
+ if (!initial_id) {
+ return;
}
-
- route_table[0] = cr;
+ // STRIPABLE route_table[0] = _session->get_nth_stripable (--initial_id, RemoteControlID::Route);
}
-
void
ControlProtocol::set_route_table_size (uint32_t size)
{
if (table_index >= route_table.size()) {
return;
}
-
+
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)
{
+#if 0 // STRIPABLE
boost::shared_ptr<Route> r = session->route_by_remote_id (remote_control_id);
if (!r) {
}
set_route_table (table_index, r);
-
+#endif
return true;
}
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
if (at) {
- at->set_record_enabled (yn, this);
+ at->rec_enable_control()->set_value (1.0, Controllable::UseGroup);
}
}
boost::shared_ptr<AudioTrack> at = boost::dynamic_pointer_cast<AudioTrack>(r);
if (at) {
- return at->record_enabled ();
+ return at->rec_enable_control()->get_value();
}
return false;
return 0.0f;
}
- return r->amp()->gain ();
+ return r->gain_control()->get_value();
}
void
}
boost::shared_ptr<Route> r = route_table[table_index];
-
+
if (r != 0) {
- r->set_gain (gain, this);
+ r->gain_control()->set_value (gain, Controllable::UseGroup);
}
}
return 0.0f;
}
- return r->peak_meter().peak_power (which_input);
+ return r->peak_meter()->meter_level (which_input, MeterPeak);
}
-
bool
ControlProtocol::route_get_muted (uint32_t table_index)
{
return false;
}
- return r->muted ();
+ return r->mute_control()->muted ();
}
void
boost::shared_ptr<Route> r = route_table[table_index];
if (r != 0) {
- r->set_mute (yn, this);
+ r->mute_control()->set_value (yn ? 1.0 : 0.0, Controllable::UseGroup);
}
}
boost::shared_ptr<Route> r = route_table[table_index];
if (r != 0) {
- r->set_solo (yn, this);
+ r->solo_control()->set_value (yn ? 1.0 : 0.0, Controllable::UseGroup);
}
}
list<boost::shared_ptr<Bundle> >
ControlProtocol::bundles ()
{
- return list<boost::shared_ptr<Bundle> > ();
+ return list<boost::shared_ptr<Bundle> > ();
+}
+
+XMLNode&
+ControlProtocol::get_state ()
+{
+ XMLNode* node = new XMLNode (state_node_name);
+
+ node->add_property ("name", _name);
+ node->add_property ("feedback", get_feedback() ? "yes" : "no");
+
+ return *node;
+}
+
+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;
}