more solo/mute architecture work. NOTE: changes to mute points are ignored right now

git-svn-id: svn://localhost/ardour2/branches/3.0@7009 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-04-28 01:29:06 +00:00
parent f0db054a07
commit 6dac4da983
10 changed files with 156 additions and 163 deletions

View File

@ -348,10 +348,10 @@ style "solo_button_alternate2" = "small_button"
# this is the "half-bright" solo theme
#
bg[NORMAL] = { 0.91, 0.97, 0.82 }
bg[ACTIVE] = { 0.91, 0.97, 0.82 }
bg[SELECTED] = { 0.91, 0.97, 0.82 }
bg[PRELIGHT] = { 0.91, 0.97, 0.82 }
bg[NORMAL] = { 0.752, 0.886, 0.752 }
bg[ACTIVE] = { 0.752, 0.886, 0.752 }
bg[SELECTED] = { 0.752, 0.886, 0.752 }
bg[PRELIGHT] = { 0.752, 0.886, 0.752 }
fg[ACTIVE] = { 0, 0, 0 }
fg[SELECTED] = { 0, 0, 0 }

View File

@ -247,7 +247,6 @@ RouteUI::set_route (boost::shared_ptr<Route> rp)
void
RouteUI::invert_toggled ()
{
cerr << this << " button state = " << invert_button->get_active() << " PI = " << _route->phase_invert() << endl;
_route->set_phase_invert (invert_button->get_active());
}
@ -833,9 +832,9 @@ RouteUI::mute_visual_state (Session* s, boost::shared_ptr<Route> r)
if (r->is_master() || r->is_monitor()) {
return 0;
}
if (Config->get_show_solo_mutes()) {
if (r->self_muted ()) {
/* full mute */
return 2;
@ -867,7 +866,7 @@ RouteUI::update_mute_display ()
return;
}
bool model = _route->muted();
bool model = _route->self_muted();
bool view = mute_button->get_active();
/* first make sure the button's "depressed" visual

View File

@ -81,7 +81,7 @@ Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, n
}
if (_mute_master) {
mute_gain = _mute_master->mute_gain_at (MuteMaster::PreFader);
mute_gain = _mute_master->mute_gain_at (MuteMaster::PreFader);
} else {
mute_gain = 1.0;
}

View File

@ -75,10 +75,6 @@ public:
void no_outs_cuz_we_no_monitor(bool);
void set_solo_level (int32_t sl) { _solo_level = sl; }
void set_solo_isolated (bool yn) { _solo_isolated = yn; }
void set_solo_ignored (bool yn) { _solo_ignored = yn; }
void cycle_start (nframes_t);
void increment_output_offset (nframes_t);
void transport_stopped (sframes_t frame);
@ -113,9 +109,6 @@ public:
gain_t _current_gain;
nframes_t _output_offset;
bool _no_outs_cuz_we_no_monitor;
uint32_t _solo_level;
bool _solo_isolated;
bool _solo_ignored;
boost::shared_ptr<MuteMaster> _mute_master;
bool no_panner_reset;
boost::shared_ptr<Panner> _panner;

View File

@ -48,6 +48,8 @@ class MuteMaster : public PBD::Stateful
bool muted_by_others() const { return _muted_by_others && (_mute_point != MutePoint (0)); }
bool muted() const { return (_self_muted || (_muted_by_others > 0)) && (_mute_point != MutePoint (0)); }
bool muted_at (MutePoint mp) const { return (_self_muted || (_muted_by_others > 0)) && (_mute_point & mp); }
bool self_muted_at (MutePoint mp) const { return _self_muted && (_mute_point & mp); }
bool muted_by_others_at (MutePoint mp) const { return (_muted_by_others > 0) && (_mute_point & mp); }
bool muted_pre_fader() const { return muted_at (PreFader); }
bool muted_post_fader() const { return muted_at (PostFader); }
@ -58,8 +60,8 @@ class MuteMaster : public PBD::Stateful
void set_self_muted (bool yn) { _self_muted = yn; }
void mod_muted_by_others (int delta);
void clear_muted_by_others ();
void clear_mute ();
void mute_at (MutePoint);
void unmute_at (MutePoint);
@ -67,15 +69,18 @@ class MuteMaster : public PBD::Stateful
void set_mute_points (MutePoint);
MutePoint mute_points() const { return _mute_point; }
void set_solo_level (int32_t);
PBD::Signal0<void> MutePointChanged;
XMLNode& get_state();
int set_state(const XMLNode&, int version);
private:
MutePoint _mute_point;
bool _self_muted;
uint32_t _muted_by_others;
volatile MutePoint _mute_point;
volatile bool _self_muted;
volatile uint32_t _muted_by_others;
volatile int32_t _solo_level;
};
} // namespace ARDOUR

View File

@ -476,8 +476,7 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
void placement_range (Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end);
void set_self_solo (bool yn);
void set_delivery_solo ();
void markup_solo_ignore ();
void set_mute_master_solo ();
};
} // namespace ARDOUR

View File

@ -55,9 +55,6 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Mute
, _current_gain (1.0)
, _output_offset (0)
, _no_outs_cuz_we_no_monitor (false)
, _solo_level (0)
, _solo_isolated (false)
, _solo_ignored (false)
, _mute_master (mm)
, no_panner_reset (false)
{
@ -80,9 +77,6 @@ Delivery::Delivery (Session& s, boost::shared_ptr<MuteMaster> mm, const string&
, _current_gain (1.0)
, _output_offset (0)
, _no_outs_cuz_we_no_monitor (false)
, _solo_level (0)
, _solo_isolated (false)
, _solo_ignored (false)
, _mute_master (mm)
, no_panner_reset (false)
{
@ -257,7 +251,6 @@ Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nfra
tgain = target_gain ();
if (tgain != _current_gain) {
/* target gain has changed */
Amp::apply_gain (bufs, nframes, _current_gain, tgain);
@ -297,11 +290,37 @@ Delivery::run (BufferSet& bufs, sframes_t start_frame, sframes_t end_frame, nfra
if (bufs.count().n_audio() > 0 && ports.count().n_audio () > 0) {
_output->copy_to_outputs (bufs, DataType::AUDIO, nframes, _output_offset);
}
bool silent;
for (uint32_t b = 0; b < bufs.count().n_audio(); ++b) {
AudioBuffer& ab (bufs.get_audio (b));
Sample* s = ab.data();
nframes_t n;
silent = false;
for (n = 0; nframes < nframes; ++n) {
if (s[n] != 0) {
break;
}
}
if (n == nframes) {
silent = true;
}
if (silent) {
cerr << _name << ": Buffer " << b << " is silent\n";
}
}
}
if (bufs.count().n_midi() > 0 && ports.count().n_midi () > 0) {
_output->copy_to_outputs (bufs, DataType::MIDI, nframes, _output_offset);
}
}
out:
@ -488,49 +507,36 @@ Delivery::target_gain ()
gain_t desired_gain = -1.0f;
if (_solo_level || _solo_ignored) {
desired_gain = 1.0;
} else {
if (_role == Listen && _session.monitor_out() && !_session.soloing()) {
/* nobody is soloed, so control/monitor/listen bus gets its
signal from master out, we should be silent
*/
desired_gain = 0.0;
} else {
MuteMaster::MutePoint mp;
switch (_role) {
case Main:
mp = MuteMaster::Main;
break;
case Listen:
mp = MuteMaster::Listen;
break;
case Send:
case Insert:
case Aux:
/* XXX FIX ME this is wrong, we need per-delivery muting */
mp = MuteMaster::PreFader;
break;
}
if (!_solo_isolated && _session.soloing()) {
desired_gain = min (Config->get_solo_mute_gain(), _mute_master->mute_gain_at (mp));
} else {
desired_gain = _mute_master->mute_gain_at (mp);
}
}
MuteMaster::MutePoint mp;
switch (_role) {
case Main:
mp = MuteMaster::Main;
break;
case Listen:
mp = MuteMaster::Listen;
break;
case Send:
case Insert:
case Aux:
/* XXX FIX ME this is wrong, we need per-delivery muting */
mp = MuteMaster::PreFader;
break;
}
desired_gain = _mute_master->mute_gain_at (mp);
if (_role == Listen && _session.monitor_out() && !_session.listening()) {
/* nobody is soloed, and this delivery is a listen-send to the
control/monitor/listen bus, we should be silent since
it gets its signal from the master out.
*/
desired_gain = 0.0;
}
return desired_gain;
}

