From f2d2ea4baae86318454f29edc365a9e4112d33f7 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sat, 6 Feb 2021 18:39:25 +0100 Subject: [PATCH] Refactor Solo/Mute release This is in preparation to move RoueUI::SoloMuteRelease to libardour to reuse the implementation in various places. This also prepares the solo logic for exclusive port-monitoring. --- libs/ardour/ardour/solo_mute_release.h | 59 +++++++++++++++++ libs/ardour/solo_mute_release.cc | 87 ++++++++++++++++++++++++++ libs/ardour/wscript | 1 + 3 files changed, 147 insertions(+) create mode 100644 libs/ardour/ardour/solo_mute_release.h create mode 100644 libs/ardour/solo_mute_release.cc diff --git a/libs/ardour/ardour/solo_mute_release.h b/libs/ardour/ardour/solo_mute_release.h new file mode 100644 index 0000000000..ec54733f78 --- /dev/null +++ b/libs/ardour/ardour/solo_mute_release.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2000-2019 Paul Davis + * Copyright (C) 2012-2021 Robin Gareus + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _ardour_solo_mute_release_h_ +#define _ardour_solo_mute_release_h_ + +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + +#include "ardour/libardour_visibility.h" +#include "ardour/types.h" + +namespace ARDOUR { + +class Session; + +class LIBARDOUR_API SoloMuteRelease +{ +public: + SoloMuteRelease (bool was_active); + + void set_exclusive (bool exclusive = true); + + void set (boost::shared_ptr); + void set (boost::shared_ptr); + void set (boost::shared_ptr, boost::shared_ptr); + void set (boost::shared_ptr >); + + void release (Session*, bool mute) const; + +private: + bool active; + bool exclusive; + + boost::shared_ptr routes_on; + boost::shared_ptr routes_off; + + boost::shared_ptr > port_monitors; +}; + +} // namespace ARDOUR +#endif diff --git a/libs/ardour/solo_mute_release.cc b/libs/ardour/solo_mute_release.cc new file mode 100644 index 0000000000..474884e47b --- /dev/null +++ b/libs/ardour/solo_mute_release.cc @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2000-2019 Paul Davis + * Copyright (C) 2012-2021 Robin Gareus + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "pbd/controllable.h" + +#include "ardour/audioengine.h" +#include "ardour/session.h" +#include "ardour/solo_mute_release.h" +#include "ardour/utils.h" + +using namespace PBD; +using namespace ARDOUR; + +SoloMuteRelease::SoloMuteRelease (bool was_active) + : active (was_active) + , exclusive (false) +{ +} + +void +SoloMuteRelease::set_exclusive (bool e) +{ + exclusive = e; +} + +void +SoloMuteRelease::set (boost::shared_ptr r) +{ + if (active) { + routes_on.reset (new RouteList); + routes_on->push_back (r); + } else { + routes_off.reset (new RouteList); + routes_off->push_back (r); + } +} + +void +SoloMuteRelease::set (boost::shared_ptr rl) +{ + if (active) { + routes_on = rl; + } else { + routes_off = rl; + } +} + +void +SoloMuteRelease::set (boost::shared_ptr on, boost::shared_ptr off) +{ + routes_on = on; + routes_off = off; +} + +void +SoloMuteRelease::set (boost::shared_ptr > pml) +{ + port_monitors = pml; +} + +void +SoloMuteRelease::release (Session* s, bool mute) const +{ + if (mute) { + s->set_controls (route_list_to_control_list (routes_off, &Stripable::mute_control), 0.0, exclusive ? Controllable::NoGroup : Controllable::UseGroup); + s->set_controls (route_list_to_control_list (routes_on, &Stripable::mute_control), 1.0, exclusive ? Controllable::NoGroup : Controllable::UseGroup); + } else { + s->set_controls (route_list_to_control_list (routes_off, &Stripable::solo_control), 0.0, exclusive ? Controllable::NoGroup : Controllable::UseGroup); + s->set_controls (route_list_to_control_list (routes_on, &Stripable::solo_control), 1.0, exclusive ? Controllable::NoGroup : Controllable::UseGroup); + } +} diff --git a/libs/ardour/wscript b/libs/ardour/wscript index 4146333533..a973593b15 100644 --- a/libs/ardour/wscript +++ b/libs/ardour/wscript @@ -236,6 +236,7 @@ libardour_sources = [ 'sndfilesource.cc', 'solo_control.cc', 'solo_isolate_control.cc', + 'solo_mute_release.cc', 'solo_safe_control.cc', 'soundcloud_upload.cc', 'source.cc',