diff options
-rw-r--r-- | libs/ardour/ardour/route.h | 2 | ||||
-rw-r--r-- | libs/ardour/ardour/track.h | 8 | ||||
-rw-r--r-- | libs/ardour/route.cc | 13 | ||||
-rw-r--r-- | libs/ardour/track.cc | 80 |
4 files changed, 103 insertions, 0 deletions
diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 94b856f3f4..2df8ce4414 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -203,6 +203,8 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, } } + boost::shared_ptr<Processor> processor_by_id (PBD::ID) const; + boost::shared_ptr<Processor> nth_plugin (uint32_t n); boost::shared_ptr<Processor> nth_send (uint32_t n); diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 52120d1627..79e968c8ed 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -165,6 +165,10 @@ class Track : public Route, public PublicDiskstream boost::shared_ptr<Diskstream> _diskstream; MeterPoint _saved_meter_point; + /** used to keep track of processors that we are deactivating during record, + if `do-not-record-plugins' is enabled. + */ + std::list<boost::weak_ptr<Processor> > _deactivated_processors; TrackMode _mode; bool _needs_butler; MonitorChoice _monitoring; @@ -223,6 +227,10 @@ private: void diskstream_record_enable_changed (); void diskstream_speed_changed (); void diskstream_alignment_style_changed (); + + void parameter_changed (std::string); + void deactivate_visible_processors (); + void activate_deactivated_processors (); }; }; /* namespace ARDOUR*/ diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 58589acfee..adeda63972 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -3908,3 +3908,16 @@ Route::maybe_note_meter_position () } } } + +boost::shared_ptr<Processor> +Route::processor_by_id (PBD::ID id) const +{ + Glib::RWLock::ReaderLock lm (_processor_lock); + for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) { + if ((*i)->id() == id) { + return *i; + } + } + + return boost::shared_ptr<Processor> (); +} diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index d2274e5039..9d6b82e4c0 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -48,6 +48,8 @@ Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, Data { _freeze_record.state = NoFreeze; _declickable = true; + + Config->ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1)); } Track::~Track () @@ -79,6 +81,20 @@ Track::state (bool full) root.add_property (X_("saved-meter-point"), enum_2_string (_saved_meter_point)); root.add_child_nocopy (_rec_enable_control->get_state()); root.add_child_nocopy (_diskstream->get_state ()); + + if (!_deactivated_processors.empty ()) { + XMLNode* node = new XMLNode (X_("DeactivatedProcessors")); + for (list<boost::weak_ptr<Processor> >::iterator i = _deactivated_processors.begin(); i != _deactivated_processors.end(); ++i) { + boost::shared_ptr<Processor> p = i->lock (); + if (p) { + XMLNode* c = new XMLNode (X_("Processor")); + c->add_property (X_("id"), p->id().to_s()); + node->add_child_nocopy (*c); + } + } + root.add_child_nocopy (*node); + } + return root; } @@ -113,6 +129,18 @@ Track::set_state (const XMLNode& node, int version) _rec_enable_control->set_state (*child, version); } } + + if (child->name() == X_("DeactivatedProcessors")) { + XMLNodeList dp = child->children (); + for (XMLNodeConstIterator i = dp.begin(); i != dp.end(); ++i) { + assert ((*i)->name() == X_("Processor")); + XMLProperty* prop = (*i)->property (X_("id")); + boost::shared_ptr<Processor> p = processor_by_id (PBD::ID (prop->value ())); + if (p) { + _deactivated_processors.push_back (p); + } + } + } } const XMLProperty* prop; @@ -196,6 +224,33 @@ Track::can_record() return will_record; } +/* Turn off visible processors (except Fader), keeping track of the old states */ +void +Track::deactivate_visible_processors () +{ + _deactivated_processors.clear (); + Glib::RWLock::ReaderLock lm (_processor_lock); + + for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { + if ((*i)->active() && (*i)->display_to_user() && boost::dynamic_pointer_cast<Amp> (*i) == 0) { + (*i)->deactivate (); + _deactivated_processors.push_back (*i); + } + } +} + +/* Turn deactivated processors back on again */ +void +Track::activate_deactivated_processors () +{ + for (list<boost::weak_ptr<Processor> >::iterator i = _deactivated_processors.begin(); i != _deactivated_processors.end(); ++i) { + boost::shared_ptr<Processor> p = i->lock (); + if (p) { + p->activate (); + } + } +} + void Track::set_record_enabled (bool yn, void *src) { @@ -217,6 +272,14 @@ Track::set_record_enabled (bool yn, void *src) _saved_meter_point = _meter_point; } + if (Config->get_do_not_record_plugins ()) { + if (yn) { + deactivate_visible_processors (); + } else { + activate_deactivated_processors (); + } + } + _diskstream->set_record_enabled (yn); if (_diskstream->record_enabled()) { @@ -845,3 +908,20 @@ Track::set_monitoring (MonitorChoice mc) } } +void +Track::parameter_changed (string p) +{ + if (p != "do-not-record-plugins") { + return; + } + + if (record_enabled ()) { + if (Config->get_do_not_record_plugins ()) { + deactivate_visible_processors (); + } else { + activate_deactivated_processors (); + } + } +} + + |