From 52b150ba5dda50e52a5e1bfa0aeb900defce3d54 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 25 Apr 2016 12:31:18 -0400 Subject: generalize VCA assign/unassign code. Need to share this approach across Slavables --- libs/ardour/vca.cc | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'libs/ardour/vca.cc') diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc index d1e93cc403..2d1fbdec8f 100644 --- a/libs/ardour/vca.cc +++ b/libs/ardour/vca.cc @@ -164,9 +164,26 @@ VCA::clear_all_solo_state () int VCA::assign_controls (boost::shared_ptr vca) { - _gain_control->add_master (vca->gain_control()); - _solo_control->add_master (vca->solo_control()); - _mute_control->add_master (vca->mute_control()); + 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; } @@ -174,15 +191,26 @@ VCA::assign_controls (boost::shared_ptr vca) int VCA::unassign_controls (boost::shared_ptr vca) { - if (!vca) { - /* unassign from all */ - _gain_control->clear_masters (); - _solo_control->clear_masters (); - _mute_control->clear_masters (); - } else { - _gain_control->remove_master (vca->gain_control()); - _solo_control->remove_master (vca->solo_control()); - _mute_control->remove_master (vca->mute_control()); + 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