2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "libardour-config.h"
29 #include <boost/algorithm/string.hpp>
31 #include "pbd/xml++.h"
32 #include "pbd/enumwriter.h"
33 #include "pbd/locale_guard.h"
34 #include "pbd/memento_command.h"
35 #include "pbd/stacktrace.h"
36 #include "pbd/types_convert.h"
37 #include "pbd/unwind.h"
39 #include "ardour/amp.h"
40 #include "ardour/audio_buffer.h"
41 #include "ardour/audio_track.h"
42 #include "ardour/audio_port.h"
43 #include "ardour/audioengine.h"
44 #include "ardour/boost_debug.h"
45 #include "ardour/buffer.h"
46 #include "ardour/buffer_set.h"
47 #include "ardour/capturing_processor.h"
48 #include "ardour/debug.h"
49 #include "ardour/delivery.h"
50 #include "ardour/event_type_map.h"
51 #include "ardour/gain_control.h"
52 #include "ardour/internal_return.h"
53 #include "ardour/internal_send.h"
54 #include "ardour/meter.h"
55 #include "ardour/delayline.h"
56 #include "ardour/midi_buffer.h"
57 #include "ardour/midi_port.h"
58 #include "ardour/monitor_processor.h"
59 #include "ardour/pannable.h"
60 #include "ardour/panner.h"
61 #include "ardour/panner_shell.h"
62 #include "ardour/parameter_descriptor.h"
63 #include "ardour/phase_control.h"
64 #include "ardour/plugin_insert.h"
65 #include "ardour/port.h"
66 #include "ardour/port_insert.h"
67 #include "ardour/processor.h"
68 #include "ardour/profile.h"
69 #include "ardour/route.h"
70 #include "ardour/route_group.h"
71 #include "ardour/send.h"
72 #include "ardour/session.h"
73 #include "ardour/solo_control.h"
74 #include "ardour/solo_isolate_control.h"
75 #include "ardour/types_convert.h"
76 #include "ardour/unknown_processor.h"
77 #include "ardour/utils.h"
78 #include "ardour/vca.h"
83 using namespace ARDOUR;
86 PBD::Signal3<int,boost::shared_ptr<Route>, boost::shared_ptr<PluginInsert>, Route::PluginSetupOptions > Route::PluginSetup;
88 /** Base class for all routable/mixable objects (tracks and busses) */
89 Route::Route (Session& sess, string name, PresentationInfo::Flag flag, DataType default_type)
90 : Stripable (sess, name, PresentationInfo (flag))
91 , GraphNode (sess._process_graph)
92 , Muteable (sess, name)
95 , _signal_latency_at_amp_position (0)
96 , _signal_latency_at_trim_position (0)
99 , _pending_process_reorder (0)
100 , _pending_signals (0)
101 , _pending_declick (true)
102 , _meter_point (MeterPostFader)
103 , _pending_meter_point (MeterPostFader)
104 , _meter_type (MeterPeak)
105 , _denormal_protection (false)
108 , _declickable (false)
109 , _have_internal_generator (false)
110 , _default_type (default_type)
112 , _in_configure_processors (false)
113 , _initial_io_setup (false)
114 , _in_sidechain_setup (false)
116 , _custom_meter_position_noted (false)
119 processor_max_streams.reset();
122 boost::weak_ptr<Route>
123 Route::weakroute () {
124 return boost::weak_ptr<Route> (boost::dynamic_pointer_cast<Route> (shared_from_this ()));
130 /* set default meter type */
132 _meter_type = Config->get_meter_type_master ();
134 else if (dynamic_cast<Track*>(this)) {
135 _meter_type = Config->get_meter_type_track ();
137 _meter_type = Config->get_meter_type_bus ();
140 /* add standard controls */
142 _gain_control.reset (new GainControl (_session, GainAutomation));
143 _trim_control.reset (new GainControl (_session, TrimAutomation));
144 /* While the route has-a gain-control for consistency with Stripable and VCA
145 * ownership is handed over to the Amp Processor which manages the
146 * state of the Control and AutomationList as part of its
147 * Automatable API. -- Don't call add_control () here.
150 _solo_control.reset (new SoloControl (_session, X_("solo"), *this, *this));
151 add_control (_solo_control);
152 _solo_control->Changed.connect_same_thread (*this, boost::bind (&Route::solo_control_changed, this, _1, _2));
154 _mute_control.reset (new MuteControl (_session, X_("mute"), *this));
155 add_control (_mute_control);
157 _phase_control.reset (new PhaseControl (_session, X_("phase")));
158 add_control (_phase_control);
160 _solo_isolate_control.reset (new SoloIsolateControl (_session, X_("solo-iso"), *this, *this));
161 add_control (_solo_isolate_control);
163 _solo_safe_control.reset (new SoloSafeControl (_session, X_("solo-safe")));
164 add_control (_solo_safe_control);
168 if (!(_presentation_info.flags() & PresentationInfo::MonitorOut)) {
169 _pannable.reset (new Pannable (_session));
172 /* input and output objects */
174 _input.reset (new IO (_session, _name, IO::Input, _default_type));
175 _output.reset (new IO (_session, _name, IO::Output, _default_type));
177 _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2));
178 _input->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::input_port_count_changing, this, _1));
180 _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
181 _output->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::output_port_count_changing, this, _1));
183 /* add the amp/fader processor.
184 * it should be the first processor to be added on every route.
187 _amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
188 add_processor (_amp, PostFader);
191 _amp->set_display_name (_("Monitor"));
194 #if 0 // not used - just yet
195 if (!is_master() && !is_monitor() && !is_auditioner()) {
196 _delayline.reset (new DelayLine (_session, _name));
197 add_processor (_delayline, PreFader);
203 _trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
204 _trim->set_display_to_user (false);
206 if (dynamic_cast<AudioTrack*>(this)) {
207 /* we can't do this in the AudioTrack's constructor
208 * because _trim does not exit then
212 else if (!dynamic_cast<Track*>(this) && ! ( is_monitor() || is_auditioner() )) {
217 /* create standard processors: meter, main outs, monitor out;
218 they will be added to _processors by setup_invisible_processors ()
221 _meter.reset (new PeakMeter (_session, _name));
222 _meter->set_owner (this);
223 _meter->set_display_to_user (false);
226 _main_outs.reset (new Delivery (_session, _output, _pannable, _mute_master, _name, Delivery::Main));
227 _main_outs->activate ();
230 /* where we listen to tracks */
231 _intreturn.reset (new InternalReturn (_session));
232 _intreturn->activate ();
234 /* the thing that provides proper control over a control/monitor/listen bus
235 (such as per-channel cut, dim, solo, invert, etc).
237 _monitor_control.reset (new MonitorProcessor (_session));
238 _monitor_control->activate ();
241 /* now that we have _meter, its safe to connect to this */
244 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
245 configure_processors (0);
253 DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
255 /* do this early so that we don't get incoming signals as we are going through destruction
260 /* don't use clear_processors here, as it depends on the session which may
261 be half-destroyed by now
264 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
265 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
266 (*i)->drop_references ();
269 _processors.clear ();
273 Route::ensure_track_or_route_name(string name, Session &session)
275 string newname = name;
277 while (!session.io_name_is_legal (newname)) {
278 newname = bump_name_once (newname, ' ');
285 Route::set_trim (gain_t val, Controllable::GroupControlDisposition /* group override */)
287 // TODO route group, see set_gain()
288 // _trim_control->route_set_value (val);
292 Route::maybe_declick (BufferSet&, framecnt_t, int)
294 /* this is the "bus" implementation and they never declick.
299 /** Process this route for one (sub) cycle (process thread)
301 * @param bufs Scratch buffers to use for the signal path
302 * @param start_frame Initial transport frame
303 * @param end_frame Final transport frame
304 * @param nframes Number of frames to output (to ports)
306 * Note that (end_frame - start_frame) may not be equal to nframes when the
307 * transport speed isn't 1.0 (eg varispeed).
310 Route::process_output_buffers (BufferSet& bufs,
311 framepos_t start_frame, framepos_t end_frame, pframes_t nframes,
312 int declick, bool gain_automation_ok)
314 /* Caller must hold process lock */
315 assert (!AudioEngine::instance()->process_lock().trylock());
317 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
319 // can this actually happen? functions calling process_output_buffers()
320 // already take a reader-lock.
321 bufs.silence (nframes, 0);
325 _mute_control->automation_run (start_frame, nframes);
327 /* figure out if we're going to use gain automation */
328 if (gain_automation_ok) {
329 _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
330 _amp->setup_gain_automation (
331 start_frame + _signal_latency_at_amp_position,
332 end_frame + _signal_latency_at_amp_position,
335 _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
336 _trim->setup_gain_automation (
337 start_frame + _signal_latency_at_trim_position,
338 end_frame + _signal_latency_at_trim_position,
341 _amp->apply_gain_automation (false);
342 _trim->apply_gain_automation (false);
345 /* Tell main outs what to do about monitoring. We do this so that
346 on a transition between monitoring states we get a de-clicking gain
347 change in the _main_outs delivery, if config.get_use_monitor_fades()
350 We override this in the case where we have an internal generator.
352 bool silence = _have_internal_generator ? false : (monitoring_state () == MonitoringSilence);
354 _main_outs->no_outs_cuz_we_no_monitor (silence);
356 /* -------------------------------------------------------------------------------------------
357 GLOBAL DECLICK (for transport changes etc.)
358 ----------------------------------------------------------------------------------------- */
360 maybe_declick (bufs, nframes, declick);
361 _pending_declick = 0;
363 /* -------------------------------------------------------------------------------------------
364 DENORMAL CONTROL/PHASE INVERT
365 ----------------------------------------------------------------------------------------- */
367 if (!_phase_control->none()) {
371 if (_denormal_protection || Config->get_denormal_protection()) {
373 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
374 Sample* const sp = i->data();
376 if (_phase_control->inverted (chn)) {
377 for (pframes_t nx = 0; nx < nframes; ++nx) {
382 for (pframes_t nx = 0; nx < nframes; ++nx) {
390 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
391 Sample* const sp = i->data();
393 if (_phase_control->inverted (chn)) {
394 for (pframes_t nx = 0; nx < nframes; ++nx) {
403 if (_denormal_protection || Config->get_denormal_protection()) {
405 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
406 Sample* const sp = i->data();
407 for (pframes_t nx = 0; nx < nframes; ++nx) {
415 /* -------------------------------------------------------------------------------------------
417 ----------------------------------------------------------------------------------------- */
419 /* set this to be true if the meter will already have been ::run() earlier */
420 bool const meter_already_run = metering_state() == MeteringInput;
422 framecnt_t latency = 0;
423 const double speed = _session.transport_speed ();
425 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
427 if (meter_already_run && boost::dynamic_pointer_cast<PeakMeter> (*i)) {
428 /* don't ::run() the meter, otherwise it will have its previous peak corrupted */
433 /* if it has any inputs, make sure they match */
434 if (boost::dynamic_pointer_cast<UnknownProcessor> (*i) == 0 && (*i)->input_streams() != ChanCount::ZERO) {
435 if (bufs.count() != (*i)->input_streams()) {
437 DEBUG::Processors, string_compose (
438 "input port mismatch %1 bufs = %2 input for %3 = %4\n",
439 _name, bufs.count(), (*i)->name(), (*i)->input_streams()
446 /* should we NOT run plugins here if the route is inactive?
447 do we catch route != active somewhere higher?
450 if (boost::dynamic_pointer_cast<Send>(*i) != 0) {
451 boost::dynamic_pointer_cast<Send>(*i)->set_delay_in(_signal_latency - latency);
453 if (boost::dynamic_pointer_cast<PluginInsert>(*i) != 0) {
454 const framecnt_t longest_session_latency = _initial_delay + _signal_latency;
455 boost::dynamic_pointer_cast<PluginInsert>(*i)->set_sidechain_latency (
456 _initial_delay + latency, longest_session_latency - latency);
459 (*i)->run (bufs, start_frame - latency, end_frame - latency, speed, nframes, *i != _processors.back());
460 bufs.set_count ((*i)->output_streams());
462 if ((*i)->active ()) {
463 latency += (*i)->signal_latency ();
469 Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
470 boost::shared_ptr<Processor> endpoint,
471 bool include_endpoint, bool for_export, bool for_freeze)
473 /* If no processing is required, there's no need to go any further. */
474 if (!endpoint && !include_endpoint) {
478 framecnt_t latency = bounce_get_latency(_amp, false, for_export, for_freeze);
479 _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
480 _amp->setup_gain_automation (start - latency, start - latency + nframes, nframes);
482 /* trim is always at the top, for bounce no latency compensation is needed */
483 _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
484 _trim->setup_gain_automation (start, start + nframes, nframes);
487 const double speed = _session.transport_speed ();
488 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
490 if (!include_endpoint && (*i) == endpoint) {
494 /* if we're *not* exporting, stop processing if we come across a routing processor. */
495 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
498 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
502 /* special case the panner (export outputs)
503 * Ideally we'd only run the panner, not the delivery itself...
504 * but panners need separate input/output buffers and some context
505 * (panshell, panner type, etc). AFAICT there is no ill side effect
506 * of re-using the main delivery when freewheeling/exporting a region.
508 if ((*i) == _main_outs) {
509 assert ((*i)->does_routing());
510 (*i)->run (buffers, start - latency, start - latency + nframes, speed, nframes, true);
511 buffers.set_count ((*i)->output_streams());
514 /* don't run any processors that do routing.
515 * Also don't bother with metering.
517 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
518 (*i)->run (buffers, start - latency, start - latency + nframes, 1.0, nframes, true);
519 buffers.set_count ((*i)->output_streams());
520 latency += (*i)->signal_latency ();
523 if ((*i) == endpoint) {
530 Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint,
531 bool include_endpoint, bool for_export, bool for_freeze) const
533 framecnt_t latency = 0;
534 if (!endpoint && !include_endpoint) {
538 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
539 if (!include_endpoint && (*i) == endpoint) {
542 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
545 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
548 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
549 latency += (*i)->signal_latency ();
551 if ((*i) == endpoint) {
559 Route::bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint,
560 bool include_endpoint, bool for_export, bool for_freeze) const
562 if (!endpoint && !include_endpoint) {
566 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
567 if (!include_endpoint && (*i) == endpoint) {
570 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
573 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
576 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
577 cc = (*i)->output_streams();
579 if ((*i) == endpoint) {
587 Route::n_process_buffers ()
589 return max (_input->n_ports(), processor_max_streams);
593 Route::monitor_run (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
595 assert (is_monitor());
596 BufferSet& bufs (_session.get_route_buffers (n_process_buffers()));
597 fill_buffers_with_input (bufs, _input, nframes);
598 passthru (bufs, start_frame, end_frame, nframes, declick);
602 Route::passthru (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
606 if (is_monitor() && _session.listening() && !_session.is_auditioning()) {
608 /* control/monitor bus ignores input ports when something is
609 feeding the listen "stream". data will "arrive" into the
610 route from the intreturn processor element.
613 bufs.silence (nframes, 0);
616 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
617 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, true);
621 Route::passthru_silence (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
623 BufferSet& bufs (_session.get_route_buffers (n_process_buffers(), true));
625 bufs.set_count (_input->n_ports());
626 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
627 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, false);
631 Route::set_listen (bool yn)
634 if (_monitor_send->active() == yn) {
638 _monitor_send->activate ();
640 _monitor_send->deactivate ();
646 Route::solo_control_changed (bool, Controllable::GroupControlDisposition)
648 /* nothing to do if we're not using AFL/PFL. But if we are, we need
649 to alter the active state of the monitor send.
652 if (Config->get_solo_control_is_listen_control ()) {
653 set_listen (_solo_control->self_soloed() || _solo_control->get_masters_value());
658 Route::push_solo_isolate_upstream (int32_t delta)
660 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
662 boost::shared_ptr<RouteList> routes = _session.get_routes ();
663 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
665 if ((*i).get() == this || !(*i)->can_solo()) {
670 bool does_feed = feeds (*i, &sends_only);
672 if (does_feed && !sends_only) {
673 (*i)->solo_isolate_control()->mod_solo_isolated_by_upstream (delta);
679 Route::push_solo_upstream (int delta)
681 DEBUG_TRACE (DEBUG::Solo, string_compose("\t ... INVERT push from %1\n", _name));
682 for (FedBy::iterator i = _fed_by.begin(); i != _fed_by.end(); ++i) {
686 boost::shared_ptr<Route> sr (i->r.lock());
688 sr->solo_control()->mod_solo_by_others_downstream (-delta);
695 dump_processors(const string& name, const list<boost::shared_ptr<Processor> >& procs)
697 cerr << name << " {" << endl;
698 for (list<boost::shared_ptr<Processor> >::const_iterator p = procs.begin();
699 p != procs.end(); ++p) {
700 cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << " @ " << (*p) << endl;
706 /** Supposing that we want to insert a Processor at a given Placement, return
707 * the processor to add the new one before (or 0 to add at the end).
709 boost::shared_ptr<Processor>
710 Route::before_processor_for_placement (Placement p)
712 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
714 ProcessorList::iterator loc;
717 /* generic pre-fader: insert immediately before the amp */
718 loc = find (_processors.begin(), _processors.end(), _amp);
720 /* generic post-fader: insert right before the main outs */
721 loc = find (_processors.begin(), _processors.end(), _main_outs);
724 return loc != _processors.end() ? *loc : boost::shared_ptr<Processor> ();
727 /** Supposing that we want to insert a Processor at a given index, return
728 * the processor to add the new one before (or 0 to add at the end).
730 boost::shared_ptr<Processor>
731 Route::before_processor_for_index (int index)
734 return boost::shared_ptr<Processor> ();
737 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
739 ProcessorList::iterator i = _processors.begin ();
741 while (i != _processors.end() && j < index) {
742 if ((*i)->display_to_user()) {
749 return (i != _processors.end() ? *i : boost::shared_ptr<Processor> ());
752 /** Add a processor either pre- or post-fader
753 * @return 0 on success, non-0 on failure.
756 Route::add_processor (boost::shared_ptr<Processor> processor, Placement placement, ProcessorStreams* err, bool activation_allowed)
758 return add_processor (processor, before_processor_for_placement (placement), err, activation_allowed);
762 /** Add a processor to a route such that it ends up with a given index into the visible processors.
763 * @param index Index to add the processor at, or -1 to add at the end of the list.
764 * @return 0 on success, non-0 on failure.
767 Route::add_processor_by_index (boost::shared_ptr<Processor> processor, int index, ProcessorStreams* err, bool activation_allowed)
769 return add_processor (processor, before_processor_for_index (index), err, activation_allowed);
772 /** Add a processor to the route.
773 * @param before An existing processor in the list, or 0; the new processor will be inserted immediately before it (or at the end).
774 * @return 0 on success, non-0 on failure.
777 Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<Processor> before, ProcessorStreams* err, bool activation_allowed)
779 assert (processor != _meter);
780 assert (processor != _main_outs);
782 DEBUG_TRACE (DEBUG::Processors, string_compose (
783 "%1 adding processor %2\n", name(), processor->name()));
787 pl.push_back (processor);
788 int rv = add_processors (pl, before, err);
794 if (activation_allowed && (!_session.get_bypass_all_loaded_plugins () || !processor->display_to_user ())) {
795 processor->activate ();
802 Route::processor_selfdestruct (boost::weak_ptr<Processor> wp)
804 /* We cannot destruct the processor here (usually RT-thread
805 * with various locks held - in case of sends also io_locks).
806 * Queue for deletion in low-priority thread.
808 Glib::Threads::Mutex::Lock lx (selfdestruct_lock);
809 selfdestruct_sequence.push_back (wp);
813 Route::add_processor_from_xml_2X (const XMLNode& node, int version)
815 XMLProperty const * prop;
818 boost::shared_ptr<Processor> processor;
820 /* bit of a hack: get the `placement' property from the <Redirect> tag here
821 so that we can add the processor in the right place (pre/post-fader)
824 XMLNodeList const & children = node.children ();
825 XMLNodeList::const_iterator i = children.begin ();
827 while (i != children.end() && (*i)->name() != X_("Redirect")) {
831 Placement placement = PreFader;
833 if (i != children.end()) {
834 if ((prop = (*i)->property (X_("placement"))) != 0) {
835 placement = Placement (string_2_enum (prop->value(), placement));
839 if (node.name() == "Insert") {
841 if ((prop = node.property ("type")) != 0) {
843 if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
844 prop->value() == "lv2" ||
845 prop->value() == "windows-vst" ||
846 prop->value() == "mac-vst" ||
847 prop->value() == "lxvst" ||
848 prop->value() == "audiounit") {
850 if (_session.get_disable_all_loaded_plugins ()) {
851 processor.reset (new UnknownProcessor (_session, node));
853 processor.reset (new PluginInsert (_session));
854 processor->set_owner (this);
859 processor.reset (new PortInsert (_session, _pannable, _mute_master));
864 } else if (node.name() == "Send") {
866 boost::shared_ptr<Pannable> sendpan (new Pannable (_session));
867 processor.reset (new Send (_session, sendpan, _mute_master));
871 error << string_compose(_("unknown Processor type \"%1\"; ignored"), node.name()) << endmsg;
875 if (processor->set_state (node, version)) {
879 //A2 uses the "active" flag in the toplevel redirect node, not in the child plugin/IO
880 if (i != children.end()) {
881 if ((prop = (*i)->property (X_("active"))) != 0) {
882 if ( string_to<bool> (prop->value()) && (!_session.get_bypass_all_loaded_plugins () || !processor->display_to_user () ) )
883 processor->activate();
885 processor->deactivate();
889 return (add_processor (processor, placement, 0, false) == 0);
892 catch (failed_constructor &err) {
893 warning << _("processor could not be created. Ignored.") << endmsg;
899 inline Route::PluginSetupOptions operator|= (Route::PluginSetupOptions& a, const Route::PluginSetupOptions& b) {
900 return a = static_cast<Route::PluginSetupOptions> (static_cast <int>(a) | static_cast<int> (b));
903 inline Route::PluginSetupOptions operator&= (Route::PluginSetupOptions& a, const Route::PluginSetupOptions& b) {
904 return a = static_cast<Route::PluginSetupOptions> (static_cast <int>(a) & static_cast<int> (b));
908 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
910 ProcessorList::iterator loc;
911 boost::shared_ptr <PluginInsert> fanout;
913 if (g_atomic_int_get (&_pending_process_reorder)) {
914 /* we need to flush any pending re-order changes */
915 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
916 apply_processor_changes_rt ();
920 loc = find(_processors.begin(), _processors.end(), before);
921 if (loc == _processors.end ()) {
925 /* nothing specified - at end */
926 loc = _processors.end ();
929 if (!AudioEngine::instance()->connected()) {
933 if (others.empty()) {
937 ProcessorList to_skip;
939 // check if there's an instrument to replace or configure
940 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
941 boost::shared_ptr<PluginInsert> pi;
942 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) == 0) {
945 if (!pi->plugin ()->get_info ()->is_instrument ()) {
948 boost::shared_ptr<Processor> instrument = the_instrument ();
949 ChanCount in (DataType::MIDI, 1);
950 ChanCount out (DataType::AUDIO, 2); // XXX route's out?!
952 PluginSetupOptions flags = None;
955 in = instrument->input_streams ();
956 out = instrument->output_streams ();
958 if (pi->has_output_presets (in, out)) {
962 pi->set_strict_io (_strict_io);
964 PluginSetupOptions mask = None;
965 if (Config->get_ask_replace_instrument ()) {
968 if (Config->get_ask_setup_instrument ()) {
975 boost::optional<int> rv = PluginSetup (boost::dynamic_pointer_cast<Route>(shared_from_this ()), pi, flags); /* EMIT SIGNAL */
976 int mode = rv.get_value_or (0);
979 to_skip.push_back (*i); // don't add this one;
982 replace_processor (instrument, *i, err);
983 to_skip.push_back (*i);
988 if ((mode & 5) == 4) {
995 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
996 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
997 ProcessorState pstate (this);
999 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
1004 ProcessorList::iterator check = find (to_skip.begin(), to_skip.end(), *i);
1005 if (check != to_skip.end()) {
1009 boost::shared_ptr<PluginInsert> pi;
1011 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1012 pi->set_strict_io (_strict_io);
1016 /* Ensure that only one amp is in the list at any time */
1017 ProcessorList::iterator check = find (_processors.begin(), _processors.end(), *i);
1018 if (check != _processors.end()) {
1019 if (before == _amp) {
1020 /* Already in position; all is well */
1023 _processors.erase (check);
1028 assert (find (_processors.begin(), _processors.end(), *i) == _processors.end ());
1030 _processors.insert (loc, *i);
1031 (*i)->set_owner (this);
1034 if (configure_processors_unlocked (err, &lm)) {
1036 configure_processors_unlocked (0, &lm); // it worked before we tried to add it ...
1041 if (pi && pi->has_sidechain ()) {
1042 pi->sidechain_input ()->changed.connect_same_thread (*this, boost::bind (&Route::sidechain_change_handler, this, _1, _2));
1045 if ((*i)->active()) {
1046 // emit ActiveChanged() and latency_changed() if needed
1050 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1052 boost::shared_ptr<Send> send;
1053 if ((send = boost::dynamic_pointer_cast<Send> (*i))) {
1054 send->SelfDestruct.connect_same_thread (*this,
1055 boost::bind (&Route::processor_selfdestruct, this, boost::weak_ptr<Processor> (*i)));
1059 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
1060 boost::shared_ptr<PluginInsert> pi;
1062 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1063 if (pi->has_no_inputs ()) {
1064 _have_internal_generator = true;
1070 _output->set_user_latency (0);
1073 reset_instrument_info ();
1074 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1075 set_processor_positions ();
1077 if (fanout && fanout->configured ()
1078 && fanout->output_streams().n_audio() > 2
1079 && boost::dynamic_pointer_cast<PluginInsert> (the_instrument ()) == fanout) {
1080 fan_out (); /* EMIT SIGNAL */
1086 Route::placement_range(Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end)
1088 if (p == PreFader) {
1089 start = _processors.begin();
1090 end = find(_processors.begin(), _processors.end(), _amp);
1092 start = find(_processors.begin(), _processors.end(), _amp);
1094 end = _processors.end();
1098 /** Turn off all processors with a given placement
1099 * @param p Placement of processors to disable
1102 Route::disable_processors (Placement p)
1104 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1106 ProcessorList::iterator start, end;
1107 placement_range(p, start, end);
1109 for (ProcessorList::iterator i = start; i != end; ++i) {
1110 (*i)->enable (false);
1113 _session.set_dirty ();
1116 /** Turn off all redirects
1119 Route::disable_processors ()
1121 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1123 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1124 (*i)->enable (false);
1127 _session.set_dirty ();
1130 /** Turn off all redirects with a given placement
1131 * @param p Placement of redirects to disable
1134 Route::disable_plugins (Placement p)
1136 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1138 ProcessorList::iterator start, end;
1139 placement_range(p, start, end);
1141 for (ProcessorList::iterator i = start; i != end; ++i) {
1142 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1143 (*i)->enable (false);
1147 _session.set_dirty ();
1150 /** Turn off all plugins
1153 Route::disable_plugins ()
1155 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1157 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1158 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1159 (*i)->enable (false);
1163 _session.set_dirty ();
1168 Route::ab_plugins (bool forward)
1170 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1174 /* forward = turn off all active redirects, and mark them so that the next time
1175 we go the other way, we will revert them
1178 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1179 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1182 if (!(*i)->display_to_user ()) {
1186 if (boost::dynamic_pointer_cast<PluginInsert> (*i)->is_channelstrip()) {
1191 if ((*i)->enabled ()) {
1192 (*i)->enable (false);
1193 (*i)->set_next_ab_is_active (true);
1195 (*i)->set_next_ab_is_active (false);
1201 /* backward = if the redirect was marked to go active on the next ab, do so */
1203 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1204 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1207 if (!(*i)->display_to_user ()) {
1211 if (boost::dynamic_pointer_cast<PluginInsert> (*i)->is_channelstrip()) {
1216 (*i)->enable ((*i)->get_next_ab_is_active ());
1220 _session.set_dirty ();
1224 /** Remove processors with a given placement.
1225 * @param p Placement of processors to remove.
1228 Route::clear_processors (Placement p)
1230 if (!_session.engine().connected()) {
1234 bool already_deleting = _session.deletion_in_progress();
1235 if (!already_deleting) {
1236 _session.set_deletion_in_progress();
1240 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1241 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1242 ProcessorList new_list;
1243 ProcessorStreams err;
1244 bool seen_amp = false;
1246 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1252 if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline || (*i) == _trim) {
1254 /* you can't remove these */
1256 new_list.push_back (*i);
1263 new_list.push_back (*i);
1266 (*i)->drop_references ();
1274 (*i)->drop_references ();
1277 new_list.push_back (*i);
1284 _processors = new_list;
1285 configure_processors_unlocked (&err, &lm); // this can't fail
1288 processor_max_streams.reset();
1289 _have_internal_generator = false;
1290 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1291 set_processor_positions ();
1293 reset_instrument_info ();
1295 if (!already_deleting) {
1296 _session.clear_deletion_in_progress();
1301 Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStreams* err, bool need_process_lock)
1303 // TODO once the export point can be configured properly, do something smarter here
1304 if (processor == _capturing_processor) {
1305 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
1306 if (need_process_lock) {
1310 _capturing_processor.reset();
1312 if (need_process_lock) {
1317 /* these can never be removed */
1319 if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
1323 if (!_session.engine().connected()) {
1327 processor_max_streams.reset();
1330 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
1331 if (need_process_lock) {
1335 /* Caller must hold process lock */
1336 assert (!AudioEngine::instance()->process_lock().trylock());
1338 Glib::Threads::RWLock::WriterLock lm (_processor_lock); // XXX deadlock after export
1340 ProcessorState pstate (this);
1342 ProcessorList::iterator i;
1343 bool removed = false;
1345 for (i = _processors.begin(); i != _processors.end(); ) {
1346 if (*i == processor) {
1348 /* move along, see failure case for configure_processors()
1349 where we may need to reconfigure the processor.
1352 /* stop redirects that send signals to JACK ports
1353 from causing noise as a result of no longer being
1357 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
1358 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*i);
1362 iop = pi->sidechain();
1369 i = _processors.erase (i);
1377 _output->set_user_latency (0);
1385 if (configure_processors_unlocked (err, &lm)) {
1387 /* we know this will work, because it worked before :) */
1388 configure_processors_unlocked (0, &lm);
1392 _have_internal_generator = false;
1394 for (i = _processors.begin(); i != _processors.end(); ++i) {
1395 boost::shared_ptr<PluginInsert> pi;
1397 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1398 if (pi->has_no_inputs ()) {
1399 _have_internal_generator = true;
1404 if (need_process_lock) {
1409 reset_instrument_info ();
1410 processor->drop_references ();
1411 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1412 set_processor_positions ();
1418 Route::replace_processor (boost::shared_ptr<Processor> old, boost::shared_ptr<Processor> sub, ProcessorStreams* err)
1420 /* these can never be removed */
1421 if (old == _amp || old == _meter || old == _main_outs || old == _delayline || old == _trim) {
1424 /* and can't be used as substitute, either */
1425 if (sub == _amp || sub == _meter || sub == _main_outs || sub == _delayline || sub == _trim) {
1429 /* I/Os are out, too */
1430 if (boost::dynamic_pointer_cast<IOProcessor> (old) || boost::dynamic_pointer_cast<IOProcessor> (sub)) {
1434 /* this function cannot be used to swap/reorder processors */
1435 if (find (_processors.begin(), _processors.end(), sub) != _processors.end ()) {
1439 if (!AudioEngine::instance()->connected() || !old || !sub) {
1443 /* ensure that sub is not owned by another route */
1444 if (sub->owner ()) {
1449 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1450 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1451 ProcessorState pstate (this);
1453 assert (find (_processors.begin(), _processors.end(), sub) == _processors.end ());
1455 ProcessorList::iterator i;
1456 bool replaced = false;
1457 bool enable = old->enabled ();
1459 for (i = _processors.begin(); i != _processors.end(); ) {
1461 i = _processors.erase (i);
1462 _processors.insert (i, sub);
1463 sub->set_owner (this);
1476 boost::shared_ptr<PluginInsert> pi;
1477 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(sub)) != 0) {
1478 pi->set_strict_io (true);
1482 if (configure_processors_unlocked (err, &lm)) {
1484 configure_processors_unlocked (0, &lm);
1488 _have_internal_generator = false;
1490 for (i = _processors.begin(); i != _processors.end(); ++i) {
1491 boost::shared_ptr<PluginInsert> pi;
1492 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1493 if (pi->has_no_inputs ()) {
1494 _have_internal_generator = true;
1504 sub->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1505 _output->set_user_latency (0);
1508 reset_instrument_info ();
1509 old->drop_references ();
1510 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1511 set_processor_positions ();
1516 Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err)
1518 ProcessorList deleted;
1520 if (!_session.engine().connected()) {
1524 processor_max_streams.reset();
1527 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1528 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1529 ProcessorState pstate (this);
1531 ProcessorList::iterator i;
1532 boost::shared_ptr<Processor> processor;
1534 for (i = _processors.begin(); i != _processors.end(); ) {
1538 /* these can never be removed */
1540 if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
1545 /* see if its in the list of processors to delete */
1547 if (find (to_be_deleted.begin(), to_be_deleted.end(), processor) == to_be_deleted.end()) {
1552 /* stop IOProcessors that send to JACK ports
1553 from causing noise as a result of no longer being
1557 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(processor);
1558 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(processor);
1561 iop = pi->sidechain();
1568 deleted.push_back (processor);
1569 i = _processors.erase (i);
1572 if (deleted.empty()) {
1573 /* none of those in the requested list were found */
1577 _output->set_user_latency (0);
1579 if (configure_processors_unlocked (err, &lm)) {
1581 /* we know this will work, because it worked before :) */
1582 configure_processors_unlocked (0, &lm);
1587 _have_internal_generator = false;
1589 for (i = _processors.begin(); i != _processors.end(); ++i) {
1590 boost::shared_ptr<PluginInsert> pi;
1592 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1593 if (pi->has_no_inputs ()) {
1594 _have_internal_generator = true;
1601 /* now try to do what we need to so that those that were removed will be deleted */
1603 for (ProcessorList::iterator i = deleted.begin(); i != deleted.end(); ++i) {
1604 (*i)->drop_references ();
1607 reset_instrument_info ();
1608 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1609 set_processor_positions ();
1615 Route::reset_instrument_info ()
1617 boost::shared_ptr<Processor> instr = the_instrument();
1619 _instrument_info.set_internal_instrument (instr);
1623 /** Caller must hold process lock */
1625 Route::configure_processors (ProcessorStreams* err)
1627 #ifndef PLATFORM_WINDOWS
1628 assert (!AudioEngine::instance()->process_lock().trylock());
1631 if (!_in_configure_processors) {
1632 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1633 return configure_processors_unlocked (err, &lm);
1640 Route::input_streams () const
1642 return _input->n_ports ();
1645 list<pair<ChanCount, ChanCount> >
1646 Route::try_configure_processors (ChanCount in, ProcessorStreams* err)
1648 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1650 return try_configure_processors_unlocked (in, err);
1653 list<pair<ChanCount, ChanCount> >
1654 Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err)
1656 // Check each processor in order to see if we can configure as requested
1658 list<pair<ChanCount, ChanCount> > configuration;
1661 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configure processors\n", _name));
1662 DEBUG_TRACE (DEBUG::Processors, "{\n");
1664 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++index) {
1666 if ((*p)->can_support_io_configuration(in, out)) {
1668 if (boost::dynamic_pointer_cast<Delivery> (*p)
1669 && boost::dynamic_pointer_cast<Delivery> (*p)->role() == Delivery::Main
1671 && (is_monitor() || _strict_io || Profile->get_mixbus ())) {
1672 /* with strict I/O the panner + output are forced to
1673 * follow the last processor's output.
1675 * Delivery::can_support_io_configuration() will only add ports,
1676 * but not remove excess ports.
1678 * This works because the delivery only requires
1679 * as many outputs as there are inputs.
1680 * Delivery::configure_io() will do the actual removal
1681 * by calling _output->ensure_io()
1683 if (!is_master() && _session.master_out () && in.n_audio() > 0) {
1684 /* ..but at least as many as there are master-inputs, if
1685 * the delivery is dealing with audio */
1686 // XXX this may need special-casing for mixbus (master-outputs)
1687 // and should maybe be a preference anyway ?!
1688 out = ChanCount::max (in, _session.master_out ()->n_inputs ());
1694 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1 ID=%2 in=%3 out=%4\n",(*p)->name(), (*p)->id(), in, out));
1695 configuration.push_back(make_pair(in, out));
1698 // restriction for Monitor Section Processors
1699 if (in.n_audio() != out.n_audio() || out.n_midi() > 0) {
1700 /* Note: The Monitor follows the master-bus and has no panner.
1702 * The general idea is to only allow plugins that retain the channel-count
1703 * and plugins with MIDI in (e.g VSTs with control that will remain unconnected).
1704 * Then again 5.1 in, monitor stereo is a valid use-case.
1706 * and worse: we only refuse adding plugins *here*.
1708 * 1) stereo-master, stereo-mon, add a stereo-plugin, OK
1709 * 2) change master-bus, add a channel
1710 * 2a) monitor-secion follows
1711 * 3) monitor processors fail to re-reconfigure (stereo plugin)
1712 * 4) re-load session, monitor-processor remains unconfigured, crash.
1714 DEBUG_TRACE (DEBUG::Processors, "Monitor: Channel configuration change.\n");
1716 if (boost::dynamic_pointer_cast<InternalSend> (*p)) {
1717 // internal sends make no sense, only feedback
1718 DEBUG_TRACE (DEBUG::Processors, "Monitor: No Sends allowed.\n");
1719 return list<pair<ChanCount, ChanCount> > ();
1721 if (boost::dynamic_pointer_cast<PortInsert> (*p)) {
1722 /* External Sends can be problematic. one can add/remove ports
1723 * there signal leaves the DAW to external monitors anyway, so there's
1724 * no real use for allowing them here anyway.
1726 DEBUG_TRACE (DEBUG::Processors, "Monitor: No External Sends allowed.\n");
1727 return list<pair<ChanCount, ChanCount> > ();
1729 if (boost::dynamic_pointer_cast<Send> (*p)) {
1731 DEBUG_TRACE (DEBUG::Processors, "Monitor: No Sends allowed.\n");
1732 return list<pair<ChanCount, ChanCount> > ();
1741 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
1742 DEBUG_TRACE (DEBUG::Processors, string_compose ("---- %1 cannot support in=%2 out=%3\n", (*p)->name(), in, out));
1743 DEBUG_TRACE (DEBUG::Processors, "}\n");
1744 return list<pair<ChanCount, ChanCount> > ();
1748 DEBUG_TRACE (DEBUG::Processors, "}\n");
1750 return configuration;
1753 /** Set the input/output configuration of each processor in the processors list.
1754 * Caller must hold process lock.
1755 * Return 0 on success, otherwise configuration is impossible.
1758 Route::configure_processors_unlocked (ProcessorStreams* err, Glib::Threads::RWLock::WriterLock* lm)
1760 #ifndef PLATFORM_WINDOWS
1761 assert (!AudioEngine::instance()->process_lock().trylock());
1764 if (_in_configure_processors) {
1768 /* put invisible processors where they should be */
1769 setup_invisible_processors ();
1771 _in_configure_processors = true;
1773 list<pair<ChanCount, ChanCount> > configuration = try_configure_processors_unlocked (input_streams (), err);
1775 if (configuration.empty ()) {
1776 _in_configure_processors = false;
1781 bool seen_mains_out = false;
1782 processor_out_streams = _input->n_ports();
1783 processor_max_streams.reset();
1785 /* processor configure_io() may result in adding ports
1786 * e.g. Delivery::configure_io -> ARDOUR::IO::ensure_io ()
1788 * with jack2 adding ports results in a graph-order callback,
1789 * which calls Session::resort_routes() and eventually
1790 * Route::direct_feeds_according_to_reality()
1791 * which takes a ReaderLock (_processor_lock).
1793 * so we can't hold a WriterLock here until jack2 threading
1796 * NB. we still hold the process lock
1798 * (ardour's own engines do call graph-order from the
1799 * process-thread and hence do not have this issue; besides
1800 * merely adding ports won't trigger a graph-order, only
1801 * making connections does)
1805 // TODO check for a potential ReaderLock after ReaderLock ??
1806 Glib::Threads::RWLock::ReaderLock lr (_processor_lock);
1808 list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
1809 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
1811 if (!(*p)->configure_io(c->first, c->second)) {
1812 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration failed\n", _name));
1813 _in_configure_processors = false;
1818 processor_max_streams = ChanCount::max(processor_max_streams, c->first);
1819 processor_max_streams = ChanCount::max(processor_max_streams, c->second);
1821 boost::shared_ptr<IOProcessor> iop;
1822 boost::shared_ptr<PluginInsert> pi;
1823 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
1824 /* plugins connected via Split or Hide Match may have more channels.
1825 * route/scratch buffers are needed for all of them
1826 * The configuration may only be a subset (both input and output)
1828 processor_max_streams = ChanCount::max(processor_max_streams, pi->required_buffers());
1830 else if ((iop = boost::dynamic_pointer_cast<IOProcessor>(*p)) != 0) {
1831 processor_max_streams = ChanCount::max(processor_max_streams, iop->natural_input_streams());
1832 processor_max_streams = ChanCount::max(processor_max_streams, iop->natural_output_streams());
1836 if (boost::dynamic_pointer_cast<Delivery> (*p)
1837 && boost::dynamic_pointer_cast<Delivery> (*p)->role() == Delivery::Main) {
1838 /* main delivery will increase port count to match input.
1839 * the Delivery::Main is usually the last processor - followed only by
1842 seen_mains_out = true;
1844 if (!seen_mains_out) {
1845 processor_out_streams = out;
1854 _meter->set_max_channels (processor_max_streams);
1857 /* make sure we have sufficient scratch buffers to cope with the new processor
1860 _session.ensure_buffers (n_process_buffers ());
1862 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration complete\n", _name));
1864 _in_configure_processors = false;
1868 /** Set all visible processors to a given active state (except Fader, whose state is not changed)
1869 * @param state New active state for those processors.
1872 Route::all_visible_processors_active (bool state)
1874 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1876 if (_processors.empty()) {
1880 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1881 if (!(*i)->display_to_user() || boost::dynamic_pointer_cast<Amp> (*i)) {
1885 boost::shared_ptr<PluginInsert> pi;
1886 if (0 != (pi = boost::dynamic_pointer_cast<PluginInsert>(*i))) {
1887 if (pi->is_channelstrip ()) {
1892 (*i)->enable (state);
1895 _session.set_dirty ();
1899 Route::processors_reorder_needs_configure (const ProcessorList& new_order)
1901 /* check if re-order requires re-configuration of any processors
1902 * -> compare channel configuration for all processors
1904 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1905 ChanCount c = input_streams ();
1907 for (ProcessorList::const_iterator j = new_order.begin(); j != new_order.end(); ++j) {
1909 if (c != (*j)->input_streams()) {
1912 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
1915 if ((*i)->input_streams() != c) {
1918 c = (*i)->output_streams();
1930 __attribute__((annotate("realtime")))
1933 Route::apply_processor_order (const ProcessorList& new_order)
1935 /* need to hold processor_lock; either read or write lock
1936 * and the engine process_lock.
1937 * Due to r/w lock ambiguity we can only assert the latter
1939 assert (!AudioEngine::instance()->process_lock().trylock());
1942 /* "new_order" is an ordered list of processors to be positioned according to "placement".
1943 * NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
1944 * processors in the current actual processor list that are hidden. Any visible processors
1945 * in the current list but not in "new_order" will be assumed to be deleted.
1948 /* "as_it_will_be" and "_processors" are lists of shared pointers.
1949 * actual memory usage is small, but insert/erase is not actually rt-safe :(
1950 * (note though that ::processors_reorder_needs_configure() ensured that
1951 * this function will only ever be called from the rt-thread if no processor were removed)
1953 * either way, I can't proove it, but an x-run due to re-order here is less likley
1954 * than an x-run-less 'ardour-silent cycle' both of which effectively "click".
1957 ProcessorList as_it_will_be;
1958 ProcessorList::iterator oiter;
1959 ProcessorList::const_iterator niter;
1961 oiter = _processors.begin();
1962 niter = new_order.begin();
1964 while (niter != new_order.end()) {
1966 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
1967 then append it to the temp list.
1969 Otherwise, see if the next processor in the old list is in the new list. if not,
1970 its been deleted. If its there, append it to the temp list.
1973 if (oiter == _processors.end()) {
1975 /* no more elements in the old list, so just stick the rest of
1976 the new order onto the temp list.
1979 as_it_will_be.insert (as_it_will_be.end(), niter, new_order.end());
1980 while (niter != new_order.end()) {
1987 if (!(*oiter)->display_to_user()) {
1989 as_it_will_be.push_back (*oiter);
1993 /* visible processor: check that its in the new order */
1995 if (find (new_order.begin(), new_order.end(), (*oiter)) == new_order.end()) {
1996 /* deleted: do nothing, shared_ptr<> will clean up */
1998 /* ignore this one, and add the next item from the new order instead */
1999 as_it_will_be.push_back (*niter);
2004 /* now remove from old order - its taken care of no matter what */
2005 oiter = _processors.erase (oiter);
2009 _processors.insert (oiter, as_it_will_be.begin(), as_it_will_be.end());
2011 /* If the meter is in a custom position, find it and make a rough note of its position */
2012 maybe_note_meter_position ();
2016 Route::move_instrument_down (bool postfader)
2018 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2019 ProcessorList new_order;
2020 boost::shared_ptr<Processor> instrument;
2021 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2022 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*i);
2023 if (pi && pi->plugin ()->get_info ()->is_instrument ()) {
2025 } else if (instrument && *i == _amp) {
2027 new_order.push_back (*i);
2028 new_order.push_back (instrument);
2030 new_order.push_back (instrument);
2031 new_order.push_back (*i);
2034 new_order.push_back (*i);
2041 reorder_processors (new_order, 0);
2045 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
2047 // it a change is already queued, wait for it
2048 // (unless engine is stopped. apply immediately and proceed
2049 while (g_atomic_int_get (&_pending_process_reorder)) {
2050 if (!AudioEngine::instance()->running()) {
2051 DEBUG_TRACE (DEBUG::Processors, "offline apply queued processor re-order.\n");
2052 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2054 apply_processor_order(_pending_processor_order);
2055 setup_invisible_processors ();
2057 g_atomic_int_set (&_pending_process_reorder, 0);
2059 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2060 set_processor_positions ();
2062 // TODO rather use a semaphore or something.
2063 // but since ::reorder_processors() is called
2064 // from the GUI thread, this is fine..
2069 if (processors_reorder_needs_configure (new_order) || !AudioEngine::instance()->running()) {
2071 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2072 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2073 ProcessorState pstate (this);
2075 apply_processor_order (new_order);
2077 if (configure_processors_unlocked (err, &lm)) {
2085 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2086 set_processor_positions ();
2089 DEBUG_TRACE (DEBUG::Processors, "Queue clickless processor re-order.\n");
2090 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2092 // _pending_processor_order is protected by _processor_lock
2093 _pending_processor_order = new_order;
2094 g_atomic_int_set (&_pending_process_reorder, 1);
2101 Route::add_remove_sidechain (boost::shared_ptr<Processor> proc, bool add)
2103 boost::shared_ptr<PluginInsert> pi;
2104 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2108 if (pi->has_sidechain () == add) {
2109 return true; // ?? call failed, but result is as expected.
2113 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2114 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2115 if (i == _processors.end ()) {
2121 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); // take before Writerlock to avoid deadlock
2122 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2123 PBD::Unwinder<bool> uw (_in_sidechain_setup, true);
2125 lx.release (); // IO::add_port() and ~IO takes process lock - XXX check if this is safe
2127 if (!pi->add_sidechain ()) {
2131 if (!pi->del_sidechain ()) {
2137 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2142 pi->del_sidechain ();
2144 pi->add_sidechain ();
2145 // TODO restore side-chain's state.
2150 configure_processors_unlocked (0, &lm);
2153 if (pi->has_sidechain ()) {
2154 pi->sidechain_input ()->changed.connect_same_thread (*this, boost::bind (&Route::sidechain_change_handler, this, _1, _2));
2157 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2158 _session.set_dirty ();
2163 Route::plugin_preset_output (boost::shared_ptr<Processor> proc, ChanCount outs)
2165 boost::shared_ptr<PluginInsert> pi;
2166 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2171 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2172 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2173 if (i == _processors.end ()) {
2179 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2180 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2182 const ChanCount& old (pi->preset_out ());
2183 if (!pi->set_preset_out (outs)) {
2184 return true; // no change, OK
2187 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2190 pi->set_preset_out (old);
2193 configure_processors_unlocked (0, &lm);
2196 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2197 _session.set_dirty ();
2202 Route::reset_plugin_insert (boost::shared_ptr<Processor> proc)
2205 return customize_plugin_insert (proc, 0, unused, unused);
2209 Route::customize_plugin_insert (boost::shared_ptr<Processor> proc, uint32_t count, ChanCount outs, ChanCount sinks)
2211 boost::shared_ptr<PluginInsert> pi;
2212 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2217 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2218 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2219 if (i == _processors.end ()) {
2225 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2226 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2228 bool old_cust = pi->custom_cfg ();
2229 uint32_t old_cnt = pi->get_count ();
2230 ChanCount old_chan = pi->output_streams ();
2231 ChanCount old_sinks = pi->natural_input_streams ();
2234 pi->set_custom_cfg (false);
2236 pi->set_custom_cfg (true);
2237 pi->set_count (count);
2238 pi->set_outputs (outs);
2239 pi->set_sinks (sinks);
2242 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2246 pi->set_count (old_cnt);
2247 pi->set_sinks (old_sinks);
2248 pi->set_outputs (old_chan);
2249 pi->set_custom_cfg (old_cust);
2253 configure_processors_unlocked (0, &lm);
2256 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2257 _session.set_dirty ();
2262 Route::set_strict_io (const bool enable)
2264 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2266 if (_strict_io != enable) {
2267 _strict_io = enable;
2268 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2269 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2270 boost::shared_ptr<PluginInsert> pi;
2271 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2272 pi->set_strict_io (_strict_io);
2276 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2280 _strict_io = !enable; // restore old value
2281 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2282 boost::shared_ptr<PluginInsert> pi;
2283 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2284 pi->set_strict_io (_strict_io);
2291 configure_processors (0);
2294 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2295 _session.set_dirty ();
2307 Route::get_template()
2309 return state(false);
2313 Route::state(bool full_state)
2315 if (!_session._template_state_dir.empty()) {
2316 foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), _session._template_state_dir));
2319 XMLNode *node = new XMLNode("Route");
2320 ProcessorList::iterator i;
2322 node->set_property ("id", id ());
2323 node->set_property ("name", name());
2324 node->set_property ("default-type", _default_type);
2325 node->set_property ("strict-io", _strict_io);
2327 node->add_child_nocopy (_presentation_info.get_state());
2329 node->set_property ("active", _active);
2330 node->set_property ("denormal-protection", _denormal_protection);
2331 node->set_property ("meter-point", _meter_point);
2333 node->set_property ("meter-type", _meter_type);
2336 node->set_property ("route-group", _route_group->name());
2339 node->add_child_nocopy (_solo_control->get_state ());
2340 node->add_child_nocopy (_solo_isolate_control->get_state ());
2341 node->add_child_nocopy (_solo_safe_control->get_state ());
2343 node->add_child_nocopy (_input->state (full_state));
2344 node->add_child_nocopy (_output->state (full_state));
2345 node->add_child_nocopy (_mute_master->get_state ());
2347 node->add_child_nocopy (_mute_control->get_state ());
2348 node->add_child_nocopy (_phase_control->get_state ());
2351 node->add_child_nocopy (Automatable::get_automation_xml_state ());
2354 if (_comment.length()) {
2355 XMLNode *cmt = node->add_child ("Comment");
2356 cmt->add_content (_comment);
2360 node->add_child_nocopy (_pannable->state (full_state));
2364 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2365 for (i = _processors.begin(); i != _processors.end(); ++i) {
2367 /* template save: do not include internal sends functioning as
2368 aux sends because the chance of the target ID
2369 in the session where this template is used
2372 similarly, do not save listen sends which connect to
2373 the monitor section, because these will always be
2376 boost::shared_ptr<InternalSend> is;
2378 if ((is = boost::dynamic_pointer_cast<InternalSend> (*i)) != 0) {
2379 if (is->role() == Delivery::Listen) {
2384 node->add_child_nocopy((*i)->state (full_state));
2389 node->add_child_copy (*_extra_xml);
2392 if (_custom_meter_position_noted) {
2393 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
2395 node->set_property (X_("processor-after-last-custom-meter"), after->id());
2399 if (!_session._template_state_dir.empty()) {
2400 foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), ""));
2403 node->add_child_copy (Slavable::get_state());
2409 Route::set_state (const XMLNode& node, int version)
2411 if (version < 3000) {
2412 return set_state_2X (node, version);
2416 XMLNodeConstIterator niter;
2419 if (node.name() != "Route"){
2420 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2424 std::string route_name;
2425 if (node.get_property (X_("name"), route_name)) {
2426 Route::set_name (route_name);
2430 _initial_io_setup = true;
2432 Stripable::set_state (node, version);
2434 node.get_property (X_("strict-io"), _strict_io);
2437 /* monitor bus does not get a panner, but if (re)created
2438 via XML, it will already have one by the time we
2439 call ::set_state(). so ... remove it.
2444 /* add all processors (except amp, which is always present) */
2446 nlist = node.children();
2447 XMLNode processor_state (X_("processor_state"));
2449 Stateful::save_extra_xml (node);
2451 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2455 if (child->name() == IO::state_node_name) {
2456 std::string direction;
2457 if (!child->get_property (X_("direction"), direction)) {
2461 if (direction == "Input") {
2462 _input->set_state (*child, version);
2463 } else if (direction == "Output") {
2464 _output->set_state (*child, version);
2467 } else if (child->name() == X_("Processor")) {
2468 processor_state.add_child_copy (*child);
2469 } else if (child->name() == X_("Pannable")) {
2471 _pannable->set_state (*child, version);
2473 warning << string_compose (_("Pannable state found for route (%1) without a panner!"), name()) << endmsg;
2475 } else if (child->name() == Slavable::xml_node_name) {
2476 Slavable::set_state (*child, version);
2481 if (node.get_property (X_("meter-point"), mp)) {
2482 set_meter_point (mp, true);
2484 _meter->set_display_to_user (_meter_point == MeterCustom);
2488 node.get_property (X_("meter-type"), _meter_type);
2490 _initial_io_setup = false;
2492 set_processor_state (processor_state);
2494 // this looks up the internal instrument in processors
2495 reset_instrument_info();
2497 bool denormal_protection;
2498 if (node.get_property (X_("denormal-protection"), denormal_protection)) {
2499 set_denormal_protection (denormal_protection);
2502 /* convert old 3001 state */
2503 std::string phase_invert_str;
2504 if (node.get_property (X_("phase-invert"), phase_invert_str)) {
2505 _phase_control->set_phase_invert (boost::dynamic_bitset<> (phase_invert_str));
2509 if (node.get_property (X_("active"), is_active)) {
2510 set_active (is_active, this);
2513 std::string id_string;
2514 if (node.get_property (X_("processor-after-last-custom-meter"), id_string)) {
2515 PBD::ID id (id_string);
2516 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2517 ProcessorList::const_iterator i = _processors.begin ();
2518 while (i != _processors.end() && (*i)->id() != id) {
2522 if (i != _processors.end ()) {
2523 _processor_after_last_custom_meter = *i;
2524 _custom_meter_position_noted = true;
2528 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2531 if (child->name() == X_("Comment")) {
2533 /* XXX this is a terrible API design in libxml++ */
2535 XMLNode *cmt = *(child->children().begin());
2536 _comment = cmt->content();
2538 } else if (child->name() == Controllable::xml_node_name) {
2539 std::string control_name;
2540 if (!child->get_property (X_("name"), control_name)) {
2544 if (control_name == _solo_control->name()) {
2545 _solo_control->set_state (*child, version);
2546 } else if (control_name == _solo_safe_control->name()) {
2547 _solo_safe_control->set_state (*child, version);
2548 } else if (control_name == _solo_isolate_control->name()) {
2549 _solo_isolate_control->set_state (*child, version);
2550 } else if (control_name == _mute_control->name()) {
2551 _mute_control->set_state (*child, version);
2552 } else if (control_name == _phase_control->name()) {
2553 _phase_control->set_state (*child, version);
2555 Evoral::Parameter p = EventTypeMap::instance().from_symbol (control_name);
2556 if (p.type () >= MidiCCAutomation && p.type () < MidiSystemExclusiveAutomation) {
2557 boost::shared_ptr<AutomationControl> ac = automation_control (p, true);
2559 ac->set_state (*child, version);
2563 } else if (child->name() == MuteMaster::xml_node_name) {
2564 _mute_master->set_state (*child, version);
2566 } else if (child->name() == Automatable::xml_node_name) {
2567 set_automation_xml_state (*child, Evoral::Parameter(NullAutomation));
2575 Route::set_state_2X (const XMLNode& node, int version)
2579 XMLNodeConstIterator niter;
2581 XMLProperty const * prop;
2583 /* 2X things which still remain to be handled:
2589 if (node.name() != "Route") {
2590 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2594 Stripable::set_state (node, version);
2596 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2597 set_denormal_protection (string_to<bool> (prop->value()));
2600 if ((prop = node.property (X_("muted"))) != 0) {
2603 bool muted = string_to<bool> (prop->value());
2609 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
2611 if (string_to<bool> (prop->value())){
2612 mute_point = mute_point + "PreFader";
2617 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
2619 if (string_to<bool> (prop->value())){
2622 mute_point = mute_point + ",";
2625 mute_point = mute_point + "PostFader";
2630 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
2632 if (string_to<bool> (prop->value())){
2635 mute_point = mute_point + ",";
2638 mute_point = mute_point + "Listen";
2643 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
2645 if (string_to<bool> (prop->value())){
2648 mute_point = mute_point + ",";
2651 mute_point = mute_point + "Main";
2655 _mute_master->set_mute_points (mute_point);
2656 _mute_master->set_muted_by_self (true);
2660 if ((prop = node.property (X_("meter-point"))) != 0) {
2661 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
2666 nlist = node.children ();
2667 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2671 if (child->name() == IO::state_node_name) {
2673 /* there is a note in IO::set_state_2X() about why we have to call
2677 _input->set_state_2X (*child, version, true);
2678 _output->set_state_2X (*child, version, false);
2680 if ((prop = child->property (X_("name"))) != 0) {
2681 Route::set_name (prop->value ());
2686 if ((prop = child->property (X_("active"))) != 0) {
2687 bool yn = string_to<bool> (prop->value());
2688 _active = !yn; // force switch
2689 set_active (yn, this);
2692 if ((prop = child->property (X_("gain"))) != 0) {
2695 if (sscanf (prop->value().c_str(), "%f", &val) == 1) {
2696 _amp->gain_control()->set_value (val, Controllable::NoGroup);
2700 /* Set up Panners in the IO */
2701 XMLNodeList io_nlist = child->children ();
2703 XMLNodeConstIterator io_niter;
2706 for (io_niter = io_nlist.begin(); io_niter != io_nlist.end(); ++io_niter) {
2708 io_child = *io_niter;
2710 if (io_child->name() == X_("Panner")) {
2711 _main_outs->panner_shell()->set_state(*io_child, version);
2712 } else if (io_child->name() == X_("Automation")) {
2713 /* IO's automation is for the fader */
2714 _amp->set_automation_xml_state (*io_child, Evoral::Parameter (GainAutomation));
2720 XMLNodeList redirect_nodes;
2722 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2726 if (child->name() == X_("Send") || child->name() == X_("Insert")) {
2727 redirect_nodes.push_back(child);
2732 set_processor_state_2X (redirect_nodes, version);
2734 Stateful::save_extra_xml (node);
2736 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2739 if (child->name() == X_("Comment")) {
2741 /* XXX this is a terrible API design in libxml++ */
2743 XMLNode *cmt = *(child->children().begin());
2744 _comment = cmt->content();
2746 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
2747 if (prop->value() == X_("solo")) {
2748 _solo_control->set_state (*child, version);
2749 } else if (prop->value() == X_("mute")) {
2750 _mute_control->set_state (*child, version);
2760 Route::get_processor_state ()
2762 XMLNode* root = new XMLNode (X_("redirects"));
2763 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2764 root->add_child_nocopy ((*i)->state (true));
2771 Route::set_processor_state_2X (XMLNodeList const & nList, int version)
2773 /* We don't bother removing existing processors not in nList, as this
2774 method will only be called when creating a Route from scratch, not
2775 for undo purposes. Just put processors in at the appropriate place
2779 for (XMLNodeConstIterator i = nList.begin(); i != nList.end(); ++i) {
2780 add_processor_from_xml_2X (**i, version);
2785 Route::set_processor_state (const XMLNode& node)
2787 const XMLNodeList &nlist = node.children();
2788 XMLNodeConstIterator niter;
2789 ProcessorList new_order;
2790 bool must_configure = false;
2792 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2794 XMLProperty* prop = (*niter)->property ("type");
2796 if (prop->value() == "amp") {
2797 _amp->set_state (**niter, Stateful::current_state_version);
2798 new_order.push_back (_amp);
2799 } else if (prop->value() == "trim") {
2800 _trim->set_state (**niter, Stateful::current_state_version);
2801 new_order.push_back (_trim);
2802 } else if (prop->value() == "meter") {
2803 _meter->set_state (**niter, Stateful::current_state_version);
2804 new_order.push_back (_meter);
2805 } else if (prop->value() == "delay") {
2807 _delayline->set_state (**niter, Stateful::current_state_version);
2808 new_order.push_back (_delayline);
2810 } else if (prop->value() == "main-outs") {
2811 _main_outs->set_state (**niter, Stateful::current_state_version);
2812 } else if (prop->value() == "intreturn") {
2814 _intreturn.reset (new InternalReturn (_session));
2815 must_configure = true;
2817 _intreturn->set_state (**niter, Stateful::current_state_version);
2818 } else if (is_monitor() && prop->value() == "monitor") {
2819 if (!_monitor_control) {
2820 _monitor_control.reset (new MonitorProcessor (_session));
2821 must_configure = true;
2823 _monitor_control->set_state (**niter, Stateful::current_state_version);
2824 } else if (prop->value() == "capture") {
2825 /* CapturingProcessor should never be restored, it's always
2826 added explicitly when needed */
2828 ProcessorList::iterator o;
2830 for (o = _processors.begin(); o != _processors.end(); ++o) {
2831 XMLProperty const * id_prop = (*niter)->property(X_("id"));
2832 if (id_prop && (*o)->id() == id_prop->value()) {
2833 (*o)->set_state (**niter, Stateful::current_state_version);
2834 new_order.push_back (*o);
2839 // If the processor (*niter) is not on the route then create it
2841 if (o == _processors.end()) {
2843 boost::shared_ptr<Processor> processor;
2845 if (prop->value() == "intsend") {
2847 processor.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), boost::shared_ptr<Route>(), Delivery::Aux, true));
2849 } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
2850 prop->value() == "lv2" ||
2851 prop->value() == "windows-vst" ||
2852 prop->value() == "mac-vst" ||
2853 prop->value() == "lxvst" ||
2854 prop->value() == "luaproc" ||
2855 prop->value() == "audiounit") {
2857 if (_session.get_disable_all_loaded_plugins ()) {
2858 processor.reset (new UnknownProcessor (_session, **niter));
2860 processor.reset (new PluginInsert (_session));
2861 processor->set_owner (this);
2863 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(processor);
2864 pi->set_strict_io (true);
2868 } else if (prop->value() == "port") {
2870 processor.reset (new PortInsert (_session, _pannable, _mute_master));
2872 } else if (prop->value() == "send") {
2874 processor.reset (new Send (_session, _pannable, _mute_master, Delivery::Send, true));
2875 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (processor);
2876 send->SelfDestruct.connect_same_thread (*this,
2877 boost::bind (&Route::processor_selfdestruct, this, boost::weak_ptr<Processor> (processor)));
2880 error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
2884 if (processor->set_state (**niter, Stateful::current_state_version) != 0) {
2885 /* This processor could not be configured. Turn it into a UnknownProcessor */
2886 processor.reset (new UnknownProcessor (_session, **niter));
2889 /* subscribe to Sidechain IO changes */
2890 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
2891 if (pi && pi->has_sidechain ()) {
2892 pi->sidechain_input ()->changed.connect_same_thread (*this, boost::bind (&Route::sidechain_change_handler, this, _1, _2));
2895 /* we have to note the monitor send here, otherwise a new one will be created
2896 and the state of this one will be lost.
2898 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
2899 if (isend && isend->role() == Delivery::Listen) {
2900 _monitor_send = isend;
2903 /* it doesn't matter if invisible processors are added here, as they
2904 will be sorted out by setup_invisible_processors () shortly.
2907 new_order.push_back (processor);
2908 must_configure = true;
2914 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2915 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2916 /* re-assign _processors w/o process-lock.
2917 * if there's an IO-processor present in _processors but
2918 * not in new_order, it will be deleted and ~IO takes
2921 _processors = new_order;
2923 if (must_configure) {
2924 configure_processors_unlocked (0, &lm);
2927 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2929 (*i)->set_owner (this);
2930 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
2932 boost::shared_ptr<PluginInsert> pi;
2934 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
2935 if (pi->has_no_inputs ()) {
2936 _have_internal_generator = true;
2943 reset_instrument_info ();
2944 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2945 set_processor_positions ();
2949 Route::curve_reallocate ()
2951 // _gain_automation_curve.finish_resize ();
2952 // _pan_automation_curve.finish_resize ();
2956 Route::silence (framecnt_t nframes)
2958 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
2963 silence_unlocked (nframes);
2967 Route::silence_unlocked (framecnt_t nframes)
2969 /* Must be called with the processor lock held */
2971 const framepos_t now = _session.transport_frame ();
2975 _output->silence (nframes);
2977 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2978 boost::shared_ptr<PluginInsert> pi;
2980 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
2981 // skip plugins, they don't need anything when we're not active
2985 (*i)->silence (nframes, now);
2988 if (nframes == _session.get_block_size()) {
2995 Route::add_internal_return ()
2998 _intreturn.reset (new InternalReturn (_session));
2999 add_processor (_intreturn, PreFader);
3004 Route::add_send_to_internal_return (InternalSend* send)
3006 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3008 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
3009 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
3012 return d->add_send (send);
3018 Route::remove_send_from_internal_return (InternalSend* send)
3020 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3022 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
3023 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
3026 return d->remove_send (send);
3032 Route::enable_monitor_send ()
3034 /* Caller must hold process lock */
3035 assert (!AudioEngine::instance()->process_lock().trylock());
3037 /* master never sends to monitor section via the normal mechanism */
3038 assert (!is_master ());
3039 assert (!is_monitor ());
3041 /* make sure we have one */
3042 if (!_monitor_send) {
3043 _monitor_send.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), _session.monitor_out(), Delivery::Listen));
3044 _monitor_send->set_display_to_user (false);
3048 configure_processors (0);
3051 /** Add an aux send to a route.
3052 * @param route route to send to.
3053 * @param before Processor to insert before, or 0 to insert at the end.
3056 Route::add_aux_send (boost::shared_ptr<Route> route, boost::shared_ptr<Processor> before)
3058 assert (route != _session.monitor_out ());
3061 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3063 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
3065 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend> (*x);
3067 if (d && d->target_route() == route) {
3068 /* already listening via the specified IO: do nothing */
3076 boost::shared_ptr<InternalSend> listener;
3079 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
3080 listener.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), route, Delivery::Aux));
3083 add_processor (listener, before);
3085 } catch (failed_constructor& err) {
3093 Route::remove_aux_or_listen (boost::shared_ptr<Route> route)
3095 ProcessorStreams err;
3096 ProcessorList::iterator tmp;
3099 Glib::Threads::RWLock::ReaderLock rl(_processor_lock);
3101 /* have to do this early because otherwise processor reconfig
3102 * will put _monitor_send back in the list
3105 if (route == _session.monitor_out()) {
3106 _monitor_send.reset ();
3110 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
3112 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
3114 if (d && d->target_route() == route) {
3116 if (remove_processor (*x, &err, false) > 0) {
3122 /* list could have been demolished while we dropped the lock
3125 if (_session.engine().connected()) {
3126 /* i/o processors cannot be removed if the engine is not running
3127 * so don't live-loop in case the engine is N/A or dies
3137 Route::set_comment (string cmt, void *src)
3141 _session.set_dirty ();
3145 Route::add_fed_by (boost::shared_ptr<Route> other, bool via_sends_only)
3147 FeedRecord fr (other, via_sends_only);
3149 pair<FedBy::iterator,bool> result = _fed_by.insert (fr);
3151 if (!result.second) {
3153 /* already a record for "other" - make sure sends-only information is correct */
3154 if (!via_sends_only && result.first->sends_only) {
3155 FeedRecord* frp = const_cast<FeedRecord*>(&(*result.first));
3156 frp->sends_only = false;
3160 return result.second;
3164 Route::clear_fed_by ()
3170 Route::feeds (boost::shared_ptr<Route> other, bool* via_sends_only)
3172 const FedBy& fed_by (other->fed_by());
3174 for (FedBy::const_iterator f = fed_by.begin(); f != fed_by.end(); ++f) {
3175 boost::shared_ptr<Route> sr = f->r.lock();
3177 if (sr && (sr.get() == this)) {
3179 if (via_sends_only) {
3180 *via_sends_only = f->sends_only;
3191 Route::all_inputs () const
3193 /* TODO, if this works as expected,
3194 * cache the IOVector and maintain it via
3195 * input_change_handler(), sidechain_change_handler() etc
3198 ios.push_back (_input);
3200 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3201 for (ProcessorList::const_iterator r = _processors.begin(); r != _processors.end(); ++r) {
3203 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(*r);
3204 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*r);
3207 iop = pi->sidechain();
3210 if (iop != 0 && iop->input()) {
3211 ios.push_back (iop->input());
3218 Route::all_outputs () const
3221 // _output is included via Delivery
3222 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3223 for (ProcessorList::const_iterator r = _processors.begin(); r != _processors.end(); ++r) {
3224 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(*r);
3225 if (iop != 0 && iop->output()) {
3226 ios.push_back (iop->output());
3233 Route::direct_feeds_according_to_reality (boost::shared_ptr<Route> other, bool* via_send_only)
3235 DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds? %1\n", _name));
3236 if (other->all_inputs().fed_by (_output)) {
3237 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS %2\n", other->name()));
3238 if (via_send_only) {
3239 *via_send_only = false;
3245 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3247 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
3249 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(*r);
3250 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*r);
3253 iop = pi->sidechain();
3257 boost::shared_ptr<const IO> iop_out = iop->output();
3258 if (other.get() == this && iop_out && iop->input() && iop_out->connected_to (iop->input())) {
3259 // TODO this needs a delaylines in the Insert to align connections (!)
3260 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed its own return (%2)\n", iop->name(), other->name()));
3263 if ((iop_out && other->all_inputs().fed_by (iop_out)) || iop->feeds (other)) {
3264 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name()));
3265 if (via_send_only) {
3266 *via_send_only = true;
3270 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does NOT feed %2\n", iop->name(), other->name()));
3273 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tPROC %1 is not an IOP\n", (*r)->name()));
3278 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdoes NOT feed %1\n", other->name()));
3283 Route::direct_feeds_according_to_graph (boost::shared_ptr<Route> other, bool* via_send_only)
3285 return _session._current_route_graph.has (boost::dynamic_pointer_cast<Route> (shared_from_this ()), other, via_send_only);
3289 Route::feeds_according_to_graph (boost::shared_ptr<Route> other)
3291 return _session._current_route_graph.feeds (boost::dynamic_pointer_cast<Route> (shared_from_this ()), other);
3294 /** Called from the (non-realtime) butler thread when the transport is stopped */
3296 Route::nonrealtime_handle_transport_stopped (bool /*abort_ignored*/, bool /*did_locate*/, bool can_flush_processors)
3298 framepos_t now = _session.transport_frame();
3301 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3303 Automatable::transport_stopped (now);
3305 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3307 if (!_have_internal_generator && (Config->get_plugins_stop_with_transport() && can_flush_processors)) {
3311 (*i)->transport_stopped (now);
3315 _roll_delay = _initial_delay;
3319 Route::input_change_handler (IOChange change, void * /*src*/)
3321 if ((change.type & IOChange::ConfigurationChanged)) {
3322 /* This is called with the process lock held if change
3323 contains ConfigurationChanged
3325 configure_processors (0);
3326 _phase_control->resize (_input->n_ports().n_audio ());
3327 io_changed (); /* EMIT SIGNAL */
3330 if (_solo_control->soloed_by_others_upstream() || _solo_isolate_control->solo_isolated_by_upstream()) {
3333 boost::shared_ptr<RouteList> routes = _session.get_routes ();
3334 if (_input->connected()) {
3335 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3336 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3340 bool does_feed = (*i)->direct_feeds_according_to_reality (boost::dynamic_pointer_cast<Route> (shared_from_this()), &sends_only);
3341 if (does_feed && !sends_only) {
3342 if ((*i)->soloed()) {
3345 if ((*i)->solo_isolate_control()->solo_isolated()) {
3352 int delta = sbou - _solo_control->soloed_by_others_upstream();
3353 int idelta = ibou - _solo_isolate_control->solo_isolated_by_upstream();
3356 PBD::warning << string_compose (
3357 _("Invalid Solo-Isolate propagation: from:%1 new:%2 - old:%3 = delta:%4"),
3358 _name, ibou, _solo_isolate_control->solo_isolated_by_upstream(), idelta)
3363 if (_solo_control->soloed_by_others_upstream()) {
3364 // ignore new connections (they're not propagated)
3366 _solo_control->mod_solo_by_others_upstream (delta);
3370 if (_solo_isolate_control->solo_isolated_by_upstream()) {
3371 // solo-isolate currently only propagates downstream
3373 _solo_isolate_control->mod_solo_isolated_by_upstream (1);
3375 //_solo_isolated_by_upstream = ibou;
3378 // Session::route_solo_changed does not propagate indirect solo-changes
3379 // propagate downstream to tracks
3380 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3381 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3385 bool does_feed = feeds (*i, &sends_only);
3386 if (delta <= 0 && does_feed && !sends_only) {
3387 (*i)->solo_control()->mod_solo_by_others_upstream (delta);
3390 if (idelta < 0 && does_feed && !sends_only) {
3391 (*i)->solo_isolate_control()->mod_solo_isolated_by_upstream (-1);
3398 Route::output_change_handler (IOChange change, void * /*src*/)
3400 if (_initial_io_setup) {
3404 if ((change.type & IOChange::ConfigurationChanged)) {
3405 /* This is called with the process lock held if change
3406 contains ConfigurationChanged
3408 configure_processors (0);
3411 _session.reset_monitor_section();
3414 io_changed (); /* EMIT SIGNAL */
3417 if ((change.type & IOChange::ConnectionsChanged)) {
3419 /* do this ONLY if connections have changed. Configuration
3420 * changes do not, by themselves alter solo upstream or
3421 * downstream status.
3424 if (_solo_control->soloed_by_others_downstream()) {
3426 /* checking all all downstream routes for
3427 * explicit of implict solo is a rather drastic measure,
3428 * ideally the input_change_handler() of the other route
3429 * would propagate the change to us.
3431 boost::shared_ptr<RouteList> routes = _session.get_routes ();
3432 if (_output->connected()) {
3433 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3434 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3438 bool does_feed = direct_feeds_according_to_reality (*i, &sends_only);
3439 if (does_feed && !sends_only) {
3440 if ((*i)->soloed()) {
3448 int delta = sbod - _solo_control->soloed_by_others_downstream();
3450 // do not allow new connections to change implicit solo (no propagation)
3451 _solo_control->mod_solo_by_others_downstream (delta);
3452 // Session::route_solo_changed() does not propagate indirect solo-changes
3453 // propagate upstream to tracks
3454 boost::shared_ptr<Route> shared_this = boost::dynamic_pointer_cast<Route> (shared_from_this());
3455 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3456 if ((*i).get() == this || !can_solo()) {
3460 bool does_feed = (*i)->feeds (shared_this, &sends_only);
3461 if (delta != 0 && does_feed && !sends_only) {
3462 (*i)->solo_control()->mod_solo_by_others_downstream (delta);
3472 Route::sidechain_change_handler (IOChange change, void* src)
3474 if (_initial_io_setup || _in_sidechain_setup) {
3478 input_change_handler (change, src);
3482 Route::pans_required () const
3484 if (n_outputs().n_audio() < 2) {
3488 return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
3492 Route::flush_processor_buffers_locked (framecnt_t nframes)
3494 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3495 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery> (*i);
3497 d->flush_buffers (nframes);
3499 boost::shared_ptr<PortInsert> p = boost::dynamic_pointer_cast<PortInsert> (*i);
3501 p->flush_buffers (nframes);
3508 Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
3510 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3517 silence_unlocked (nframes);
3521 if (session_state_changing) {
3522 if (_session.transport_speed() != 0.0f) {
3523 /* we're rolling but some state is changing (e.g. our diskstream contents)
3524 so we cannot use them. Be silent till this is over.
3526 XXX note the absurdity of ::no_roll() being called when we ARE rolling!
3528 silence_unlocked (nframes);
3531 /* we're really not rolling, so we're either delivery silence or actually
3532 monitoring, both of which are safe to do while session_state_changing is true.
3536 BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
3538 fill_buffers_with_input (bufs, _input, nframes);
3540 if (_meter_point == MeterInput) {
3541 _meter->run (bufs, start_frame, end_frame, 0.0, nframes, true);
3544 _amp->apply_gain_automation (false);
3545 _trim->apply_gain_automation (false);
3546 passthru (bufs, start_frame, end_frame, nframes, 0);
3548 flush_processor_buffers_locked (nframes);
3554 Route::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& /* need_butler */)
3556 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3562 silence_unlocked (nframes);
3566 framepos_t unused = 0;
3568 if ((nframes = check_initial_delay (nframes, unused)) == 0) {
3574 BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
3576 fill_buffers_with_input (bufs, _input, nframes);
3578 if (_meter_point == MeterInput) {
3579 _meter->run (bufs, start_frame, end_frame, 1.0, nframes, true);
3582 passthru (bufs, start_frame, end_frame, nframes, declick);
3584 flush_processor_buffers_locked (nframes);
3590 Route::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*end_frame*/, bool& /* need_butler */)
3593 flush_processor_buffers_locked (nframes);
3598 Route::flush_processors ()
3600 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3602 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3608 __attribute__((annotate("realtime")))
3611 Route::apply_processor_changes_rt ()
3613 int emissions = EmitNone;
3615 if (_pending_meter_point != _meter_point) {
3616 Glib::Threads::RWLock::WriterLock pwl (_processor_lock, Glib::Threads::TRY_LOCK);
3618 /* meters always have buffers for 'processor_max_streams'
3619 * they can be re-positioned without re-allocation */
3620 if (set_meter_point_unlocked()) {
3621 emissions |= EmitMeterChanged | EmitMeterVisibilityChange;;
3623 emissions |= EmitMeterChanged;
3628 bool changed = false;
3630 if (g_atomic_int_get (&_pending_process_reorder)) {
3631 Glib::Threads::RWLock::WriterLock pwl (_processor_lock, Glib::Threads::TRY_LOCK);
3633 apply_processor_order (_pending_processor_order);
3634 setup_invisible_processors ();
3636 g_atomic_int_set (&_pending_process_reorder, 0);
3637 emissions |= EmitRtProcessorChange;
3641 set_processor_positions ();
3643 if (emissions != 0) {
3644 g_atomic_int_set (&_pending_signals, emissions);
3647 return (!selfdestruct_sequence.empty ());
3651 Route::emit_pending_signals ()
3653 int sig = g_atomic_int_and (&_pending_signals, 0);
3654 if (sig & EmitMeterChanged) {
3655 _meter->emit_configuration_changed();
3656 meter_change (); /* EMIT SIGNAL */
3657 if (sig & EmitMeterVisibilityChange) {
3658 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */
3660 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */
3663 if (sig & EmitRtProcessorChange) {
3664 processors_changed (RouteProcessorChange (RouteProcessorChange::RealTimeChange)); /* EMIT SIGNAL */
3667 /* this would be a job for the butler.
3668 * Conceptually we should not take processe/processor locks here.
3669 * OTOH its more efficient (less overhead for summoning the butler and
3670 * telling her what do do) and signal emission is called
3671 * directly after the process callback, which decreases the chance
3672 * of x-runs when taking the locks.
3674 while (!selfdestruct_sequence.empty ()) {
3675 Glib::Threads::Mutex::Lock lx (selfdestruct_lock);
3676 if (selfdestruct_sequence.empty ()) { break; } // re-check with lock
3677 boost::shared_ptr<Processor> proc = selfdestruct_sequence.back ().lock ();
3678 selfdestruct_sequence.pop_back ();
3681 remove_processor (proc);
3687 Route::set_meter_point (MeterPoint p, bool force)
3689 if (_pending_meter_point == p && !force) {
3693 if (force || !AudioEngine::instance()->running()) {
3694 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
3695 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
3696 _pending_meter_point = p;
3697 _meter->emit_configuration_changed();
3698 meter_change (); /* EMIT SIGNAL */
3699 if (set_meter_point_unlocked()) {
3700 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */
3702 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */
3705 _pending_meter_point = p;
3711 __attribute__((annotate("realtime")))
3714 Route::set_meter_point_unlocked ()
3717 /* Caller must hold process and processor write lock */
3718 assert (!AudioEngine::instance()->process_lock().trylock());
3719 Glib::Threads::RWLock::WriterLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3720 assert (!lm.locked ());
3723 _meter_point = _pending_meter_point;
3725 bool meter_was_visible_to_user = _meter->display_to_user ();
3727 if (!_custom_meter_position_noted) {
3728 maybe_note_meter_position ();
3731 if (_meter_point != MeterCustom) {
3733 _meter->set_display_to_user (false);
3735 setup_invisible_processors ();
3738 _meter->set_display_to_user (true);
3740 /* If we have a previous position for the custom meter, try to put it there */
3741 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
3743 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), after);
3744 if (i != _processors.end ()) {
3745 _processors.remove (_meter);
3746 _processors.insert (i, _meter);
3748 } else {// at end, right before the mains_out/panner
3749 _processors.remove (_meter);
3750 ProcessorList::iterator main = _processors.end();
3751 _processors.insert (--main, _meter);
3755 /* Set up the meter for its new position */
3757 ProcessorList::iterator loc = find (_processors.begin(), _processors.end(), _meter);
3761 if (loc == _processors.begin()) {
3762 m_in = _input->n_ports();
3764 ProcessorList::iterator before = loc;
3766 m_in = (*before)->output_streams ();
3769 _meter->reflect_inputs (m_in);
3771 /* we do not need to reconfigure the processors, because the meter
3772 (a) is always ready to handle processor_max_streams
3773 (b) is always an N-in/N-out processor, and thus moving
3774 it doesn't require any changes to the other processors.
3777 /* these should really be done after releasing the lock
3778 * but all those signals are subscribed to with gui_thread()
3781 return (_meter->display_to_user() != meter_was_visible_to_user);
3785 Route::listen_position_changed ()
3788 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
3789 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
3790 ProcessorState pstate (this);
3792 if (configure_processors_unlocked (0, &lm)) {
3793 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
3795 configure_processors_unlocked (0, &lm); // it worked before we tried to add it ...
3800 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
3801 _session.set_dirty ();
3804 boost::shared_ptr<CapturingProcessor>
3805 Route::add_export_point()
3807 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3808 if (!_capturing_processor) {
3810 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
3811 Glib::Threads::RWLock::WriterLock lw (_processor_lock);
3813 // this aligns all tracks; but not tracks + busses
3814 assert (_session.worst_track_latency () >= _initial_delay);
3815 _capturing_processor.reset (new CapturingProcessor (_session, _session.worst_track_latency () - _initial_delay));
3816 _capturing_processor->activate ();
3818 configure_processors_unlocked (0, &lw);
3822 return _capturing_processor;
3826 Route::update_signal_latency ()
3828 framecnt_t l = _output->user_latency();
3829 framecnt_t lamp = 0;
3830 bool before_amp = true;
3831 framecnt_t ltrim = 0;
3832 bool before_trim = true;
3834 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3835 if ((*i)->active ()) {
3836 l += (*i)->signal_latency ();
3841 if ((*i) == _trim) {
3852 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal signal latency = %2\n", _name, l));
3854 // TODO: (lamp - _signal_latency) to sync to output (read-ahed), currently _roll_delay shifts this around
3855 _signal_latency_at_amp_position = lamp;
3856 _signal_latency_at_trim_position = ltrim;
3858 if (_signal_latency != l) {
3859 _signal_latency = l;
3860 signal_latency_changed (); /* EMIT SIGNAL */
3863 return _signal_latency;
3867 Route::set_user_latency (framecnt_t nframes)
3869 _output->set_user_latency (nframes);
3870 _session.update_latency_compensation ();
3874 Route::set_latency_compensation (framecnt_t longest_session_latency)
3876 framecnt_t old = _initial_delay;
3878 if (_signal_latency < longest_session_latency) {
3879 _initial_delay = longest_session_latency - _signal_latency;
3884 DEBUG_TRACE (DEBUG::Latency, string_compose (
3885 "%1: compensate for maximum latency of %2,"
3886 "given own latency of %3, using initial delay of %4\n",
3887 name(), longest_session_latency, _signal_latency, _initial_delay));
3889 if (_initial_delay != old) {
3890 initial_delay_changed (); /* EMIT SIGNAL */
3893 if (_session.transport_stopped()) {
3894 _roll_delay = _initial_delay;
3899 Route::set_block_size (pframes_t nframes)
3901 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3902 (*i)->set_block_size (nframes);
3905 _session.ensure_buffers (n_process_buffers ());
3909 Route::protect_automation ()
3911 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i)
3912 (*i)->protect_automation();
3915 /** @param declick 1 to set a pending declick fade-in,
3916 * -1 to set a pending declick fade-out
3919 Route::set_pending_declick (int declick)
3922 /* this call is not allowed to turn off a pending declick */
3924 _pending_declick = declick;
3927 _pending_declick = 0;
3931 /** Shift automation forwards from a particular place, thereby inserting time.
3932 * Adds undo commands for any shifts that are performed.
3934 * @param pos Position to start shifting from.
3935 * @param frames Amount to shift forwards by.
3939 Route::shift (framepos_t pos, framecnt_t frames)
3941 /* gain automation */
3943 boost::shared_ptr<AutomationControl> gc = _amp->gain_control();
3945 XMLNode &before = gc->alist()->get_state ();
3946 gc->alist()->shift (pos, frames);
3947 XMLNode &after = gc->alist()->get_state ();
3948 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
3951 /* gain automation */
3953 boost::shared_ptr<AutomationControl> gc = _trim->gain_control();
3955 XMLNode &before = gc->alist()->get_state ();
3956 gc->alist()->shift (pos, frames);
3957 XMLNode &after = gc->alist()->get_state ();
3958 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
3961 // TODO mute automation ??
3963 /* pan automation */
3965 ControlSet::Controls& c (_pannable->controls());
3967 for (ControlSet::Controls::const_iterator ci = c.begin(); ci != c.end(); ++ci) {
3968 boost::shared_ptr<AutomationControl> pc = boost::dynamic_pointer_cast<AutomationControl> (ci->second);
3970 boost::shared_ptr<AutomationList> al = pc->alist();
3971 XMLNode& before = al->get_state ();
3972 al->shift (pos, frames);
3973 XMLNode& after = al->get_state ();
3974 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
3979 /* redirect automation */
3981 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3982 for (ProcessorList::iterator i = _processors.begin (); i != _processors.end (); ++i) {
3984 set<Evoral::Parameter> parameters = (*i)->what_can_be_automated();
3986 for (set<Evoral::Parameter>::const_iterator p = parameters.begin (); p != parameters.end (); ++p) {
3987 boost::shared_ptr<AutomationControl> ac = (*i)->automation_control (*p);
3989 boost::shared_ptr<AutomationList> al = ac->alist();
3990 XMLNode &before = al->get_state ();
3991 al->shift (pos, frames);
3992 XMLNode &after = al->get_state ();
3993 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
4001 Route::set_plugin_state_dir (boost::weak_ptr<Processor> p, const std::string& d)
4003 boost::shared_ptr<Processor> processor (p.lock ());
4004 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
4008 pi->set_state_dir (d);
4012 Route::save_as_template (const string& path, const string& name)
4014 std::string state_dir = path.substr (0, path.find_last_of ('.')); // strip template_suffix
4015 PBD::Unwinder<std::string> uw (_session._template_state_dir, state_dir);
4017 XMLNode& node (state (false));
4021 IO::set_name_in_state (*node.children().front(), name);
4023 tree.set_root (&node);
4025 /* return zero on success, non-zero otherwise */
4026 return !tree.write (path.c_str());
4031 Route::set_name (const string& str)
4037 if (str == name()) {
4041 string name = Route::ensure_track_or_route_name (str, _session);
4042 SessionObject::set_name (name);
4044 bool ret = (_input->set_name(name) && _output->set_name(name));
4047 /* rename the main outs. Leave other IO processors
4048 * with whatever name they already have, because its
4049 * just fine as it is (it will not contain the route
4050 * name if its a port insert, port send or port return).
4054 if (_main_outs->set_name (name)) {
4055 /* XXX returning false here is stupid because
4056 we already changed the route name.
4066 /** Set the name of a route in an XML description.
4067 * @param node XML <Route> node to set the name in.
4068 * @param name New name.
4071 Route::set_name_in_state (XMLNode& node, string const & name, bool rename_playlist)
4073 node.set_property (X_("name"), name);
4075 XMLNodeList children = node.children();
4076 for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
4078 if ((*i)->name() == X_("IO")) {
4080 IO::set_name_in_state (**i, name);
4082 } else if ((*i)->name() == X_("Processor")) {
4085 if ((*i)->get_property (X_("role"), str) && str == X_("Main")) {
4086 (*i)->set_property (X_("name"), name);
4089 } else if ((*i)->name() == X_("Diskstream")) {
4091 if (rename_playlist) {
4092 (*i)->set_property (X_("playlist"), name + ".1");
4094 (*i)->set_property (X_("name"), name);
4100 boost::shared_ptr<Send>
4101 Route::internal_send_for (boost::shared_ptr<const Route> target) const
4103 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4105 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4106 boost::shared_ptr<InternalSend> send;
4108 if ((send = boost::dynamic_pointer_cast<InternalSend>(*i)) != 0) {
4109 if (send->target_route() == target) {
4115 return boost::shared_ptr<Send>();
4119 Route::set_denormal_protection (bool yn)
4121 if (_denormal_protection != yn) {
4122 _denormal_protection = yn;
4123 denormal_protection_changed (); /* EMIT SIGNAL */
4128 Route::denormal_protection () const
4130 return _denormal_protection;
4134 Route::set_active (bool yn, void* src)
4136 if (_session.transport_rolling()) {
4140 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_route_active()) {
4141 _route_group->foreach_route (boost::bind (&Route::set_active, _1, yn, _route_group));
4145 if (_active != yn) {
4147 _input->set_active (yn);
4148 _output->set_active (yn);
4149 flush_processors ();
4150 active_changed (); // EMIT SIGNAL
4151 _session.set_dirty ();
4155 boost::shared_ptr<Pannable>
4156 Route::pannable() const
4161 boost::shared_ptr<Panner>
4162 Route::panner() const
4165 return _main_outs->panner_shell()->panner();
4168 boost::shared_ptr<PannerShell>
4169 Route::panner_shell() const
4171 return _main_outs->panner_shell();
4174 boost::shared_ptr<GainControl>
4175 Route::gain_control() const
4177 return _gain_control;
4180 boost::shared_ptr<GainControl>
4181 Route::trim_control() const
4183 return _trim_control;
4186 boost::shared_ptr<PhaseControl>
4187 Route::phase_control() const
4189 return _phase_control;
4192 boost::shared_ptr<AutomationControl>
4193 Route::get_control (const Evoral::Parameter& param)
4195 /* either we own the control or .... */
4197 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(control (param));
4201 /* maybe one of our processors does or ... */
4203 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
4204 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4205 if ((c = boost::dynamic_pointer_cast<AutomationControl>((*i)->control (param))) != 0) {
4213 /* nobody does so we'll make a new one */
4215 c = boost::dynamic_pointer_cast<AutomationControl>(control_factory(param));
4222 boost::shared_ptr<Processor>
4223 Route::nth_plugin (uint32_t n) const
4225 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4226 ProcessorList::const_iterator i;
4228 for (i = _processors.begin(); i != _processors.end(); ++i) {
4229 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
4236 return boost::shared_ptr<Processor> ();
4239 boost::shared_ptr<Processor>
4240 Route::nth_send (uint32_t n) const
4242 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4243 ProcessorList::const_iterator i;
4245 for (i = _processors.begin(); i != _processors.end(); ++i) {
4246 if (boost::dynamic_pointer_cast<Send> (*i)) {
4248 if ((*i)->name().find (_("Monitor")) == 0) {
4249 /* send to monitor section is not considered
4250 to be an accessible send.
4261 return boost::shared_ptr<Processor> ();
4265 Route::has_io_processor_named (const string& name)
4267 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4268 ProcessorList::iterator i;
4270 for (i = _processors.begin(); i != _processors.end(); ++i) {
4271 if (boost::dynamic_pointer_cast<Send> (*i) ||
4272 boost::dynamic_pointer_cast<PortInsert> (*i)) {
4273 if ((*i)->name() == name) {
4283 Route::set_processor_positions ()
4285 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4287 bool had_amp = false;
4288 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4289 (*i)->set_pre_fader (!had_amp);
4296 /** Called when there is a proposed change to the input port count */
4298 Route::input_port_count_changing (ChanCount to)
4300 list<pair<ChanCount, ChanCount> > c = try_configure_processors (to, 0);
4302 /* The processors cannot be configured with the new input arrangement, so
4308 /* The change is ok */
4312 /** Called when there is a proposed change to the output port count */
4314 Route::output_port_count_changing (ChanCount to)
4316 if (_strict_io && !_in_configure_processors) {
4319 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
4320 if (processor_out_streams.get(*t) > to.get(*t)) {
4324 /* The change is ok */
4329 Route::unknown_processors () const
4333 if (_session.get_disable_all_loaded_plugins ()) {
4334 // Do not list "missing plugins" if they are explicitly disabled
4338 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4339 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4340 if (boost::dynamic_pointer_cast<UnknownProcessor const> (*i)) {
4341 p.push_back ((*i)->name ());
4350 Route::update_port_latencies (PortSet& from, PortSet& to, bool playback, framecnt_t our_latency) const
4352 /* we assume that all our input ports feed all our output ports. its not
4353 universally true, but the alternative is way too corner-case to worry about.
4356 LatencyRange all_connections;
4359 all_connections.min = 0;
4360 all_connections.max = 0;
4362 all_connections.min = ~((pframes_t) 0);
4363 all_connections.max = 0;
4365 /* iterate over all "from" ports and determine the latency range for all of their
4366 connections to the "outside" (outside of this Route).
4369 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
4373 p->get_connected_latency_range (range, playback);
4375 all_connections.min = min (all_connections.min, range.min);
4376 all_connections.max = max (all_connections.max, range.max);
4380 /* set the "from" port latencies to the max/min range of all their connections */
4382 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
4383 p->set_private_latency_range (all_connections, playback);
4386 /* set the ports "in the direction of the flow" to the same value as above plus our own signal latency */
4388 all_connections.min += our_latency;
4389 all_connections.max += our_latency;
4391 for (PortSet::iterator p = to.begin(); p != to.end(); ++p) {
4392 p->set_private_latency_range (all_connections, playback);
4395 return all_connections.max;
4399 Route::set_private_port_latencies (bool playback) const
4401 framecnt_t own_latency = 0;
4403 /* Processor list not protected by lock: MUST BE CALLED FROM PROCESS THREAD
4404 OR LATENCY CALLBACK.
4406 This is called (early) from the latency callback. It computes the REAL
4407 latency associated with each port and stores the result as the "private"
4408 latency of the port. A later call to Route::set_public_port_latencies()
4409 sets all ports to the same value to reflect the fact that we do latency
4410 compensation and so all signals are delayed by the same amount as they
4411 flow through ardour.
4414 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4415 if ((*i)->active ()) {
4416 own_latency += (*i)->signal_latency ();
4421 /* playback: propagate latency from "outside the route" to outputs to inputs */
4422 return update_port_latencies (_output->ports (), _input->ports (), true, own_latency);
4424 /* capture: propagate latency from "outside the route" to inputs to outputs */
4425 return update_port_latencies (_input->ports (), _output->ports (), false, own_latency);
4430 Route::set_public_port_latencies (framecnt_t value, bool playback) const
4432 /* this is called to set the JACK-visible port latencies, which take
4433 latency compensation into account.
4442 const PortSet& ports (_input->ports());
4443 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
4444 p->set_public_latency_range (range, playback);
4449 const PortSet& ports (_output->ports());
4450 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
4451 p->set_public_latency_range (range, playback);
4456 /** Put the invisible processors in the right place in _processors.
4457 * Must be called with a writer lock on _processor_lock held.
4460 __attribute__((annotate("realtime")))
4463 Route::setup_invisible_processors ()
4466 Glib::Threads::RWLock::WriterLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
4467 assert (!lm.locked ());
4471 /* too early to be doing this stuff */
4475 /* we'll build this new list here and then use it
4477 * TODO put the ProcessorList is on the stack for RT-safety.
4480 ProcessorList new_processors;
4482 /* find visible processors */
4484 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4485 if ((*i)->display_to_user ()) {
4486 new_processors.push_back (*i);
4492 ProcessorList::iterator amp = find (new_processors.begin(), new_processors.end(), _amp);
4494 if (amp == new_processors.end ()) {
4495 error << string_compose (_("Amp/Fader on Route '%1' went AWOL. Re-added."), name()) << endmsg;
4496 new_processors.push_front (_amp);
4497 amp = find (new_processors.begin(), new_processors.end(), _amp);
4500 /* and the processor after the amp */
4502 ProcessorList::iterator after_amp = amp;
4508 switch (_meter_point) {
4510 assert (!_meter->display_to_user ());
4511 new_processors.push_front (_meter);
4514 assert (!_meter->display_to_user ());
4515 new_processors.insert (amp, _meter);
4517 case MeterPostFader:
4518 /* do nothing here */
4521 /* do nothing here */
4524 /* the meter is visible, so we don't touch it here */
4531 assert (_main_outs);
4532 assert (!_main_outs->display_to_user ());
4533 new_processors.push_back (_main_outs);
4535 /* iterator for the main outs */
4537 ProcessorList::iterator main = new_processors.end();
4540 /* OUTPUT METERING */
4542 if (_meter && (_meter_point == MeterOutput || _meter_point == MeterPostFader)) {
4543 assert (!_meter->display_to_user ());
4545 /* add the processor just before or just after the main outs */
4547 ProcessorList::iterator meter_point = main;
4549 if (_meter_point == MeterOutput) {
4552 new_processors.insert (meter_point, _meter);
4557 if (_monitor_send && !is_monitor ()) {
4558 assert (!_monitor_send->display_to_user ());
4559 switch (Config->get_listen_position ()) {
4560 case PreFaderListen:
4561 switch (Config->get_pfl_position ()) {
4562 case PFLFromBeforeProcessors:
4563 new_processors.push_front (_monitor_send);
4565 case PFLFromAfterProcessors:
4566 new_processors.insert (amp, _monitor_send);
4569 _monitor_send->set_can_pan (false);
4571 case AfterFaderListen:
4572 switch (Config->get_afl_position ()) {
4573 case AFLFromBeforeProcessors:
4574 new_processors.insert (after_amp, _monitor_send);
4576 case AFLFromAfterProcessors:
4577 new_processors.insert (new_processors.end(), _monitor_send);
4580 _monitor_send->set_can_pan (true);
4585 #if 0 // not used - just yet
4586 if (!is_master() && !is_monitor() && !is_auditioner()) {
4587 new_processors.push_front (_delayline);
4591 /* MONITOR CONTROL */
4593 if (_monitor_control && is_monitor ()) {
4594 assert (!_monitor_control->display_to_user ());
4595 new_processors.insert (amp, _monitor_control);
4600 if (_trim && _trim->active()) {
4601 assert (!_trim->display_to_user ());
4602 new_processors.push_front (_trim);
4605 /* INTERNAL RETURN */
4607 /* doing this here means that any monitor control will come after
4608 the return and trim.
4612 assert (!_intreturn->display_to_user ());
4613 new_processors.push_front (_intreturn);
4616 /* EXPORT PROCESSOR */
4618 if (_capturing_processor) {
4619 assert (!_capturing_processor->display_to_user ());
4620 new_processors.push_front (_capturing_processor);
4623 _processors = new_processors;
4625 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4626 if (!(*i)->display_to_user () && !(*i)->enabled () && (*i) != _monitor_send) {
4627 (*i)->enable (true);
4631 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: setup_invisible_processors\n", _name));
4632 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4633 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1\n", (*i)->name ()));
4640 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
4641 Glib::Threads::RWLock::ReaderLock lp (_processor_lock);
4645 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4646 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery>(*i);
4653 /** If the meter point is `Custom', make a note of where the meter is.
4654 * This is so that if the meter point is subsequently set to something else,
4655 * and then back to custom, we can put the meter back where it was last time
4656 * custom was enabled.
4658 * Must be called with the _processor_lock held.
4661 Route::maybe_note_meter_position ()
4663 if (_meter_point != MeterCustom) {
4667 _custom_meter_position_noted = true;
4668 /* custom meter points range from after trim to before panner/main_outs
4669 * this is a limitation by the current processor UI
4671 bool seen_trim = false;
4672 _processor_after_last_custom_meter.reset();
4673 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4674 if ((*i) == _trim) {
4677 if ((*i) == _main_outs) {
4678 _processor_after_last_custom_meter = *i;
4681 if (boost::dynamic_pointer_cast<PeakMeter> (*i)) {
4683 _processor_after_last_custom_meter = _trim;
4685 ProcessorList::iterator j = i;
4687 assert(j != _processors.end ()); // main_outs should be before
4688 _processor_after_last_custom_meter = *j;
4693 assert(_processor_after_last_custom_meter.lock());
4696 boost::shared_ptr<Processor>
4697 Route::processor_by_id (PBD::ID id) const
4699 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4700 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4701 if ((*i)->id() == id) {
4706 return boost::shared_ptr<Processor> ();
4709 /** @return the monitoring state, or in other words what data we are pushing
4710 * into the route (data from the inputs, data from disk or silence)
4713 Route::monitoring_state () const
4715 return MonitoringInput;
4718 /** @return what we should be metering; either the data coming from the input
4719 * IO or the data that is flowing through the route.
4722 Route::metering_state () const
4724 return MeteringRoute;
4728 Route::has_external_redirects () const
4730 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4732 /* ignore inactive processors and obviously ignore the main
4733 * outs since everything has them and we don't care.
4736 if ((*i)->active() && (*i) != _main_outs && (*i)->does_routing()) {
4744 boost::shared_ptr<Processor>
4745 Route::the_instrument () const
4747 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4748 return the_instrument_unlocked ();
4751 boost::shared_ptr<Processor>
4752 Route::the_instrument_unlocked () const
4754 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4755 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*i);
4756 if (pi && pi->plugin ()->get_info ()->is_instrument ()) {
4760 return boost::shared_ptr<Processor>();
4766 Route::non_realtime_locate (framepos_t pos)
4769 _pannable->transport_located (pos);
4772 if (_delayline.get()) {
4773 _delayline.get()->flush();
4777 //Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
4778 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4780 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4781 (*i)->transport_located (pos);
4784 _roll_delay = _initial_delay;
4788 Route::fill_buffers_with_input (BufferSet& bufs, boost::shared_ptr<IO> io, pframes_t nframes)
4795 * We don't currently mix MIDI input together, so we don't need the
4796 * complex logic of the audio case.
4799 n_buffers = bufs.count().n_midi ();
4801 for (i = 0; i < n_buffers; ++i) {
4803 boost::shared_ptr<MidiPort> source_port = io->midi (i);
4804 MidiBuffer& buf (bufs.get_midi (i));
4807 buf.copy (source_port->get_midi_buffer(nframes));
4809 buf.silence (nframes);
4815 n_buffers = bufs.count().n_audio();
4817 size_t n_ports = io->n_ports().n_audio();
4818 float scaling = 1.0f;
4820 if (n_ports > n_buffers) {
4821 scaling = ((float) n_buffers) / n_ports;
4824 for (i = 0; i < n_ports; ++i) {
4826 /* if there are more ports than buffers, map them onto buffers
4827 * in a round-robin fashion
4830 boost::shared_ptr<AudioPort> source_port = io->audio (i);
4831 AudioBuffer& buf (bufs.get_audio (i%n_buffers));
4834 if (i < n_buffers) {
4836 /* first time through just copy a channel into
4840 buf.read_from (source_port->get_audio_buffer (nframes), nframes);
4842 if (scaling != 1.0f) {
4843 buf.apply_gain (scaling, nframes);
4848 /* on subsequent times around, merge data from
4849 * the port with what is already there
4852 if (scaling != 1.0f) {
4853 buf.accumulate_with_gain_from (source_port->get_audio_buffer (nframes), nframes, 0, scaling);
4855 buf.accumulate_from (source_port->get_audio_buffer (nframes), nframes);
4860 /* silence any remaining buffers */
4862 for (; i < n_buffers; ++i) {
4863 AudioBuffer& buf (bufs.get_audio (i));
4864 buf.silence (nframes);
4867 /* establish the initial setup of the buffer set, reflecting what was
4868 copied into it. unless, of course, we are the auditioner, in which
4869 case nothing was fed into it from the inputs at all.
4872 if (!is_auditioner()) {
4873 bufs.set_count (io->n_ports());
4877 boost::shared_ptr<AutomationControl>
4878 Route::pan_azimuth_control() const
4881 # undef MIXBUS_PORTS_H
4882 # include "../../gtk2_ardour/mixbus_ports.h"
4883 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
4885 return boost::shared_ptr<AutomationControl>();
4887 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
4889 if (!_pannable || !panner()) {
4890 return boost::shared_ptr<AutomationControl>();
4892 return _pannable->pan_azimuth_control;
4896 boost::shared_ptr<AutomationControl>
4897 Route::pan_elevation_control() const
4899 if (Profile->get_mixbus() || !_pannable || !panner()) {
4900 return boost::shared_ptr<AutomationControl>();
4903 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
4905 if (c.find (PanElevationAutomation) != c.end()) {
4906 return _pannable->pan_elevation_control;
4908 return boost::shared_ptr<AutomationControl>();
4911 boost::shared_ptr<AutomationControl>
4912 Route::pan_width_control() const
4915 if (mixbus() && _ch_pre) {
4917 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(_ch_pre->control(Evoral::Parameter(PluginAutomation, 0, 5)));
4920 if (Profile->get_mixbus() || !_pannable || !panner()) {
4921 return boost::shared_ptr<AutomationControl>();
4924 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
4926 if (c.find (PanWidthAutomation) != c.end()) {
4927 return _pannable->pan_width_control;
4929 return boost::shared_ptr<AutomationControl>();
4932 boost::shared_ptr<AutomationControl>
4933 Route::pan_frontback_control() const
4935 if (Profile->get_mixbus() || !_pannable || !panner()) {
4936 return boost::shared_ptr<AutomationControl>();
4939 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
4941 if (c.find (PanFrontBackAutomation) != c.end()) {
4942 return _pannable->pan_frontback_control;
4944 return boost::shared_ptr<AutomationControl>();
4947 boost::shared_ptr<AutomationControl>
4948 Route::pan_lfe_control() const
4950 if (Profile->get_mixbus() || !_pannable || !panner()) {
4951 return boost::shared_ptr<AutomationControl>();
4954 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
4956 if (c.find (PanLFEAutomation) != c.end()) {
4957 return _pannable->pan_lfe_control;
4959 return boost::shared_ptr<AutomationControl>();
4964 Route::eq_band_cnt () const
4966 if (Profile->get_mixbus()) {
4968 if (is_master() || mixbus()) {
4977 /* Ardour has no well-known EQ object */
4982 boost::shared_ptr<AutomationControl>
4983 Route::eq_gain_controllable (uint32_t band) const
4986 boost::shared_ptr<PluginInsert> eq = ch_eq();
4989 return boost::shared_ptr<AutomationControl>();
4992 uint32_t port_number;
4993 if (is_master() || mixbus()) {
4995 case 0: port_number = 4; break;
4996 case 1: port_number = 3; break;
4997 case 2: port_number = 2; break;
4999 return boost::shared_ptr<AutomationControl>();
5004 case 0: port_number = 14; break;
5005 case 1: port_number = 12; break;
5006 case 2: port_number = 10; break;
5007 case 3: port_number = 8; break;
5009 return boost::shared_ptr<AutomationControl>();
5013 case 0: port_number = 8; break;
5014 case 1: port_number = 6; break;
5015 case 2: port_number = 4; break;
5017 return boost::shared_ptr<AutomationControl>();
5022 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
5024 return boost::shared_ptr<AutomationControl>();
5027 boost::shared_ptr<AutomationControl>
5028 Route::eq_freq_controllable (uint32_t band) const
5031 if (mixbus() || is_master()) {
5032 /* no frequency controls for mixbusses or master */
5033 return boost::shared_ptr<AutomationControl>();
5036 boost::shared_ptr<PluginInsert> eq = ch_eq();
5039 return boost::shared_ptr<AutomationControl>();
5042 uint32_t port_number;
5045 case 0: port_number = 13; break; // lo
5046 case 1: port_number = 11; break; // lo mid
5047 case 2: port_number = 9; break; // hi mid
5048 case 3: port_number = 7; break; // hi
5050 return boost::shared_ptr<AutomationControl>();
5054 case 0: port_number = 7; break;
5055 case 1: port_number = 5; break;
5056 case 2: port_number = 3; break;
5058 return boost::shared_ptr<AutomationControl>();
5062 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
5064 return boost::shared_ptr<AutomationControl>();
5068 boost::shared_ptr<AutomationControl>
5069 Route::eq_q_controllable (uint32_t band) const
5071 return boost::shared_ptr<AutomationControl>();
5074 boost::shared_ptr<AutomationControl>
5075 Route::eq_shape_controllable (uint32_t band) const
5078 boost::shared_ptr<PluginInsert> eq = ch_eq();
5079 if (is_master() || mixbus() || !eq) {
5080 return boost::shared_ptr<AutomationControl>();
5084 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 4))); // lo bell
5087 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 3))); // hi bell
5093 return boost::shared_ptr<AutomationControl>();
5096 boost::shared_ptr<AutomationControl>
5097 Route::eq_enable_controllable () const
5100 boost::shared_ptr<PluginInsert> eq = ch_eq();
5103 return boost::shared_ptr<AutomationControl>();
5106 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 1)));
5108 return boost::shared_ptr<AutomationControl>();
5112 boost::shared_ptr<AutomationControl>
5113 Route::filter_freq_controllable (bool hpf) const
5116 boost::shared_ptr<PluginInsert> eq = ch_eq();
5118 if (is_master() || mixbus() || !eq) {
5119 return boost::shared_ptr<AutomationControl>();
5123 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 5))); // HPF freq
5125 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5129 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 6))); // LPF freq
5131 return boost::shared_ptr<AutomationControl>();
5136 return boost::shared_ptr<AutomationControl>();
5140 boost::shared_ptr<AutomationControl>
5141 Route::filter_slope_controllable (bool) const
5143 return boost::shared_ptr<AutomationControl>();
5146 boost::shared_ptr<AutomationControl>
5147 Route::filter_enable_controllable (bool) const
5150 boost::shared_ptr<PluginInsert> eq = ch_eq();
5152 if (is_master() || mixbus() || !eq) {
5153 return boost::shared_ptr<AutomationControl>();
5156 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5158 return boost::shared_ptr<AutomationControl>();
5163 Route::eq_band_name (uint32_t band) const
5166 if (is_master() || mixbus()) {
5168 if (Profile->get_mixbus()) {
5170 case 0: return _("lo");
5171 case 1: return _("mid");
5172 case 2: return _("hi");
5173 default: return string();
5181 case 0: return _("lo");
5182 case 1: return _("lo mid");
5183 case 2: return _("hi mid");
5184 case 3: return _("hi");
5185 default: return string();
5191 boost::shared_ptr<AutomationControl>
5192 Route::comp_enable_controllable () const
5195 boost::shared_ptr<PluginInsert> comp = ch_comp();
5198 return boost::shared_ptr<AutomationControl>();
5201 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 1)));
5203 return boost::shared_ptr<AutomationControl>();
5206 boost::shared_ptr<AutomationControl>
5207 Route::comp_threshold_controllable () const
5210 boost::shared_ptr<PluginInsert> comp = ch_comp();
5213 return boost::shared_ptr<AutomationControl>();
5216 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5219 return boost::shared_ptr<AutomationControl>();
5222 boost::shared_ptr<AutomationControl>
5223 Route::comp_speed_controllable () const
5226 boost::shared_ptr<PluginInsert> comp = ch_comp();
5229 return boost::shared_ptr<AutomationControl>();
5232 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 3)));
5234 return boost::shared_ptr<AutomationControl>();
5237 boost::shared_ptr<AutomationControl>
5238 Route::comp_mode_controllable () const
5241 boost::shared_ptr<PluginInsert> comp = ch_comp();
5244 return boost::shared_ptr<AutomationControl>();
5247 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 4)));
5249 return boost::shared_ptr<AutomationControl>();
5252 boost::shared_ptr<AutomationControl>
5253 Route::comp_makeup_controllable () const
5256 boost::shared_ptr<PluginInsert> comp = ch_comp();
5259 return boost::shared_ptr<AutomationControl>();
5262 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 5)));
5264 return boost::shared_ptr<AutomationControl>();
5267 boost::shared_ptr<ReadOnlyControl>
5268 Route::comp_redux_controllable () const
5271 boost::shared_ptr<PluginInsert> comp = ch_comp();
5274 return boost::shared_ptr<ReadOnlyControl>();
5277 return comp->control_output (2);
5279 return comp->control_output (6);
5283 return boost::shared_ptr<ReadOnlyControl>();
5288 Route::comp_mode_name (uint32_t mode) const
5293 return _("Leveler");
5295 return _("Compressor");
5297 return _("Limiter");
5299 return mixbus() ? _("Sidechain") : _("Limiter");
5309 Route::comp_speed_name (uint32_t mode) const
5327 boost::shared_ptr<AutomationControl>
5328 Route::send_level_controllable (uint32_t n) const
5331 # undef MIXBUS_PORTS_H
5332 # include "../../gtk2_ardour/mixbus_ports.h"
5333 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5335 uint32_t port_id = 0;
5337 case 0: port_id = port_channel_post_aux1_level; break;
5338 case 1: port_id = port_channel_post_aux2_level; break;
5339 case 2: port_id = port_channel_post_aux3_level; break;
5340 case 3: port_id = port_channel_post_aux4_level; break;
5341 case 4: port_id = port_channel_post_aux5_level; break;
5342 case 5: port_id = port_channel_post_aux6_level; break;
5343 case 6: port_id = port_channel_post_aux7_level; break;
5344 case 7: port_id = port_channel_post_aux8_level; break;
5346 case 8: port_id = port_channel_post_aux9_level; break;
5347 case 9: port_id = port_channel_post_aux10_level; break;
5348 case 10: port_id = port_channel_post_aux11_level; break;
5349 case 11: port_id = port_channel_post_aux12_level; break;
5356 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_id)));
5367 boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(nth_send (n));
5369 return boost::shared_ptr<AutomationControl>();
5371 return s->gain_control ();
5374 boost::shared_ptr<AutomationControl>
5375 Route::send_enable_controllable (uint32_t n) const
5378 # undef MIXBUS_PORTS_H
5379 # include "../../gtk2_ardour/mixbus_ports.h"
5380 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5382 uint32_t port_id = 0;
5384 case 0: port_id = port_channel_post_aux1_asgn; break;
5385 case 1: port_id = port_channel_post_aux2_asgn; break;
5386 case 2: port_id = port_channel_post_aux3_asgn; break;
5387 case 3: port_id = port_channel_post_aux4_asgn; break;
5388 case 4: port_id = port_channel_post_aux5_asgn; break;
5389 case 5: port_id = port_channel_post_aux6_asgn; break;
5390 case 6: port_id = port_channel_post_aux7_asgn; break;
5391 case 7: port_id = port_channel_post_aux8_asgn; break;
5393 case 8: port_id = port_channel_post_aux9_asgn; break;
5394 case 9: port_id = port_channel_post_aux10_asgn; break;
5395 case 10: port_id = port_channel_post_aux11_asgn; break;
5396 case 11: port_id = port_channel_post_aux12_asgn; break;
5403 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_id)));
5414 /* although Ardour sends have enable/disable as part of the Processor
5415 * API, it is not exposed as a controllable.
5417 * XXX: we should fix this (make it click-free, automatable enable-control)
5419 return boost::shared_ptr<AutomationControl>();
5423 Route::send_name (uint32_t n) const
5428 return _session.get_mixbus (n)->name();
5433 return _session.get_mixbus (n)->name();
5438 boost::shared_ptr<Processor> p = nth_send (n);
5446 boost::shared_ptr<AutomationControl>
5447 Route::master_send_enable_controllable () const
5450 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5452 return boost::shared_ptr<AutomationControl>();
5454 # undef MIXBUS_PORTS_H
5455 # include "../../gtk2_ardour/mixbus_ports.h"
5456 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_mstr_assign)));
5458 return boost::shared_ptr<AutomationControl>();
5463 Route::slaved () const
5465 if (!_gain_control) {
5468 /* just test one particular control, not all of them */
5469 return _gain_control->slaved ();
5473 Route::slaved_to (boost::shared_ptr<VCA> vca) const
5475 if (!vca || !_gain_control) {
5479 /* just test one particular control, not all of them */
5481 return _gain_control->slaved_to (vca->gain_control());
5485 Route::muted_by_others_soloing () const
5487 if (!can_be_muted_by_others ()) {
5491 return _session.soloing() && !_solo_control->soloed() && !_solo_isolate_control->solo_isolated();
5495 Route::clear_all_solo_state ()
5497 _solo_control->clear_all_solo_state ();
5500 boost::shared_ptr<AutomationControl>
5501 Route::automation_control_recurse (PBD::ID const & id) const
5503 boost::shared_ptr<AutomationControl> ac = Automatable::automation_control (id);
5509 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5511 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5512 if ((ac = (*i)->automation_control (id))) {
5517 return boost::shared_ptr<AutomationControl> ();