SiP and "solo overrides mutes" tweak:
[ardour.git] / libs / ardour / mute_master.cc
index a58bb8a421d11edced397bd4e62c97b49d1564c1..8f81a5e672058f98fb4e92470c1deb86175f0c87 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "pbd/enumwriter.h"
 #include "pbd/xml++.h"
+#include "pbd/convert.h"
 
 #include "ardour/types.h"
 #include "ardour/mute_master.h"
 using namespace ARDOUR;
 using namespace std;
 
+const MuteMaster::MutePoint MuteMaster::AllPoints = MuteMaster::MutePoint(
+       PreFader|PostFader|Listen|Main);
+
 MuteMaster::MuteMaster (Session& s, const std::string&)
        : SessionHandleRef (s)
        , _mute_point (MutePoint (0))
         , _muted_by_self (false)
-        , _soloed (false)
+        , _soloed_by_self (false)
+        , _soloed_by_others (false)
         , _solo_ignore (false)
 {
 
@@ -73,39 +78,33 @@ MuteMaster::unmute_at (MutePoint mp)
        }
 }
 
-void
-MuteMaster::set_soloed (bool yn)
-{
-        _soloed = yn;
-}
-
 gain_t
 MuteMaster::mute_gain_at (MutePoint mp) const
 {
         gain_t gain;
 
         if (Config->get_solo_mute_override()) {
-                if (_soloed) {
-                        gain = 1.0;
+                if (_soloed_by_self) {
+                        gain = GAIN_COEFF_UNITY;
                 } else if (muted_by_self_at (mp)) {
-                        gain = 0.0;
+                        gain = GAIN_COEFF_ZERO;
                 } else {
-                        if (muted_by_others_at (mp)) {
+                        if (muted_by_others_at (mp) && !_soloed_by_others) {
                                 gain = Config->get_solo_mute_gain ();
                         } else {
-                                gain = 1.0;
+                                gain = GAIN_COEFF_UNITY;
                         }
                 }
         } else {
                 if (muted_by_self_at (mp)) {
-                        gain = 0.0;
-                } else if (_soloed) {
-                        gain = 1.0;
+                        gain = GAIN_COEFF_ZERO;
+                } else if (_soloed_by_self || _soloed_by_others) {
+                        gain = GAIN_COEFF_UNITY;
                 } else {
                         if (muted_by_others_at (mp)) {
                                 gain = Config->get_solo_mute_gain ();
                         } else {
-                                gain = 1.0;
+                                gain = GAIN_COEFF_UNITY;
                         }
                 }
         }
@@ -144,7 +143,7 @@ MuteMaster::set_state (const XMLNode& node, int /*version*/)
        }
 
        if ((prop = node.property ("muted")) != 0) {
-               _muted_by_self = string_is_affirmative (prop->value());
+               _muted_by_self = PBD::string_is_affirmative (prop->value());
        } else {
                 _muted_by_self = (_mute_point != MutePoint (0));
         }