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/memento_command.h"
34 #include "pbd/stacktrace.h"
35 #include "pbd/convert.h"
36 #include "pbd/boost_debug.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/buffer.h"
45 #include "ardour/buffer_set.h"
46 #include "ardour/capturing_processor.h"
47 #include "ardour/debug.h"
48 #include "ardour/delivery.h"
49 #include "ardour/gain_control.h"
50 #include "ardour/internal_return.h"
51 #include "ardour/internal_send.h"
52 #include "ardour/meter.h"
53 #include "ardour/delayline.h"
54 #include "ardour/midi_buffer.h"
55 #include "ardour/midi_port.h"
56 #include "ardour/monitor_processor.h"
57 #include "ardour/pannable.h"
58 #include "ardour/panner.h"
59 #include "ardour/panner_shell.h"
60 #include "ardour/parameter_descriptor.h"
61 #include "ardour/plugin_insert.h"
62 #include "ardour/port.h"
63 #include "ardour/port_insert.h"
64 #include "ardour/processor.h"
65 #include "ardour/profile.h"
66 #include "ardour/route.h"
67 #include "ardour/route_group.h"
68 #include "ardour/send.h"
69 #include "ardour/session.h"
70 #include "ardour/unknown_processor.h"
71 #include "ardour/utils.h"
76 using namespace ARDOUR;
79 PBD::Signal0<void> Route::SyncOrderKeys;
80 PBD::Signal0<void> Route::RemoteControlIDChange;
82 Route::Route (Session& sess, string name, Flag flg, DataType default_type)
83 : SessionObject (sess, name)
85 , GraphNode (sess._process_graph)
88 , _signal_latency_at_amp_position (0)
89 , _signal_latency_at_trim_position (0)
92 , _pending_process_reorder (0)
93 , _pending_signals (0)
95 , _pending_declick (true)
96 , _meter_point (MeterPostFader)
97 , _pending_meter_point (MeterPostFader)
98 , _meter_type (MeterPeak)
100 , _soloed_by_others_upstream (0)
101 , _soloed_by_others_downstream (0)
102 , _solo_isolated (false)
103 , _solo_isolated_by_upstream (0)
104 , _denormal_protection (false)
107 , _declickable (false)
108 , _mute_master (new MuteMaster (sess, name))
109 , _have_internal_generator (false)
111 , _default_type (default_type)
113 , _has_order_key (false)
114 , _remote_control_id (0)
116 , _in_configure_processors (false)
117 , _initial_io_setup (false)
118 , _in_sidechain_setup (false)
120 , _custom_meter_position_noted (false)
122 processor_max_streams.reset();
128 /* set default meter type */
130 _meter_type = Config->get_meter_type_master ();
132 else if (dynamic_cast<Track*>(this)) {
133 _meter_type = Config->get_meter_type_track ();
135 _meter_type = Config->get_meter_type_bus ();
138 /* add standard controls */
140 _solo_control.reset (new SoloControllable (X_("solo"), shared_from_this ()));
141 _mute_control.reset (new MuteControllable (X_("mute"), shared_from_this ()));
142 _phase_control.reset (new PhaseControllable (X_("phase"), shared_from_this ()));
144 _solo_isolate_control.reset (new SoloIsolateControllable (X_("solo-iso"), shared_from_this ()));
145 _solo_safe_control.reset (new SoloSafeControllable (X_("solo-safe"), shared_from_this ()));
147 _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
148 _mute_control->set_flags (Controllable::Flag (_mute_control->flags() | Controllable::Toggle));
149 _phase_control->set_flags (Controllable::Flag (_phase_control->flags() | Controllable::Toggle));
151 add_control (_solo_control);
152 add_control (_mute_control);
153 add_control (_phase_control);
157 if (!(_flags & Route::MonitorOut)) {
158 _pannable.reset (new Pannable (_session));
161 /* input and output objects */
163 _input.reset (new IO (_session, _name, IO::Input, _default_type));
164 _output.reset (new IO (_session, _name, IO::Output, _default_type));
166 _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2));
167 _input->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::input_port_count_changing, this, _1));
169 _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
170 _output->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::output_port_count_changing, this, _1));
172 #if 0 // not used - just yet
173 if (!is_master() && !is_monitor() && !is_auditioner()) {
174 _delayline.reset (new DelayLine (_session, _name));
175 add_processor (_delayline, PreFader);
179 /* add amp processor */
181 _gain_control = boost::shared_ptr<GainControllable> (new GainControllable (_session, GainAutomation, shared_from_this ()));
182 add_control (_gain_control);
184 _amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
185 add_processor (_amp, PostFader);
188 _amp->set_display_name (_("Monitor"));
193 _trim_control = boost::shared_ptr<GainControllable> (new GainControllable (_session, TrimAutomation, shared_from_this ()));
194 add_control (_trim_control);
196 _trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
197 _trim->set_display_to_user (false);
199 if (dynamic_cast<AudioTrack*>(this)) {
200 /* we can't do this in the AudioTrack's constructor
201 * because _trim does not exit then
205 else if (!dynamic_cast<Track*>(this) && ! ( is_monitor() || is_auditioner() )) {
210 /* create standard processors: meter, main outs, monitor out;
211 they will be added to _processors by setup_invisible_processors ()
214 _meter.reset (new PeakMeter (_session, _name));
215 _meter->set_owner (this);
216 _meter->set_display_to_user (false);
219 _main_outs.reset (new Delivery (_session, _output, _pannable, _mute_master, _name, Delivery::Main));
220 _main_outs->activate ();
223 /* where we listen to tracks */
224 _intreturn.reset (new InternalReturn (_session));
225 _intreturn->activate ();
227 /* the thing that provides proper control over a control/monitor/listen bus
228 (such as per-channel cut, dim, solo, invert, etc).
230 _monitor_control.reset (new MonitorProcessor (_session));
231 _monitor_control->activate ();
234 if (is_master() || is_monitor() || is_auditioner()) {
235 _mute_master->set_solo_ignore (true);
238 /* now that we have _meter, its safe to connect to this */
241 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
242 configure_processors (0);
250 DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
252 /* do this early so that we don't get incoming signals as we are going through destruction
257 /* don't use clear_processors here, as it depends on the session which may
258 be half-destroyed by now
261 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
262 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
263 (*i)->drop_references ();
266 _processors.clear ();
270 Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
272 if (Config->get_remote_model() != UserOrdered) {
276 set_remote_control_id_internal (id, notify_class_listeners);
280 Route::set_remote_control_id_internal (uint32_t id, bool notify_class_listeners)
282 /* force IDs for master/monitor busses and prevent
283 any other route from accidentally getting these IDs
284 (i.e. legacy sessions)
287 if (is_master() && id != MasterBusRemoteControlID) {
288 id = MasterBusRemoteControlID;
291 if (is_monitor() && id != MonitorBusRemoteControlID) {
292 id = MonitorBusRemoteControlID;
299 /* don't allow it to collide */
301 if (!is_master () && !is_monitor() &&
302 (id == MasterBusRemoteControlID || id == MonitorBusRemoteControlID)) {
303 id += MonitorBusRemoteControlID;
306 if (id != remote_control_id()) {
307 _remote_control_id = id;
308 RemoteControlIDChanged ();
310 if (notify_class_listeners) {
311 RemoteControlIDChange ();
317 Route::remote_control_id() const
320 return MasterBusRemoteControlID;
324 return MonitorBusRemoteControlID;
327 return _remote_control_id;
331 Route::has_order_key () const
333 return _has_order_key;
337 Route::order_key () const
343 Route::set_remote_control_id_explicit (uint32_t rid)
345 if (is_master() || is_monitor() || is_auditioner()) {
346 /* hard-coded remote IDs, or no remote ID */
350 if (_remote_control_id != rid) {
351 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: set edit-based RID to %2\n", name(), rid));
352 _remote_control_id = rid;
353 RemoteControlIDChanged (); /* EMIT SIGNAL (per-route) */
356 /* don't emit the class-level RID signal RemoteControlIDChange here,
357 leave that to the entity that changed the order key, so that we
358 don't get lots of emissions for no good reasons (e.g. when changing
359 all route order keys).
361 See Session::sync_remote_id_from_order_keys() for the (primary|only)
362 spot where that is emitted.
367 Route::set_order_key (uint32_t n)
369 _has_order_key = true;
371 if (_order_key == n) {
377 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1 order key set to %2\n",
378 name(), order_key ()));
380 _session.set_dirty ();
384 Route::ensure_track_or_route_name(string name, Session &session)
386 string newname = name;
388 while (!session.io_name_is_legal (newname)) {
389 newname = bump_name_once (newname, ' ');
396 Route::inc_gain (gain_t factor)
398 /* To be used ONLY when doing group-relative gain adjustment, from
402 float desired_gain = _gain_control->user_double();
404 if (fabsf (desired_gain) < GAIN_COEFF_SMALL) {
405 // really?! what's the idea here?
406 _gain_control->route_set_value (0.000001f + (0.000001f * factor));
408 _gain_control->route_set_value (desired_gain + (desired_gain * factor));
413 Route::set_gain (gain_t val, Controllable::GroupControlDisposition group_override)
415 if (use_group (group_override, &RouteGroup::is_gain)) {
417 if (_route_group->is_relative()) {
419 gain_t usable_gain = _gain_control->get_value();
420 if (usable_gain < 0.000001f) {
421 usable_gain = 0.000001f;
425 if (delta < 0.000001f) {
429 delta -= usable_gain;
434 gain_t factor = delta / usable_gain;
437 factor = _route_group->get_max_factor(factor);
438 if (factor == 0.0f) {
439 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
443 factor = _route_group->get_min_factor(factor);
444 if (factor == 0.0f) {
445 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
450 _route_group->foreach_route (boost::bind (&Route::inc_gain, _1, factor));
454 _route_group->foreach_route (boost::bind (&Route::set_gain, _1, val, Controllable::NoGroup));
460 if (val == _gain_control->get_value()) {
464 _gain_control->route_set_value (val);
468 Route::set_trim (gain_t val, Controllable::GroupControlDisposition /* group override */)
470 // TODO route group, see set_gain()
471 _trim_control->route_set_value (val);
475 Route::maybe_declick (BufferSet&, framecnt_t, int)
477 /* this is the "bus" implementation and they never declick.
482 /** Process this route for one (sub) cycle (process thread)
484 * @param bufs Scratch buffers to use for the signal path
485 * @param start_frame Initial transport frame
486 * @param end_frame Final transport frame
487 * @param nframes Number of frames to output (to ports)
489 * Note that (end_frame - start_frame) may not be equal to nframes when the
490 * transport speed isn't 1.0 (eg varispeed).
493 Route::process_output_buffers (BufferSet& bufs,
494 framepos_t start_frame, framepos_t end_frame, pframes_t nframes,
495 int declick, bool gain_automation_ok)
497 /* Caller must hold process lock */
498 assert (!AudioEngine::instance()->process_lock().trylock());
500 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
502 // can this actually happen? functions calling process_output_buffers()
503 // already take a reader-lock.
504 bufs.silence (nframes, 0);
508 /* figure out if we're going to use gain automation */
509 if (gain_automation_ok) {
510 _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
511 _amp->setup_gain_automation (
512 start_frame + _signal_latency_at_amp_position,
513 end_frame + _signal_latency_at_amp_position,
516 _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
517 _trim->setup_gain_automation (
518 start_frame + _signal_latency_at_trim_position,
519 end_frame + _signal_latency_at_trim_position,
522 _amp->apply_gain_automation (false);
523 _trim->apply_gain_automation (false);
526 /* Tell main outs what to do about monitoring. We do this so that
527 on a transition between monitoring states we get a de-clicking gain
528 change in the _main_outs delivery, if config.get_use_monitor_fades()
531 We override this in the case where we have an internal generator.
533 bool silence = _have_internal_generator ? false : (monitoring_state () == MonitoringSilence);
535 _main_outs->no_outs_cuz_we_no_monitor (silence);
537 /* -------------------------------------------------------------------------------------------
538 GLOBAL DECLICK (for transport changes etc.)
539 ----------------------------------------------------------------------------------------- */
541 maybe_declick (bufs, nframes, declick);
542 _pending_declick = 0;
544 /* -------------------------------------------------------------------------------------------
545 DENORMAL CONTROL/PHASE INVERT
546 ----------------------------------------------------------------------------------------- */
548 if (_phase_invert.any ()) {
552 if (_denormal_protection || Config->get_denormal_protection()) {
554 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
555 Sample* const sp = i->data();
557 if (_phase_invert[chn]) {
558 for (pframes_t nx = 0; nx < nframes; ++nx) {
563 for (pframes_t nx = 0; nx < nframes; ++nx) {
571 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
572 Sample* const sp = i->data();
574 if (_phase_invert[chn]) {
575 for (pframes_t nx = 0; nx < nframes; ++nx) {
584 if (_denormal_protection || Config->get_denormal_protection()) {
586 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
587 Sample* const sp = i->data();
588 for (pframes_t nx = 0; nx < nframes; ++nx) {
596 /* -------------------------------------------------------------------------------------------
598 ----------------------------------------------------------------------------------------- */
600 /* set this to be true if the meter will already have been ::run() earlier */
601 bool const meter_already_run = metering_state() == MeteringInput;
603 framecnt_t latency = 0;
605 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
607 if (meter_already_run && boost::dynamic_pointer_cast<PeakMeter> (*i)) {
608 /* don't ::run() the meter, otherwise it will have its previous peak corrupted */
613 /* if it has any inputs, make sure they match */
614 if (boost::dynamic_pointer_cast<UnknownProcessor> (*i) == 0 && (*i)->input_streams() != ChanCount::ZERO) {
615 if (bufs.count() != (*i)->input_streams()) {
617 DEBUG::Processors, string_compose (
618 "input port mismatch %1 bufs = %2 input for %3 = %4\n",
619 _name, bufs.count(), (*i)->name(), (*i)->input_streams()
626 /* should we NOT run plugins here if the route is inactive?
627 do we catch route != active somewhere higher?
630 if (boost::dynamic_pointer_cast<Send>(*i) != 0) {
631 boost::dynamic_pointer_cast<Send>(*i)->set_delay_in(_signal_latency - latency);
634 (*i)->run (bufs, start_frame - latency, end_frame - latency, nframes, *i != _processors.back());
635 bufs.set_count ((*i)->output_streams());
637 if ((*i)->active ()) {
638 latency += (*i)->signal_latency ();
644 Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
645 boost::shared_ptr<Processor> endpoint,
646 bool include_endpoint, bool for_export, bool for_freeze)
648 /* If no processing is required, there's no need to go any further. */
649 if (!endpoint && !include_endpoint) {
653 framecnt_t latency = bounce_get_latency(_amp, false, for_export, for_freeze);
654 _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
655 _amp->setup_gain_automation (start - latency, start - latency + nframes, nframes);
657 /* trim is always at the top, for bounce no latency compensation is needed */
658 _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
659 _trim->setup_gain_automation (start, start + nframes, nframes);
662 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
664 if (!include_endpoint && (*i) == endpoint) {
668 /* if we're *not* exporting, stop processing if we come across a routing processor. */
669 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
672 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
676 /* special case the panner (export outputs)
677 * Ideally we'd only run the panner, not the delivery itself...
678 * but panners need separate input/output buffers and some context
679 * (panshell, panner type, etc). AFAICT there is no ill side effect
680 * of re-using the main delivery when freewheeling/exporting a region.
682 if ((*i) == _main_outs) {
683 assert ((*i)->does_routing());
684 (*i)->run (buffers, start - latency, start - latency + nframes, nframes, true);
685 buffers.set_count ((*i)->output_streams());
688 /* don't run any processors that do routing.
689 * Also don't bother with metering.
691 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
692 (*i)->run (buffers, start - latency, start - latency + nframes, nframes, true);
693 buffers.set_count ((*i)->output_streams());
694 latency += (*i)->signal_latency ();
697 if ((*i) == endpoint) {
704 Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint,
705 bool include_endpoint, bool for_export, bool for_freeze) const
707 framecnt_t latency = 0;
708 if (!endpoint && !include_endpoint) {
712 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
713 if (!include_endpoint && (*i) == endpoint) {
716 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
719 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
722 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
723 latency += (*i)->signal_latency ();
725 if ((*i) == endpoint) {
733 Route::bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint,
734 bool include_endpoint, bool for_export, bool for_freeze) const
736 if (!endpoint && !include_endpoint) {
740 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
741 if (!include_endpoint && (*i) == endpoint) {
744 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
747 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
750 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
751 cc = (*i)->output_streams();
753 if ((*i) == endpoint) {
761 Route::n_process_buffers ()
763 return max (_input->n_ports(), processor_max_streams);
767 Route::monitor_run (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
769 assert (is_monitor());
770 BufferSet& bufs (_session.get_route_buffers (n_process_buffers()));
771 fill_buffers_with_input (bufs, _input, nframes);
772 passthru (bufs, start_frame, end_frame, nframes, declick);
776 Route::passthru (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
780 if (is_monitor() && _session.listening() && !_session.is_auditioning()) {
782 /* control/monitor bus ignores input ports when something is
783 feeding the listen "stream". data will "arrive" into the
784 route from the intreturn processor element.
787 bufs.silence (nframes, 0);
790 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
791 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, true);
795 Route::passthru_silence (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
797 BufferSet& bufs (_session.get_route_buffers (n_process_buffers(), true));
799 bufs.set_count (_input->n_ports());
800 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
801 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, false);
805 Route::set_listen (bool yn, Controllable::GroupControlDisposition group_override)
811 if (use_group (group_override, &RouteGroup::is_solo)) {
812 _route_group->foreach_route (boost::bind (&Route::set_listen, _1, yn, Controllable::ForGroup));
817 if (yn != _monitor_send->active()) {
819 _monitor_send->activate ();
820 _mute_master->set_soloed_by_self (true);
822 _monitor_send->deactivate ();
823 _mute_master->set_soloed_by_self (false);
825 _mute_master->set_soloed_by_others (false);
827 listen_changed (group_override); /* EMIT SIGNAL */
833 Route::listening_via_monitor () const
836 return _monitor_send->active ();
843 Route::set_solo_safe (bool yn, Controllable::GroupControlDisposition /* group_override */)
845 if (_solo_safe != yn) {
847 solo_safe_changed (); /* EMIT SIGNAL */
848 _solo_safe_control->Changed(); /* EMIT SIGNAL */
853 Route::solo_safe() const
859 Route::clear_all_solo_state ()
861 // ideally this function will never do anything, it only exists to forestall Murphy
862 bool emit_changed = false;
865 // these are really debug messages, but of possible interest.
867 PBD::info << string_compose (_("Cleared Explicit solo: %1\n"), name());
869 if (_soloed_by_others_upstream || _soloed_by_others_downstream) {
870 PBD::info << string_compose (_("Cleared Implicit solo: %1 up:%2 down:%3\n"),
871 name(), _soloed_by_others_upstream, _soloed_by_others_downstream);
875 if (!_self_solo && (_soloed_by_others_upstream || _soloed_by_others_downstream)) {
876 // if self-soled, set_solo() will do signal emission
880 _soloed_by_others_upstream = 0;
881 _soloed_by_others_downstream = 0;
884 PBD::Unwinder<bool> uw (_solo_safe, false);
885 set_solo (false, Controllable::NoGroup);
889 set_mute_master_solo ();
890 solo_changed (false, Controllable::UseGroup); /* EMIT SIGNAL */
895 Route::set_solo (bool yn, Controllable::GroupControlDisposition group_override)
897 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1: set solo => %2, grp ? %3 currently self-soloed ? %4\n",
898 name(), yn, enum_2_string(group_override), self_soloed()));
901 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 ignore solo change due to solo-safe\n", name()));
905 if (is_master() || is_monitor() || is_auditioner()) {
906 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 ignore solo change (master, monitor or auditioner)\n", name()));
910 if (use_group (group_override, &RouteGroup::is_solo)) {
911 _route_group->foreach_route (boost::bind (&Route::set_solo, _1, yn, Controllable::ForGroup));
915 if (self_soloed() != yn) {
917 solo_changed (true, group_override); /* EMIT SIGNAL */
918 _solo_control->Changed (); /* EMIT SIGNAL */
921 assert (Config->get_solo_control_is_listen_control() || !_monitor_send || !_monitor_send->active());
923 /* XXX TRACKS DEVELOPERS: THIS LOGIC SUGGESTS THAT YOU ARE NOT AWARE OF
924 Config->get_solo_mute_overrride().
927 if (yn && Profile->get_trx()) {
928 set_mute (false, Controllable::UseGroup);
933 Route::set_self_solo (bool yn)
935 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1: set SELF solo => %2\n", name(), yn));
937 set_mute_master_solo ();
941 Route::mod_solo_by_others_upstream (int32_t delta)
943 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod solo-by-upstream by %2, current up = %3 down = %4\n",
944 name(), delta, _soloed_by_others_upstream, _soloed_by_others_downstream));
946 uint32_t old_sbu = _soloed_by_others_upstream;
949 if (_soloed_by_others_upstream >= (uint32_t) abs (delta)) {
950 _soloed_by_others_upstream += delta;
952 _soloed_by_others_upstream = 0;
955 _soloed_by_others_upstream += delta;
958 DEBUG_TRACE (DEBUG::Solo, string_compose (
959 "%1 SbU delta %2 = %3 old = %4 sbd %5 ss %6 exclusive %7\n",
960 name(), delta, _soloed_by_others_upstream, old_sbu,
961 _soloed_by_others_downstream, _self_solo, Config->get_exclusive_solo()));
963 /* push the inverse solo change to everything that feeds us.
965 This is important for solo-within-group. When we solo 1 track out of N that
966 feed a bus, that track will cause mod_solo_by_upstream (+1) to be called
967 on the bus. The bus then needs to call mod_solo_by_downstream (-1) on all
968 tracks that feed it. This will silence them if they were audible because
969 of a bus solo, but the newly soloed track will still be audible (because
972 but .. do this only when we are being told to solo-by-upstream (i.e delta = +1),
976 if ((_self_solo || _soloed_by_others_downstream) &&
977 ((old_sbu == 0 && _soloed_by_others_upstream > 0) ||
978 (old_sbu > 0 && _soloed_by_others_upstream == 0))) {
980 if (delta > 0 || !Config->get_exclusive_solo()) {
981 DEBUG_TRACE (DEBUG::Solo, string_compose("\t ... INVERT push from %1\n", _name));
982 for (FedBy::iterator i = _fed_by.begin(); i != _fed_by.end(); ++i) {
986 boost::shared_ptr<Route> sr = i->r.lock();
988 sr->mod_solo_by_others_downstream (-delta);
994 set_mute_master_solo ();
995 solo_changed (false, Controllable::UseGroup); /* EMIT SIGNAL */
999 Route::mod_solo_by_others_downstream (int32_t delta)
1001 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod solo-by-downstream by %2, current up = %3 down = %4\n",
1002 name(), delta, _soloed_by_others_upstream, _soloed_by_others_downstream));
1005 if (_soloed_by_others_downstream >= (uint32_t) abs (delta)) {
1006 _soloed_by_others_downstream += delta;
1008 _soloed_by_others_downstream = 0;
1011 _soloed_by_others_downstream += delta;
1014 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 SbD delta %2 = %3\n", name(), delta, _soloed_by_others_downstream));
1016 set_mute_master_solo ();
1017 solo_changed (false, Controllable::UseGroup); /* EMIT SIGNAL */
1021 Route::set_mute_master_solo ()
1023 _mute_master->set_soloed_by_self (self_soloed());
1024 _mute_master->set_soloed_by_others (soloed_by_others_downstream() || soloed_by_others_upstream());
1028 Route::mod_solo_isolated_by_upstream (bool yn)
1030 bool old = solo_isolated ();
1031 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod_solo_isolated_by_upstream cur: %2 d: %3\n",
1032 name(), _solo_isolated_by_upstream, yn ? "+1" : "-1"));
1035 if (_solo_isolated_by_upstream >= 1) {
1036 _solo_isolated_by_upstream--;
1038 _solo_isolated_by_upstream = 0;
1041 _solo_isolated_by_upstream++;
1044 if (solo_isolated() != old) {
1045 /* solo isolated status changed */
1046 _mute_master->set_solo_ignore (solo_isolated());
1047 solo_isolated_changed (); /* EMIT SIGNAL */
1052 Route::set_solo_isolated (bool yn, Controllable::GroupControlDisposition group_override)
1054 if (is_master() || is_monitor() || is_auditioner()) {
1058 if (use_group (group_override, &RouteGroup::is_solo)) {
1059 _route_group->foreach_route (boost::bind (&Route::set_solo_isolated, _1, yn, Controllable::ForGroup));
1063 bool changed = false;
1066 if (_solo_isolated == false) {
1067 _mute_master->set_solo_ignore (true);
1070 _solo_isolated = true;
1072 if (_solo_isolated == true) {
1073 _solo_isolated = false;
1074 _mute_master->set_solo_ignore (false);
1084 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
1086 boost::shared_ptr<RouteList> routes = _session.get_routes ();
1087 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
1089 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
1094 bool does_feed = feeds (*i, &sends_only);
1096 if (does_feed && !sends_only) {
1097 (*i)->mod_solo_isolated_by_upstream (yn);
1101 /* XXX should we back-propagate as well? (April 2010: myself and chris goddard think not) */
1103 solo_isolated_changed (); /* EMIT SIGNAL */
1104 _solo_isolate_control->Changed(); /* EMIT SIGNAL */
1108 Route::solo_isolated () const
1110 return (_solo_isolated == true) || (_solo_isolated_by_upstream > 0);
1114 Route::set_mute_points (MuteMaster::MutePoint mp)
1116 _mute_master->set_mute_points (mp);
1117 mute_points_changed (); /* EMIT SIGNAL */
1119 if (_mute_master->muted_by_self()) {
1120 mute_changed (); /* EMIT SIGNAL */
1121 _mute_control->Changed (); /* EMIT SIGNAL */
1126 Route::set_mute (bool yn, Controllable::GroupControlDisposition group_override)
1128 if (use_group (group_override, &RouteGroup::is_mute)) {
1129 _route_group->foreach_route (boost::bind (&Route::set_mute, _1, yn, Controllable::ForGroup));
1133 if (muted() != yn) {
1134 _mute_master->set_muted_by_self (yn);
1135 /* allow any derived classes to respond to the mute change
1136 before anybody else knows about it.
1139 /* tell everyone else */
1140 mute_changed (); /* EMIT SIGNAL */
1141 _mute_control->Changed (); /* EMIT SIGNAL */
1146 Route::muted () const
1148 return _mute_master->muted_by_self();
1152 Route::muted_by_others () const
1154 // This method is only used by route_ui for display state.
1155 // The real thing is MuteMaster::muted_by_others_at()
1157 //master is never muted by others
1161 //now check to see if something is soloed (and I am not)
1162 //see also MuteMaster::mute_gain_at()
1163 return (_session.soloing() && !soloed() && !solo_isolated());
1168 dump_processors(const string& name, const list<boost::shared_ptr<Processor> >& procs)
1170 cerr << name << " {" << endl;
1171 for (list<boost::shared_ptr<Processor> >::const_iterator p = procs.begin();
1172 p != procs.end(); ++p) {
1173 cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << " @ " << (*p) << endl;
1175 cerr << "}" << endl;
1179 /** Supposing that we want to insert a Processor at a given Placement, return
1180 * the processor to add the new one before (or 0 to add at the end).
1182 boost::shared_ptr<Processor>
1183 Route::before_processor_for_placement (Placement p)
1185 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1187 ProcessorList::iterator loc;
1189 if (p == PreFader) {
1190 /* generic pre-fader: insert immediately before the amp */
1191 loc = find (_processors.begin(), _processors.end(), _amp);
1193 /* generic post-fader: insert right before the main outs */
1194 loc = find (_processors.begin(), _processors.end(), _main_outs);
1197 return loc != _processors.end() ? *loc : boost::shared_ptr<Processor> ();
1200 /** Supposing that we want to insert a Processor at a given index, return
1201 * the processor to add the new one before (or 0 to add at the end).
1203 boost::shared_ptr<Processor>
1204 Route::before_processor_for_index (int index)
1207 return boost::shared_ptr<Processor> ();
1210 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1212 ProcessorList::iterator i = _processors.begin ();
1214 while (i != _processors.end() && j < index) {
1215 if ((*i)->display_to_user()) {
1222 return (i != _processors.end() ? *i : boost::shared_ptr<Processor> ());
1225 /** Add a processor either pre- or post-fader
1226 * @return 0 on success, non-0 on failure.
1229 Route::add_processor (boost::shared_ptr<Processor> processor, Placement placement, ProcessorStreams* err, bool activation_allowed)
1231 return add_processor (processor, before_processor_for_placement (placement), err, activation_allowed);
1235 /** Add a processor to a route such that it ends up with a given index into the visible processors.
1236 * @param index Index to add the processor at, or -1 to add at the end of the list.
1237 * @return 0 on success, non-0 on failure.
1240 Route::add_processor_by_index (boost::shared_ptr<Processor> processor, int index, ProcessorStreams* err, bool activation_allowed)
1242 return add_processor (processor, before_processor_for_index (index), err, activation_allowed);
1245 /** Add a processor to the route.
1246 * @param before An existing processor in the list, or 0; the new processor will be inserted immediately before it (or at the end).
1247 * @return 0 on success, non-0 on failure.
1250 Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<Processor> before, ProcessorStreams* err, bool activation_allowed)
1252 assert (processor != _meter);
1253 assert (processor != _main_outs);
1255 DEBUG_TRACE (DEBUG::Processors, string_compose (
1256 "%1 adding processor %2\n", name(), processor->name()));
1258 if (!AudioEngine::instance()->connected() || !processor) {
1263 boost::shared_ptr<PluginInsert> pi;
1264 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
1265 pi->set_strict_io (true);
1270 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1271 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1272 ProcessorState pstate (this);
1274 boost::shared_ptr<PluginInsert> pi;
1275 boost::shared_ptr<PortInsert> porti;
1277 if (processor == _amp) {
1278 /* Ensure that only one amp is in the list at any time */
1279 ProcessorList::iterator check = find (_processors.begin(), _processors.end(), processor);
1280 if (check != _processors.end()) {
1281 if (before == _amp) {
1282 /* Already in position; all is well */
1285 _processors.erase (check);
1290 assert (find (_processors.begin(), _processors.end(), processor) == _processors.end ());
1292 ProcessorList::iterator loc;
1294 /* inserting before a processor; find it */
1295 loc = find (_processors.begin(), _processors.end(), before);
1296 if (loc == _processors.end ()) {
1301 /* inserting at end */
1302 loc = _processors.end ();
1305 _processors.insert (loc, processor);
1306 processor->set_owner (this);
1308 // Set up processor list channels. This will set processor->[input|output]_streams(),
1309 // configure redirect ports properly, etc.
1312 if (configure_processors_unlocked (err)) {
1314 configure_processors_unlocked (0); // it worked before we tried to add it ...
1319 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
1321 if (pi->has_no_inputs ()) {
1322 /* generator plugin */
1323 _have_internal_generator = true;
1328 if (activation_allowed && (!_session.get_bypass_all_loaded_plugins () || !processor->display_to_user ())) {
1329 processor->activate ();
1332 processor->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1334 _output->set_user_latency (0);
1337 reset_instrument_info ();
1338 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1339 set_processor_positions ();
1345 Route::add_processor_from_xml_2X (const XMLNode& node, int version)
1347 const XMLProperty *prop;
1350 boost::shared_ptr<Processor> processor;
1352 /* bit of a hack: get the `placement' property from the <Redirect> tag here
1353 so that we can add the processor in the right place (pre/post-fader)
1356 XMLNodeList const & children = node.children ();
1357 XMLNodeList::const_iterator i = children.begin ();
1359 while (i != children.end() && (*i)->name() != X_("Redirect")) {
1363 Placement placement = PreFader;
1365 if (i != children.end()) {
1366 if ((prop = (*i)->property (X_("placement"))) != 0) {
1367 placement = Placement (string_2_enum (prop->value(), placement));
1371 if (node.name() == "Insert") {
1373 if ((prop = node.property ("type")) != 0) {
1375 if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
1376 prop->value() == "lv2" ||
1377 prop->value() == "windows-vst" ||
1378 prop->value() == "lxvst" ||
1379 prop->value() == "audiounit") {
1381 if (_session.get_disable_all_loaded_plugins ()) {
1382 processor.reset (new UnknownProcessor (_session, node));
1384 processor.reset (new PluginInsert (_session));
1385 processor->set_owner (this);
1390 processor.reset (new PortInsert (_session, _pannable, _mute_master));
1395 } else if (node.name() == "Send") {
1397 boost::shared_ptr<Pannable> sendpan (new Pannable (_session));
1398 processor.reset (new Send (_session, sendpan, _mute_master));
1402 error << string_compose(_("unknown Processor type \"%1\"; ignored"), node.name()) << endmsg;
1406 if (processor->set_state (node, version)) {
1410 //A2 uses the "active" flag in the toplevel redirect node, not in the child plugin/IO
1411 if (i != children.end()) {
1412 if ((prop = (*i)->property (X_("active"))) != 0) {
1413 if ( string_is_affirmative (prop->value()) && (!_session.get_bypass_all_loaded_plugins () || !processor->display_to_user () ) )
1414 processor->activate();
1416 processor->deactivate();
1420 return (add_processor (processor, placement, 0, false) == 0);
1423 catch (failed_constructor &err) {
1424 warning << _("processor could not be created. Ignored.") << endmsg;
1430 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
1432 /* NOTE: this is intended to be used ONLY when copying
1433 processors from another Route. Hence the subtle
1434 differences between this and ::add_processor()
1437 ProcessorList::iterator loc;
1440 loc = find(_processors.begin(), _processors.end(), before);
1442 /* nothing specified - at end */
1443 loc = _processors.end ();
1446 if (!_session.engine().connected()) {
1450 if (others.empty()) {
1455 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1456 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1457 ProcessorState pstate (this);
1459 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
1465 boost::shared_ptr<PluginInsert> pi;
1467 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1468 pi->set_count (1); // why? configure_processors_unlocked() will re-do this
1469 pi->set_strict_io (_strict_io);
1472 _processors.insert (loc, *i);
1473 (*i)->set_owner (this);
1475 if ((*i)->active()) {
1479 /* Think: does this really need to be called for every processor in the loop? */
1481 if (configure_processors_unlocked (err)) {
1483 configure_processors_unlocked (0); // it worked before we tried to add it ...
1488 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1491 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
1492 boost::shared_ptr<PluginInsert> pi;
1494 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1495 if (pi->has_no_inputs ()) {
1496 _have_internal_generator = true;
1502 _output->set_user_latency (0);
1505 reset_instrument_info ();
1506 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1507 set_processor_positions ();
1513 Route::placement_range(Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end)
1515 if (p == PreFader) {
1516 start = _processors.begin();
1517 end = find(_processors.begin(), _processors.end(), _amp);
1519 start = find(_processors.begin(), _processors.end(), _amp);
1521 end = _processors.end();
1525 /** Turn off all processors with a given placement
1526 * @param p Placement of processors to disable
1529 Route::disable_processors (Placement p)
1531 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1533 ProcessorList::iterator start, end;
1534 placement_range(p, start, end);
1536 for (ProcessorList::iterator i = start; i != end; ++i) {
1537 (*i)->deactivate ();
1540 _session.set_dirty ();
1543 /** Turn off all redirects
1546 Route::disable_processors ()
1548 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1550 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1551 (*i)->deactivate ();
1554 _session.set_dirty ();
1557 /** Turn off all redirects with a given placement
1558 * @param p Placement of redirects to disable
1561 Route::disable_plugins (Placement p)
1563 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1565 ProcessorList::iterator start, end;
1566 placement_range(p, start, end);
1568 for (ProcessorList::iterator i = start; i != end; ++i) {
1569 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1570 (*i)->deactivate ();
1574 _session.set_dirty ();
1577 /** Turn off all plugins
1580 Route::disable_plugins ()
1582 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1584 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1585 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1586 (*i)->deactivate ();
1590 _session.set_dirty ();
1595 Route::ab_plugins (bool forward)
1597 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1601 /* forward = turn off all active redirects, and mark them so that the next time
1602 we go the other way, we will revert them
1605 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1606 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1610 if ((*i)->active()) {
1611 (*i)->deactivate ();
1612 (*i)->set_next_ab_is_active (true);
1614 (*i)->set_next_ab_is_active (false);
1620 /* backward = if the redirect was marked to go active on the next ab, do so */
1622 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1624 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1628 if ((*i)->get_next_ab_is_active()) {
1631 (*i)->deactivate ();
1636 _session.set_dirty ();
1640 /** Remove processors with a given placement.
1641 * @param p Placement of processors to remove.
1644 Route::clear_processors (Placement p)
1646 if (!_session.engine().connected()) {
1650 bool already_deleting = _session.deletion_in_progress();
1651 if (!already_deleting) {
1652 _session.set_deletion_in_progress();
1656 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1657 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1658 ProcessorList new_list;
1659 ProcessorStreams err;
1660 bool seen_amp = false;
1662 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1668 if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline || (*i) == _trim) {
1670 /* you can't remove these */
1672 new_list.push_back (*i);
1679 new_list.push_back (*i);
1682 (*i)->drop_references ();
1690 (*i)->drop_references ();
1693 new_list.push_back (*i);
1700 _processors = new_list;
1701 configure_processors_unlocked (&err); // this can't fail
1704 processor_max_streams.reset();
1705 _have_internal_generator = false;
1706 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1707 set_processor_positions ();
1709 reset_instrument_info ();
1711 if (!already_deleting) {
1712 _session.clear_deletion_in_progress();
1717 Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStreams* err, bool need_process_lock)
1719 // TODO once the export point can be configured properly, do something smarter here
1720 if (processor == _capturing_processor) {
1721 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
1722 if (need_process_lock) {
1726 _capturing_processor.reset();
1728 if (need_process_lock) {
1733 /* these can never be removed */
1735 if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
1739 if (!_session.engine().connected()) {
1743 processor_max_streams.reset();
1746 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
1747 if (need_process_lock) {
1751 /* Caller must hold process lock */
1752 assert (!AudioEngine::instance()->process_lock().trylock());
1754 Glib::Threads::RWLock::WriterLock lm (_processor_lock); // XXX deadlock after export
1756 ProcessorState pstate (this);
1758 ProcessorList::iterator i;
1759 bool removed = false;
1761 for (i = _processors.begin(); i != _processors.end(); ) {
1762 if (*i == processor) {
1764 /* move along, see failure case for configure_processors()
1765 where we may need to reconfigure the processor.
1768 /* stop redirects that send signals to JACK ports
1769 from causing noise as a result of no longer being
1773 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
1774 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*i);
1778 iop = pi->sidechain();
1785 i = _processors.erase (i);
1793 _output->set_user_latency (0);
1801 if (configure_processors_unlocked (err)) {
1803 /* we know this will work, because it worked before :) */
1804 configure_processors_unlocked (0);
1808 _have_internal_generator = false;
1810 for (i = _processors.begin(); i != _processors.end(); ++i) {
1811 boost::shared_ptr<PluginInsert> pi;
1813 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1814 if (pi->has_no_inputs ()) {
1815 _have_internal_generator = true;
1820 if (need_process_lock) {
1825 reset_instrument_info ();
1826 processor->drop_references ();
1827 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1828 set_processor_positions ();
1834 Route::replace_processor (boost::shared_ptr<Processor> old, boost::shared_ptr<Processor> sub, ProcessorStreams* err)
1836 /* these can never be removed */
1837 if (old == _amp || old == _meter || old == _main_outs || old == _delayline || old == _trim) {
1840 /* and can't be used as substitute, either */
1841 if (sub == _amp || sub == _meter || sub == _main_outs || sub == _delayline || sub == _trim) {
1845 /* I/Os are out, too */
1846 if (boost::dynamic_pointer_cast<IOProcessor> (old) || boost::dynamic_pointer_cast<IOProcessor> (sub)) {
1850 /* this function cannot be used to swap/reorder processors */
1851 if (find (_processors.begin(), _processors.end(), sub) != _processors.end ()) {
1855 if (!AudioEngine::instance()->connected() || !old || !sub) {
1859 /* ensure that sub is not owned by another route */
1860 if (sub->owner ()) {
1865 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1866 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1867 ProcessorState pstate (this);
1869 assert (find (_processors.begin(), _processors.end(), sub) == _processors.end ());
1871 ProcessorList::iterator i;
1872 bool replaced = false;
1873 bool enable = old->active ();
1875 for (i = _processors.begin(); i != _processors.end(); ) {
1877 i = _processors.erase (i);
1878 _processors.insert (i, sub);
1879 sub->set_owner (this);
1892 boost::shared_ptr<PluginInsert> pi;
1893 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(sub)) != 0) {
1894 pi->set_strict_io (true);
1898 if (configure_processors_unlocked (err)) {
1900 configure_processors_unlocked (0);
1904 _have_internal_generator = false;
1906 for (i = _processors.begin(); i != _processors.end(); ++i) {
1907 boost::shared_ptr<PluginInsert> pi;
1908 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1909 if (pi->has_no_inputs ()) {
1910 _have_internal_generator = true;
1920 sub->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1921 _output->set_user_latency (0);
1924 reset_instrument_info ();
1925 old->drop_references ();
1926 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1927 set_processor_positions ();
1932 Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err)
1934 ProcessorList deleted;
1936 if (!_session.engine().connected()) {
1940 processor_max_streams.reset();
1943 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1944 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1945 ProcessorState pstate (this);
1947 ProcessorList::iterator i;
1948 boost::shared_ptr<Processor> processor;
1950 for (i = _processors.begin(); i != _processors.end(); ) {
1954 /* these can never be removed */
1956 if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
1961 /* see if its in the list of processors to delete */
1963 if (find (to_be_deleted.begin(), to_be_deleted.end(), processor) == to_be_deleted.end()) {
1968 /* stop IOProcessors that send to JACK ports
1969 from causing noise as a result of no longer being
1973 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(processor);
1974 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(processor);
1977 iop = pi->sidechain();
1984 deleted.push_back (processor);
1985 i = _processors.erase (i);
1988 if (deleted.empty()) {
1989 /* none of those in the requested list were found */
1993 _output->set_user_latency (0);
1995 if (configure_processors_unlocked (err)) {
1997 /* we know this will work, because it worked before :) */
1998 configure_processors_unlocked (0);
2003 _have_internal_generator = false;
2005 for (i = _processors.begin(); i != _processors.end(); ++i) {
2006 boost::shared_ptr<PluginInsert> pi;
2008 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
2009 if (pi->has_no_inputs ()) {
2010 _have_internal_generator = true;
2017 /* now try to do what we need to so that those that were removed will be deleted */
2019 for (ProcessorList::iterator i = deleted.begin(); i != deleted.end(); ++i) {
2020 (*i)->drop_references ();
2023 reset_instrument_info ();
2024 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2025 set_processor_positions ();
2031 Route::reset_instrument_info ()
2033 boost::shared_ptr<Processor> instr = the_instrument();
2035 _instrument_info.set_internal_instrument (instr);
2039 /** Caller must hold process lock */
2041 Route::configure_processors (ProcessorStreams* err)
2043 #ifndef PLATFORM_WINDOWS
2044 assert (!AudioEngine::instance()->process_lock().trylock());
2047 if (!_in_configure_processors) {
2048 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2049 return configure_processors_unlocked (err);
2056 Route::input_streams () const
2058 return _input->n_ports ();
2061 list<pair<ChanCount, ChanCount> >
2062 Route::try_configure_processors (ChanCount in, ProcessorStreams* err)
2064 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2066 return try_configure_processors_unlocked (in, err);
2069 list<pair<ChanCount, ChanCount> >
2070 Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err)
2072 // Check each processor in order to see if we can configure as requested
2074 list<pair<ChanCount, ChanCount> > configuration;
2077 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configure processors\n", _name));
2078 DEBUG_TRACE (DEBUG::Processors, "{\n");
2080 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++index) {
2082 if ((*p)->can_support_io_configuration(in, out)) {
2083 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1 ID=%2 in=%3 out=%4\n",(*p)->name(), (*p)->id(), in, out));
2084 configuration.push_back(make_pair(in, out));
2087 // restriction for Monitor Section Processors
2088 if (in.n_audio() != out.n_audio() || out.n_midi() > 0) {
2089 /* do not allow to add/remove channels (for now)
2090 * The Monitor follows the master-bus and has no panner (unpan)
2091 * but do allow processors with midi-in to be added (e.g VSTs with control that
2092 * will remain unconnected)
2094 DEBUG_TRACE (DEBUG::Processors, "Monitor: Channel configuration not allowed.\n");
2095 return list<pair<ChanCount, ChanCount> > ();
2097 if (boost::dynamic_pointer_cast<InternalSend> (*p)) {
2098 // internal sends make no sense, only feedback
2099 DEBUG_TRACE (DEBUG::Processors, "Monitor: No Sends allowed.\n");
2100 return list<pair<ChanCount, ChanCount> > ();
2102 if (boost::dynamic_pointer_cast<PortInsert> (*p)) {
2103 /* External Sends can be problematic. one can add/remove ports
2104 * there signal leaves the DAW to external monitors anyway, so there's
2105 * no real use for allowing them here anyway.
2107 DEBUG_TRACE (DEBUG::Processors, "Monitor: No External Sends allowed.\n");
2108 return list<pair<ChanCount, ChanCount> > ();
2110 if (boost::dynamic_pointer_cast<Send> (*p)) {
2112 DEBUG_TRACE (DEBUG::Processors, "Monitor: No Sends allowed.\n");
2113 return list<pair<ChanCount, ChanCount> > ();
2122 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
2123 DEBUG_TRACE (DEBUG::Processors, string_compose ("---- %1 cannot support in=%2 out=%3\n", (*p)->name(), in, out));
2124 DEBUG_TRACE (DEBUG::Processors, "}\n");
2125 return list<pair<ChanCount, ChanCount> > ();
2129 DEBUG_TRACE (DEBUG::Processors, "}\n");
2131 return configuration;
2134 /** Set the input/output configuration of each processor in the processors list.
2135 * Caller must hold process lock.
2136 * Return 0 on success, otherwise configuration is impossible.
2139 Route::configure_processors_unlocked (ProcessorStreams* err)
2141 #ifndef PLATFORM_WINDOWS
2142 assert (!AudioEngine::instance()->process_lock().trylock());
2145 if (_in_configure_processors) {
2149 /* put invisible processors where they should be */
2150 setup_invisible_processors ();
2152 _in_configure_processors = true;
2154 list<pair<ChanCount, ChanCount> > configuration = try_configure_processors_unlocked (input_streams (), err);
2156 if (configuration.empty ()) {
2157 _in_configure_processors = false;
2162 bool seen_mains_out = false;
2163 processor_out_streams = _input->n_ports();
2164 processor_max_streams.reset();
2166 list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
2167 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
2169 if (!(*p)->configure_io(c->first, c->second)) {
2170 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration failed\n", _name));
2171 _in_configure_processors = false;
2174 processor_max_streams = ChanCount::max(processor_max_streams, c->first);
2175 processor_max_streams = ChanCount::max(processor_max_streams, c->second);
2177 boost::shared_ptr<PluginInsert> pi;
2178 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2179 /* plugins connected via Split or Hide Match may have more channels.
2180 * route/scratch buffers are needed for all of them
2181 * The configuration may only be a subset (both input and output)
2183 processor_max_streams = ChanCount::max(processor_max_streams, pi->input_streams());
2184 processor_max_streams = ChanCount::max(processor_max_streams, pi->internal_streams());
2185 processor_max_streams = ChanCount::max(processor_max_streams, pi->output_streams());
2186 processor_max_streams = ChanCount::max(processor_max_streams, pi->natural_input_streams() * pi->get_count());
2187 processor_max_streams = ChanCount::max(processor_max_streams, pi->natural_output_streams() * pi->get_count());
2191 if (boost::dynamic_pointer_cast<Delivery> (*p)
2192 && boost::dynamic_pointer_cast<Delivery> (*p)->role() == Delivery::Main) {
2193 /* main delivery will increase port count to match input.
2194 * the Delivery::Main is usually the last processor - followed only by
2197 seen_mains_out = true;
2199 if (!seen_mains_out) {
2200 processor_out_streams = out;
2206 _meter->set_max_channels (processor_max_streams);
2209 /* make sure we have sufficient scratch buffers to cope with the new processor
2212 _session.ensure_buffers (n_process_buffers ());
2214 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration complete\n", _name));
2216 _in_configure_processors = false;
2220 /** Set all visible processors to a given active state (except Fader, whose state is not changed)
2221 * @param state New active state for those processors.
2224 Route::all_visible_processors_active (bool state)
2226 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2228 if (_processors.empty()) {
2232 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2233 if (!(*i)->display_to_user() || boost::dynamic_pointer_cast<Amp> (*i)) {
2240 (*i)->deactivate ();
2244 _session.set_dirty ();
2248 Route::processors_reorder_needs_configure (const ProcessorList& new_order)
2250 /* check if re-order requires re-configuration of any processors
2251 * -> compare channel configuration for all processors
2253 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2254 ChanCount c = input_streams ();
2256 for (ProcessorList::const_iterator j = new_order.begin(); j != new_order.end(); ++j) {
2258 if (c != (*j)->input_streams()) {
2261 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2264 if ((*i)->input_streams() != c) {
2267 c = (*i)->output_streams();
2279 __attribute__((annotate("realtime")))
2282 Route::apply_processor_order (const ProcessorList& new_order)
2284 /* need to hold processor_lock; either read or write lock
2285 * and the engine process_lock.
2286 * Due to r/w lock ambiguity we can only assert the latter
2288 assert (!AudioEngine::instance()->process_lock().trylock());
2291 /* "new_order" is an ordered list of processors to be positioned according to "placement".
2292 * NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
2293 * processors in the current actual processor list that are hidden. Any visible processors
2294 * in the current list but not in "new_order" will be assumed to be deleted.
2297 /* "as_it_will_be" and "_processors" are lists of shared pointers.
2298 * actual memory usage is small, but insert/erase is not actually rt-safe :(
2299 * (note though that ::processors_reorder_needs_configure() ensured that
2300 * this function will only ever be called from the rt-thread if no processor were removed)
2302 * either way, I can't proove it, but an x-run due to re-order here is less likley
2303 * than an x-run-less 'ardour-silent cycle' both of which effectively "click".
2306 ProcessorList as_it_will_be;
2307 ProcessorList::iterator oiter;
2308 ProcessorList::const_iterator niter;
2310 oiter = _processors.begin();
2311 niter = new_order.begin();
2313 while (niter != new_order.end()) {
2315 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
2316 then append it to the temp list.
2318 Otherwise, see if the next processor in the old list is in the new list. if not,
2319 its been deleted. If its there, append it to the temp list.
2322 if (oiter == _processors.end()) {
2324 /* no more elements in the old list, so just stick the rest of
2325 the new order onto the temp list.
2328 as_it_will_be.insert (as_it_will_be.end(), niter, new_order.end());
2329 while (niter != new_order.end()) {
2336 if (!(*oiter)->display_to_user()) {
2338 as_it_will_be.push_back (*oiter);
2342 /* visible processor: check that its in the new order */
2344 if (find (new_order.begin(), new_order.end(), (*oiter)) == new_order.end()) {
2345 /* deleted: do nothing, shared_ptr<> will clean up */
2347 /* ignore this one, and add the next item from the new order instead */
2348 as_it_will_be.push_back (*niter);
2353 /* now remove from old order - its taken care of no matter what */
2354 oiter = _processors.erase (oiter);
2358 _processors.insert (oiter, as_it_will_be.begin(), as_it_will_be.end());
2360 /* If the meter is in a custom position, find it and make a rough note of its position */
2361 maybe_note_meter_position ();
2365 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
2367 // it a change is already queued, wait for it
2368 // (unless engine is stopped. apply immediately and proceed
2369 while (g_atomic_int_get (&_pending_process_reorder)) {
2370 if (!AudioEngine::instance()->running()) {
2371 DEBUG_TRACE (DEBUG::Processors, "offline apply queued processor re-order.\n");
2372 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2374 apply_processor_order(_pending_processor_order);
2375 setup_invisible_processors ();
2377 g_atomic_int_set (&_pending_process_reorder, 0);
2379 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2380 set_processor_positions ();
2382 // TODO rather use a semaphore or something.
2383 // but since ::reorder_processors() is called
2384 // from the GUI thread, this is fine..
2389 if (processors_reorder_needs_configure (new_order) || !AudioEngine::instance()->running()) {
2391 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2392 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2393 ProcessorState pstate (this);
2395 apply_processor_order (new_order);
2397 if (configure_processors_unlocked (err)) {
2405 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2406 set_processor_positions ();
2409 DEBUG_TRACE (DEBUG::Processors, "Queue clickless processor re-order.\n");
2410 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2412 // _pending_processor_order is protected by _processor_lock
2413 _pending_processor_order = new_order;
2414 g_atomic_int_set (&_pending_process_reorder, 1);
2421 Route::add_remove_sidechain (boost::shared_ptr<Processor> proc, bool add)
2423 boost::shared_ptr<PluginInsert> pi;
2424 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2428 if (pi->has_sidechain () == add) {
2429 return true; // ?? call failed, but result is as expected.
2433 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2434 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2435 if (i == _processors.end ()) {
2441 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); // take before Writerlock to avoid deadlock
2442 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2443 PBD::Unwinder<bool> uw (_in_sidechain_setup, true);
2445 lx.release (); // IO::add_port() and ~IO takes process lock - XXX check if this is safe
2447 if (!pi->add_sidechain ()) {
2451 if (!pi->del_sidechain ()) {
2457 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2462 pi->del_sidechain ();
2464 pi->add_sidechain ();
2465 // TODO restore side-chain's state.
2470 configure_processors_unlocked (0);
2473 if (pi->has_sidechain ()) {
2474 pi->sidechain_input ()->changed.connect_same_thread (*this, boost::bind (&Route::sidechain_change_handler, this, _1, _2));
2477 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2478 _session.set_dirty ();
2483 Route::reset_plugin_insert (boost::shared_ptr<Processor> proc)
2486 return customize_plugin_insert (proc, 0, unused);
2490 Route::customize_plugin_insert (boost::shared_ptr<Processor> proc, uint32_t count, ChanCount outs)
2492 boost::shared_ptr<PluginInsert> pi;
2493 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2498 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2499 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2500 if (i == _processors.end ()) {
2506 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2507 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2509 bool old_cust = pi->custom_cfg ();
2510 uint32_t old_cnt = pi->get_count ();
2511 ChanCount old_chan = pi->output_streams ();
2514 pi->set_custom_cfg (false);
2516 pi->set_custom_cfg (true);
2517 pi->set_count (count);
2518 pi->set_outputs (outs);
2521 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2525 pi->set_count (old_cnt);
2526 pi->set_outputs (old_chan);
2527 pi->set_custom_cfg (old_cust);
2531 configure_processors_unlocked (0);
2534 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2535 _session.set_dirty ();
2540 Route::set_strict_io (const bool enable)
2542 if (_strict_io != enable) {
2543 _strict_io = enable;
2544 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2545 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2546 boost::shared_ptr<PluginInsert> pi;
2547 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2548 pi->set_strict_io (_strict_io);
2552 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2556 _strict_io = !enable; // restore old value
2557 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2558 boost::shared_ptr<PluginInsert> pi;
2559 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2560 pi->set_strict_io (_strict_io);
2568 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2569 configure_processors (0);
2571 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2572 _session.set_dirty ();
2584 Route::get_template()
2586 return state(false);
2590 Route::state(bool full_state)
2592 if (!_session._template_state_dir.empty()) {
2593 assert (!full_state); // only for templates
2594 foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), _session._template_state_dir));
2597 XMLNode *node = new XMLNode("Route");
2598 ProcessorList::iterator i;
2601 id().print (buf, sizeof (buf));
2602 node->add_property("id", buf);
2603 node->add_property ("name", _name);
2604 node->add_property("default-type", _default_type.to_string());
2605 node->add_property ("strict-io", _strict_io);
2608 node->add_property("flags", enum_2_string (_flags));
2611 node->add_property("active", _active?"yes":"no");
2613 boost::to_string (_phase_invert, p);
2614 node->add_property("phase-invert", p);
2615 node->add_property("denormal-protection", _denormal_protection?"yes":"no");
2616 node->add_property("meter-point", enum_2_string (_meter_point));
2618 node->add_property("meter-type", enum_2_string (_meter_type));
2621 node->add_property("route-group", _route_group->name());
2624 snprintf (buf, sizeof (buf), "%d", _order_key);
2625 node->add_property ("order-key", buf);
2626 node->add_property ("self-solo", (_self_solo ? "yes" : "no"));
2627 snprintf (buf, sizeof (buf), "%d", _soloed_by_others_upstream);
2628 node->add_property ("soloed-by-upstream", buf);
2629 snprintf (buf, sizeof (buf), "%d", _soloed_by_others_downstream);
2630 node->add_property ("soloed-by-downstream", buf);
2631 node->add_property ("solo-isolated", solo_isolated() ? "yes" : "no");
2632 node->add_property ("solo-safe", _solo_safe ? "yes" : "no");
2634 node->add_child_nocopy (_input->state (full_state));
2635 node->add_child_nocopy (_output->state (full_state));
2636 node->add_child_nocopy (_solo_control->get_state ());
2637 node->add_child_nocopy (_mute_control->get_state ());
2638 node->add_child_nocopy (_mute_master->get_state ());
2641 node->add_child_nocopy (Automatable::get_automation_xml_state ());
2644 XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
2645 snprintf (buf, sizeof (buf), "%d", _remote_control_id);
2646 remote_control_node->add_property (X_("id"), buf);
2647 node->add_child_nocopy (*remote_control_node);
2649 if (_comment.length()) {
2650 XMLNode *cmt = node->add_child ("Comment");
2651 cmt->add_content (_comment);
2655 node->add_child_nocopy (_pannable->state (full_state));
2658 for (i = _processors.begin(); i != _processors.end(); ++i) {
2660 /* template save: do not include internal sends functioning as
2661 aux sends because the chance of the target ID
2662 in the session where this template is used
2665 similarly, do not save listen sends which connect to
2666 the monitor section, because these will always be
2669 boost::shared_ptr<InternalSend> is;
2671 if ((is = boost::dynamic_pointer_cast<InternalSend> (*i)) != 0) {
2672 if (is->role() == Delivery::Listen) {
2677 node->add_child_nocopy((*i)->state (full_state));
2681 node->add_child_copy (*_extra_xml);
2684 if (_custom_meter_position_noted) {
2685 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
2687 after->id().print (buf, sizeof (buf));
2688 node->add_property (X_("processor-after-last-custom-meter"), buf);
2692 if (!_session._template_state_dir.empty()) {
2693 foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), ""));
2700 Route::set_state (const XMLNode& node, int version)
2702 if (version < 3000) {
2703 return set_state_2X (node, version);
2707 XMLNodeConstIterator niter;
2709 const XMLProperty *prop;
2711 if (node.name() != "Route"){
2712 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2716 if ((prop = node.property (X_("name"))) != 0) {
2717 Route::set_name (prop->value());
2721 _initial_io_setup = true;
2723 if ((prop = node.property (X_("flags"))) != 0) {
2724 _flags = Flag (string_2_enum (prop->value(), _flags));
2729 if ((prop = node.property (X_("strict-io"))) != 0) {
2730 _strict_io = string_is_affirmative (prop->value());
2733 if (is_master() || is_monitor() || is_auditioner()) {
2734 _mute_master->set_solo_ignore (true);
2738 /* monitor bus does not get a panner, but if (re)created
2739 via XML, it will already have one by the time we
2740 call ::set_state(). so ... remove it.
2745 /* add all processors (except amp, which is always present) */
2747 nlist = node.children();
2748 XMLNode processor_state (X_("processor_state"));
2750 Stateful::save_extra_xml (node);
2752 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2756 if (child->name() == IO::state_node_name) {
2757 if ((prop = child->property (X_("direction"))) == 0) {
2761 if (prop->value() == "Input") {
2762 _input->set_state (*child, version);
2763 } else if (prop->value() == "Output") {
2764 _output->set_state (*child, version);
2768 if (child->name() == X_("Processor")) {
2769 processor_state.add_child_copy (*child);
2772 if (child->name() == X_("Pannable")) {
2774 _pannable->set_state (*child, version);
2776 warning << string_compose (_("Pannable state found for route (%1) without a panner!"), name()) << endmsg;
2781 if ((prop = node.property (X_("meter-point"))) != 0) {
2782 MeterPoint mp = MeterPoint (string_2_enum (prop->value (), _meter_point));
2783 set_meter_point (mp, true);
2785 _meter->set_display_to_user (_meter_point == MeterCustom);
2789 if ((prop = node.property (X_("meter-type"))) != 0) {
2790 _meter_type = MeterType (string_2_enum (prop->value (), _meter_type));
2793 _initial_io_setup = false;
2795 set_processor_state (processor_state);
2797 // this looks up the internal instrument in processors
2798 reset_instrument_info();
2800 if ((prop = node.property ("self-solo")) != 0) {
2801 set_self_solo (string_is_affirmative (prop->value()));
2804 if ((prop = node.property ("soloed-by-upstream")) != 0) {
2805 _soloed_by_others_upstream = 0; // needed for mod_.... () to work
2806 mod_solo_by_others_upstream (atoi (prop->value()));
2809 if ((prop = node.property ("soloed-by-downstream")) != 0) {
2810 _soloed_by_others_downstream = 0; // needed for mod_.... () to work
2811 mod_solo_by_others_downstream (atoi (prop->value()));
2814 if ((prop = node.property ("solo-isolated")) != 0) {
2815 set_solo_isolated (string_is_affirmative (prop->value()), Controllable::NoGroup);
2818 if ((prop = node.property ("solo-safe")) != 0) {
2819 set_solo_safe (string_is_affirmative (prop->value()), Controllable::NoGroup);
2822 if ((prop = node.property (X_("phase-invert"))) != 0) {
2823 set_phase_invert (boost::dynamic_bitset<> (prop->value ()));
2826 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2827 set_denormal_protection (string_is_affirmative (prop->value()));
2830 if ((prop = node.property (X_("active"))) != 0) {
2831 bool yn = string_is_affirmative (prop->value());
2832 _active = !yn; // force switch
2833 set_active (yn, this);
2836 if ((prop = node.property (X_("order-key"))) != 0) { // New order key (no separate mixer/editor ordering)
2837 set_order_key (atoi(prop->value()));
2840 if ((prop = node.property (X_("order-keys"))) != 0) { // Deprecated order keys
2844 string::size_type colon, equal;
2845 string remaining = prop->value();
2847 while (remaining.length()) {
2849 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
2850 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2853 if (sscanf (remaining.substr (equal+1).c_str(), "%d", &n) != 1) {
2854 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2857 string keyname = remaining.substr (0, equal);
2859 if ((keyname == "EditorSort") || (keyname == "editor")) {
2860 cerr << "Setting " << name() << " order key to " << n << " using saved Editor order." << endl;
2866 colon = remaining.find_first_of (':');
2868 if (colon != string::npos) {
2869 remaining = remaining.substr (colon+1);
2876 if ((prop = node.property (X_("processor-after-last-custom-meter"))) != 0) {
2877 PBD::ID id (prop->value ());
2878 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2879 ProcessorList::const_iterator i = _processors.begin ();
2880 while (i != _processors.end() && (*i)->id() != id) {
2884 if (i != _processors.end ()) {
2885 _processor_after_last_custom_meter = *i;
2886 _custom_meter_position_noted = true;
2890 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2893 if (child->name() == X_("Comment")) {
2895 /* XXX this is a terrible API design in libxml++ */
2897 XMLNode *cmt = *(child->children().begin());
2898 _comment = cmt->content();
2900 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
2901 if (prop->value() == "solo") {
2902 _solo_control->set_state (*child, version);
2903 } else if (prop->value() == "mute") {
2904 _mute_control->set_state (*child, version);
2907 } else if (child->name() == X_("RemoteControl")) {
2908 if ((prop = child->property (X_("id"))) != 0) {
2910 sscanf (prop->value().c_str(), "%d", &x);
2911 set_remote_control_id_internal (x);
2914 } else if (child->name() == X_("MuteMaster")) {
2915 _mute_master->set_state (*child, version);
2917 } else if (child->name() == Automatable::xml_node_name) {
2918 set_automation_xml_state (*child, Evoral::Parameter(NullAutomation));
2926 Route::set_state_2X (const XMLNode& node, int version)
2928 LocaleGuard lg (X_("C"));
2930 XMLNodeConstIterator niter;
2932 const XMLProperty *prop;
2934 /* 2X things which still remain to be handled:
2940 if (node.name() != "Route") {
2941 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2945 if ((prop = node.property (X_("flags"))) != 0) {
2946 string f = prop->value ();
2947 boost::replace_all (f, "ControlOut", "MonitorOut");
2948 _flags = Flag (string_2_enum (f, _flags));
2953 if (is_master() || is_monitor() || is_auditioner()) {
2954 _mute_master->set_solo_ignore (true);
2957 if ((prop = node.property (X_("phase-invert"))) != 0) {
2958 boost::dynamic_bitset<> p (_input->n_ports().n_audio ());
2959 if (string_is_affirmative (prop->value ())) {
2962 set_phase_invert (p);
2965 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2966 set_denormal_protection (string_is_affirmative (prop->value()));
2969 if ((prop = node.property (X_("soloed"))) != 0) {
2970 bool yn = string_is_affirmative (prop->value());
2972 /* XXX force reset of solo status */
2977 if ((prop = node.property (X_("muted"))) != 0) {
2980 bool muted = string_is_affirmative (prop->value());
2986 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
2988 if (string_is_affirmative (prop->value())){
2989 mute_point = mute_point + "PreFader";
2994 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
2996 if (string_is_affirmative (prop->value())){
2999 mute_point = mute_point + ",";
3002 mute_point = mute_point + "PostFader";
3007 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
3009 if (string_is_affirmative (prop->value())){
3012 mute_point = mute_point + ",";
3015 mute_point = mute_point + "Listen";
3020 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
3022 if (string_is_affirmative (prop->value())){
3025 mute_point = mute_point + ",";
3028 mute_point = mute_point + "Main";
3032 _mute_master->set_mute_points (mute_point);
3033 _mute_master->set_muted_by_self (true);
3037 if ((prop = node.property (X_("meter-point"))) != 0) {
3038 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
3041 /* do not carry over edit/mix groups from 2.X because (a) its hard (b) they
3042 don't mean the same thing.
3045 if ((prop = node.property (X_("order-keys"))) != 0) {
3049 string::size_type colon, equal;
3050 string remaining = prop->value();
3052 while (remaining.length()) {
3054 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
3055 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
3058 if (sscanf (remaining.substr (equal+1).c_str(), "%d", &n) != 1) {
3059 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
3062 string keyname = remaining.substr (0, equal);
3064 if (keyname == "EditorSort" || keyname == "editor") {
3065 info << string_compose(_("Converting deprecated order key for %1 using Editor order %2"), name (), n) << endmsg;
3071 colon = remaining.find_first_of (':');
3073 if (colon != string::npos) {
3074 remaining = remaining.substr (colon+1);
3083 nlist = node.children ();
3084 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3088 if (child->name() == IO::state_node_name) {
3090 /* there is a note in IO::set_state_2X() about why we have to call
3094 _input->set_state_2X (*child, version, true);
3095 _output->set_state_2X (*child, version, false);
3097 if ((prop = child->property (X_("name"))) != 0) {
3098 Route::set_name (prop->value ());
3103 if ((prop = child->property (X_("active"))) != 0) {
3104 bool yn = string_is_affirmative (prop->value());
3105 _active = !yn; // force switch
3106 set_active (yn, this);
3109 if ((prop = child->property (X_("gain"))) != 0) {
3112 if (sscanf (prop->value().c_str(), "%f", &val) == 1) {
3113 _amp->gain_control()->set_value (val, Controllable::NoGroup);
3117 /* Set up Panners in the IO */
3118 XMLNodeList io_nlist = child->children ();
3120 XMLNodeConstIterator io_niter;
3123 for (io_niter = io_nlist.begin(); io_niter != io_nlist.end(); ++io_niter) {
3125 io_child = *io_niter;
3127 if (io_child->name() == X_("Panner")) {
3128 _main_outs->panner_shell()->set_state(*io_child, version);
3129 } else if (io_child->name() == X_("Automation")) {
3130 /* IO's automation is for the fader */
3131 _amp->set_automation_xml_state (*io_child, Evoral::Parameter (GainAutomation));
3137 XMLNodeList redirect_nodes;
3139 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
3143 if (child->name() == X_("Send") || child->name() == X_("Insert")) {
3144 redirect_nodes.push_back(child);
3149 set_processor_state_2X (redirect_nodes, version);
3151 Stateful::save_extra_xml (node);
3153 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
3156 if (child->name() == X_("Comment")) {
3158 /* XXX this is a terrible API design in libxml++ */
3160 XMLNode *cmt = *(child->children().begin());
3161 _comment = cmt->content();
3163 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
3164 if (prop->value() == X_("solo")) {
3165 _solo_control->set_state (*child, version);
3166 } else if (prop->value() == X_("mute")) {
3167 _mute_control->set_state (*child, version);
3170 } else if (child->name() == X_("RemoteControl")) {
3171 if ((prop = child->property (X_("id"))) != 0) {
3173 sscanf (prop->value().c_str(), "%d", &x);
3174 set_remote_control_id_internal (x);
3184 Route::get_processor_state ()
3186 XMLNode* root = new XMLNode (X_("redirects"));
3187 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3188 root->add_child_nocopy ((*i)->state (true));
3195 Route::set_processor_state_2X (XMLNodeList const & nList, int version)
3197 /* We don't bother removing existing processors not in nList, as this
3198 method will only be called when creating a Route from scratch, not
3199 for undo purposes. Just put processors in at the appropriate place
3203 for (XMLNodeConstIterator i = nList.begin(); i != nList.end(); ++i) {
3204 add_processor_from_xml_2X (**i, version);
3209 Route::set_processor_state (const XMLNode& node)
3211 const XMLNodeList &nlist = node.children();
3212 XMLNodeConstIterator niter;
3213 ProcessorList new_order;
3214 bool must_configure = false;
3216 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3218 XMLProperty* prop = (*niter)->property ("type");
3220 if (prop->value() == "amp") {
3221 _amp->set_state (**niter, Stateful::current_state_version);
3222 new_order.push_back (_amp);
3223 } else if (prop->value() == "trim") {
3224 _trim->set_state (**niter, Stateful::current_state_version);
3225 new_order.push_back (_trim);
3226 } else if (prop->value() == "meter") {
3227 _meter->set_state (**niter, Stateful::current_state_version);
3228 new_order.push_back (_meter);
3229 } else if (prop->value() == "delay") {
3231 _delayline->set_state (**niter, Stateful::current_state_version);
3232 new_order.push_back (_delayline);
3234 } else if (prop->value() == "main-outs") {
3235 _main_outs->set_state (**niter, Stateful::current_state_version);
3236 } else if (prop->value() == "intreturn") {
3238 _intreturn.reset (new InternalReturn (_session));
3239 must_configure = true;
3241 _intreturn->set_state (**niter, Stateful::current_state_version);
3242 } else if (is_monitor() && prop->value() == "monitor") {
3243 if (!_monitor_control) {
3244 _monitor_control.reset (new MonitorProcessor (_session));
3245 must_configure = true;
3247 _monitor_control->set_state (**niter, Stateful::current_state_version);
3248 } else if (prop->value() == "capture") {
3249 /* CapturingProcessor should never be restored, it's always
3250 added explicitly when needed */
3252 ProcessorList::iterator o;
3254 for (o = _processors.begin(); o != _processors.end(); ++o) {
3255 XMLProperty* id_prop = (*niter)->property(X_("id"));
3256 if (id_prop && (*o)->id() == id_prop->value()) {
3257 (*o)->set_state (**niter, Stateful::current_state_version);
3258 new_order.push_back (*o);
3263 // If the processor (*niter) is not on the route then create it
3265 if (o == _processors.end()) {
3267 boost::shared_ptr<Processor> processor;
3269 if (prop->value() == "intsend") {
3271 processor.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), boost::shared_ptr<Route>(), Delivery::Aux, true));
3273 } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
3274 prop->value() == "lv2" ||
3275 prop->value() == "windows-vst" ||
3276 prop->value() == "lxvst" ||
3277 prop->value() == "luaproc" ||
3278 prop->value() == "audiounit") {
3280 if (_session.get_disable_all_loaded_plugins ()) {
3281 processor.reset (new UnknownProcessor (_session, **niter));
3283 processor.reset (new PluginInsert (_session));
3284 processor->set_owner (this);
3286 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(processor);
3287 pi->set_strict_io (true);
3291 } else if (prop->value() == "port") {
3293 processor.reset (new PortInsert (_session, _pannable, _mute_master));
3295 } else if (prop->value() == "send") {
3297 processor.reset (new Send (_session, _pannable, _mute_master, Delivery::Send, true));
3300 error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
3304 if (processor->set_state (**niter, Stateful::current_state_version) != 0) {
3305 /* This processor could not be configured. Turn it into a UnknownProcessor */
3306 processor.reset (new UnknownProcessor (_session, **niter));
3309 /* subscribe to Sidechain IO changes */
3310 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
3311 if (pi && pi->has_sidechain ()) {
3312 pi->sidechain_input ()->changed.connect_same_thread (*this, boost::bind (&Route::sidechain_change_handler, this, _1, _2));
3315 /* we have to note the monitor send here, otherwise a new one will be created
3316 and the state of this one will be lost.
3318 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
3319 if (isend && isend->role() == Delivery::Listen) {
3320 _monitor_send = isend;
3323 /* it doesn't matter if invisible processors are added here, as they
3324 will be sorted out by setup_invisible_processors () shortly.
3327 new_order.push_back (processor);
3328 must_configure = true;
3334 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
3335 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
3336 _processors = new_order;
3338 if (must_configure) {
3339 configure_processors_unlocked (0);
3342 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3344 (*i)->set_owner (this);
3345 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
3347 boost::shared_ptr<PluginInsert> pi;
3349 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
3350 if (pi->has_no_inputs ()) {
3351 _have_internal_generator = true;
3358 reset_instrument_info ();
3359 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
3360 set_processor_positions ();
3364 Route::curve_reallocate ()
3366 // _gain_automation_curve.finish_resize ();
3367 // _pan_automation_curve.finish_resize ();
3371 Route::silence (framecnt_t nframes)
3373 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3378 silence_unlocked (nframes);
3382 Route::silence_unlocked (framecnt_t nframes)
3384 /* Must be called with the processor lock held */
3388 _output->silence (nframes);
3390 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3391 boost::shared_ptr<PluginInsert> pi;
3393 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
3394 // skip plugins, they don't need anything when we're not active
3398 (*i)->silence (nframes);
3401 if (nframes == _session.get_block_size()) {
3408 Route::add_internal_return ()
3411 _intreturn.reset (new InternalReturn (_session));
3412 add_processor (_intreturn, PreFader);
3417 Route::add_send_to_internal_return (InternalSend* send)
3419 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3421 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
3422 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
3425 return d->add_send (send);
3431 Route::remove_send_from_internal_return (InternalSend* send)
3433 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3435 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
3436 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
3439 return d->remove_send (send);
3445 Route::enable_monitor_send ()
3447 /* Caller must hold process lock */
3448 assert (!AudioEngine::instance()->process_lock().trylock());
3450 /* master never sends to monitor section via the normal mechanism */
3451 assert (!is_master ());
3452 assert (!is_monitor ());
3454 /* make sure we have one */
3455 if (!_monitor_send) {
3456 _monitor_send.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), _session.monitor_out(), Delivery::Listen));
3457 _monitor_send->set_display_to_user (false);
3461 configure_processors (0);
3464 /** Add an aux send to a route.
3465 * @param route route to send to.
3466 * @param before Processor to insert before, or 0 to insert at the end.
3469 Route::add_aux_send (boost::shared_ptr<Route> route, boost::shared_ptr<Processor> before)
3471 assert (route != _session.monitor_out ());
3474 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3476 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
3478 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend> (*x);
3480 if (d && d->target_route() == route) {
3481 /* already listening via the specified IO: do nothing */
3489 boost::shared_ptr<InternalSend> listener;
3492 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
3493 boost::shared_ptr<Pannable> sendpan (new Pannable (_session));
3494 listener.reset (new InternalSend (_session, sendpan, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), route, Delivery::Aux));
3497 add_processor (listener, before);
3499 } catch (failed_constructor& err) {
3507 Route::remove_aux_or_listen (boost::shared_ptr<Route> route)
3509 ProcessorStreams err;
3510 ProcessorList::iterator tmp;
3513 Glib::Threads::RWLock::ReaderLock rl(_processor_lock);
3515 /* have to do this early because otherwise processor reconfig
3516 * will put _monitor_send back in the list
3519 if (route == _session.monitor_out()) {
3520 _monitor_send.reset ();
3524 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
3526 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
3528 if (d && d->target_route() == route) {
3530 if (remove_processor (*x, &err, false) > 0) {
3536 /* list could have been demolished while we dropped the lock
3539 if (_session.engine().connected()) {
3540 /* i/o processors cannot be removed if the engine is not running
3541 * so don't live-loop in case the engine is N/A or dies
3551 Route::set_comment (string cmt, void *src)
3555 _session.set_dirty ();
3559 Route::add_fed_by (boost::shared_ptr<Route> other, bool via_sends_only)
3561 FeedRecord fr (other, via_sends_only);
3563 pair<FedBy::iterator,bool> result = _fed_by.insert (fr);
3565 if (!result.second) {
3567 /* already a record for "other" - make sure sends-only information is correct */
3568 if (!via_sends_only && result.first->sends_only) {
3569 FeedRecord* frp = const_cast<FeedRecord*>(&(*result.first));
3570 frp->sends_only = false;
3574 return result.second;
3578 Route::clear_fed_by ()
3584 Route::feeds (boost::shared_ptr<Route> other, bool* via_sends_only)
3586 const FedBy& fed_by (other->fed_by());
3588 for (FedBy::const_iterator f = fed_by.begin(); f != fed_by.end(); ++f) {
3589 boost::shared_ptr<Route> sr = f->r.lock();
3591 if (sr && (sr.get() == this)) {
3593 if (via_sends_only) {
3594 *via_sends_only = f->sends_only;
3605 Route::direct_feeds_according_to_reality (boost::shared_ptr<Route> other, bool* via_send_only)
3607 DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds? %1\n", _name));
3609 if (_output->connected_to (other->input())) {
3610 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS %2\n", other->name()));
3611 if (via_send_only) {
3612 *via_send_only = false;
3619 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
3621 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(*r);
3622 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*r);
3625 iop = pi->sidechain();
3629 if (iop->feeds (other)) {
3630 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name()));
3631 if (via_send_only) {
3632 *via_send_only = true;
3636 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does NOT feed %2\n", iop->name(), other->name()));
3639 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tPROC %1 is not an IOP\n", (*r)->name()));
3644 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdoes NOT feed %1\n", other->name()));
3649 Route::direct_feeds_according_to_graph (boost::shared_ptr<Route> other, bool* via_send_only)
3651 return _session._current_route_graph.has (shared_from_this (), other, via_send_only);
3654 /** Called from the (non-realtime) butler thread when the transport is stopped */
3656 Route::nonrealtime_handle_transport_stopped (bool /*abort_ignored*/, bool /*did_locate*/, bool can_flush_processors)
3658 framepos_t now = _session.transport_frame();
3661 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3663 Automatable::transport_stopped (now);
3665 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3667 if (!_have_internal_generator && (Config->get_plugins_stop_with_transport() && can_flush_processors)) {
3671 (*i)->transport_stopped (now);
3675 _roll_delay = _initial_delay;
3679 Route::input_change_handler (IOChange change, void * /*src*/)
3681 if ((change.type & IOChange::ConfigurationChanged)) {
3682 /* This is called with the process lock held if change
3683 contains ConfigurationChanged
3685 configure_processors (0);
3686 _phase_invert.resize (_input->n_ports().n_audio ());
3687 io_changed (); /* EMIT SIGNAL */
3690 if (_soloed_by_others_upstream || _solo_isolated_by_upstream) {
3693 boost::shared_ptr<RouteList> routes = _session.get_routes ();
3694 if (_input->connected()) {
3695 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3696 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3700 bool does_feed = (*i)->direct_feeds_according_to_reality (shared_from_this(), &sends_only);
3701 if (does_feed && !sends_only) {
3702 if ((*i)->soloed()) {
3705 if ((*i)->solo_isolated()) {
3712 int delta = sbou - _soloed_by_others_upstream;
3713 int idelta = ibou - _solo_isolated_by_upstream;
3716 PBD::warning << string_compose (
3717 _("Invalid Solo-Isolate propagation: from:%1 new:%2 - old:%3 = delta:%4"),
3718 _name, ibou, _solo_isolated_by_upstream, idelta)
3723 if (_soloed_by_others_upstream) {
3724 // ignore new connections (they're not propagated)
3726 mod_solo_by_others_upstream (delta);
3730 if (_solo_isolated_by_upstream) {
3731 // solo-isolate currently only propagates downstream
3733 mod_solo_isolated_by_upstream (false);
3735 // TODO think: mod_solo_isolated_by_upstream() does not take delta arg,
3736 // but idelta can't be smaller than -1, can it?
3737 //_solo_isolated_by_upstream = ibou;
3740 // Session::route_solo_changed does not propagate indirect solo-changes
3741 // propagate downstream to tracks
3742 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3743 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3747 bool does_feed = feeds (*i, &sends_only);
3748 if (delta <= 0 && does_feed && !sends_only) {
3749 (*i)->mod_solo_by_others_upstream (delta);
3752 if (idelta < 0 && does_feed && !sends_only) {
3753 (*i)->mod_solo_isolated_by_upstream (false);
3760 Route::output_change_handler (IOChange change, void * /*src*/)
3762 if (_initial_io_setup) {
3766 if ((change.type & IOChange::ConfigurationChanged)) {
3767 /* This is called with the process lock held if change
3768 contains ConfigurationChanged
3770 configure_processors (0);
3773 _session.reset_monitor_section();
3776 io_changed (); /* EMIT SIGNAL */
3779 if (_soloed_by_others_downstream) {
3781 /* checking all all downstream routes for
3782 * explicit of implict solo is a rather drastic measure,
3783 * ideally the input_change_handler() of the other route
3784 * would propagate the change to us.
3786 boost::shared_ptr<RouteList> routes = _session.get_routes ();
3787 if (_output->connected()) {
3788 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3789 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3793 bool does_feed = direct_feeds_according_to_reality (*i, &sends_only);
3794 if (does_feed && !sends_only) {
3795 if ((*i)->soloed()) {
3802 int delta = sbod - _soloed_by_others_downstream;
3804 // do not allow new connections to change implicit solo (no propagation)
3805 mod_solo_by_others_downstream (delta);
3806 // Session::route_solo_changed() does not propagate indirect solo-changes
3807 // propagate upstream to tracks
3808 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3809 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3813 bool does_feed = (*i)->feeds (shared_from_this(), &sends_only);
3814 if (delta != 0 && does_feed && !sends_only) {
3815 (*i)->mod_solo_by_others_downstream (delta);
3824 Route::sidechain_change_handler (IOChange change, void * /*src*/)
3826 if (_initial_io_setup || _in_sidechain_setup) {
3830 if ((change.type & IOChange::ConfigurationChanged)) {
3831 /* This is called with the process lock held if change
3832 contains ConfigurationChanged
3834 configure_processors (0);
3839 Route::pans_required () const
3841 if (n_outputs().n_audio() < 2) {
3845 return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
3849 Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
3851 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3857 if (n_outputs().n_total() == 0) {
3861 if (!_active || n_inputs() == ChanCount::ZERO) {
3862 silence_unlocked (nframes);
3866 if (session_state_changing) {
3867 if (_session.transport_speed() != 0.0f) {
3868 /* we're rolling but some state is changing (e.g. our diskstream contents)
3869 so we cannot use them. Be silent till this is over.
3871 XXX note the absurdity of ::no_roll() being called when we ARE rolling!
3873 silence_unlocked (nframes);
3876 /* we're really not rolling, so we're either delivery silence or actually
3877 monitoring, both of which are safe to do while session_state_changing is true.
3881 BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
3883 fill_buffers_with_input (bufs, _input, nframes);
3885 if (_meter_point == MeterInput) {
3886 _meter->run (bufs, start_frame, end_frame, nframes, true);
3889 _amp->apply_gain_automation (false);
3890 _trim->apply_gain_automation (false);
3891 passthru (bufs, start_frame, end_frame, nframes, 0);
3897 Route::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& /* need_butler */)
3899 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3904 if (n_outputs().n_total() == 0) {
3908 if (!_active || n_inputs().n_total() == 0) {
3909 silence_unlocked (nframes);
3913 framepos_t unused = 0;
3915 if ((nframes = check_initial_delay (nframes, unused)) == 0) {
3921 BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
3923 fill_buffers_with_input (bufs, _input, nframes);
3925 if (_meter_point == MeterInput) {
3926 _meter->run (bufs, start_frame, end_frame, nframes, true);
3929 passthru (bufs, start_frame, end_frame, nframes, declick);
3935 Route::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*end_frame*/, bool& /* need_butler */)
3942 Route::flush_processors ()
3944 /* XXX shouldn't really try to take this lock, since
3945 this is called from the RT audio thread.
3948 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3950 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3956 __attribute__((annotate("realtime")))
3959 Route::apply_processor_changes_rt ()
3961 int emissions = EmitNone;
3963 if (_pending_meter_point != _meter_point) {
3964 Glib::Threads::RWLock::WriterLock pwl (_processor_lock, Glib::Threads::TRY_LOCK);
3966 /* meters always have buffers for 'processor_max_streams'
3967 * they can be re-positioned without re-allocation */
3968 if (set_meter_point_unlocked()) {
3969 emissions |= EmitMeterChanged | EmitMeterVisibilityChange;;
3971 emissions |= EmitMeterChanged;
3976 bool changed = false;
3978 if (g_atomic_int_get (&_pending_process_reorder)) {
3979 Glib::Threads::RWLock::WriterLock pwl (_processor_lock, Glib::Threads::TRY_LOCK);
3981 apply_processor_order (_pending_processor_order);
3982 setup_invisible_processors ();
3984 g_atomic_int_set (&_pending_process_reorder, 0);
3985 emissions |= EmitRtProcessorChange;
3989 set_processor_positions ();
3991 if (emissions != 0) {
3992 g_atomic_int_set (&_pending_signals, emissions);
3999 Route::emit_pending_signals ()
4002 int sig = g_atomic_int_and (&_pending_signals, 0);
4003 if (sig & EmitMeterChanged) {
4004 _meter->emit_configuration_changed();
4005 meter_change (); /* EMIT SIGNAL */
4006 if (sig & EmitMeterVisibilityChange) {
4007 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */
4009 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */
4012 if (sig & EmitRtProcessorChange) {
4013 processors_changed (RouteProcessorChange (RouteProcessorChange::RealTimeChange)); /* EMIT SIGNAL */
4018 Route::set_meter_point (MeterPoint p, bool force)
4020 if (_pending_meter_point == p && !force) {
4024 if (force || !AudioEngine::instance()->running()) {
4025 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
4026 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
4027 _pending_meter_point = p;
4028 _meter->emit_configuration_changed();
4029 meter_change (); /* EMIT SIGNAL */
4030 if (set_meter_point_unlocked()) {
4031 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */
4033 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */
4036 _pending_meter_point = p;
4042 __attribute__((annotate("realtime")))
4045 Route::set_meter_point_unlocked ()
4048 /* Caller must hold process and processor write lock */
4049 assert (!AudioEngine::instance()->process_lock().trylock());
4050 Glib::Threads::RWLock::WriterLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
4051 assert (!lm.locked ());
4054 _meter_point = _pending_meter_point;
4056 bool meter_was_visible_to_user = _meter->display_to_user ();
4058 if (!_custom_meter_position_noted) {
4059 maybe_note_meter_position ();
4062 if (_meter_point != MeterCustom) {
4064 _meter->set_display_to_user (false);
4066 setup_invisible_processors ();
4069 _meter->set_display_to_user (true);
4071 /* If we have a previous position for the custom meter, try to put it there */
4072 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
4074 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), after);
4075 if (i != _processors.end ()) {
4076 _processors.remove (_meter);
4077 _processors.insert (i, _meter);
4079 } else {// at end, right before the mains_out/panner
4080 _processors.remove (_meter);
4081 ProcessorList::iterator main = _processors.end();
4082 _processors.insert (--main, _meter);
4086 /* Set up the meter for its new position */
4088 ProcessorList::iterator loc = find (_processors.begin(), _processors.end(), _meter);
4092 if (loc == _processors.begin()) {
4093 m_in = _input->n_ports();
4095 ProcessorList::iterator before = loc;
4097 m_in = (*before)->output_streams ();
4100 _meter->reflect_inputs (m_in);
4102 /* we do not need to reconfigure the processors, because the meter
4103 (a) is always ready to handle processor_max_streams
4104 (b) is always an N-in/N-out processor, and thus moving
4105 it doesn't require any changes to the other processors.
4108 /* these should really be done after releasing the lock
4109 * but all those signals are subscribed to with gui_thread()
4112 return (_meter->display_to_user() != meter_was_visible_to_user);
4116 Route::listen_position_changed ()
4119 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
4120 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
4121 ProcessorState pstate (this);
4123 if (configure_processors_unlocked (0)) {
4124 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
4126 configure_processors_unlocked (0); // it worked before we tried to add it ...
4131 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
4132 _session.set_dirty ();
4135 boost::shared_ptr<CapturingProcessor>
4136 Route::add_export_point()
4138 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4139 if (!_capturing_processor) {
4141 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
4142 Glib::Threads::RWLock::WriterLock lw (_processor_lock);
4144 _capturing_processor.reset (new CapturingProcessor (_session));
4145 _capturing_processor->activate ();
4147 configure_processors_unlocked (0);
4151 return _capturing_processor;
4155 Route::update_signal_latency ()
4157 framecnt_t l = _output->user_latency();
4158 framecnt_t lamp = 0;
4159 bool before_amp = true;
4160 framecnt_t ltrim = 0;
4161 bool before_trim = true;
4163 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4164 if ((*i)->active ()) {
4165 l += (*i)->signal_latency ();
4170 if ((*i) == _trim) {
4181 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal signal latency = %2\n", _name, l));
4183 // TODO: (lamp - _signal_latency) to sync to output (read-ahed), currently _roll_delay shifts this around
4184 _signal_latency_at_amp_position = lamp;
4185 _signal_latency_at_trim_position = ltrim;
4187 if (_signal_latency != l) {
4188 _signal_latency = l;
4189 signal_latency_changed (); /* EMIT SIGNAL */
4192 return _signal_latency;
4196 Route::set_user_latency (framecnt_t nframes)
4198 _output->set_user_latency (nframes);
4199 _session.update_latency_compensation ();
4203 Route::set_latency_compensation (framecnt_t longest_session_latency)
4205 framecnt_t old = _initial_delay;
4207 if (_signal_latency < longest_session_latency) {
4208 _initial_delay = longest_session_latency - _signal_latency;
4213 DEBUG_TRACE (DEBUG::Latency, string_compose (
4214 "%1: compensate for maximum latency of %2,"
4215 "given own latency of %3, using initial delay of %4\n",
4216 name(), longest_session_latency, _signal_latency, _initial_delay));
4218 if (_initial_delay != old) {
4219 initial_delay_changed (); /* EMIT SIGNAL */
4222 if (_session.transport_stopped()) {
4223 _roll_delay = _initial_delay;
4228 Route::set_block_size (pframes_t nframes)
4230 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4231 (*i)->set_block_size (nframes);
4234 _session.ensure_buffers (n_process_buffers ());
4238 Route::protect_automation ()
4240 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i)
4241 (*i)->protect_automation();
4244 /** @param declick 1 to set a pending declick fade-in,
4245 * -1 to set a pending declick fade-out
4248 Route::set_pending_declick (int declick)
4251 /* this call is not allowed to turn off a pending declick */
4253 _pending_declick = declick;
4256 _pending_declick = 0;
4260 /** Shift automation forwards from a particular place, thereby inserting time.
4261 * Adds undo commands for any shifts that are performed.
4263 * @param pos Position to start shifting from.
4264 * @param frames Amount to shift forwards by.
4268 Route::shift (framepos_t pos, framecnt_t frames)
4270 /* gain automation */
4272 boost::shared_ptr<AutomationControl> gc = _amp->gain_control();
4274 XMLNode &before = gc->alist()->get_state ();
4275 gc->alist()->shift (pos, frames);
4276 XMLNode &after = gc->alist()->get_state ();
4277 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
4280 /* gain automation */
4282 boost::shared_ptr<AutomationControl> gc = _trim->gain_control();
4284 XMLNode &before = gc->alist()->get_state ();
4285 gc->alist()->shift (pos, frames);
4286 XMLNode &after = gc->alist()->get_state ();
4287 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
4290 // TODO mute automation ??
4292 /* pan automation */
4294 ControlSet::Controls& c (_pannable->controls());
4296 for (ControlSet::Controls::const_iterator ci = c.begin(); ci != c.end(); ++ci) {
4297 boost::shared_ptr<AutomationControl> pc = boost::dynamic_pointer_cast<AutomationControl> (ci->second);
4299 boost::shared_ptr<AutomationList> al = pc->alist();
4300 XMLNode& before = al->get_state ();
4301 al->shift (pos, frames);
4302 XMLNode& after = al->get_state ();
4303 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
4308 /* redirect automation */
4310 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4311 for (ProcessorList::iterator i = _processors.begin (); i != _processors.end (); ++i) {
4313 set<Evoral::Parameter> parameters = (*i)->what_can_be_automated();
4315 for (set<Evoral::Parameter>::const_iterator p = parameters.begin (); p != parameters.end (); ++p) {
4316 boost::shared_ptr<AutomationControl> ac = (*i)->automation_control (*p);
4318 boost::shared_ptr<AutomationList> al = ac->alist();
4319 XMLNode &before = al->get_state ();
4320 al->shift (pos, frames);
4321 XMLNode &after = al->get_state ();
4322 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
4330 Route::set_plugin_state_dir (boost::weak_ptr<Processor> p, const std::string& d)
4332 boost::shared_ptr<Processor> processor (p.lock ());
4333 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
4337 pi->set_state_dir (d);
4341 Route::save_as_template (const string& path, const string& name)
4343 std::string state_dir = path.substr (0, path.find_last_of ('.')); // strip template_suffix
4344 PBD::Unwinder<std::string> uw (_session._template_state_dir, state_dir);
4346 XMLNode& node (state (false));
4350 IO::set_name_in_state (*node.children().front(), name);
4352 tree.set_root (&node);
4354 /* return zero on success, non-zero otherwise */
4355 return !tree.write (path.c_str());
4360 Route::set_name (const string& str)
4362 if (str == name()) {
4366 string name = Route::ensure_track_or_route_name (str, _session);
4367 SessionObject::set_name (name);
4369 bool ret = (_input->set_name(name) && _output->set_name(name));
4372 /* rename the main outs. Leave other IO processors
4373 * with whatever name they already have, because its
4374 * just fine as it is (it will not contain the route
4375 * name if its a port insert, port send or port return).
4379 if (_main_outs->set_name (name)) {
4380 /* XXX returning false here is stupid because
4381 we already changed the route name.
4391 /** Set the name of a route in an XML description.
4392 * @param node XML <Route> node to set the name in.
4393 * @param name New name.
4396 Route::set_name_in_state (XMLNode& node, string const & name, bool rename_playlist)
4398 node.add_property (X_("name"), name);
4400 XMLNodeList children = node.children();
4401 for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
4403 if ((*i)->name() == X_("IO")) {
4405 IO::set_name_in_state (**i, name);
4407 } else if ((*i)->name() == X_("Processor")) {
4409 XMLProperty* role = (*i)->property (X_("role"));
4410 if (role && role->value() == X_("Main")) {
4411 (*i)->add_property (X_("name"), name);
4414 } else if ((*i)->name() == X_("Diskstream")) {
4416 if (rename_playlist) {
4417 (*i)->add_property (X_("playlist"), string_compose ("%1.1", name).c_str());
4419 (*i)->add_property (X_("name"), name);
4425 boost::shared_ptr<Send>
4426 Route::internal_send_for (boost::shared_ptr<const Route> target) const
4428 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4430 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4431 boost::shared_ptr<InternalSend> send;
4433 if ((send = boost::dynamic_pointer_cast<InternalSend>(*i)) != 0) {
4434 if (send->target_route() == target) {
4440 return boost::shared_ptr<Send>();
4443 /** @param c Audio channel index.
4444 * @param yn true to invert phase, otherwise false.
4447 Route::set_phase_invert (uint32_t c, bool yn)
4449 if (_phase_invert[c] != yn) {
4450 _phase_invert[c] = yn;
4451 phase_invert_changed (); /* EMIT SIGNAL */
4452 _phase_control->Changed(); /* EMIT SIGNAL */
4453 _session.set_dirty ();
4458 Route::set_phase_invert (boost::dynamic_bitset<> p)
4460 if (_phase_invert != p) {
4462 phase_invert_changed (); /* EMIT SIGNAL */
4463 _session.set_dirty ();
4468 Route::phase_invert (uint32_t c) const
4470 return _phase_invert[c];
4473 boost::dynamic_bitset<>
4474 Route::phase_invert () const
4476 return _phase_invert;
4480 Route::set_denormal_protection (bool yn)
4482 if (_denormal_protection != yn) {
4483 _denormal_protection = yn;
4484 denormal_protection_changed (); /* EMIT SIGNAL */
4489 Route::denormal_protection () const
4491 return _denormal_protection;
4495 Route::set_active (bool yn, void* src)
4497 if (_session.transport_rolling()) {
4501 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_route_active()) {
4502 _route_group->foreach_route (boost::bind (&Route::set_active, _1, yn, _route_group));
4506 if (_active != yn) {
4508 _input->set_active (yn);
4509 _output->set_active (yn);
4510 active_changed (); // EMIT SIGNAL
4511 _session.set_dirty ();
4515 boost::shared_ptr<Pannable>
4516 Route::pannable() const
4521 boost::shared_ptr<Panner>
4522 Route::panner() const
4525 return _main_outs->panner_shell()->panner();
4528 boost::shared_ptr<PannerShell>
4529 Route::panner_shell() const
4531 return _main_outs->panner_shell();
4534 boost::shared_ptr<GainControl>
4535 Route::gain_control() const
4537 return _gain_control;
4540 boost::shared_ptr<GainControl>
4541 Route::trim_control() const
4543 return _trim_control;
4546 boost::shared_ptr<Route::PhaseControllable>
4547 Route::phase_control() const
4549 if (phase_invert().size()) {
4550 return _phase_control;
4552 return boost::shared_ptr<PhaseControllable>();
4556 boost::shared_ptr<AutomationControl>
4557 Route::get_control (const Evoral::Parameter& param)
4559 /* either we own the control or .... */
4561 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(control (param));
4565 /* maybe one of our processors does or ... */
4567 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
4568 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4569 if ((c = boost::dynamic_pointer_cast<AutomationControl>((*i)->control (param))) != 0) {
4577 /* nobody does so we'll make a new one */
4579 c = boost::dynamic_pointer_cast<AutomationControl>(control_factory(param));
4586 boost::shared_ptr<Processor>
4587 Route::nth_plugin (uint32_t n) const
4589 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4590 ProcessorList::const_iterator i;
4592 for (i = _processors.begin(); i != _processors.end(); ++i) {
4593 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
4600 return boost::shared_ptr<Processor> ();
4603 boost::shared_ptr<Processor>
4604 Route::nth_send (uint32_t n) const
4606 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4607 ProcessorList::const_iterator i;
4609 for (i = _processors.begin(); i != _processors.end(); ++i) {
4610 if (boost::dynamic_pointer_cast<Send> (*i)) {
4612 if ((*i)->name().find (_("Monitor")) == 0) {
4613 /* send to monitor section is not considered
4614 to be an accessible send.
4625 return boost::shared_ptr<Processor> ();
4629 Route::has_io_processor_named (const string& name)
4631 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4632 ProcessorList::iterator i;
4634 for (i = _processors.begin(); i != _processors.end(); ++i) {
4635 if (boost::dynamic_pointer_cast<Send> (*i) ||
4636 boost::dynamic_pointer_cast<PortInsert> (*i)) {
4637 if ((*i)->name() == name) {
4646 MuteMaster::MutePoint
4647 Route::mute_points () const
4649 return _mute_master->mute_points ();
4653 Route::set_processor_positions ()
4655 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4657 bool had_amp = false;
4658 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4659 (*i)->set_pre_fader (!had_amp);
4666 /** Called when there is a proposed change to the input port count */
4668 Route::input_port_count_changing (ChanCount to)
4670 list<pair<ChanCount, ChanCount> > c = try_configure_processors (to, 0);
4672 /* The processors cannot be configured with the new input arrangement, so
4678 /* The change is ok */
4682 /** Called when there is a proposed change to the output port count */
4684 Route::output_port_count_changing (ChanCount to)
4686 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
4687 if (processor_out_streams.get(*t) > to.get(*t)) {
4691 /* The change is ok */
4696 Route::unknown_processors () const
4700 if (_session.get_disable_all_loaded_plugins ()) {
4701 // Do not list "missing plugins" if they are explicitly disabled
4705 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4706 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4707 if (boost::dynamic_pointer_cast<UnknownProcessor const> (*i)) {
4708 p.push_back ((*i)->name ());
4717 Route::update_port_latencies (PortSet& from, PortSet& to, bool playback, framecnt_t our_latency) const
4719 /* we assume that all our input ports feed all our output ports. its not
4720 universally true, but the alternative is way too corner-case to worry about.
4723 LatencyRange all_connections;
4726 all_connections.min = 0;
4727 all_connections.max = 0;
4729 all_connections.min = ~((pframes_t) 0);
4730 all_connections.max = 0;
4732 /* iterate over all "from" ports and determine the latency range for all of their
4733 connections to the "outside" (outside of this Route).
4736 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
4740 p->get_connected_latency_range (range, playback);
4742 all_connections.min = min (all_connections.min, range.min);
4743 all_connections.max = max (all_connections.max, range.max);
4747 /* set the "from" port latencies to the max/min range of all their connections */
4749 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
4750 p->set_private_latency_range (all_connections, playback);
4753 /* set the ports "in the direction of the flow" to the same value as above plus our own signal latency */
4755 all_connections.min += our_latency;
4756 all_connections.max += our_latency;
4758 for (PortSet::iterator p = to.begin(); p != to.end(); ++p) {
4759 p->set_private_latency_range (all_connections, playback);
4762 return all_connections.max;
4766 Route::set_private_port_latencies (bool playback) const
4768 framecnt_t own_latency = 0;
4770 /* Processor list not protected by lock: MUST BE CALLED FROM PROCESS THREAD
4771 OR LATENCY CALLBACK.
4773 This is called (early) from the latency callback. It computes the REAL
4774 latency associated with each port and stores the result as the "private"
4775 latency of the port. A later call to Route::set_public_port_latencies()
4776 sets all ports to the same value to reflect the fact that we do latency
4777 compensation and so all signals are delayed by the same amount as they
4778 flow through ardour.
4781 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4782 if ((*i)->active ()) {
4783 own_latency += (*i)->signal_latency ();
4788 /* playback: propagate latency from "outside the route" to outputs to inputs */
4789 return update_port_latencies (_output->ports (), _input->ports (), true, own_latency);
4791 /* capture: propagate latency from "outside the route" to inputs to outputs */
4792 return update_port_latencies (_input->ports (), _output->ports (), false, own_latency);
4797 Route::set_public_port_latencies (framecnt_t value, bool playback) const
4799 /* this is called to set the JACK-visible port latencies, which take
4800 latency compensation into account.
4809 const PortSet& ports (_input->ports());
4810 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
4811 p->set_public_latency_range (range, playback);
4816 const PortSet& ports (_output->ports());
4817 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
4818 p->set_public_latency_range (range, playback);
4823 /** Put the invisible processors in the right place in _processors.
4824 * Must be called with a writer lock on _processor_lock held.
4827 __attribute__((annotate("realtime")))
4830 Route::setup_invisible_processors ()
4833 Glib::Threads::RWLock::WriterLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
4834 assert (!lm.locked ());
4838 /* too early to be doing this stuff */
4842 /* we'll build this new list here and then use it
4844 * TODO put the ProcessorList is on the stack for RT-safety.
4847 ProcessorList new_processors;
4849 /* find visible processors */
4851 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4852 if ((*i)->display_to_user ()) {
4853 new_processors.push_back (*i);
4859 ProcessorList::iterator amp = new_processors.begin ();
4860 while (amp != new_processors.end() && *amp != _amp) {
4864 assert (amp != new_processors.end ());
4866 /* and the processor after the amp */
4868 ProcessorList::iterator after_amp = amp;
4874 switch (_meter_point) {
4876 assert (!_meter->display_to_user ());
4877 new_processors.push_front (_meter);
4880 assert (!_meter->display_to_user ());
4881 new_processors.insert (amp, _meter);
4883 case MeterPostFader:
4884 /* do nothing here */
4887 /* do nothing here */
4890 /* the meter is visible, so we don't touch it here */
4897 assert (_main_outs);
4898 assert (!_main_outs->display_to_user ());
4899 new_processors.push_back (_main_outs);
4901 /* iterator for the main outs */
4903 ProcessorList::iterator main = new_processors.end();
4906 /* OUTPUT METERING */
4908 if (_meter && (_meter_point == MeterOutput || _meter_point == MeterPostFader)) {
4909 assert (!_meter->display_to_user ());
4911 /* add the processor just before or just after the main outs */
4913 ProcessorList::iterator meter_point = main;
4915 if (_meter_point == MeterOutput) {
4918 new_processors.insert (meter_point, _meter);
4923 if (_monitor_send && !is_monitor ()) {
4924 assert (!_monitor_send->display_to_user ());
4925 switch (Config->get_listen_position ()) {
4926 case PreFaderListen:
4927 switch (Config->get_pfl_position ()) {
4928 case PFLFromBeforeProcessors:
4929 new_processors.push_front (_monitor_send);
4931 case PFLFromAfterProcessors:
4932 new_processors.insert (amp, _monitor_send);
4935 _monitor_send->set_can_pan (false);
4937 case AfterFaderListen:
4938 switch (Config->get_afl_position ()) {
4939 case AFLFromBeforeProcessors:
4940 new_processors.insert (after_amp, _monitor_send);
4942 case AFLFromAfterProcessors:
4943 new_processors.insert (new_processors.end(), _monitor_send);
4946 _monitor_send->set_can_pan (true);
4951 #if 0 // not used - just yet
4952 if (!is_master() && !is_monitor() && !is_auditioner()) {
4953 new_processors.push_front (_delayline);
4957 /* MONITOR CONTROL */
4959 if (_monitor_control && is_monitor ()) {
4960 assert (!_monitor_control->display_to_user ());
4961 new_processors.insert (amp, _monitor_control);
4964 /* INTERNAL RETURN */
4966 /* doing this here means that any monitor control will come just after
4971 assert (!_intreturn->display_to_user ());
4972 new_processors.push_front (_intreturn);
4975 if (_trim && _trim->active()) {
4976 assert (!_trim->display_to_user ());
4977 new_processors.push_front (_trim);
4979 /* EXPORT PROCESSOR */
4981 if (_capturing_processor) {
4982 assert (!_capturing_processor->display_to_user ());
4983 new_processors.push_front (_capturing_processor);
4986 _processors = new_processors;
4988 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4989 if (!(*i)->display_to_user () && !(*i)->active () && (*i) != _monitor_send) {
4994 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: setup_invisible_processors\n", _name));
4995 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4996 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1\n", (*i)->name ()));
5003 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
5004 Glib::Threads::RWLock::ReaderLock lp (_processor_lock);
5008 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
5009 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery>(*i);
5016 /** If the meter point is `Custom', make a note of where the meter is.
5017 * This is so that if the meter point is subsequently set to something else,
5018 * and then back to custom, we can put the meter back where it was last time
5019 * custom was enabled.
5021 * Must be called with the _processor_lock held.
5024 Route::maybe_note_meter_position ()
5026 if (_meter_point != MeterCustom) {
5030 _custom_meter_position_noted = true;
5031 /* custom meter points range from after trim to before panner/main_outs
5032 * this is a limitation by the current processor UI
5034 bool seen_trim = false;
5035 _processor_after_last_custom_meter.reset();
5036 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
5037 if ((*i) == _trim) {
5040 if ((*i) == _main_outs) {
5041 _processor_after_last_custom_meter = *i;
5044 if (boost::dynamic_pointer_cast<PeakMeter> (*i)) {
5046 _processor_after_last_custom_meter = _trim;
5048 ProcessorList::iterator j = i;
5050 assert(j != _processors.end ()); // main_outs should be before
5051 _processor_after_last_custom_meter = *j;
5056 assert(_processor_after_last_custom_meter.lock());
5059 boost::shared_ptr<Processor>
5060 Route::processor_by_id (PBD::ID id) const
5062 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5063 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5064 if ((*i)->id() == id) {
5069 return boost::shared_ptr<Processor> ();
5072 /** @return the monitoring state, or in other words what data we are pushing
5073 * into the route (data from the inputs, data from disk or silence)
5076 Route::monitoring_state () const
5078 return MonitoringInput;
5081 /** @return what we should be metering; either the data coming from the input
5082 * IO or the data that is flowing through the route.
5085 Route::metering_state () const
5087 return MeteringRoute;
5091 Route::has_external_redirects () const
5093 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5095 /* ignore inactive processors and obviously ignore the main
5096 * outs since everything has them and we don't care.
5099 if ((*i)->active() && (*i) != _main_outs && (*i)->does_routing()) {
5107 boost::shared_ptr<Processor>
5108 Route::the_instrument () const
5110 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5111 return the_instrument_unlocked ();
5114 boost::shared_ptr<Processor>
5115 Route::the_instrument_unlocked () const
5117 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5118 if (boost::dynamic_pointer_cast<PluginInsert>(*i)) {
5119 if ((*i)->input_streams().n_midi() > 0 &&
5120 (*i)->output_streams().n_audio() > 0) {
5125 return boost::shared_ptr<Processor>();
5131 Route::non_realtime_locate (framepos_t pos)
5134 _pannable->transport_located (pos);
5137 if (_delayline.get()) {
5138 _delayline.get()->flush();
5142 //Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
5143 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5145 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
5146 (*i)->transport_located (pos);
5149 _roll_delay = _initial_delay;
5153 Route::fill_buffers_with_input (BufferSet& bufs, boost::shared_ptr<IO> io, pframes_t nframes)
5160 * We don't currently mix MIDI input together, so we don't need the
5161 * complex logic of the audio case.
5164 n_buffers = bufs.count().n_midi ();
5166 for (i = 0; i < n_buffers; ++i) {
5168 boost::shared_ptr<MidiPort> source_port = io->midi (i);
5169 MidiBuffer& buf (bufs.get_midi (i));
5172 buf.copy (source_port->get_midi_buffer(nframes));
5174 buf.silence (nframes);
5180 n_buffers = bufs.count().n_audio();
5182 size_t n_ports = io->n_ports().n_audio();
5183 float scaling = 1.0f;
5185 if (n_ports > n_buffers) {
5186 scaling = ((float) n_buffers) / n_ports;
5189 for (i = 0; i < n_ports; ++i) {
5191 /* if there are more ports than buffers, map them onto buffers
5192 * in a round-robin fashion
5195 boost::shared_ptr<AudioPort> source_port = io->audio (i);
5196 AudioBuffer& buf (bufs.get_audio (i%n_buffers));
5199 if (i < n_buffers) {
5201 /* first time through just copy a channel into
5205 buf.read_from (source_port->get_audio_buffer (nframes), nframes);
5207 if (scaling != 1.0f) {
5208 buf.apply_gain (scaling, nframes);
5213 /* on subsequent times around, merge data from
5214 * the port with what is already there
5217 if (scaling != 1.0f) {
5218 buf.accumulate_with_gain_from (source_port->get_audio_buffer (nframes), nframes, 0, scaling);
5220 buf.accumulate_from (source_port->get_audio_buffer (nframes), nframes);
5225 /* silence any remaining buffers */
5227 for (; i < n_buffers; ++i) {
5228 AudioBuffer& buf (bufs.get_audio (i));
5229 buf.silence (nframes);
5232 /* establish the initial setup of the buffer set, reflecting what was
5233 copied into it. unless, of course, we are the auditioner, in which
5234 case nothing was fed into it from the inputs at all.
5237 if (!is_auditioner()) {
5238 bufs.set_count (io->n_ports());
5242 boost::shared_ptr<AutomationControl>
5243 Route::pan_azimuth_control() const
5246 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5248 return boost::shared_ptr<AutomationControl>();
5250 const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
5251 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
5253 if (!_pannable || !panner()) {
5254 return boost::shared_ptr<AutomationControl>();
5256 return _pannable->pan_azimuth_control;
5260 boost::shared_ptr<AutomationControl>
5261 Route::pan_elevation_control() const
5263 if (Profile->get_mixbus() || !_pannable || !panner()) {
5264 return boost::shared_ptr<AutomationControl>();
5267 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5269 if (c.find (PanElevationAutomation) != c.end()) {
5270 return _pannable->pan_elevation_control;
5272 return boost::shared_ptr<AutomationControl>();
5275 boost::shared_ptr<AutomationControl>
5276 Route::pan_width_control() const
5278 if (Profile->get_mixbus() || !_pannable || !panner()) {
5279 return boost::shared_ptr<AutomationControl>();
5282 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5284 if (c.find (PanWidthAutomation) != c.end()) {
5285 return _pannable->pan_width_control;
5287 return boost::shared_ptr<AutomationControl>();
5290 boost::shared_ptr<AutomationControl>
5291 Route::pan_frontback_control() const
5293 if (Profile->get_mixbus() || !_pannable || !panner()) {
5294 return boost::shared_ptr<AutomationControl>();
5297 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5299 if (c.find (PanFrontBackAutomation) != c.end()) {
5300 return _pannable->pan_frontback_control;
5302 return boost::shared_ptr<AutomationControl>();
5305 boost::shared_ptr<AutomationControl>
5306 Route::pan_lfe_control() const
5308 if (Profile->get_mixbus() || !_pannable || !panner()) {
5309 return boost::shared_ptr<AutomationControl>();
5312 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5314 if (c.find (PanLFEAutomation) != c.end()) {
5315 return _pannable->pan_lfe_control;
5317 return boost::shared_ptr<AutomationControl>();
5322 Route::eq_band_cnt () const
5324 if (Profile->get_mixbus()) {
5327 /* Ardour has no well-known EQ object */
5332 boost::shared_ptr<AutomationControl>
5333 Route::eq_gain_controllable (uint32_t band) const
5336 boost::shared_ptr<PluginInsert> eq = ch_eq();
5339 return boost::shared_ptr<AutomationControl>();
5342 uint32_t port_number;
5345 if (is_master() || mixbus()) {
5352 if (is_master() || mixbus()) {
5359 if (is_master() || mixbus()) {
5366 return boost::shared_ptr<AutomationControl>();
5369 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
5371 return boost::shared_ptr<AutomationControl>();
5374 boost::shared_ptr<AutomationControl>
5375 Route::eq_freq_controllable (uint32_t band) const
5379 if (mixbus() || is_master()) {
5380 /* no frequency controls for mixbusses or master */
5381 return boost::shared_ptr<AutomationControl>();
5384 boost::shared_ptr<PluginInsert> eq = ch_eq();
5387 return boost::shared_ptr<AutomationControl>();
5390 uint32_t port_number;
5402 return boost::shared_ptr<AutomationControl>();
5405 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
5407 return boost::shared_ptr<AutomationControl>();
5411 boost::shared_ptr<AutomationControl>
5412 Route::eq_q_controllable (uint32_t band) const
5414 return boost::shared_ptr<AutomationControl>();
5417 boost::shared_ptr<AutomationControl>
5418 Route::eq_shape_controllable (uint32_t band) const
5420 return boost::shared_ptr<AutomationControl>();
5423 boost::shared_ptr<AutomationControl>
5424 Route::eq_enable_controllable () const
5427 boost::shared_ptr<PluginInsert> eq = ch_eq();
5430 return boost::shared_ptr<AutomationControl>();
5433 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 1)));
5435 return boost::shared_ptr<AutomationControl>();
5439 boost::shared_ptr<AutomationControl>
5440 Route::eq_hpf_controllable () const
5443 boost::shared_ptr<PluginInsert> eq = ch_eq();
5446 return boost::shared_ptr<AutomationControl>();
5449 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5451 return boost::shared_ptr<AutomationControl>();
5456 Route::eq_band_name (uint32_t band) const
5458 if (Profile->get_mixbus()) {
5474 boost::shared_ptr<AutomationControl>
5475 Route::comp_enable_controllable () const
5478 boost::shared_ptr<PluginInsert> comp = ch_comp();
5481 return boost::shared_ptr<AutomationControl>();
5484 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 1)));
5486 return boost::shared_ptr<AutomationControl>();
5489 boost::shared_ptr<AutomationControl>
5490 Route::comp_threshold_controllable () const
5493 boost::shared_ptr<PluginInsert> comp = ch_comp();
5496 return boost::shared_ptr<AutomationControl>();
5499 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5502 return boost::shared_ptr<AutomationControl>();
5505 boost::shared_ptr<AutomationControl>
5506 Route::comp_speed_controllable () const
5509 boost::shared_ptr<PluginInsert> comp = ch_comp();
5512 return boost::shared_ptr<AutomationControl>();
5515 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 3)));
5517 return boost::shared_ptr<AutomationControl>();
5520 boost::shared_ptr<AutomationControl>
5521 Route::comp_mode_controllable () const
5524 boost::shared_ptr<PluginInsert> comp = ch_comp();
5527 return boost::shared_ptr<AutomationControl>();
5530 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 4)));
5532 return boost::shared_ptr<AutomationControl>();
5535 boost::shared_ptr<AutomationControl>
5536 Route::comp_makeup_controllable () const
5539 boost::shared_ptr<PluginInsert> comp = ch_comp();
5542 return boost::shared_ptr<AutomationControl>();
5545 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 5)));
5547 return boost::shared_ptr<AutomationControl>();
5550 boost::shared_ptr<AutomationControl>
5551 Route::comp_redux_controllable () const
5554 boost::shared_ptr<PluginInsert> comp = ch_comp();
5557 return boost::shared_ptr<AutomationControl>();
5560 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 6)));
5562 return boost::shared_ptr<AutomationControl>();
5567 Route::comp_mode_name (uint32_t mode) const
5572 return _("Leveler");
5574 return _("Compressor");
5576 return _("Limiter");
5578 return mixbus() ? _("Sidechain") : _("Limiter");
5588 Route::comp_speed_name (uint32_t mode) const
5606 boost::shared_ptr<AutomationControl>
5607 Route::send_level_controllable (uint32_t n) const
5610 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5612 return boost::shared_ptr<AutomationControl>();
5617 return boost::shared_ptr<AutomationControl>();
5620 const uint32_t port_id = port_channel_post_aux1_level + (2*n); // gtk2_ardour/mixbus_ports.h
5621 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_id)));
5623 boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(nth_send (n));
5625 return boost::shared_ptr<AutomationControl>();
5627 return s->gain_control ();
5631 boost::shared_ptr<AutomationControl>
5632 Route::send_enable_controllable (uint32_t n) const
5635 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5637 return boost::shared_ptr<AutomationControl>();
5642 return boost::shared_ptr<AutomationControl>();
5645 const uint32_t port_id = port_channel_post_aux1_asgn + (2*n); // gtk2_ardour/mixbus_ports.h
5646 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_id)));
5648 /* although Ardour sends have enable/disable as part of the Processor
5649 API, it is not exposed as a controllable.
5651 XXX: we should fix this.
5653 return boost::shared_ptr<AutomationControl>();
5658 Route::send_name (uint32_t n) const
5664 boost::shared_ptr<Route> r = _session.get_mixbus (n);
5668 boost::shared_ptr<Processor> p = nth_send (n);
5677 boost::shared_ptr<AutomationControl>
5678 Route::master_send_enable_controllable () const
5681 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5683 return boost::shared_ptr<AutomationControl>();
5685 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_mstr_assign)));
5687 return boost::shared_ptr<AutomationControl>();