From 47de938e998ffceb0d9cfa829b47dad721445dc9 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 27 Apr 2010 17:10:04 +0000 Subject: add muted-by-other concept to solo support infrastructure git-svn-id: svn://localhost/ardour2/branches/3.0@7005 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/mute_master.cc | 57 ++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 4 deletions(-) (limited to 'libs/ardour/mute_master.cc') diff --git a/libs/ardour/mute_master.cc b/libs/ardour/mute_master.cc index 45499696a9..b3b3d23724 100644 --- a/libs/ardour/mute_master.cc +++ b/libs/ardour/mute_master.cc @@ -36,6 +36,8 @@ const MuteMaster::MutePoint MuteMaster::AllPoints = MutePoint (MuteMaster::PreFa MuteMaster::MuteMaster (Session&, const std::string&) : _mute_point (MutePoint (0)) + , _self_muted (false) + , _muted_by_others (0) { } @@ -66,22 +68,49 @@ MuteMaster::unmute_at (MutePoint mp) } } +void +MuteMaster::mod_muted_by_others (int32_t delta) +{ + if (delta < 0) { + if (_muted_by_others >= (uint32_t) abs (delta)) { + _muted_by_others += delta; + } else { + _muted_by_others = 0; + } + } else { + _muted_by_others += delta; + } +} + gain_t MuteMaster::mute_gain_at (MutePoint mp) const { - if (_mute_point & mp) { + if (muted_at (mp)) { return Config->get_solo_mute_gain (); } else { return 1.0; } } -int -MuteMaster::set_state (std::string mute_point) +void +MuteMaster::set_mute_points (const std::string& mute_point) { + MutePoint old = _mute_point; + _mute_point = (MutePoint) string_2_enum (mute_point, _mute_point); - return 0; + if (old != _mute_point) { + MutePointChanged(); /* EMIT SIGNAL */ + } +} + +void +MuteMaster::set_mute_points (MutePoint mp) +{ + if (_mute_point != mp) { + _mute_point = mp; + MutePointChanged (); /* EMIT SIGNAL */ + } } int @@ -93,6 +122,20 @@ MuteMaster::set_state (const XMLNode& node, int /*version*/) _mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point); } + if ((prop = node.property ("muted")) != 0) { + _self_muted = string_is_affirmative (prop->value()); + } else { + _self_muted = (_mute_point != MutePoint (0)); + } + + if ((prop = node.property ("muted-by-others")) != 0) { + if (sscanf (prop->value().c_str(), "%u", &_muted_by_others) != 1) { + _muted_by_others = 0; + } + } else { + _muted_by_others = 0; + } + return 0; } @@ -101,5 +144,11 @@ MuteMaster::get_state() { XMLNode* node = new XMLNode (X_("MuteMaster")); node->add_property ("mute-point", enum_2_string (_mute_point)); + node->add_property ("muted", (_self_muted ? X_("yes") : X_("no"))); + + char buf[32]; + snprintf (buf, sizeof (buf), "%u", _muted_by_others); + node->add_property ("muted-by-others", buf); + return *node; } -- cgit v1.2.3