summaryrefslogtreecommitdiff
path: root/libs/ardour/solo_isolate_control.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-04-08 16:51:34 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-31 15:30:40 -0400
commit4aa1c242ab1e1bf4fc3575c5d88a22824976a04f (patch)
treef71d4c56255a9c72bfd582668d03caed1d2c731c /libs/ardour/solo_isolate_control.cc
parent653ae4acd639fef149314fe6f8c7a0d862afae40 (diff)
add new files to source tree
Diffstat (limited to 'libs/ardour/solo_isolate_control.cc')
-rw-r--r--libs/ardour/solo_isolate_control.cc180
1 files changed, 180 insertions, 0 deletions
diff --git a/libs/ardour/solo_isolate_control.cc b/libs/ardour/solo_isolate_control.cc
new file mode 100644
index 0000000000..d85a973ba3
--- /dev/null
+++ b/libs/ardour/solo_isolate_control.cc
@@ -0,0 +1,180 @@
+/*
+ Copyright (C) 2016 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU 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.
+*/
+
+#include "ardour/debug.h"
+#include "ardour/mute_master.h"
+#include "ardour/session.h"
+#include "ardour/solo_isolate_control.h"
+
+#include "i18n.h"
+
+using namespace ARDOUR;
+using namespace std;
+using namespace PBD;
+
+SoloIsolateControl::SoloIsolateControl (Session& session, std::string const & name, Soloable& s, Muteable& m)
+ : SlavableAutomationControl (session, SoloAutomation, ParameterDescriptor (SoloIsolateAutomation),
+ boost::shared_ptr<AutomationList>(new AutomationList(Evoral::Parameter(SoloIsolateAutomation))),
+ name)
+ , _soloable (s)
+ , _muteable (m)
+ , _solo_isolated (false)
+ , _solo_isolated_by_upstream (0)
+{
+ _list->set_interpolation (Evoral::ControlList::Discrete);
+ /* isolate changes must be synchronized by the process cycle */
+ set_flags (Controllable::Flag (flags() | Controllable::RealTime));
+}
+
+void
+SoloIsolateControl::master_changed (bool from_self, PBD::Controllable::GroupControlDisposition gcd)
+{
+ if (!_soloable.can_solo()) {
+ return;
+ }
+
+ bool master_soloed;
+
+ {
+ Glib::Threads::RWLock::ReaderLock lm (master_lock);
+ master_soloed = (bool) get_masters_value_locked ();
+ }
+
+ /* Master is considered equivalent to an upstream solo control, not
+ * direct control over self-soloed.
+ */
+
+ mod_solo_isolated_by_upstream (master_soloed ? 1 : -1);
+
+ /* no need to call AutomationControl::master_changed() since it just
+ emits Changed() which we already did in mod_solo_by_others_upstream()
+ */
+}
+
+void
+SoloIsolateControl::mod_solo_isolated_by_upstream (int32_t delta)
+{
+ bool old = solo_isolated ();
+ DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod_solo_isolated_by_upstream cur: %2 d: %3\n",
+ name(), _solo_isolated_by_upstream, delta));
+
+ if (delta < 0) {
+ if (_solo_isolated_by_upstream >= (uint32_t) abs(delta)) {
+ _solo_isolated_by_upstream += delta;
+ } else {
+ _solo_isolated_by_upstream = 0;
+ }
+ } else {
+ _solo_isolated_by_upstream += delta;
+ }
+
+ if (solo_isolated() != old) {
+ /* solo isolated status changed */
+ _muteable.mute_master()->set_solo_ignore (solo_isolated());
+ Changed (false, Controllable::NoGroup); /* EMIT SIGNAL */
+ }
+}
+
+void
+SoloIsolateControl::actually_set_value (double val, PBD::Controllable::GroupControlDisposition gcd)
+{
+ if (!_soloable.can_solo()) {
+ return;
+ }
+
+ set_solo_isolated (val == 0.0 ? false : true, gcd);
+
+ /* this sets the Evoral::Control::_user_value for us, which will
+ be retrieved by AutomationControl::get_value (), and emits Changed
+ */
+
+ AutomationControl::actually_set_value (val, gcd);
+ _session.set_dirty ();
+}
+
+void
+SoloIsolateControl::set_solo_isolated (bool yn, Controllable::GroupControlDisposition group_override)
+{
+ if (_soloable.can_solo()) {
+ return;
+ }
+
+ bool changed = false;
+
+ if (yn) {
+ if (_solo_isolated == false) {
+ _muteable.mute_master()->set_solo_ignore (true);
+ changed = true;
+ }
+ _solo_isolated = true;
+ } else {
+ if (_solo_isolated == true) {
+ _solo_isolated = false;
+ _muteable.mute_master()->set_solo_ignore (false);
+ changed = true;
+ }
+ }
+
+
+ if (!changed) {
+ return;
+ }
+
+ _soloable.push_solo_isolate_upstream (yn ? 1 : -1);
+
+ /* XXX should we back-propagate as well? (April 2010: myself and chris goddard think not) */
+
+ Changed (true, group_override); /* EMIT SIGNAL */
+}
+
+
+double
+SoloIsolateControl::get_value () const
+{
+ if (slaved()) {
+ Glib::Threads::RWLock::ReaderLock lm (master_lock);
+ return get_masters_value_locked () ? 1.0 : 0.0;
+ }
+
+ if (_list && boost::dynamic_pointer_cast<AutomationList>(_list)->automation_playback()) {
+ // Playing back automation, get the value from the list
+ return AutomationControl::get_value();
+ }
+
+ return solo_isolated () ? 1.0 : 0.0;
+}
+
+int
+SoloIsolateControl::set_state (XMLNode const & node, int)
+{
+ XMLProperty const * prop;
+
+ if ((prop = node.property ("solo-isolated")) != 0) {
+ _solo_isolated = string_is_affirmative (prop->value());
+ }
+
+ return 0;
+}
+
+XMLNode&
+SoloIsolateControl::get_state ()
+{
+ XMLNode& node (SlavableAutomationControl::get_state());
+ node.add_property (X_("solo-isolated"), _solo_isolated ? X_("yes") : X_("no"));
+ return node;
+}