View File

@ -28,6 +28,7 @@
#include "i18n.h"
using namespace ARDOUR;
using namespace std;
const MuteMaster::MutePoint MuteMaster::AllPoints = MutePoint (MuteMaster::PreFader|
MuteMaster::PostFader|
@ -35,26 +36,18 @@ const MuteMaster::MutePoint MuteMaster::AllPoints = MutePoint (MuteMaster::PreFa
MuteMaster::Main);
MuteMaster::MuteMaster (Session&, const std::string&)
: _mute_point (MutePoint (0))
: _mute_point (AllPoints)
, _self_muted (false)
, _muted_by_others (0)
{
}
void
MuteMaster::clear_mute ()
{
if (_mute_point != MutePoint (0)) {
_mute_point = MutePoint (0);
MutePointChanged (); // EMIT SIGNAL
}
}
void
MuteMaster::mute_at (MutePoint mp)
{
if ((_mute_point & mp) != mp) {
_mute_point = MutePoint (_mute_point | mp);
cerr << "Mute point set, now " << _mute_point << endl;
MutePointChanged (); // EMIT SIGNAL
}
}
@ -64,10 +57,17 @@ MuteMaster::unmute_at (MutePoint mp)
{
if ((_mute_point & mp) == mp) {
_mute_point = MutePoint (_mute_point & ~mp);
cerr << "Mute point unset, now " << _mute_point << endl;
MutePointChanged (); // EMIT SIGNAL
}
}
void
MuteMaster::clear_muted_by_others ()
{
_muted_by_others = 0;
}
void
MuteMaster::mod_muted_by_others (int32_t delta)
{
@ -82,14 +82,45 @@ MuteMaster::mod_muted_by_others (int32_t delta)
}
}
void
MuteMaster::set_solo_level (int32_t l)
{
_solo_level = l;
}
gain_t
MuteMaster::mute_gain_at (MutePoint mp) const
{
if (muted_at (mp)) {
return Config->get_solo_mute_gain ();
} else {
return 1.0;
}
gain_t gain;
int32_t l = _solo_level;
if (Config->get_solo_mute_override()) {
if (l == 2) { // self-soloed
gain = 1.0;
} else if (self_muted_at (mp)) { // self-muted
gain = Config->get_solo_mute_gain ();
} else if (l == 1) { // soloed by others
gain = 1.0;
} else if (muted_by_others_at (mp)) { // muted by others
gain = Config->get_solo_mute_gain ();
} else {
gain = 1.0;
}
} else {
if (self_muted_at (mp)) { // self-muted
gain = Config->get_solo_mute_gain ();
} else if (l == 2) { // self-soloed
gain = 1.0;
} else if (muted_by_others_at (mp)) { // muted by others
gain = Config->get_solo_mute_gain ();
} else if (l == 1) { // soloed by others
gain = 1.0;
} else {
gain = 1.0;
}
}
return gain;
}
void
@ -98,6 +129,7 @@ MuteMaster::set_mute_points (const std::string& mute_point)
MutePoint old = _mute_point;
_mute_point = (MutePoint) string_2_enum (mute_point, _mute_point);
cerr << "Mute point set from string, now " << _mute_point << endl;
if (old != _mute_point) {
MutePointChanged(); /* EMIT SIGNAL */
@ -109,6 +141,7 @@ MuteMaster::set_mute_points (MutePoint mp)
{
if (_mute_point != mp) {
_mute_point = mp;
cerr << "Mute point set from mp, now " << _mute_point << endl;
MutePointChanged (); /* EMIT SIGNAL */
}
}
@ -119,7 +152,8 @@ MuteMaster::set_state (const XMLNode& node, int /*version*/)
const XMLProperty* prop;
if ((prop = node.property ("mute-point")) != 0) {
_mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
//_mute_point = (MutePoint) string_2_enum (prop->value(), _mute_point);
cerr << "Mute point set from STATE string, now " << _mute_point << endl;
}
if ((prop = node.property ("muted")) != 0) {

View File

@ -161,8 +161,6 @@ Route::init ()
_main_outs->panner()->set_bypassed (true);
}
markup_solo_ignore ();
/* now that we have _meter, its safe to connect to this */
Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this)));
@ -529,10 +527,8 @@ Route::set_listen (bool yn, void* src)
if (_monitor_send) {
if (yn != _monitor_send->active()) {
if (yn) {
_monitor_send->set_solo_level (1);
_monitor_send->activate ();
} else {
_monitor_send->set_solo_level (0);
_monitor_send->deactivate ();
}
@ -580,7 +576,7 @@ Route::set_solo (bool yn, void *src)
if (self_soloed() != yn) {
set_self_solo (yn);
set_delivery_solo ();
set_mute_master_solo ();
solo_changed (true, src); /* EMIT SIGNAL */
_solo_control->Changed (); /* EMIT SIGNAL */
}
@ -609,27 +605,24 @@ Route::mod_solo_by_others (int32_t delta)
_soloed_by_others += delta;
}
set_delivery_solo ();
set_mute_master_solo ();
solo_changed (false, this);
}
void
Route::set_delivery_solo ()
Route::set_mute_master_solo ()
{
/* tell all delivery processors what the solo situation is, so that they keep
delivering even though Session::soloing() is true and they were not
explicitly soloed.
*/
int32_t level;
Glib::RWLock::ReaderLock rm (_processor_lock);
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
boost::shared_ptr<Delivery> d;
if ((d = boost::dynamic_pointer_cast<Delivery> (*i)) != 0) {
d->set_solo_level (soloed ());
d->set_solo_isolated (solo_isolated());
}
}
if (self_soloed()) {
level = 2;
} else if (soloed_by_others()) {
level = 1;
} else {
level = 0;
}
_mute_master->set_solo_level (level);
}
void
@ -648,34 +641,30 @@ Route::set_solo_isolated (bool yn, void *src)
boost::shared_ptr<RouteList> routes = _session.get_routes ();
for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
continue;
}
bool sends_only;
bool does_feed = direct_feeds (*i, &sends_only);
bool does_feed = direct_feeds (*i, &sends_only); // we will recurse anyway, so don't use ::feeds()
if (does_feed && !sends_only) {
(*i)->set_solo_isolated (yn, (*i)->route_group());
}
}
/* XXX should we back-propagate as well? */
bool changed = false;
/* XXX should we back-propagate as well? (April 2010: myself and chris goddard think not) */
if (yn) {
if (_solo_isolated == 0) {
changed = true;
}
_solo_isolated++;
_mute_master->clear_muted_by_others ();
} else {
changed = (_solo_isolated == 1);
if (_solo_isolated > 0) {
_solo_isolated--;
}
}
if (changed) {
set_delivery_solo ();
solo_isolated_changed (src);
}
}
bool
@ -687,14 +676,12 @@ Route::solo_isolated () const
void
Route::set_mute_points (MuteMaster::MutePoint mp)
{
if (mp != _mute_points) {
_mute_points = mp;
_mute_master->set_mute_points (_mute_points);
mute_points_changed (); /* EMIT SIGNAL */
if (_mute_master->muted()) {
mute_changed (this); /* EMIT SIGNAL */
}
_mute_points = mp;
_mute_master->set_mute_points (MuteMaster::AllPoints);
mute_points_changed (); /* EMIT SIGNAL */
if (_mute_master->muted()) {
mute_changed (this); /* EMIT SIGNAL */
}
}
@ -735,6 +722,10 @@ Route::mod_muted_by_others (int delta)
{
bool old = muted ();
if (_solo_isolated) {
return;
}
_mute_master->mod_muted_by_others (delta);
if (old != muted()) {
@ -846,12 +837,6 @@ Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::ite
if (isend && _session.monitor_out() && (isend->target_id() == _session.monitor_out()->id())) {
_monitor_send = isend;
if (_monitor_send->active()) {
_monitor_send->set_solo_level (1);
} else {
_monitor_send->set_solo_level (0);
}
}
if (activation_allowed && (processor != _monitor_send)) {
@ -1940,7 +1925,7 @@ Route::_set_state_2X (const XMLNode& node, int version)
bool first = true;
bool muted = string_is_affirmative (prop->value());
if(muted){
if (muted){
string mute_point;
@ -2270,30 +2255,9 @@ Route::set_processor_state (const XMLNode& node)
}
}
markup_solo_ignore ();
processors_changed (RouteProcessorChange ());
}
void
Route::markup_solo_ignore ()
{
Glib::RWLock::ReaderLock lm (_processor_lock);
for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
/* all delivery processors on master, monitor and auditioner never ever pay attention to solo
*/
boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery>(*p);
if (d && (is_master() || is_monitor() || is_hidden())) {
cerr << _name << " Found a delivery unit, mark solo ignored\n";
d->set_solo_ignored (true);
}
}
}
void
Route::curve_reallocate ()
{
@ -2393,11 +2357,6 @@ Route::listen_via (boost::shared_ptr<Route> route, Placement placement, bool /*a
if (route == _session.monitor_out()) {
_monitor_send = boost::dynamic_pointer_cast<Delivery>(d);
if (_monitor_send->active()) {
_monitor_send->set_solo_level (1);
} else {
_monitor_send->set_solo_level (0);
}
}
/* already listening via the specified IO: do nothing */
@ -3029,7 +2988,7 @@ Route::MuteControllable::set_value (float val)
float
Route::MuteControllable::get_value (void) const
{
return route.muted() ? 1.0f : 0.0f;
return route.self_muted() ? 1.0f : 0.0f;
}
void

View File

@ -2205,7 +2205,6 @@ Session::route_solo_changed (bool self_solo_change, void* /*src*/, boost::weak_p
if ((*i)->feeds (route, &via_sends_only)) {
if (!via_sends_only) {
(*i)->mod_solo_by_others (delta);
(*i)->mod_muted_by_others (-delta);
in_signal_flow = true;
}
}
@ -2220,7 +2219,6 @@ Session::route_solo_changed (bool self_solo_change, void* /*src*/, boost::weak_p
if (route->feeds (*i, &via_sends_only)) {
(*i)->mod_solo_by_others (delta);
(*i)->mod_muted_by_others (-delta);
in_signal_flow = true;
}