From f485cfa324717f57b9f820f43f1b53307b96a8b9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 25 Apr 2016 13:41:38 -0400 Subject: rearrange inheritance so that Automatable IS-A Slavable Share assign code via Slavable; add visibility tags to Slavable+SlavableAutomationControl --- libs/ardour/slavable.cc | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'libs/ardour/slavable.cc') diff --git a/libs/ardour/slavable.cc b/libs/ardour/slavable.cc index 7a7b8e2919..4a759f5fef 100644 --- a/libs/ardour/slavable.cc +++ b/libs/ardour/slavable.cc @@ -26,6 +26,7 @@ #include "pbd/xml++.h" #include "ardour/slavable.h" +#include "ardour/slavable_automation_control.h" #include "ardour/vca.h" #include "ardour/vca_manager.h" @@ -127,3 +128,59 @@ Slavable::unassign (boost::shared_ptr v) (void) unassign_controls (v); _masters.erase (v->number()); } + +int +Slavable::assign_controls (boost::shared_ptr vca) +{ + boost::shared_ptr slave; + boost::shared_ptr master; + AutomationType types[] = { + GainAutomation, + SoloAutomation, + MuteAutomation, + RecEnableAutomation, + MonitoringAutomation, + NullAutomation + }; + + for (uint32_t n = 0; types[n] != NullAutomation; ++n) { + + slave = boost::dynamic_pointer_cast (automation_control (types[n])); + master = vca->automation_control (types[n]); + + if (slave && master) { + slave->add_master (master); + } + } + + return 0; +} + +int +Slavable::unassign_controls (boost::shared_ptr vca) +{ + boost::shared_ptr slave; + boost::shared_ptr master; + AutomationType types[] = { + GainAutomation, + SoloAutomation, + MuteAutomation, + RecEnableAutomation, + MonitoringAutomation, + NullAutomation + }; + + for (uint32_t n = 0; types[n] != NullAutomation; ++n) { + + slave = boost::dynamic_pointer_cast (automation_control (types[n])); + if (!vca) { + /* unassign from all */ + slave->clear_masters (); + } else { + slave->remove_master (master); + } + } + + return 0; +} + -- cgit v1.2.3