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)
119 , _custom_meter_position_noted (false)
121 processor_max_streams.reset();
127 /* set default meter type */
129 _meter_type = Config->get_meter_type_master ();
131 else if (dynamic_cast<Track*>(this)) {
132 _meter_type = Config->get_meter_type_track ();
134 _meter_type = Config->get_meter_type_bus ();
137 /* add standard controls */
139 _solo_control.reset (new SoloControllable (X_("solo"), shared_from_this ()));
140 _mute_control.reset (new MuteControllable (X_("mute"), shared_from_this ()));
141 _phase_control.reset (new PhaseControllable (X_("phase"), shared_from_this ()));
143 _solo_isolate_control.reset (new SoloIsolateControllable (X_("solo-iso"), shared_from_this ()));
144 _solo_safe_control.reset (new SoloSafeControllable (X_("solo-safe"), shared_from_this ()));
146 _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
147 _mute_control->set_flags (Controllable::Flag (_mute_control->flags() | Controllable::Toggle));
148 _phase_control->set_flags (Controllable::Flag (_phase_control->flags() | Controllable::Toggle));
150 add_control (_solo_control);
151 add_control (_mute_control);
152 add_control (_phase_control);
156 if (!(_flags & Route::MonitorOut)) {
157 _pannable.reset (new Pannable (_session));
160 /* input and output objects */
162 _input.reset (new IO (_session, _name, IO::Input, _default_type));
163 _output.reset (new IO (_session, _name, IO::Output, _default_type));
165 _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2));
166 _input->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::input_port_count_changing, this, _1));
168 _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
169 _output->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::output_port_count_changing, this, _1));
171 #if 0 // not used - just yet
172 if (!is_master() && !is_monitor() && !is_auditioner()) {
173 _delayline.reset (new DelayLine (_session, _name));
174 add_processor (_delayline, PreFader);
178 /* add amp processor */
180 _gain_control = boost::shared_ptr<GainControllable> (new GainControllable (_session, GainAutomation, shared_from_this ()));
181 add_control (_gain_control);
183 _amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
184 add_processor (_amp, PostFader);
187 _amp->set_display_name (_("Monitor"));
192 _trim_control = boost::shared_ptr<GainControllable> (new GainControllable (_session, TrimAutomation, shared_from_this ()));
193 add_control (_trim_control);
195 _trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
196 _trim->set_display_to_user (false);
198 if (dynamic_cast<AudioTrack*>(this)) {
199 /* we can't do this in the AudioTrack's constructor
200 * because _trim does not exit then
204 else if (!dynamic_cast<Track*>(this) && ! ( is_monitor() || is_auditioner() )) {
209 /* create standard processors: meter, main outs, monitor out;
210 they will be added to _processors by setup_invisible_processors ()
213 _meter.reset (new PeakMeter (_session, _name));
214 _meter->set_owner (this);
215 _meter->set_display_to_user (false);
218 _main_outs.reset (new Delivery (_session, _output, _pannable, _mute_master, _name, Delivery::Main));
219 _main_outs->activate ();
222 /* where we listen to tracks */
223 _intreturn.reset (new InternalReturn (_session));
224 _intreturn->activate ();
226 /* the thing that provides proper control over a control/monitor/listen bus
227 (such as per-channel cut, dim, solo, invert, etc).
229 _monitor_control.reset (new MonitorProcessor (_session));
230 _monitor_control->activate ();
233 if (is_master() || is_monitor() || is_auditioner()) {
234 _mute_master->set_solo_ignore (true);
237 /* now that we have _meter, its safe to connect to this */
240 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
241 configure_processors (0);
249 DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
251 /* do this early so that we don't get incoming signals as we are going through destruction
256 /* don't use clear_processors here, as it depends on the session which may
257 be half-destroyed by now
260 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
261 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
262 (*i)->drop_references ();
265 _processors.clear ();
269 Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
271 if (Config->get_remote_model() != UserOrdered) {
275 set_remote_control_id_internal (id, notify_class_listeners);
279 Route::set_remote_control_id_internal (uint32_t id, bool notify_class_listeners)
281 /* force IDs for master/monitor busses and prevent
282 any other route from accidentally getting these IDs
283 (i.e. legacy sessions)
286 if (is_master() && id != MasterBusRemoteControlID) {
287 id = MasterBusRemoteControlID;
290 if (is_monitor() && id != MonitorBusRemoteControlID) {
291 id = MonitorBusRemoteControlID;
298 /* don't allow it to collide */
300 if (!is_master () && !is_monitor() &&
301 (id == MasterBusRemoteControlID || id == MonitorBusRemoteControlID)) {
302 id += MonitorBusRemoteControlID;
305 if (id != remote_control_id()) {
306 _remote_control_id = id;
307 RemoteControlIDChanged ();
309 if (notify_class_listeners) {
310 RemoteControlIDChange ();
316 Route::remote_control_id() const
319 return MasterBusRemoteControlID;
323 return MonitorBusRemoteControlID;
326 return _remote_control_id;
330 Route::has_order_key () const
332 return _has_order_key;
336 Route::order_key () const
342 Route::set_remote_control_id_explicit (uint32_t rid)
344 if (is_master() || is_monitor() || is_auditioner()) {
345 /* hard-coded remote IDs, or no remote ID */
349 if (_remote_control_id != rid) {
350 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1: set edit-based RID to %2\n", name(), rid));
351 _remote_control_id = rid;
352 RemoteControlIDChanged (); /* EMIT SIGNAL (per-route) */
355 /* don't emit the class-level RID signal RemoteControlIDChange here,
356 leave that to the entity that changed the order key, so that we
357 don't get lots of emissions for no good reasons (e.g. when changing
358 all route order keys).
360 See Session::sync_remote_id_from_order_keys() for the (primary|only)
361 spot where that is emitted.
366 Route::set_order_key (uint32_t n)
368 _has_order_key = true;
370 if (_order_key == n) {
376 DEBUG_TRACE (DEBUG::OrderKeys, string_compose ("%1 order key set to %2\n",
377 name(), order_key ()));
379 _session.set_dirty ();
383 Route::ensure_track_or_route_name(string name, Session &session)
385 string newname = name;
387 while (!session.io_name_is_legal (newname)) {
388 newname = bump_name_once (newname, ' ');
395 Route::inc_gain (gain_t factor)
397 /* To be used ONLY when doing group-relative gain adjustment, from
401 float desired_gain = _gain_control->user_double();
403 if (fabsf (desired_gain) < GAIN_COEFF_SMALL) {
404 // really?! what's the idea here?
405 _gain_control->route_set_value (0.000001f + (0.000001f * factor));
407 _gain_control->route_set_value (desired_gain + (desired_gain * factor));
412 Route::set_gain (gain_t val, Controllable::GroupControlDisposition group_override)
414 if (use_group (group_override, &RouteGroup::is_gain)) {
416 if (_route_group->is_relative()) {
418 gain_t usable_gain = _gain_control->get_value();
419 if (usable_gain < 0.000001f) {
420 usable_gain = 0.000001f;
424 if (delta < 0.000001f) {
428 delta -= usable_gain;
433 gain_t factor = delta / usable_gain;
436 factor = _route_group->get_max_factor(factor);
437 if (factor == 0.0f) {
438 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
442 factor = _route_group->get_min_factor(factor);
443 if (factor == 0.0f) {
444 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
449 _route_group->foreach_route (boost::bind (&Route::inc_gain, _1, factor));
453 _route_group->foreach_route (boost::bind (&Route::set_gain, _1, val, Controllable::NoGroup));
459 if (val == _gain_control->get_value()) {
463 _gain_control->route_set_value (val);
467 Route::set_trim (gain_t val, Controllable::GroupControlDisposition /* group override */)
469 // TODO route group, see set_gain()
470 _trim_control->route_set_value (val);
474 Route::maybe_declick (BufferSet&, framecnt_t, int)
476 /* this is the "bus" implementation and they never declick.
481 /** Process this route for one (sub) cycle (process thread)
483 * @param bufs Scratch buffers to use for the signal path
484 * @param start_frame Initial transport frame
485 * @param end_frame Final transport frame
486 * @param nframes Number of frames to output (to ports)
488 * Note that (end_frame - start_frame) may not be equal to nframes when the
489 * transport speed isn't 1.0 (eg varispeed).
492 Route::process_output_buffers (BufferSet& bufs,
493 framepos_t start_frame, framepos_t end_frame, pframes_t nframes,
494 int declick, bool gain_automation_ok)
496 /* Caller must hold process lock */
497 assert (!AudioEngine::instance()->process_lock().trylock());
499 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
501 // can this actually happen? functions calling process_output_buffers()
502 // already take a reader-lock.
503 bufs.silence (nframes, 0);
507 /* figure out if we're going to use gain automation */
508 if (gain_automation_ok) {
509 _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
510 _amp->setup_gain_automation (
511 start_frame + _signal_latency_at_amp_position,
512 end_frame + _signal_latency_at_amp_position,
515 _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
516 _trim->setup_gain_automation (
517 start_frame + _signal_latency_at_trim_position,
518 end_frame + _signal_latency_at_trim_position,
521 _amp->apply_gain_automation (false);
522 _trim->apply_gain_automation (false);
525 /* Tell main outs what to do about monitoring. We do this so that
526 on a transition between monitoring states we get a de-clicking gain
527 change in the _main_outs delivery, if config.get_use_monitor_fades()
530 We override this in the case where we have an internal generator.
532 bool silence = _have_internal_generator ? false : (monitoring_state () == MonitoringSilence);
534 _main_outs->no_outs_cuz_we_no_monitor (silence);
536 /* -------------------------------------------------------------------------------------------
537 GLOBAL DECLICK (for transport changes etc.)
538 ----------------------------------------------------------------------------------------- */
540 maybe_declick (bufs, nframes, declick);
541 _pending_declick = 0;
543 /* -------------------------------------------------------------------------------------------
544 DENORMAL CONTROL/PHASE INVERT
545 ----------------------------------------------------------------------------------------- */
547 if (_phase_invert.any ()) {
551 if (_denormal_protection || Config->get_denormal_protection()) {
553 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
554 Sample* const sp = i->data();
556 if (_phase_invert[chn]) {
557 for (pframes_t nx = 0; nx < nframes; ++nx) {
562 for (pframes_t nx = 0; nx < nframes; ++nx) {
570 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
571 Sample* const sp = i->data();
573 if (_phase_invert[chn]) {
574 for (pframes_t nx = 0; nx < nframes; ++nx) {
583 if (_denormal_protection || Config->get_denormal_protection()) {
585 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
586 Sample* const sp = i->data();
587 for (pframes_t nx = 0; nx < nframes; ++nx) {
595 /* -------------------------------------------------------------------------------------------
597 ----------------------------------------------------------------------------------------- */
599 /* set this to be true if the meter will already have been ::run() earlier */
600 bool const meter_already_run = metering_state() == MeteringInput;
602 framecnt_t latency = 0;
604 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
606 if (meter_already_run && boost::dynamic_pointer_cast<PeakMeter> (*i)) {
607 /* don't ::run() the meter, otherwise it will have its previous peak corrupted */
612 /* if it has any inputs, make sure they match */
613 if (boost::dynamic_pointer_cast<UnknownProcessor> (*i) == 0 && (*i)->input_streams() != ChanCount::ZERO) {
614 if (bufs.count() != (*i)->input_streams()) {
616 DEBUG::Processors, string_compose (
617 "input port mismatch %1 bufs = %2 input for %3 = %4\n",
618 _name, bufs.count(), (*i)->name(), (*i)->input_streams()
625 /* should we NOT run plugins here if the route is inactive?
626 do we catch route != active somewhere higher?
629 if (boost::dynamic_pointer_cast<Send>(*i) != 0) {
630 boost::dynamic_pointer_cast<Send>(*i)->set_delay_in(_signal_latency - latency);
633 (*i)->run (bufs, start_frame - latency, end_frame - latency, nframes, *i != _processors.back());
634 bufs.set_count ((*i)->output_streams());
636 if ((*i)->active ()) {
637 latency += (*i)->signal_latency ();
643 Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
644 boost::shared_ptr<Processor> endpoint,
645 bool include_endpoint, bool for_export, bool for_freeze)
647 /* If no processing is required, there's no need to go any further. */
648 if (!endpoint && !include_endpoint) {
652 framecnt_t latency = bounce_get_latency(_amp, false, for_export, for_freeze);
653 _amp->set_gain_automation_buffer (_session.gain_automation_buffer ());
654 _amp->setup_gain_automation (start - latency, start - latency + nframes, nframes);
656 /* trim is always at the top, for bounce no latency compensation is needed */
657 _trim->set_gain_automation_buffer (_session.trim_automation_buffer ());
658 _trim->setup_gain_automation (start, start + nframes, nframes);
661 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
663 if (!include_endpoint && (*i) == endpoint) {
667 /* if we're *not* exporting, stop processing if we come across a routing processor. */
668 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
671 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
675 /* special case the panner (export outputs)
676 * Ideally we'd only run the panner, not the delivery itself...
677 * but panners need separate input/output buffers and some context
678 * (panshell, panner type, etc). AFAICT there is no ill side effect
679 * of re-using the main delivery when freewheeling/exporting a region.
681 if ((*i) == _main_outs) {
682 assert ((*i)->does_routing());
683 (*i)->run (buffers, start - latency, start - latency + nframes, nframes, true);
684 buffers.set_count ((*i)->output_streams());
687 /* don't run any processors that do routing.
688 * Also don't bother with metering.
690 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
691 (*i)->run (buffers, start - latency, start - latency + nframes, nframes, true);
692 buffers.set_count ((*i)->output_streams());
693 latency += (*i)->signal_latency ();
696 if ((*i) == endpoint) {
703 Route::bounce_get_latency (boost::shared_ptr<Processor> endpoint,
704 bool include_endpoint, bool for_export, bool for_freeze) const
706 framecnt_t latency = 0;
707 if (!endpoint && !include_endpoint) {
711 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
712 if (!include_endpoint && (*i) == endpoint) {
715 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
718 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
721 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
722 latency += (*i)->signal_latency ();
724 if ((*i) == endpoint) {
732 Route::bounce_get_output_streams (ChanCount &cc, boost::shared_ptr<Processor> endpoint,
733 bool include_endpoint, bool for_export, bool for_freeze) const
735 if (!endpoint && !include_endpoint) {
739 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
740 if (!include_endpoint && (*i) == endpoint) {
743 if (!for_export && boost::dynamic_pointer_cast<PortInsert>(*i)) {
746 if (!for_export && for_freeze && (*i)->does_routing() && (*i)->active()) {
749 if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
750 cc = (*i)->output_streams();
752 if ((*i) == endpoint) {
760 Route::n_process_buffers ()
762 return max (_input->n_ports(), processor_max_streams);
766 Route::monitor_run (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
768 assert (is_monitor());
769 BufferSet& bufs (_session.get_route_buffers (n_process_buffers()));
770 fill_buffers_with_input (bufs, _input, nframes);
771 passthru (bufs, start_frame, end_frame, nframes, declick);
775 Route::passthru (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
779 if (is_monitor() && _session.listening() && !_session.is_auditioning()) {
781 /* control/monitor bus ignores input ports when something is
782 feeding the listen "stream". data will "arrive" into the
783 route from the intreturn processor element.
786 bufs.silence (nframes, 0);
789 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
790 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, true);
794 Route::passthru_silence (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
796 BufferSet& bufs (_session.get_route_buffers (n_process_buffers(), true));
798 bufs.set_count (_input->n_ports());
799 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
800 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, false);
804 Route::set_listen (bool yn, Controllable::GroupControlDisposition group_override)
810 if (use_group (group_override, &RouteGroup::is_solo)) {
811 _route_group->foreach_route (boost::bind (&Route::set_listen, _1, yn, Controllable::ForGroup));
816 if (yn != _monitor_send->active()) {
818 _monitor_send->activate ();
819 _mute_master->set_soloed_by_self (true);
821 _monitor_send->deactivate ();
822 _mute_master->set_soloed_by_self (false);
824 _mute_master->set_soloed_by_others (false);
826 listen_changed (group_override); /* EMIT SIGNAL */
832 Route::listening_via_monitor () const
835 return _monitor_send->active ();
842 Route::set_solo_safe (bool yn, Controllable::GroupControlDisposition /* group_override */)
844 if (_solo_safe != yn) {
846 solo_safe_changed (); /* EMIT SIGNAL */
847 _solo_safe_control->Changed(); /* EMIT SIGNAL */
852 Route::solo_safe() const
858 Route::clear_all_solo_state ()
860 // ideally this function will never do anything, it only exists to forestall Murphy
861 bool emit_changed = false;
864 // these are really debug messages, but of possible interest.
866 PBD::info << string_compose (_("Cleared Explicit solo: %1\n"), name());
868 if (_soloed_by_others_upstream || _soloed_by_others_downstream) {
869 PBD::info << string_compose (_("Cleared Implicit solo: %1 up:%2 down:%3\n"),
870 name(), _soloed_by_others_upstream, _soloed_by_others_downstream);
874 if (!_self_solo && (_soloed_by_others_upstream || _soloed_by_others_downstream)) {
875 // if self-soled, set_solo() will do signal emission
879 _soloed_by_others_upstream = 0;
880 _soloed_by_others_downstream = 0;
883 PBD::Unwinder<bool> uw (_solo_safe, false);
884 set_solo (false, Controllable::NoGroup);
888 set_mute_master_solo ();
889 solo_changed (false, Controllable::UseGroup); /* EMIT SIGNAL */
894 Route::set_solo (bool yn, Controllable::GroupControlDisposition group_override)
896 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1: set solo => %2, grp ? %3 currently self-soloed ? %4\n",
897 name(), yn, enum_2_string(group_override), self_soloed()));
900 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 ignore solo change due to solo-safe\n", name()));
904 if (is_master() || is_monitor() || is_auditioner()) {
905 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 ignore solo change (master, monitor or auditioner)\n", name()));
909 if (use_group (group_override, &RouteGroup::is_solo)) {
910 _route_group->foreach_route (boost::bind (&Route::set_solo, _1, yn, Controllable::ForGroup));
914 if (self_soloed() != yn) {
916 solo_changed (true, group_override); /* EMIT SIGNAL */
917 _solo_control->Changed (); /* EMIT SIGNAL */
920 assert (Config->get_solo_control_is_listen_control() || !_monitor_send || !_monitor_send->active());
922 /* XXX TRACKS DEVELOPERS: THIS LOGIC SUGGESTS THAT YOU ARE NOT AWARE OF
923 Config->get_solo_mute_overrride().
926 if (yn && Profile->get_trx()) {
927 set_mute (false, Controllable::UseGroup);
932 Route::set_self_solo (bool yn)
934 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1: set SELF solo => %2\n", name(), yn));
936 set_mute_master_solo ();
940 Route::mod_solo_by_others_upstream (int32_t delta)
942 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod solo-by-upstream by %2, current up = %3 down = %4\n",
943 name(), delta, _soloed_by_others_upstream, _soloed_by_others_downstream));
945 uint32_t old_sbu = _soloed_by_others_upstream;
948 if (_soloed_by_others_upstream >= (uint32_t) abs (delta)) {
949 _soloed_by_others_upstream += delta;
951 _soloed_by_others_upstream = 0;
954 _soloed_by_others_upstream += delta;
957 DEBUG_TRACE (DEBUG::Solo, string_compose (
958 "%1 SbU delta %2 = %3 old = %4 sbd %5 ss %6 exclusive %7\n",
959 name(), delta, _soloed_by_others_upstream, old_sbu,
960 _soloed_by_others_downstream, _self_solo, Config->get_exclusive_solo()));
962 /* push the inverse solo change to everything that feeds us.
964 This is important for solo-within-group. When we solo 1 track out of N that
965 feed a bus, that track will cause mod_solo_by_upstream (+1) to be called
966 on the bus. The bus then needs to call mod_solo_by_downstream (-1) on all
967 tracks that feed it. This will silence them if they were audible because
968 of a bus solo, but the newly soloed track will still be audible (because
971 but .. do this only when we are being told to solo-by-upstream (i.e delta = +1),
975 if ((_self_solo || _soloed_by_others_downstream) &&
976 ((old_sbu == 0 && _soloed_by_others_upstream > 0) ||
977 (old_sbu > 0 && _soloed_by_others_upstream == 0))) {
979 if (delta > 0 || !Config->get_exclusive_solo()) {
980 DEBUG_TRACE (DEBUG::Solo, string_compose("\t ... INVERT push from %1\n", _name));
981 for (FedBy::iterator i = _fed_by.begin(); i != _fed_by.end(); ++i) {
985 boost::shared_ptr<Route> sr = i->r.lock();
987 sr->mod_solo_by_others_downstream (-delta);
993 set_mute_master_solo ();
994 solo_changed (false, Controllable::UseGroup); /* EMIT SIGNAL */
998 Route::mod_solo_by_others_downstream (int32_t delta)
1000 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod solo-by-downstream by %2, current up = %3 down = %4\n",
1001 name(), delta, _soloed_by_others_upstream, _soloed_by_others_downstream));
1004 if (_soloed_by_others_downstream >= (uint32_t) abs (delta)) {
1005 _soloed_by_others_downstream += delta;
1007 _soloed_by_others_downstream = 0;
1010 _soloed_by_others_downstream += delta;
1013 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 SbD delta %2 = %3\n", name(), delta, _soloed_by_others_downstream));
1015 set_mute_master_solo ();
1016 solo_changed (false, Controllable::UseGroup); /* EMIT SIGNAL */
1020 Route::set_mute_master_solo ()
1022 _mute_master->set_soloed_by_self (self_soloed());
1023 _mute_master->set_soloed_by_others (soloed_by_others_downstream() || soloed_by_others_upstream());
1027 Route::mod_solo_isolated_by_upstream (bool yn)
1029 bool old = solo_isolated ();
1030 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 mod_solo_isolated_by_upstream cur: %2 d: %3\n",
1031 name(), _solo_isolated_by_upstream, yn ? "+1" : "-1"));
1034 if (_solo_isolated_by_upstream >= 1) {
1035 _solo_isolated_by_upstream--;
1037 _solo_isolated_by_upstream = 0;
1040 _solo_isolated_by_upstream++;
1043 if (solo_isolated() != old) {
1044 /* solo isolated status changed */
1045 _mute_master->set_solo_ignore (solo_isolated());
1046 solo_isolated_changed (); /* EMIT SIGNAL */
1051 Route::set_solo_isolated (bool yn, Controllable::GroupControlDisposition group_override)
1053 if (is_master() || is_monitor() || is_auditioner()) {
1057 if (use_group (group_override, &RouteGroup::is_solo)) {
1058 _route_group->foreach_route (boost::bind (&Route::set_solo_isolated, _1, yn, Controllable::ForGroup));
1062 bool changed = false;
1065 if (_solo_isolated == false) {
1066 _mute_master->set_solo_ignore (true);
1069 _solo_isolated = true;
1071 if (_solo_isolated == true) {
1072 _solo_isolated = false;
1073 _mute_master->set_solo_ignore (false);
1083 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
1085 boost::shared_ptr<RouteList> routes = _session.get_routes ();
1086 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
1088 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
1093 bool does_feed = feeds (*i, &sends_only);
1095 if (does_feed && !sends_only) {
1096 (*i)->mod_solo_isolated_by_upstream (yn);
1100 /* XXX should we back-propagate as well? (April 2010: myself and chris goddard think not) */
1102 solo_isolated_changed (); /* EMIT SIGNAL */
1103 _solo_isolate_control->Changed(); /* EMIT SIGNAL */
1107 Route::solo_isolated () const
1109 return (_solo_isolated == true) || (_solo_isolated_by_upstream > 0);
1113 Route::set_mute_points (MuteMaster::MutePoint mp)
1115 _mute_master->set_mute_points (mp);
1116 mute_points_changed (); /* EMIT SIGNAL */
1118 if (_mute_master->muted_by_self()) {
1119 mute_changed (); /* EMIT SIGNAL */
1120 _mute_control->Changed (); /* EMIT SIGNAL */
1125 Route::set_mute (bool yn, Controllable::GroupControlDisposition group_override)
1127 if (use_group (group_override, &RouteGroup::is_mute)) {
1128 _route_group->foreach_route (boost::bind (&Route::set_mute, _1, yn, Controllable::ForGroup));
1132 if (muted() != yn) {
1133 _mute_master->set_muted_by_self (yn);
1134 /* allow any derived classes to respond to the mute change
1135 before anybody else knows about it.
1138 /* tell everyone else */
1139 mute_changed (); /* EMIT SIGNAL */
1140 _mute_control->Changed (); /* EMIT SIGNAL */
1145 Route::muted () const
1147 return _mute_master->muted_by_self();
1151 Route::muted_by_others () const
1153 // This method is only used by route_ui for display state.
1154 // The real thing is MuteMaster::muted_by_others_at()
1156 //master is never muted by others
1160 //now check to see if something is soloed (and I am not)
1161 //see also MuteMaster::mute_gain_at()
1162 return (_session.soloing() && !soloed() && !solo_isolated());
1167 dump_processors(const string& name, const list<boost::shared_ptr<Processor> >& procs)
1169 cerr << name << " {" << endl;
1170 for (list<boost::shared_ptr<Processor> >::const_iterator p = procs.begin();
1171 p != procs.end(); ++p) {
1172 cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << " @ " << (*p) << endl;
1174 cerr << "}" << endl;
1178 /** Supposing that we want to insert a Processor at a given Placement, return
1179 * the processor to add the new one before (or 0 to add at the end).
1181 boost::shared_ptr<Processor>
1182 Route::before_processor_for_placement (Placement p)
1184 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1186 ProcessorList::iterator loc;
1188 if (p == PreFader) {
1189 /* generic pre-fader: insert immediately before the amp */
1190 loc = find (_processors.begin(), _processors.end(), _amp);
1192 /* generic post-fader: insert right before the main outs */
1193 loc = find (_processors.begin(), _processors.end(), _main_outs);
1196 return loc != _processors.end() ? *loc : boost::shared_ptr<Processor> ();
1199 /** Supposing that we want to insert a Processor at a given index, return
1200 * the processor to add the new one before (or 0 to add at the end).
1202 boost::shared_ptr<Processor>
1203 Route::before_processor_for_index (int index)
1206 return boost::shared_ptr<Processor> ();
1209 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1211 ProcessorList::iterator i = _processors.begin ();
1213 while (i != _processors.end() && j < index) {
1214 if ((*i)->display_to_user()) {
1221 return (i != _processors.end() ? *i : boost::shared_ptr<Processor> ());
1224 /** Add a processor either pre- or post-fader
1225 * @return 0 on success, non-0 on failure.
1228 Route::add_processor (boost::shared_ptr<Processor> processor, Placement placement, ProcessorStreams* err, bool activation_allowed)
1230 return add_processor (processor, before_processor_for_placement (placement), err, activation_allowed);
1234 /** Add a processor to a route such that it ends up with a given index into the visible processors.
1235 * @param index Index to add the processor at, or -1 to add at the end of the list.
1236 * @return 0 on success, non-0 on failure.
1239 Route::add_processor_by_index (boost::shared_ptr<Processor> processor, int index, ProcessorStreams* err, bool activation_allowed)
1241 return add_processor (processor, before_processor_for_index (index), err, activation_allowed);
1244 /** Add a processor to the route.
1245 * @param before An existing processor in the list, or 0; the new processor will be inserted immediately before it (or at the end).
1246 * @return 0 on success, non-0 on failure.
1249 Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<Processor> before, ProcessorStreams* err, bool activation_allowed)
1251 assert (processor != _meter);
1252 assert (processor != _main_outs);
1254 DEBUG_TRACE (DEBUG::Processors, string_compose (
1255 "%1 adding processor %2\n", name(), processor->name()));
1257 if (!AudioEngine::instance()->connected() || !processor) {
1262 boost::shared_ptr<PluginInsert> pi;
1263 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
1264 pi->set_strict_io (true);
1269 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1270 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1271 ProcessorState pstate (this);
1273 boost::shared_ptr<PluginInsert> pi;
1274 boost::shared_ptr<PortInsert> porti;
1276 if (processor == _amp) {
1277 /* Ensure that only one amp is in the list at any time */
1278 ProcessorList::iterator check = find (_processors.begin(), _processors.end(), processor);
1279 if (check != _processors.end()) {
1280 if (before == _amp) {
1281 /* Already in position; all is well */
1284 _processors.erase (check);
1289 assert (find (_processors.begin(), _processors.end(), processor) == _processors.end ());
1291 ProcessorList::iterator loc;
1293 /* inserting before a processor; find it */
1294 loc = find (_processors.begin(), _processors.end(), before);
1295 if (loc == _processors.end ()) {
1300 /* inserting at end */
1301 loc = _processors.end ();
1304 _processors.insert (loc, processor);
1305 processor->set_owner (this);
1307 // Set up processor list channels. This will set processor->[input|output]_streams(),
1308 // configure redirect ports properly, etc.
1311 if (configure_processors_unlocked (err)) {
1313 configure_processors_unlocked (0); // it worked before we tried to add it ...
1318 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
1320 if (pi->has_no_inputs ()) {
1321 /* generator plugin */
1322 _have_internal_generator = true;
1327 if (activation_allowed && (!_session.get_bypass_all_loaded_plugins () || !processor->display_to_user ())) {
1328 processor->activate ();
1331 processor->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1333 _output->set_user_latency (0);
1336 reset_instrument_info ();
1337 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1338 set_processor_positions ();
1344 Route::add_processor_from_xml_2X (const XMLNode& node, int version)
1346 const XMLProperty *prop;
1349 boost::shared_ptr<Processor> processor;
1351 /* bit of a hack: get the `placement' property from the <Redirect> tag here
1352 so that we can add the processor in the right place (pre/post-fader)
1355 XMLNodeList const & children = node.children ();
1356 XMLNodeList::const_iterator i = children.begin ();
1358 while (i != children.end() && (*i)->name() != X_("Redirect")) {
1362 Placement placement = PreFader;
1364 if (i != children.end()) {
1365 if ((prop = (*i)->property (X_("placement"))) != 0) {
1366 placement = Placement (string_2_enum (prop->value(), placement));
1370 if (node.name() == "Insert") {
1372 if ((prop = node.property ("type")) != 0) {
1374 if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
1375 prop->value() == "lv2" ||
1376 prop->value() == "windows-vst" ||
1377 prop->value() == "lxvst" ||
1378 prop->value() == "audiounit") {
1380 if (_session.get_disable_all_loaded_plugins ()) {
1381 processor.reset (new UnknownProcessor (_session, node));
1383 processor.reset (new PluginInsert (_session));
1384 processor->set_owner (this);
1389 processor.reset (new PortInsert (_session, _pannable, _mute_master));
1394 } else if (node.name() == "Send") {
1396 boost::shared_ptr<Pannable> sendpan (new Pannable (_session));
1397 processor.reset (new Send (_session, sendpan, _mute_master));
1401 error << string_compose(_("unknown Processor type \"%1\"; ignored"), node.name()) << endmsg;
1405 if (processor->set_state (node, version)) {
1409 //A2 uses the "active" flag in the toplevel redirect node, not in the child plugin/IO
1410 if (i != children.end()) {
1411 if ((prop = (*i)->property (X_("active"))) != 0) {
1412 if ( string_is_affirmative (prop->value()) && (!_session.get_bypass_all_loaded_plugins () || !processor->display_to_user () ) )
1413 processor->activate();
1415 processor->deactivate();
1419 return (add_processor (processor, placement, 0, false) == 0);
1422 catch (failed_constructor &err) {
1423 warning << _("processor could not be created. Ignored.") << endmsg;
1429 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
1431 /* NOTE: this is intended to be used ONLY when copying
1432 processors from another Route. Hence the subtle
1433 differences between this and ::add_processor()
1436 ProcessorList::iterator loc;
1439 loc = find(_processors.begin(), _processors.end(), before);
1441 /* nothing specified - at end */
1442 loc = _processors.end ();
1445 if (!_session.engine().connected()) {
1449 if (others.empty()) {
1454 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1455 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1456 ProcessorState pstate (this);
1458 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
1464 boost::shared_ptr<PluginInsert> pi;
1466 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1467 pi->set_count (1); // why? configure_processors_unlocked() will re-do this
1468 pi->set_strict_io (_strict_io);
1471 _processors.insert (loc, *i);
1472 (*i)->set_owner (this);
1474 if ((*i)->active()) {
1478 /* Think: does this really need to be called for every processor in the loop? */
1480 if (configure_processors_unlocked (err)) {
1482 configure_processors_unlocked (0); // it worked before we tried to add it ...
1487 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1490 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
1491 boost::shared_ptr<PluginInsert> pi;
1493 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1494 if (pi->has_no_inputs ()) {
1495 _have_internal_generator = true;
1501 _output->set_user_latency (0);
1504 reset_instrument_info ();
1505 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1506 set_processor_positions ();
1512 Route::placement_range(Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end)
1514 if (p == PreFader) {
1515 start = _processors.begin();
1516 end = find(_processors.begin(), _processors.end(), _amp);
1518 start = find(_processors.begin(), _processors.end(), _amp);
1520 end = _processors.end();
1524 /** Turn off all processors with a given placement
1525 * @param p Placement of processors to disable
1528 Route::disable_processors (Placement p)
1530 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1532 ProcessorList::iterator start, end;
1533 placement_range(p, start, end);
1535 for (ProcessorList::iterator i = start; i != end; ++i) {
1536 (*i)->deactivate ();
1539 _session.set_dirty ();
1542 /** Turn off all redirects
1545 Route::disable_processors ()
1547 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1549 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1550 (*i)->deactivate ();
1553 _session.set_dirty ();
1556 /** Turn off all redirects with a given placement
1557 * @param p Placement of redirects to disable
1560 Route::disable_plugins (Placement p)
1562 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1564 ProcessorList::iterator start, end;
1565 placement_range(p, start, end);
1567 for (ProcessorList::iterator i = start; i != end; ++i) {
1568 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1569 (*i)->deactivate ();
1573 _session.set_dirty ();
1576 /** Turn off all plugins
1579 Route::disable_plugins ()
1581 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1583 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1584 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1585 (*i)->deactivate ();
1589 _session.set_dirty ();
1594 Route::ab_plugins (bool forward)
1596 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
1600 /* forward = turn off all active redirects, and mark them so that the next time
1601 we go the other way, we will revert them
1604 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1605 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1609 if ((*i)->active()) {
1610 (*i)->deactivate ();
1611 (*i)->set_next_ab_is_active (true);
1613 (*i)->set_next_ab_is_active (false);
1619 /* backward = if the redirect was marked to go active on the next ab, do so */
1621 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1623 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1627 if ((*i)->get_next_ab_is_active()) {
1630 (*i)->deactivate ();
1635 _session.set_dirty ();
1639 /** Remove processors with a given placement.
1640 * @param p Placement of processors to remove.
1643 Route::clear_processors (Placement p)
1645 if (!_session.engine().connected()) {
1649 bool already_deleting = _session.deletion_in_progress();
1650 if (!already_deleting) {
1651 _session.set_deletion_in_progress();
1655 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1656 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1657 ProcessorList new_list;
1658 ProcessorStreams err;
1659 bool seen_amp = false;
1661 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1667 if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs || (*i) == _delayline || (*i) == _trim) {
1669 /* you can't remove these */
1671 new_list.push_back (*i);
1678 new_list.push_back (*i);
1681 (*i)->drop_references ();
1689 (*i)->drop_references ();
1692 new_list.push_back (*i);
1699 _processors = new_list;
1700 configure_processors_unlocked (&err); // this can't fail
1703 processor_max_streams.reset();
1704 _have_internal_generator = false;
1705 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1706 set_processor_positions ();
1708 reset_instrument_info ();
1710 if (!already_deleting) {
1711 _session.clear_deletion_in_progress();
1716 Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStreams* err, bool need_process_lock)
1718 // TODO once the export point can be configured properly, do something smarter here
1719 if (processor == _capturing_processor) {
1720 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
1721 if (need_process_lock) {
1725 _capturing_processor.reset();
1727 if (need_process_lock) {
1732 /* these can never be removed */
1734 if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
1738 if (!_session.engine().connected()) {
1742 processor_max_streams.reset();
1745 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock (), Glib::Threads::NOT_LOCK);
1746 if (need_process_lock) {
1750 /* Caller must hold process lock */
1751 assert (!AudioEngine::instance()->process_lock().trylock());
1753 Glib::Threads::RWLock::WriterLock lm (_processor_lock); // XXX deadlock after export
1755 ProcessorState pstate (this);
1757 ProcessorList::iterator i;
1758 bool removed = false;
1760 for (i = _processors.begin(); i != _processors.end(); ) {
1761 if (*i == processor) {
1763 /* move along, see failure case for configure_processors()
1764 where we may need to reconfigure the processor.
1767 /* stop redirects that send signals to JACK ports
1768 from causing noise as a result of no longer being
1772 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
1773 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*i);
1777 iop = pi->sidechain();
1784 i = _processors.erase (i);
1792 _output->set_user_latency (0);
1800 if (configure_processors_unlocked (err)) {
1802 /* we know this will work, because it worked before :) */
1803 configure_processors_unlocked (0);
1807 _have_internal_generator = false;
1809 for (i = _processors.begin(); i != _processors.end(); ++i) {
1810 boost::shared_ptr<PluginInsert> pi;
1812 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1813 if (pi->has_no_inputs ()) {
1814 _have_internal_generator = true;
1819 if (need_process_lock) {
1824 reset_instrument_info ();
1825 processor->drop_references ();
1826 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1827 set_processor_positions ();
1833 Route::replace_processor (boost::shared_ptr<Processor> old, boost::shared_ptr<Processor> sub, ProcessorStreams* err)
1835 /* these can never be removed */
1836 if (old == _amp || old == _meter || old == _main_outs || old == _delayline || old == _trim) {
1839 /* and can't be used as substitute, either */
1840 if (sub == _amp || sub == _meter || sub == _main_outs || sub == _delayline || sub == _trim) {
1844 /* I/Os are out, too */
1845 if (boost::dynamic_pointer_cast<IOProcessor> (old) || boost::dynamic_pointer_cast<IOProcessor> (sub)) {
1849 /* this function cannot be used to swap/reorder processors */
1850 if (find (_processors.begin(), _processors.end(), sub) != _processors.end ()) {
1854 if (!AudioEngine::instance()->connected() || !old || !sub) {
1858 /* ensure that sub is not owned by another route */
1859 if (sub->owner ()) {
1864 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1865 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1866 ProcessorState pstate (this);
1868 assert (find (_processors.begin(), _processors.end(), sub) == _processors.end ());
1870 ProcessorList::iterator i;
1871 bool replaced = false;
1872 bool enable = old->active ();
1874 for (i = _processors.begin(); i != _processors.end(); ) {
1876 i = _processors.erase (i);
1877 _processors.insert (i, sub);
1878 sub->set_owner (this);
1891 boost::shared_ptr<PluginInsert> pi;
1892 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(sub)) != 0) {
1893 pi->set_strict_io (true);
1897 if (configure_processors_unlocked (err)) {
1899 configure_processors_unlocked (0);
1903 _have_internal_generator = false;
1905 for (i = _processors.begin(); i != _processors.end(); ++i) {
1906 boost::shared_ptr<PluginInsert> pi;
1907 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1908 if (pi->has_no_inputs ()) {
1909 _have_internal_generator = true;
1919 sub->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1920 _output->set_user_latency (0);
1923 reset_instrument_info ();
1924 old->drop_references ();
1925 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1926 set_processor_positions ();
1931 Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err)
1933 ProcessorList deleted;
1935 if (!_session.engine().connected()) {
1939 processor_max_streams.reset();
1942 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
1943 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
1944 ProcessorState pstate (this);
1946 ProcessorList::iterator i;
1947 boost::shared_ptr<Processor> processor;
1949 for (i = _processors.begin(); i != _processors.end(); ) {
1953 /* these can never be removed */
1955 if (processor == _amp || processor == _meter || processor == _main_outs || processor == _delayline || processor == _trim) {
1960 /* see if its in the list of processors to delete */
1962 if (find (to_be_deleted.begin(), to_be_deleted.end(), processor) == to_be_deleted.end()) {
1967 /* stop IOProcessors that send to JACK ports
1968 from causing noise as a result of no longer being
1972 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(processor);
1973 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(processor);
1976 iop = pi->sidechain();
1983 deleted.push_back (processor);
1984 i = _processors.erase (i);
1987 if (deleted.empty()) {
1988 /* none of those in the requested list were found */
1992 _output->set_user_latency (0);
1994 if (configure_processors_unlocked (err)) {
1996 /* we know this will work, because it worked before :) */
1997 configure_processors_unlocked (0);
2002 _have_internal_generator = false;
2004 for (i = _processors.begin(); i != _processors.end(); ++i) {
2005 boost::shared_ptr<PluginInsert> pi;
2007 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
2008 if (pi->has_no_inputs ()) {
2009 _have_internal_generator = true;
2016 /* now try to do what we need to so that those that were removed will be deleted */
2018 for (ProcessorList::iterator i = deleted.begin(); i != deleted.end(); ++i) {
2019 (*i)->drop_references ();
2022 reset_instrument_info ();
2023 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2024 set_processor_positions ();
2030 Route::reset_instrument_info ()
2032 boost::shared_ptr<Processor> instr = the_instrument();
2034 _instrument_info.set_internal_instrument (instr);
2038 /** Caller must hold process lock */
2040 Route::configure_processors (ProcessorStreams* err)
2042 #ifndef PLATFORM_WINDOWS
2043 assert (!AudioEngine::instance()->process_lock().trylock());
2046 if (!_in_configure_processors) {
2047 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2048 return configure_processors_unlocked (err);
2055 Route::input_streams () const
2057 return _input->n_ports ();
2060 list<pair<ChanCount, ChanCount> >
2061 Route::try_configure_processors (ChanCount in, ProcessorStreams* err)
2063 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2065 return try_configure_processors_unlocked (in, err);
2068 list<pair<ChanCount, ChanCount> >
2069 Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err)
2071 // Check each processor in order to see if we can configure as requested
2073 list<pair<ChanCount, ChanCount> > configuration;
2076 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configure processors\n", _name));
2077 DEBUG_TRACE (DEBUG::Processors, "{\n");
2079 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++index) {
2081 if ((*p)->can_support_io_configuration(in, out)) {
2082 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1 ID=%2 in=%3 out=%4\n",(*p)->name(), (*p)->id(), in, out));
2083 configuration.push_back(make_pair(in, out));
2086 // restriction for Monitor Section Processors
2087 if (in.n_audio() != out.n_audio() || out.n_midi() > 0) {
2088 /* do not allow to add/remove channels (for now)
2089 * The Monitor follows the master-bus and has no panner (unpan)
2090 * but do allow processors with midi-in to be added (e.g VSTs with control that
2091 * will remain unconnected)
2093 DEBUG_TRACE (DEBUG::Processors, "Monitor: Channel configuration not allowed.\n");
2094 return list<pair<ChanCount, ChanCount> > ();
2096 if (boost::dynamic_pointer_cast<InternalSend> (*p)) {
2097 // internal sends make no sense, only feedback
2098 DEBUG_TRACE (DEBUG::Processors, "Monitor: No Sends allowed.\n");
2099 return list<pair<ChanCount, ChanCount> > ();
2101 if (boost::dynamic_pointer_cast<PortInsert> (*p)) {
2102 /* External Sends can be problematic. one can add/remove ports
2103 * there signal leaves the DAW to external monitors anyway, so there's
2104 * no real use for allowing them here anyway.
2106 DEBUG_TRACE (DEBUG::Processors, "Monitor: No External Sends allowed.\n");
2107 return list<pair<ChanCount, ChanCount> > ();
2109 if (boost::dynamic_pointer_cast<Send> (*p)) {
2111 DEBUG_TRACE (DEBUG::Processors, "Monitor: No Sends allowed.\n");
2112 return list<pair<ChanCount, ChanCount> > ();
2121 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
2122 DEBUG_TRACE (DEBUG::Processors, string_compose ("---- %1 cannot support in=%2 out=%3\n", (*p)->name(), in, out));
2123 DEBUG_TRACE (DEBUG::Processors, "}\n");
2124 return list<pair<ChanCount, ChanCount> > ();
2128 DEBUG_TRACE (DEBUG::Processors, "}\n");
2130 return configuration;
2133 /** Set the input/output configuration of each processor in the processors list.
2134 * Caller must hold process lock.
2135 * Return 0 on success, otherwise configuration is impossible.
2138 Route::configure_processors_unlocked (ProcessorStreams* err)
2140 #ifndef PLATFORM_WINDOWS
2141 assert (!AudioEngine::instance()->process_lock().trylock());
2144 if (_in_configure_processors) {
2148 /* put invisible processors where they should be */
2149 setup_invisible_processors ();
2151 _in_configure_processors = true;
2153 list<pair<ChanCount, ChanCount> > configuration = try_configure_processors_unlocked (input_streams (), err);
2155 if (configuration.empty ()) {
2156 _in_configure_processors = false;
2161 bool seen_mains_out = false;
2162 processor_out_streams = _input->n_ports();
2163 processor_max_streams.reset();
2165 list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
2166 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
2168 if (!(*p)->configure_io(c->first, c->second)) {
2169 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration failed\n", _name));
2170 _in_configure_processors = false;
2173 processor_max_streams = ChanCount::max(processor_max_streams, c->first);
2174 processor_max_streams = ChanCount::max(processor_max_streams, c->second);
2176 boost::shared_ptr<PluginInsert> pi;
2177 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2178 /* plugins connected via Split or Hide Match may have more channels.
2179 * route/scratch buffers are needed for all of them
2180 * The configuration may only be a subset (both input and output)
2182 processor_max_streams = ChanCount::max(processor_max_streams, pi->input_streams());
2183 processor_max_streams = ChanCount::max(processor_max_streams, pi->internal_streams());
2184 processor_max_streams = ChanCount::max(processor_max_streams, pi->output_streams());
2185 processor_max_streams = ChanCount::max(processor_max_streams, pi->natural_input_streams() * pi->get_count());
2186 processor_max_streams = ChanCount::max(processor_max_streams, pi->natural_output_streams() * pi->get_count());
2190 if (boost::dynamic_pointer_cast<Delivery> (*p)
2191 && boost::dynamic_pointer_cast<Delivery> (*p)->role() == Delivery::Main) {
2192 /* main delivery will increase port count to match input.
2193 * the Delivery::Main is usually the last processor - followed only by
2196 seen_mains_out = true;
2198 if (!seen_mains_out) {
2199 processor_out_streams = out;
2205 _meter->set_max_channels (processor_max_streams);
2208 /* make sure we have sufficient scratch buffers to cope with the new processor
2211 _session.ensure_buffers (n_process_buffers ());
2213 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration complete\n", _name));
2215 _in_configure_processors = false;
2219 /** Set all visible processors to a given active state (except Fader, whose state is not changed)
2220 * @param state New active state for those processors.
2223 Route::all_visible_processors_active (bool state)
2225 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2227 if (_processors.empty()) {
2231 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2232 if (!(*i)->display_to_user() || boost::dynamic_pointer_cast<Amp> (*i)) {
2239 (*i)->deactivate ();
2243 _session.set_dirty ();
2247 Route::processors_reorder_needs_configure (const ProcessorList& new_order)
2249 /* check if re-order requires re-configuration of any processors
2250 * -> compare channel configuration for all processors
2252 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2253 ChanCount c = input_streams ();
2255 for (ProcessorList::const_iterator j = new_order.begin(); j != new_order.end(); ++j) {
2257 if (c != (*j)->input_streams()) {
2260 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2263 if ((*i)->input_streams() != c) {
2266 c = (*i)->output_streams();
2278 __attribute__((annotate("realtime")))
2281 Route::apply_processor_order (const ProcessorList& new_order)
2283 /* need to hold processor_lock; either read or write lock
2284 * and the engine process_lock.
2285 * Due to r/w lock ambiguity we can only assert the latter
2287 assert (!AudioEngine::instance()->process_lock().trylock());
2290 /* "new_order" is an ordered list of processors to be positioned according to "placement".
2291 * NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
2292 * processors in the current actual processor list that are hidden. Any visible processors
2293 * in the current list but not in "new_order" will be assumed to be deleted.
2296 /* "as_it_will_be" and "_processors" are lists of shared pointers.
2297 * actual memory usage is small, but insert/erase is not actually rt-safe :(
2298 * (note though that ::processors_reorder_needs_configure() ensured that
2299 * this function will only ever be called from the rt-thread if no processor were removed)
2301 * either way, I can't proove it, but an x-run due to re-order here is less likley
2302 * than an x-run-less 'ardour-silent cycle' both of which effectively "click".
2305 ProcessorList as_it_will_be;
2306 ProcessorList::iterator oiter;
2307 ProcessorList::const_iterator niter;
2309 oiter = _processors.begin();
2310 niter = new_order.begin();
2312 while (niter != new_order.end()) {
2314 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
2315 then append it to the temp list.
2317 Otherwise, see if the next processor in the old list is in the new list. if not,
2318 its been deleted. If its there, append it to the temp list.
2321 if (oiter == _processors.end()) {
2323 /* no more elements in the old list, so just stick the rest of
2324 the new order onto the temp list.
2327 as_it_will_be.insert (as_it_will_be.end(), niter, new_order.end());
2328 while (niter != new_order.end()) {
2335 if (!(*oiter)->display_to_user()) {
2337 as_it_will_be.push_back (*oiter);
2341 /* visible processor: check that its in the new order */
2343 if (find (new_order.begin(), new_order.end(), (*oiter)) == new_order.end()) {
2344 /* deleted: do nothing, shared_ptr<> will clean up */
2346 /* ignore this one, and add the next item from the new order instead */
2347 as_it_will_be.push_back (*niter);
2352 /* now remove from old order - its taken care of no matter what */
2353 oiter = _processors.erase (oiter);
2357 _processors.insert (oiter, as_it_will_be.begin(), as_it_will_be.end());
2359 /* If the meter is in a custom position, find it and make a rough note of its position */
2360 maybe_note_meter_position ();
2364 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
2366 // it a change is already queued, wait for it
2367 // (unless engine is stopped. apply immediately and proceed
2368 while (g_atomic_int_get (&_pending_process_reorder)) {
2369 if (!AudioEngine::instance()->running()) {
2370 DEBUG_TRACE (DEBUG::Processors, "offline apply queued processor re-order.\n");
2371 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2373 apply_processor_order(_pending_processor_order);
2374 setup_invisible_processors ();
2376 g_atomic_int_set (&_pending_process_reorder, 0);
2378 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2379 set_processor_positions ();
2381 // TODO rather use a semaphore or something.
2382 // but since ::reorder_processors() is called
2383 // from the GUI thread, this is fine..
2388 if (processors_reorder_needs_configure (new_order) || !AudioEngine::instance()->running()) {
2390 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2391 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2392 ProcessorState pstate (this);
2394 apply_processor_order (new_order);
2396 if (configure_processors_unlocked (err)) {
2404 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2405 set_processor_positions ();
2408 DEBUG_TRACE (DEBUG::Processors, "Queue clickless processor re-order.\n");
2409 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2411 // _pending_processor_order is protected by _processor_lock
2412 _pending_processor_order = new_order;
2413 g_atomic_int_set (&_pending_process_reorder, 1);
2420 Route::add_remove_sidechain (boost::shared_ptr<Processor> proc, bool add)
2422 boost::shared_ptr<PluginInsert> pi;
2423 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2427 if (pi->has_sidechain () == add) {
2428 return true; // ?? call failed, but result is as expected.
2432 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2433 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2434 if (i == _processors.end ()) {
2440 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ()); // take before Writerlock to avoid deadlock
2441 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2443 lx.release (); // IO::add_port() and ~IO takes process lock - XXX check if this is safe
2445 if (!pi->add_sidechain ()) {
2449 if (!pi->del_sidechain ()) {
2455 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2460 pi->del_sidechain ();
2462 pi->add_sidechain ();
2463 // TODO restore side-chain's state.
2468 configure_processors_unlocked (0);
2471 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2472 _session.set_dirty ();
2477 Route::reset_plugin_insert (boost::shared_ptr<Processor> proc)
2480 return customize_plugin_insert (proc, 0, unused);
2484 Route::customize_plugin_insert (boost::shared_ptr<Processor> proc, uint32_t count, ChanCount outs)
2486 boost::shared_ptr<PluginInsert> pi;
2487 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(proc)) == 0) {
2492 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2493 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), proc);
2494 if (i == _processors.end ()) {
2500 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2501 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
2503 bool old_cust = pi->custom_cfg ();
2504 uint32_t old_cnt = pi->get_count ();
2505 ChanCount old_chan = pi->output_streams ();
2508 pi->set_custom_cfg (false);
2510 pi->set_custom_cfg (true);
2511 pi->set_count (count);
2512 pi->set_outputs (outs);
2515 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2519 pi->set_count (old_cnt);
2520 pi->set_outputs (old_chan);
2521 pi->set_custom_cfg (old_cust);
2525 configure_processors_unlocked (0);
2528 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2529 _session.set_dirty ();
2534 Route::set_strict_io (const bool enable)
2536 if (_strict_io != enable) {
2537 _strict_io = enable;
2538 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2539 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2540 boost::shared_ptr<PluginInsert> pi;
2541 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2542 pi->set_strict_io (_strict_io);
2546 list<pair<ChanCount, ChanCount> > c = try_configure_processors_unlocked (n_inputs (), 0);
2550 _strict_io = !enable; // restore old value
2551 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2552 boost::shared_ptr<PluginInsert> pi;
2553 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*p)) != 0) {
2554 pi->set_strict_io (_strict_io);
2562 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
2563 configure_processors (0);
2565 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2566 _session.set_dirty ();
2578 Route::get_template()
2580 return state(false);
2584 Route::state(bool full_state)
2586 if (!_session._template_state_dir.empty()) {
2587 assert (!full_state); // only for templates
2588 foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), _session._template_state_dir));
2591 XMLNode *node = new XMLNode("Route");
2592 ProcessorList::iterator i;
2595 id().print (buf, sizeof (buf));
2596 node->add_property("id", buf);
2597 node->add_property ("name", _name);
2598 node->add_property("default-type", _default_type.to_string());
2599 node->add_property ("strict-io", _strict_io);
2602 node->add_property("flags", enum_2_string (_flags));
2605 node->add_property("active", _active?"yes":"no");
2607 boost::to_string (_phase_invert, p);
2608 node->add_property("phase-invert", p);
2609 node->add_property("denormal-protection", _denormal_protection?"yes":"no");
2610 node->add_property("meter-point", enum_2_string (_meter_point));
2612 node->add_property("meter-type", enum_2_string (_meter_type));
2615 node->add_property("route-group", _route_group->name());
2618 snprintf (buf, sizeof (buf), "%d", _order_key);
2619 node->add_property ("order-key", buf);
2620 node->add_property ("self-solo", (_self_solo ? "yes" : "no"));
2621 snprintf (buf, sizeof (buf), "%d", _soloed_by_others_upstream);
2622 node->add_property ("soloed-by-upstream", buf);
2623 snprintf (buf, sizeof (buf), "%d", _soloed_by_others_downstream);
2624 node->add_property ("soloed-by-downstream", buf);
2625 node->add_property ("solo-isolated", solo_isolated() ? "yes" : "no");
2626 node->add_property ("solo-safe", _solo_safe ? "yes" : "no");
2628 node->add_child_nocopy (_input->state (full_state));
2629 node->add_child_nocopy (_output->state (full_state));
2630 node->add_child_nocopy (_solo_control->get_state ());
2631 node->add_child_nocopy (_mute_control->get_state ());
2632 node->add_child_nocopy (_mute_master->get_state ());
2635 node->add_child_nocopy (Automatable::get_automation_xml_state ());
2638 XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
2639 snprintf (buf, sizeof (buf), "%d", _remote_control_id);
2640 remote_control_node->add_property (X_("id"), buf);
2641 node->add_child_nocopy (*remote_control_node);
2643 if (_comment.length()) {
2644 XMLNode *cmt = node->add_child ("Comment");
2645 cmt->add_content (_comment);
2649 node->add_child_nocopy (_pannable->state (full_state));
2652 for (i = _processors.begin(); i != _processors.end(); ++i) {
2654 /* template save: do not include internal sends functioning as
2655 aux sends because the chance of the target ID
2656 in the session where this template is used
2659 similarly, do not save listen sends which connect to
2660 the monitor section, because these will always be
2663 boost::shared_ptr<InternalSend> is;
2665 if ((is = boost::dynamic_pointer_cast<InternalSend> (*i)) != 0) {
2666 if (is->role() == Delivery::Listen) {
2671 node->add_child_nocopy((*i)->state (full_state));
2675 node->add_child_copy (*_extra_xml);
2678 if (_custom_meter_position_noted) {
2679 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
2681 after->id().print (buf, sizeof (buf));
2682 node->add_property (X_("processor-after-last-custom-meter"), buf);
2686 if (!_session._template_state_dir.empty()) {
2687 foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), ""));
2694 Route::set_state (const XMLNode& node, int version)
2696 if (version < 3000) {
2697 return set_state_2X (node, version);
2701 XMLNodeConstIterator niter;
2703 const XMLProperty *prop;
2705 if (node.name() != "Route"){
2706 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2710 if ((prop = node.property (X_("name"))) != 0) {
2711 Route::set_name (prop->value());
2715 _initial_io_setup = true;
2717 if ((prop = node.property (X_("flags"))) != 0) {
2718 _flags = Flag (string_2_enum (prop->value(), _flags));
2723 if ((prop = node.property (X_("strict-io"))) != 0) {
2724 _strict_io = string_is_affirmative (prop->value());
2727 if (is_master() || is_monitor() || is_auditioner()) {
2728 _mute_master->set_solo_ignore (true);
2732 /* monitor bus does not get a panner, but if (re)created
2733 via XML, it will already have one by the time we
2734 call ::set_state(). so ... remove it.
2739 /* add all processors (except amp, which is always present) */
2741 nlist = node.children();
2742 XMLNode processor_state (X_("processor_state"));
2744 Stateful::save_extra_xml (node);
2746 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2750 if (child->name() == IO::state_node_name) {
2751 if ((prop = child->property (X_("direction"))) == 0) {
2755 if (prop->value() == "Input") {
2756 _input->set_state (*child, version);
2757 } else if (prop->value() == "Output") {
2758 _output->set_state (*child, version);
2762 if (child->name() == X_("Processor")) {
2763 processor_state.add_child_copy (*child);
2766 if (child->name() == X_("Pannable")) {
2768 _pannable->set_state (*child, version);
2770 warning << string_compose (_("Pannable state found for route (%1) without a panner!"), name()) << endmsg;
2775 if ((prop = node.property (X_("meter-point"))) != 0) {
2776 MeterPoint mp = MeterPoint (string_2_enum (prop->value (), _meter_point));
2777 set_meter_point (mp, true);
2779 _meter->set_display_to_user (_meter_point == MeterCustom);
2783 if ((prop = node.property (X_("meter-type"))) != 0) {
2784 _meter_type = MeterType (string_2_enum (prop->value (), _meter_type));
2787 _initial_io_setup = false;
2789 set_processor_state (processor_state);
2791 // this looks up the internal instrument in processors
2792 reset_instrument_info();
2794 if ((prop = node.property ("self-solo")) != 0) {
2795 set_self_solo (string_is_affirmative (prop->value()));
2798 if ((prop = node.property ("soloed-by-upstream")) != 0) {
2799 _soloed_by_others_upstream = 0; // needed for mod_.... () to work
2800 mod_solo_by_others_upstream (atoi (prop->value()));
2803 if ((prop = node.property ("soloed-by-downstream")) != 0) {
2804 _soloed_by_others_downstream = 0; // needed for mod_.... () to work
2805 mod_solo_by_others_downstream (atoi (prop->value()));
2808 if ((prop = node.property ("solo-isolated")) != 0) {
2809 set_solo_isolated (string_is_affirmative (prop->value()), Controllable::NoGroup);
2812 if ((prop = node.property ("solo-safe")) != 0) {
2813 set_solo_safe (string_is_affirmative (prop->value()), Controllable::NoGroup);
2816 if ((prop = node.property (X_("phase-invert"))) != 0) {
2817 set_phase_invert (boost::dynamic_bitset<> (prop->value ()));
2820 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2821 set_denormal_protection (string_is_affirmative (prop->value()));
2824 if ((prop = node.property (X_("active"))) != 0) {
2825 bool yn = string_is_affirmative (prop->value());
2826 _active = !yn; // force switch
2827 set_active (yn, this);
2830 if ((prop = node.property (X_("order-key"))) != 0) { // New order key (no separate mixer/editor ordering)
2831 set_order_key (atoi(prop->value()));
2834 if ((prop = node.property (X_("order-keys"))) != 0) { // Deprecated order keys
2838 string::size_type colon, equal;
2839 string remaining = prop->value();
2841 while (remaining.length()) {
2843 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
2844 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2847 if (sscanf (remaining.substr (equal+1).c_str(), "%d", &n) != 1) {
2848 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2851 string keyname = remaining.substr (0, equal);
2853 if ((keyname == "EditorSort") || (keyname == "editor")) {
2854 cerr << "Setting " << name() << " order key to " << n << " using saved Editor order." << endl;
2860 colon = remaining.find_first_of (':');
2862 if (colon != string::npos) {
2863 remaining = remaining.substr (colon+1);
2870 if ((prop = node.property (X_("processor-after-last-custom-meter"))) != 0) {
2871 PBD::ID id (prop->value ());
2872 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
2873 ProcessorList::const_iterator i = _processors.begin ();
2874 while (i != _processors.end() && (*i)->id() != id) {
2878 if (i != _processors.end ()) {
2879 _processor_after_last_custom_meter = *i;
2880 _custom_meter_position_noted = true;
2884 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2887 if (child->name() == X_("Comment")) {
2889 /* XXX this is a terrible API design in libxml++ */
2891 XMLNode *cmt = *(child->children().begin());
2892 _comment = cmt->content();
2894 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
2895 if (prop->value() == "solo") {
2896 _solo_control->set_state (*child, version);
2897 } else if (prop->value() == "mute") {
2898 _mute_control->set_state (*child, version);
2901 } else if (child->name() == X_("RemoteControl")) {
2902 if ((prop = child->property (X_("id"))) != 0) {
2904 sscanf (prop->value().c_str(), "%d", &x);
2905 set_remote_control_id_internal (x);
2908 } else if (child->name() == X_("MuteMaster")) {
2909 _mute_master->set_state (*child, version);
2911 } else if (child->name() == Automatable::xml_node_name) {
2912 set_automation_xml_state (*child, Evoral::Parameter(NullAutomation));
2920 Route::set_state_2X (const XMLNode& node, int version)
2922 LocaleGuard lg (X_("C"));
2924 XMLNodeConstIterator niter;
2926 const XMLProperty *prop;
2928 /* 2X things which still remain to be handled:
2934 if (node.name() != "Route") {
2935 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2939 if ((prop = node.property (X_("flags"))) != 0) {
2940 string f = prop->value ();
2941 boost::replace_all (f, "ControlOut", "MonitorOut");
2942 _flags = Flag (string_2_enum (f, _flags));
2947 if (is_master() || is_monitor() || is_auditioner()) {
2948 _mute_master->set_solo_ignore (true);
2951 if ((prop = node.property (X_("phase-invert"))) != 0) {
2952 boost::dynamic_bitset<> p (_input->n_ports().n_audio ());
2953 if (string_is_affirmative (prop->value ())) {
2956 set_phase_invert (p);
2959 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2960 set_denormal_protection (string_is_affirmative (prop->value()));
2963 if ((prop = node.property (X_("soloed"))) != 0) {
2964 bool yn = string_is_affirmative (prop->value());
2966 /* XXX force reset of solo status */
2971 if ((prop = node.property (X_("muted"))) != 0) {
2974 bool muted = string_is_affirmative (prop->value());
2980 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
2982 if (string_is_affirmative (prop->value())){
2983 mute_point = mute_point + "PreFader";
2988 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
2990 if (string_is_affirmative (prop->value())){
2993 mute_point = mute_point + ",";
2996 mute_point = mute_point + "PostFader";
3001 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
3003 if (string_is_affirmative (prop->value())){
3006 mute_point = mute_point + ",";
3009 mute_point = mute_point + "Listen";
3014 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
3016 if (string_is_affirmative (prop->value())){
3019 mute_point = mute_point + ",";
3022 mute_point = mute_point + "Main";
3026 _mute_master->set_mute_points (mute_point);
3027 _mute_master->set_muted_by_self (true);
3031 if ((prop = node.property (X_("meter-point"))) != 0) {
3032 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
3035 /* do not carry over edit/mix groups from 2.X because (a) its hard (b) they
3036 don't mean the same thing.
3039 if ((prop = node.property (X_("order-keys"))) != 0) {
3043 string::size_type colon, equal;
3044 string remaining = prop->value();
3046 while (remaining.length()) {
3048 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
3049 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
3052 if (sscanf (remaining.substr (equal+1).c_str(), "%d", &n) != 1) {
3053 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
3056 string keyname = remaining.substr (0, equal);
3058 if (keyname == "EditorSort" || keyname == "editor") {
3059 info << string_compose(_("Converting deprecated order key for %1 using Editor order %2"), name (), n) << endmsg;
3065 colon = remaining.find_first_of (':');
3067 if (colon != string::npos) {
3068 remaining = remaining.substr (colon+1);
3077 nlist = node.children ();
3078 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3082 if (child->name() == IO::state_node_name) {
3084 /* there is a note in IO::set_state_2X() about why we have to call
3088 _input->set_state_2X (*child, version, true);
3089 _output->set_state_2X (*child, version, false);
3091 if ((prop = child->property (X_("name"))) != 0) {
3092 Route::set_name (prop->value ());
3097 if ((prop = child->property (X_("active"))) != 0) {
3098 bool yn = string_is_affirmative (prop->value());
3099 _active = !yn; // force switch
3100 set_active (yn, this);
3103 if ((prop = child->property (X_("gain"))) != 0) {
3106 if (sscanf (prop->value().c_str(), "%f", &val) == 1) {
3107 _amp->gain_control()->set_value (val, Controllable::NoGroup);
3111 /* Set up Panners in the IO */
3112 XMLNodeList io_nlist = child->children ();
3114 XMLNodeConstIterator io_niter;
3117 for (io_niter = io_nlist.begin(); io_niter != io_nlist.end(); ++io_niter) {
3119 io_child = *io_niter;
3121 if (io_child->name() == X_("Panner")) {
3122 _main_outs->panner_shell()->set_state(*io_child, version);
3123 } else if (io_child->name() == X_("Automation")) {
3124 /* IO's automation is for the fader */
3125 _amp->set_automation_xml_state (*io_child, Evoral::Parameter (GainAutomation));
3131 XMLNodeList redirect_nodes;
3133 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
3137 if (child->name() == X_("Send") || child->name() == X_("Insert")) {
3138 redirect_nodes.push_back(child);
3143 set_processor_state_2X (redirect_nodes, version);
3145 Stateful::save_extra_xml (node);
3147 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
3150 if (child->name() == X_("Comment")) {
3152 /* XXX this is a terrible API design in libxml++ */
3154 XMLNode *cmt = *(child->children().begin());
3155 _comment = cmt->content();
3157 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
3158 if (prop->value() == X_("solo")) {
3159 _solo_control->set_state (*child, version);
3160 } else if (prop->value() == X_("mute")) {
3161 _mute_control->set_state (*child, version);
3164 } else if (child->name() == X_("RemoteControl")) {
3165 if ((prop = child->property (X_("id"))) != 0) {
3167 sscanf (prop->value().c_str(), "%d", &x);
3168 set_remote_control_id_internal (x);
3178 Route::get_processor_state ()
3180 XMLNode* root = new XMLNode (X_("redirects"));
3181 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3182 root->add_child_nocopy ((*i)->state (true));
3189 Route::set_processor_state_2X (XMLNodeList const & nList, int version)
3191 /* We don't bother removing existing processors not in nList, as this
3192 method will only be called when creating a Route from scratch, not
3193 for undo purposes. Just put processors in at the appropriate place
3197 for (XMLNodeConstIterator i = nList.begin(); i != nList.end(); ++i) {
3198 add_processor_from_xml_2X (**i, version);
3203 Route::set_processor_state (const XMLNode& node)
3205 const XMLNodeList &nlist = node.children();
3206 XMLNodeConstIterator niter;
3207 ProcessorList new_order;
3208 bool must_configure = false;
3210 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
3212 XMLProperty* prop = (*niter)->property ("type");
3214 if (prop->value() == "amp") {
3215 _amp->set_state (**niter, Stateful::current_state_version);
3216 new_order.push_back (_amp);
3217 } else if (prop->value() == "trim") {
3218 _trim->set_state (**niter, Stateful::current_state_version);
3219 new_order.push_back (_trim);
3220 } else if (prop->value() == "meter") {
3221 _meter->set_state (**niter, Stateful::current_state_version);
3222 new_order.push_back (_meter);
3223 } else if (prop->value() == "delay") {
3225 _delayline->set_state (**niter, Stateful::current_state_version);
3226 new_order.push_back (_delayline);
3228 } else if (prop->value() == "main-outs") {
3229 _main_outs->set_state (**niter, Stateful::current_state_version);
3230 } else if (prop->value() == "intreturn") {
3232 _intreturn.reset (new InternalReturn (_session));
3233 must_configure = true;
3235 _intreturn->set_state (**niter, Stateful::current_state_version);
3236 } else if (is_monitor() && prop->value() == "monitor") {
3237 if (!_monitor_control) {
3238 _monitor_control.reset (new MonitorProcessor (_session));
3239 must_configure = true;
3241 _monitor_control->set_state (**niter, Stateful::current_state_version);
3242 } else if (prop->value() == "capture") {
3243 /* CapturingProcessor should never be restored, it's always
3244 added explicitly when needed */
3246 ProcessorList::iterator o;
3248 for (o = _processors.begin(); o != _processors.end(); ++o) {
3249 XMLProperty* id_prop = (*niter)->property(X_("id"));
3250 if (id_prop && (*o)->id() == id_prop->value()) {
3251 (*o)->set_state (**niter, Stateful::current_state_version);
3252 new_order.push_back (*o);
3257 // If the processor (*niter) is not on the route then create it
3259 if (o == _processors.end()) {
3261 boost::shared_ptr<Processor> processor;
3263 if (prop->value() == "intsend") {
3265 processor.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), boost::shared_ptr<Route>(), Delivery::Aux, true));
3267 } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
3268 prop->value() == "lv2" ||
3269 prop->value() == "windows-vst" ||
3270 prop->value() == "lxvst" ||
3271 prop->value() == "luaproc" ||
3272 prop->value() == "audiounit") {
3274 if (_session.get_disable_all_loaded_plugins ()) {
3275 processor.reset (new UnknownProcessor (_session, **niter));
3277 processor.reset (new PluginInsert (_session));
3278 processor->set_owner (this);
3280 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(processor);
3281 pi->set_strict_io (true);
3285 } else if (prop->value() == "port") {
3287 processor.reset (new PortInsert (_session, _pannable, _mute_master));
3289 } else if (prop->value() == "send") {
3291 processor.reset (new Send (_session, _pannable, _mute_master, Delivery::Send, true));
3294 error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
3298 if (processor->set_state (**niter, Stateful::current_state_version) != 0) {
3299 /* This processor could not be configured. Turn it into a UnknownProcessor */
3300 processor.reset (new UnknownProcessor (_session, **niter));
3303 /* we have to note the monitor send here, otherwise a new one will be created
3304 and the state of this one will be lost.
3306 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
3307 if (isend && isend->role() == Delivery::Listen) {
3308 _monitor_send = isend;
3311 /* it doesn't matter if invisible processors are added here, as they
3312 will be sorted out by setup_invisible_processors () shortly.
3315 new_order.push_back (processor);
3316 must_configure = true;
3322 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
3323 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
3324 _processors = new_order;
3326 if (must_configure) {
3327 configure_processors_unlocked (0);
3330 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3332 (*i)->set_owner (this);
3333 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
3335 boost::shared_ptr<PluginInsert> pi;
3337 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
3338 if (pi->has_no_inputs ()) {
3339 _have_internal_generator = true;
3346 reset_instrument_info ();
3347 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
3348 set_processor_positions ();
3352 Route::curve_reallocate ()
3354 // _gain_automation_curve.finish_resize ();
3355 // _pan_automation_curve.finish_resize ();
3359 Route::silence (framecnt_t nframes)
3361 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3366 silence_unlocked (nframes);
3370 Route::silence_unlocked (framecnt_t nframes)
3372 /* Must be called with the processor lock held */
3376 _output->silence (nframes);
3378 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3379 boost::shared_ptr<PluginInsert> pi;
3381 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
3382 // skip plugins, they don't need anything when we're not active
3386 (*i)->silence (nframes);
3389 if (nframes == _session.get_block_size()) {
3396 Route::add_internal_return ()
3399 _intreturn.reset (new InternalReturn (_session));
3400 add_processor (_intreturn, PreFader);
3405 Route::add_send_to_internal_return (InternalSend* send)
3407 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3409 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
3410 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
3413 return d->add_send (send);
3419 Route::remove_send_from_internal_return (InternalSend* send)
3421 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3423 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
3424 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
3427 return d->remove_send (send);
3433 Route::enable_monitor_send ()
3435 /* Caller must hold process lock */
3436 assert (!AudioEngine::instance()->process_lock().trylock());
3438 /* master never sends to monitor section via the normal mechanism */
3439 assert (!is_master ());
3440 assert (!is_monitor ());
3442 /* make sure we have one */
3443 if (!_monitor_send) {
3444 _monitor_send.reset (new InternalSend (_session, _pannable, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), _session.monitor_out(), Delivery::Listen));
3445 _monitor_send->set_display_to_user (false);
3449 configure_processors (0);
3452 /** Add an aux send to a route.
3453 * @param route route to send to.
3454 * @param before Processor to insert before, or 0 to insert at the end.
3457 Route::add_aux_send (boost::shared_ptr<Route> route, boost::shared_ptr<Processor> before)
3459 assert (route != _session.monitor_out ());
3462 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
3464 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
3466 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend> (*x);
3468 if (d && d->target_route() == route) {
3469 /* already listening via the specified IO: do nothing */
3477 boost::shared_ptr<InternalSend> listener;
3480 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
3481 boost::shared_ptr<Pannable> sendpan (new Pannable (_session));
3482 listener.reset (new InternalSend (_session, sendpan, _mute_master, boost::dynamic_pointer_cast<ARDOUR::Route>(shared_from_this()), route, Delivery::Aux));
3485 add_processor (listener, before);
3487 } catch (failed_constructor& err) {
3495 Route::remove_aux_or_listen (boost::shared_ptr<Route> route)
3497 ProcessorStreams err;
3498 ProcessorList::iterator tmp;
3501 Glib::Threads::RWLock::ReaderLock rl(_processor_lock);
3503 /* have to do this early because otherwise processor reconfig
3504 * will put _monitor_send back in the list
3507 if (route == _session.monitor_out()) {
3508 _monitor_send.reset ();
3512 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
3514 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
3516 if (d && d->target_route() == route) {
3518 if (remove_processor (*x, &err, false) > 0) {
3524 /* list could have been demolished while we dropped the lock
3527 if (_session.engine().connected()) {
3528 /* i/o processors cannot be removed if the engine is not running
3529 * so don't live-loop in case the engine is N/A or dies
3539 Route::set_comment (string cmt, void *src)
3543 _session.set_dirty ();
3547 Route::add_fed_by (boost::shared_ptr<Route> other, bool via_sends_only)
3549 FeedRecord fr (other, via_sends_only);
3551 pair<FedBy::iterator,bool> result = _fed_by.insert (fr);
3553 if (!result.second) {
3555 /* already a record for "other" - make sure sends-only information is correct */
3556 if (!via_sends_only && result.first->sends_only) {
3557 FeedRecord* frp = const_cast<FeedRecord*>(&(*result.first));
3558 frp->sends_only = false;
3562 return result.second;
3566 Route::clear_fed_by ()
3572 Route::feeds (boost::shared_ptr<Route> other, bool* via_sends_only)
3574 const FedBy& fed_by (other->fed_by());
3576 for (FedBy::const_iterator f = fed_by.begin(); f != fed_by.end(); ++f) {
3577 boost::shared_ptr<Route> sr = f->r.lock();
3579 if (sr && (sr.get() == this)) {
3581 if (via_sends_only) {
3582 *via_sends_only = f->sends_only;
3593 Route::direct_feeds_according_to_reality (boost::shared_ptr<Route> other, bool* via_send_only)
3595 DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds? %1\n", _name));
3597 if (_output->connected_to (other->input())) {
3598 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS %2\n", other->name()));
3599 if (via_send_only) {
3600 *via_send_only = false;
3607 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
3609 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor>(*r);
3610 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert>(*r);
3613 iop = pi->sidechain();
3617 if (iop->feeds (other)) {
3618 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name()));
3619 if (via_send_only) {
3620 *via_send_only = true;
3624 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does NOT feed %2\n", iop->name(), other->name()));
3627 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tPROC %1 is not an IOP\n", (*r)->name()));
3632 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdoes NOT feed %1\n", other->name()));
3637 Route::direct_feeds_according_to_graph (boost::shared_ptr<Route> other, bool* via_send_only)
3639 return _session._current_route_graph.has (shared_from_this (), other, via_send_only);
3642 /** Called from the (non-realtime) butler thread when the transport is stopped */
3644 Route::nonrealtime_handle_transport_stopped (bool /*abort_ignored*/, bool /*did_locate*/, bool can_flush_processors)
3646 framepos_t now = _session.transport_frame();
3649 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3651 Automatable::transport_stopped (now);
3653 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3655 if (!_have_internal_generator && (Config->get_plugins_stop_with_transport() && can_flush_processors)) {
3659 (*i)->transport_stopped (now);
3663 _roll_delay = _initial_delay;
3667 Route::input_change_handler (IOChange change, void * /*src*/)
3669 if ((change.type & IOChange::ConfigurationChanged)) {
3670 /* This is called with the process lock held if change
3671 contains ConfigurationChanged
3673 configure_processors (0);
3674 _phase_invert.resize (_input->n_ports().n_audio ());
3675 io_changed (); /* EMIT SIGNAL */
3678 if (_soloed_by_others_upstream || _solo_isolated_by_upstream) {
3681 boost::shared_ptr<RouteList> routes = _session.get_routes ();
3682 if (_input->connected()) {
3683 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3684 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3688 bool does_feed = (*i)->direct_feeds_according_to_reality (shared_from_this(), &sends_only);
3689 if (does_feed && !sends_only) {
3690 if ((*i)->soloed()) {
3693 if ((*i)->solo_isolated()) {
3700 int delta = sbou - _soloed_by_others_upstream;
3701 int idelta = ibou - _solo_isolated_by_upstream;
3704 PBD::warning << string_compose (
3705 _("Invalid Solo-Isolate propagation: from:%1 new:%2 - old:%3 = delta:%4"),
3706 _name, ibou, _solo_isolated_by_upstream, idelta)
3711 if (_soloed_by_others_upstream) {
3712 // ignore new connections (they're not propagated)
3714 mod_solo_by_others_upstream (delta);
3718 if (_solo_isolated_by_upstream) {
3719 // solo-isolate currently only propagates downstream
3721 mod_solo_isolated_by_upstream (false);
3723 // TODO think: mod_solo_isolated_by_upstream() does not take delta arg,
3724 // but idelta can't be smaller than -1, can it?
3725 //_solo_isolated_by_upstream = ibou;
3728 // Session::route_solo_changed does not propagate indirect solo-changes
3729 // propagate downstream to tracks
3730 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3731 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3735 bool does_feed = feeds (*i, &sends_only);
3736 if (delta <= 0 && does_feed && !sends_only) {
3737 (*i)->mod_solo_by_others_upstream (delta);
3740 if (idelta < 0 && does_feed && !sends_only) {
3741 (*i)->mod_solo_isolated_by_upstream (false);
3748 Route::output_change_handler (IOChange change, void * /*src*/)
3750 if (_initial_io_setup) {
3754 if ((change.type & IOChange::ConfigurationChanged)) {
3755 /* This is called with the process lock held if change
3756 contains ConfigurationChanged
3758 configure_processors (0);
3761 _session.reset_monitor_section();
3764 io_changed (); /* EMIT SIGNAL */
3767 if (_soloed_by_others_downstream) {
3769 /* checking all all downstream routes for
3770 * explicit of implict solo is a rather drastic measure,
3771 * ideally the input_change_handler() of the other route
3772 * would propagate the change to us.
3774 boost::shared_ptr<RouteList> routes = _session.get_routes ();
3775 if (_output->connected()) {
3776 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3777 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3781 bool does_feed = direct_feeds_according_to_reality (*i, &sends_only);
3782 if (does_feed && !sends_only) {
3783 if ((*i)->soloed()) {
3790 int delta = sbod - _soloed_by_others_downstream;
3792 // do not allow new connections to change implicit solo (no propagation)
3793 mod_solo_by_others_downstream (delta);
3794 // Session::route_solo_changed() does not propagate indirect solo-changes
3795 // propagate upstream to tracks
3796 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
3797 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_auditioner()) {
3801 bool does_feed = (*i)->feeds (shared_from_this(), &sends_only);
3802 if (delta != 0 && does_feed && !sends_only) {
3803 (*i)->mod_solo_by_others_downstream (delta);
3812 Route::pans_required () const
3814 if (n_outputs().n_audio() < 2) {
3818 return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
3822 Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
3824 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3830 if (n_outputs().n_total() == 0) {
3834 if (!_active || n_inputs() == ChanCount::ZERO) {
3835 silence_unlocked (nframes);
3839 if (session_state_changing) {
3840 if (_session.transport_speed() != 0.0f) {
3841 /* we're rolling but some state is changing (e.g. our diskstream contents)
3842 so we cannot use them. Be silent till this is over.
3844 XXX note the absurdity of ::no_roll() being called when we ARE rolling!
3846 silence_unlocked (nframes);
3849 /* we're really not rolling, so we're either delivery silence or actually
3850 monitoring, both of which are safe to do while session_state_changing is true.
3854 BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
3856 fill_buffers_with_input (bufs, _input, nframes);
3858 if (_meter_point == MeterInput) {
3859 _meter->run (bufs, start_frame, end_frame, nframes, true);
3862 _amp->apply_gain_automation (false);
3863 _trim->apply_gain_automation (false);
3864 passthru (bufs, start_frame, end_frame, nframes, 0);
3870 Route::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& /* need_butler */)
3872 Glib::Threads::RWLock::ReaderLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
3877 if (n_outputs().n_total() == 0) {
3881 if (!_active || n_inputs().n_total() == 0) {
3882 silence_unlocked (nframes);
3886 framepos_t unused = 0;
3888 if ((nframes = check_initial_delay (nframes, unused)) == 0) {
3894 BufferSet& bufs = _session.get_route_buffers (n_process_buffers());
3896 fill_buffers_with_input (bufs, _input, nframes);
3898 if (_meter_point == MeterInput) {
3899 _meter->run (bufs, start_frame, end_frame, nframes, true);
3902 passthru (bufs, start_frame, end_frame, nframes, declick);
3908 Route::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*end_frame*/, bool& /* need_butler */)
3915 Route::flush_processors ()
3917 /* XXX shouldn't really try to take this lock, since
3918 this is called from the RT audio thread.
3921 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
3923 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3929 __attribute__((annotate("realtime")))
3932 Route::apply_processor_changes_rt ()
3934 int emissions = EmitNone;
3936 if (_pending_meter_point != _meter_point) {
3937 Glib::Threads::RWLock::WriterLock pwl (_processor_lock, Glib::Threads::TRY_LOCK);
3939 /* meters always have buffers for 'processor_max_streams'
3940 * they can be re-positioned without re-allocation */
3941 if (set_meter_point_unlocked()) {
3942 emissions |= EmitMeterChanged | EmitMeterVisibilityChange;;
3944 emissions |= EmitMeterChanged;
3949 bool changed = false;
3951 if (g_atomic_int_get (&_pending_process_reorder)) {
3952 Glib::Threads::RWLock::WriterLock pwl (_processor_lock, Glib::Threads::TRY_LOCK);
3954 apply_processor_order (_pending_processor_order);
3955 setup_invisible_processors ();
3957 g_atomic_int_set (&_pending_process_reorder, 0);
3958 emissions |= EmitRtProcessorChange;
3962 set_processor_positions ();
3964 if (emissions != 0) {
3965 g_atomic_int_set (&_pending_signals, emissions);
3972 Route::emit_pending_signals ()
3975 int sig = g_atomic_int_and (&_pending_signals, 0);
3976 if (sig & EmitMeterChanged) {
3977 _meter->emit_configuration_changed();
3978 meter_change (); /* EMIT SIGNAL */
3979 if (sig & EmitMeterVisibilityChange) {
3980 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */
3982 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */
3985 if (sig & EmitRtProcessorChange) {
3986 processors_changed (RouteProcessorChange (RouteProcessorChange::RealTimeChange)); /* EMIT SIGNAL */
3991 Route::set_meter_point (MeterPoint p, bool force)
3993 if (_pending_meter_point == p && !force) {
3997 if (force || !AudioEngine::instance()->running()) {
3998 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
3999 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
4000 _pending_meter_point = p;
4001 _meter->emit_configuration_changed();
4002 meter_change (); /* EMIT SIGNAL */
4003 if (set_meter_point_unlocked()) {
4004 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, true)); /* EMIT SIGNAL */
4006 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, false)); /* EMIT SIGNAL */
4009 _pending_meter_point = p;
4015 __attribute__((annotate("realtime")))
4018 Route::set_meter_point_unlocked ()
4021 /* Caller must hold process and processor write lock */
4022 assert (!AudioEngine::instance()->process_lock().trylock());
4023 Glib::Threads::RWLock::WriterLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
4024 assert (!lm.locked ());
4027 _meter_point = _pending_meter_point;
4029 bool meter_was_visible_to_user = _meter->display_to_user ();
4031 if (!_custom_meter_position_noted) {
4032 maybe_note_meter_position ();
4035 if (_meter_point != MeterCustom) {
4037 _meter->set_display_to_user (false);
4039 setup_invisible_processors ();
4042 _meter->set_display_to_user (true);
4044 /* If we have a previous position for the custom meter, try to put it there */
4045 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
4047 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), after);
4048 if (i != _processors.end ()) {
4049 _processors.remove (_meter);
4050 _processors.insert (i, _meter);
4052 } else {// at end, right before the mains_out/panner
4053 _processors.remove (_meter);
4054 ProcessorList::iterator main = _processors.end();
4055 _processors.insert (--main, _meter);
4059 /* Set up the meter for its new position */
4061 ProcessorList::iterator loc = find (_processors.begin(), _processors.end(), _meter);
4065 if (loc == _processors.begin()) {
4066 m_in = _input->n_ports();
4068 ProcessorList::iterator before = loc;
4070 m_in = (*before)->output_streams ();
4073 _meter->reflect_inputs (m_in);
4075 /* we do not need to reconfigure the processors, because the meter
4076 (a) is always ready to handle processor_max_streams
4077 (b) is always an N-in/N-out processor, and thus moving
4078 it doesn't require any changes to the other processors.
4081 /* these should really be done after releasing the lock
4082 * but all those signals are subscribed to with gui_thread()
4085 return (_meter->display_to_user() != meter_was_visible_to_user);
4089 Route::listen_position_changed ()
4092 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
4093 Glib::Threads::RWLock::WriterLock lm (_processor_lock);
4094 ProcessorState pstate (this);
4096 if (configure_processors_unlocked (0)) {
4097 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
4099 configure_processors_unlocked (0); // it worked before we tried to add it ...
4104 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
4105 _session.set_dirty ();
4108 boost::shared_ptr<CapturingProcessor>
4109 Route::add_export_point()
4111 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4112 if (!_capturing_processor) {
4114 Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
4115 Glib::Threads::RWLock::WriterLock lw (_processor_lock);
4117 _capturing_processor.reset (new CapturingProcessor (_session));
4118 _capturing_processor->activate ();
4120 configure_processors_unlocked (0);
4124 return _capturing_processor;
4128 Route::update_signal_latency ()
4130 framecnt_t l = _output->user_latency();
4131 framecnt_t lamp = 0;
4132 bool before_amp = true;
4133 framecnt_t ltrim = 0;
4134 bool before_trim = true;
4136 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4137 if ((*i)->active ()) {
4138 l += (*i)->signal_latency ();
4143 if ((*i) == _trim) {
4154 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal signal latency = %2\n", _name, l));
4156 // TODO: (lamp - _signal_latency) to sync to output (read-ahed), currently _roll_delay shifts this around
4157 _signal_latency_at_amp_position = lamp;
4158 _signal_latency_at_trim_position = ltrim;
4160 if (_signal_latency != l) {
4161 _signal_latency = l;
4162 signal_latency_changed (); /* EMIT SIGNAL */
4165 return _signal_latency;
4169 Route::set_user_latency (framecnt_t nframes)
4171 _output->set_user_latency (nframes);
4172 _session.update_latency_compensation ();
4176 Route::set_latency_compensation (framecnt_t longest_session_latency)
4178 framecnt_t old = _initial_delay;
4180 if (_signal_latency < longest_session_latency) {
4181 _initial_delay = longest_session_latency - _signal_latency;
4186 DEBUG_TRACE (DEBUG::Latency, string_compose (
4187 "%1: compensate for maximum latency of %2,"
4188 "given own latency of %3, using initial delay of %4\n",
4189 name(), longest_session_latency, _signal_latency, _initial_delay));
4191 if (_initial_delay != old) {
4192 initial_delay_changed (); /* EMIT SIGNAL */
4195 if (_session.transport_stopped()) {
4196 _roll_delay = _initial_delay;
4201 Route::set_block_size (pframes_t nframes)
4203 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4204 (*i)->set_block_size (nframes);
4207 _session.ensure_buffers (n_process_buffers ());
4211 Route::protect_automation ()
4213 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i)
4214 (*i)->protect_automation();
4217 /** @param declick 1 to set a pending declick fade-in,
4218 * -1 to set a pending declick fade-out
4221 Route::set_pending_declick (int declick)
4224 /* this call is not allowed to turn off a pending declick */
4226 _pending_declick = declick;
4229 _pending_declick = 0;
4233 /** Shift automation forwards from a particular place, thereby inserting time.
4234 * Adds undo commands for any shifts that are performed.
4236 * @param pos Position to start shifting from.
4237 * @param frames Amount to shift forwards by.
4241 Route::shift (framepos_t pos, framecnt_t frames)
4243 /* gain automation */
4245 boost::shared_ptr<AutomationControl> gc = _amp->gain_control();
4247 XMLNode &before = gc->alist()->get_state ();
4248 gc->alist()->shift (pos, frames);
4249 XMLNode &after = gc->alist()->get_state ();
4250 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
4253 /* gain automation */
4255 boost::shared_ptr<AutomationControl> gc = _trim->gain_control();
4257 XMLNode &before = gc->alist()->get_state ();
4258 gc->alist()->shift (pos, frames);
4259 XMLNode &after = gc->alist()->get_state ();
4260 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
4263 // TODO mute automation ??
4265 /* pan automation */
4267 ControlSet::Controls& c (_pannable->controls());
4269 for (ControlSet::Controls::const_iterator ci = c.begin(); ci != c.end(); ++ci) {
4270 boost::shared_ptr<AutomationControl> pc = boost::dynamic_pointer_cast<AutomationControl> (ci->second);
4272 boost::shared_ptr<AutomationList> al = pc->alist();
4273 XMLNode& before = al->get_state ();
4274 al->shift (pos, frames);
4275 XMLNode& after = al->get_state ();
4276 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
4281 /* redirect automation */
4283 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4284 for (ProcessorList::iterator i = _processors.begin (); i != _processors.end (); ++i) {
4286 set<Evoral::Parameter> parameters = (*i)->what_can_be_automated();
4288 for (set<Evoral::Parameter>::const_iterator p = parameters.begin (); p != parameters.end (); ++p) {
4289 boost::shared_ptr<AutomationControl> ac = (*i)->automation_control (*p);
4291 boost::shared_ptr<AutomationList> al = ac->alist();
4292 XMLNode &before = al->get_state ();
4293 al->shift (pos, frames);
4294 XMLNode &after = al->get_state ();
4295 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
4303 Route::set_plugin_state_dir (boost::weak_ptr<Processor> p, const std::string& d)
4305 boost::shared_ptr<Processor> processor (p.lock ());
4306 boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (processor);
4310 pi->set_state_dir (d);
4314 Route::save_as_template (const string& path, const string& name)
4316 std::string state_dir = path.substr (0, path.find_last_of ('.')); // strip template_suffix
4317 PBD::Unwinder<std::string> uw (_session._template_state_dir, state_dir);
4319 XMLNode& node (state (false));
4323 IO::set_name_in_state (*node.children().front(), name);
4325 tree.set_root (&node);
4327 /* return zero on success, non-zero otherwise */
4328 return !tree.write (path.c_str());
4333 Route::set_name (const string& str)
4335 if (str == name()) {
4339 string name = Route::ensure_track_or_route_name (str, _session);
4340 SessionObject::set_name (name);
4342 bool ret = (_input->set_name(name) && _output->set_name(name));
4345 /* rename the main outs. Leave other IO processors
4346 * with whatever name they already have, because its
4347 * just fine as it is (it will not contain the route
4348 * name if its a port insert, port send or port return).
4352 if (_main_outs->set_name (name)) {
4353 /* XXX returning false here is stupid because
4354 we already changed the route name.
4364 /** Set the name of a route in an XML description.
4365 * @param node XML <Route> node to set the name in.
4366 * @param name New name.
4369 Route::set_name_in_state (XMLNode& node, string const & name, bool rename_playlist)
4371 node.add_property (X_("name"), name);
4373 XMLNodeList children = node.children();
4374 for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
4376 if ((*i)->name() == X_("IO")) {
4378 IO::set_name_in_state (**i, name);
4380 } else if ((*i)->name() == X_("Processor")) {
4382 XMLProperty* role = (*i)->property (X_("role"));
4383 if (role && role->value() == X_("Main")) {
4384 (*i)->add_property (X_("name"), name);
4387 } else if ((*i)->name() == X_("Diskstream")) {
4389 if (rename_playlist) {
4390 (*i)->add_property (X_("playlist"), string_compose ("%1.1", name).c_str());
4392 (*i)->add_property (X_("name"), name);
4398 boost::shared_ptr<Send>
4399 Route::internal_send_for (boost::shared_ptr<const Route> target) const
4401 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4403 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4404 boost::shared_ptr<InternalSend> send;
4406 if ((send = boost::dynamic_pointer_cast<InternalSend>(*i)) != 0) {
4407 if (send->target_route() == target) {
4413 return boost::shared_ptr<Send>();
4416 /** @param c Audio channel index.
4417 * @param yn true to invert phase, otherwise false.
4420 Route::set_phase_invert (uint32_t c, bool yn)
4422 if (_phase_invert[c] != yn) {
4423 _phase_invert[c] = yn;
4424 phase_invert_changed (); /* EMIT SIGNAL */
4425 _phase_control->Changed(); /* EMIT SIGNAL */
4426 _session.set_dirty ();
4431 Route::set_phase_invert (boost::dynamic_bitset<> p)
4433 if (_phase_invert != p) {
4435 phase_invert_changed (); /* EMIT SIGNAL */
4436 _session.set_dirty ();
4441 Route::phase_invert (uint32_t c) const
4443 return _phase_invert[c];
4446 boost::dynamic_bitset<>
4447 Route::phase_invert () const
4449 return _phase_invert;
4453 Route::set_denormal_protection (bool yn)
4455 if (_denormal_protection != yn) {
4456 _denormal_protection = yn;
4457 denormal_protection_changed (); /* EMIT SIGNAL */
4462 Route::denormal_protection () const
4464 return _denormal_protection;
4468 Route::set_active (bool yn, void* src)
4470 if (_session.transport_rolling()) {
4474 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_route_active()) {
4475 _route_group->foreach_route (boost::bind (&Route::set_active, _1, yn, _route_group));
4479 if (_active != yn) {
4481 _input->set_active (yn);
4482 _output->set_active (yn);
4483 active_changed (); // EMIT SIGNAL
4484 _session.set_dirty ();
4488 boost::shared_ptr<Pannable>
4489 Route::pannable() const
4494 boost::shared_ptr<Panner>
4495 Route::panner() const
4498 return _main_outs->panner_shell()->panner();
4501 boost::shared_ptr<PannerShell>
4502 Route::panner_shell() const
4504 return _main_outs->panner_shell();
4507 boost::shared_ptr<GainControl>
4508 Route::gain_control() const
4510 return _gain_control;
4513 boost::shared_ptr<GainControl>
4514 Route::trim_control() const
4516 return _trim_control;
4519 boost::shared_ptr<Route::PhaseControllable>
4520 Route::phase_control() const
4522 if (phase_invert().size()) {
4523 return _phase_control;
4525 return boost::shared_ptr<PhaseControllable>();
4529 boost::shared_ptr<AutomationControl>
4530 Route::get_control (const Evoral::Parameter& param)
4532 /* either we own the control or .... */
4534 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(control (param));
4538 /* maybe one of our processors does or ... */
4540 Glib::Threads::RWLock::ReaderLock rm (_processor_lock);
4541 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4542 if ((c = boost::dynamic_pointer_cast<AutomationControl>((*i)->control (param))) != 0) {
4550 /* nobody does so we'll make a new one */
4552 c = boost::dynamic_pointer_cast<AutomationControl>(control_factory(param));
4559 boost::shared_ptr<Processor>
4560 Route::nth_plugin (uint32_t n) const
4562 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4563 ProcessorList::const_iterator i;
4565 for (i = _processors.begin(); i != _processors.end(); ++i) {
4566 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
4573 return boost::shared_ptr<Processor> ();
4576 boost::shared_ptr<Processor>
4577 Route::nth_send (uint32_t n) const
4579 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4580 ProcessorList::const_iterator i;
4582 for (i = _processors.begin(); i != _processors.end(); ++i) {
4583 if (boost::dynamic_pointer_cast<Send> (*i)) {
4585 if ((*i)->name().find (_("Monitor")) == 0) {
4586 /* send to monitor section is not considered
4587 to be an accessible send.
4598 return boost::shared_ptr<Processor> ();
4602 Route::has_io_processor_named (const string& name)
4604 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4605 ProcessorList::iterator i;
4607 for (i = _processors.begin(); i != _processors.end(); ++i) {
4608 if (boost::dynamic_pointer_cast<Send> (*i) ||
4609 boost::dynamic_pointer_cast<PortInsert> (*i)) {
4610 if ((*i)->name() == name) {
4619 MuteMaster::MutePoint
4620 Route::mute_points () const
4622 return _mute_master->mute_points ();
4626 Route::set_processor_positions ()
4628 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4630 bool had_amp = false;
4631 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4632 (*i)->set_pre_fader (!had_amp);
4639 /** Called when there is a proposed change to the input port count */
4641 Route::input_port_count_changing (ChanCount to)
4643 list<pair<ChanCount, ChanCount> > c = try_configure_processors (to, 0);
4645 /* The processors cannot be configured with the new input arrangement, so
4651 /* The change is ok */
4655 /** Called when there is a proposed change to the output port count */
4657 Route::output_port_count_changing (ChanCount to)
4659 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
4660 if (processor_out_streams.get(*t) > to.get(*t)) {
4664 /* The change is ok */
4669 Route::unknown_processors () const
4673 if (_session.get_disable_all_loaded_plugins ()) {
4674 // Do not list "missing plugins" if they are explicitly disabled
4678 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
4679 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4680 if (boost::dynamic_pointer_cast<UnknownProcessor const> (*i)) {
4681 p.push_back ((*i)->name ());
4690 Route::update_port_latencies (PortSet& from, PortSet& to, bool playback, framecnt_t our_latency) const
4692 /* we assume that all our input ports feed all our output ports. its not
4693 universally true, but the alternative is way too corner-case to worry about.
4696 LatencyRange all_connections;
4699 all_connections.min = 0;
4700 all_connections.max = 0;
4702 all_connections.min = ~((pframes_t) 0);
4703 all_connections.max = 0;
4705 /* iterate over all "from" ports and determine the latency range for all of their
4706 connections to the "outside" (outside of this Route).
4709 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
4713 p->get_connected_latency_range (range, playback);
4715 all_connections.min = min (all_connections.min, range.min);
4716 all_connections.max = max (all_connections.max, range.max);
4720 /* set the "from" port latencies to the max/min range of all their connections */
4722 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
4723 p->set_private_latency_range (all_connections, playback);
4726 /* set the ports "in the direction of the flow" to the same value as above plus our own signal latency */
4728 all_connections.min += our_latency;
4729 all_connections.max += our_latency;
4731 for (PortSet::iterator p = to.begin(); p != to.end(); ++p) {
4732 p->set_private_latency_range (all_connections, playback);
4735 return all_connections.max;
4739 Route::set_private_port_latencies (bool playback) const
4741 framecnt_t own_latency = 0;
4743 /* Processor list not protected by lock: MUST BE CALLED FROM PROCESS THREAD
4744 OR LATENCY CALLBACK.
4746 This is called (early) from the latency callback. It computes the REAL
4747 latency associated with each port and stores the result as the "private"
4748 latency of the port. A later call to Route::set_public_port_latencies()
4749 sets all ports to the same value to reflect the fact that we do latency
4750 compensation and so all signals are delayed by the same amount as they
4751 flow through ardour.
4754 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4755 if ((*i)->active ()) {
4756 own_latency += (*i)->signal_latency ();
4761 /* playback: propagate latency from "outside the route" to outputs to inputs */
4762 return update_port_latencies (_output->ports (), _input->ports (), true, own_latency);
4764 /* capture: propagate latency from "outside the route" to inputs to outputs */
4765 return update_port_latencies (_input->ports (), _output->ports (), false, own_latency);
4770 Route::set_public_port_latencies (framecnt_t value, bool playback) const
4772 /* this is called to set the JACK-visible port latencies, which take
4773 latency compensation into account.
4782 const PortSet& ports (_input->ports());
4783 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
4784 p->set_public_latency_range (range, playback);
4789 const PortSet& ports (_output->ports());
4790 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
4791 p->set_public_latency_range (range, playback);
4796 /** Put the invisible processors in the right place in _processors.
4797 * Must be called with a writer lock on _processor_lock held.
4800 __attribute__((annotate("realtime")))
4803 Route::setup_invisible_processors ()
4806 Glib::Threads::RWLock::WriterLock lm (_processor_lock, Glib::Threads::TRY_LOCK);
4807 assert (!lm.locked ());
4811 /* too early to be doing this stuff */
4815 /* we'll build this new list here and then use it
4817 * TODO put the ProcessorList is on the stack for RT-safety.
4820 ProcessorList new_processors;
4822 /* find visible processors */
4824 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4825 if ((*i)->display_to_user ()) {
4826 new_processors.push_back (*i);
4832 ProcessorList::iterator amp = new_processors.begin ();
4833 while (amp != new_processors.end() && *amp != _amp) {
4837 assert (amp != new_processors.end ());
4839 /* and the processor after the amp */
4841 ProcessorList::iterator after_amp = amp;
4847 switch (_meter_point) {
4849 assert (!_meter->display_to_user ());
4850 new_processors.push_front (_meter);
4853 assert (!_meter->display_to_user ());
4854 new_processors.insert (amp, _meter);
4856 case MeterPostFader:
4857 /* do nothing here */
4860 /* do nothing here */
4863 /* the meter is visible, so we don't touch it here */
4870 assert (_main_outs);
4871 assert (!_main_outs->display_to_user ());
4872 new_processors.push_back (_main_outs);
4874 /* iterator for the main outs */
4876 ProcessorList::iterator main = new_processors.end();
4879 /* OUTPUT METERING */
4881 if (_meter && (_meter_point == MeterOutput || _meter_point == MeterPostFader)) {
4882 assert (!_meter->display_to_user ());
4884 /* add the processor just before or just after the main outs */
4886 ProcessorList::iterator meter_point = main;
4888 if (_meter_point == MeterOutput) {
4891 new_processors.insert (meter_point, _meter);
4896 if (_monitor_send && !is_monitor ()) {
4897 assert (!_monitor_send->display_to_user ());
4898 switch (Config->get_listen_position ()) {
4899 case PreFaderListen:
4900 switch (Config->get_pfl_position ()) {
4901 case PFLFromBeforeProcessors:
4902 new_processors.push_front (_monitor_send);
4904 case PFLFromAfterProcessors:
4905 new_processors.insert (amp, _monitor_send);
4908 _monitor_send->set_can_pan (false);
4910 case AfterFaderListen:
4911 switch (Config->get_afl_position ()) {
4912 case AFLFromBeforeProcessors:
4913 new_processors.insert (after_amp, _monitor_send);
4915 case AFLFromAfterProcessors:
4916 new_processors.insert (new_processors.end(), _monitor_send);
4919 _monitor_send->set_can_pan (true);
4924 #if 0 // not used - just yet
4925 if (!is_master() && !is_monitor() && !is_auditioner()) {
4926 new_processors.push_front (_delayline);
4930 /* MONITOR CONTROL */
4932 if (_monitor_control && is_monitor ()) {
4933 assert (!_monitor_control->display_to_user ());
4934 new_processors.insert (amp, _monitor_control);
4937 /* INTERNAL RETURN */
4939 /* doing this here means that any monitor control will come just after
4944 assert (!_intreturn->display_to_user ());
4945 new_processors.push_front (_intreturn);
4948 if (_trim && _trim->active()) {
4949 assert (!_trim->display_to_user ());
4950 new_processors.push_front (_trim);
4952 /* EXPORT PROCESSOR */
4954 if (_capturing_processor) {
4955 assert (!_capturing_processor->display_to_user ());
4956 new_processors.push_front (_capturing_processor);
4959 _processors = new_processors;
4961 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4962 if (!(*i)->display_to_user () && !(*i)->active () && (*i) != _monitor_send) {
4967 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: setup_invisible_processors\n", _name));
4968 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4969 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1\n", (*i)->name ()));
4976 Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
4977 Glib::Threads::RWLock::ReaderLock lp (_processor_lock);
4981 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
4982 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery>(*i);
4989 /** If the meter point is `Custom', make a note of where the meter is.
4990 * This is so that if the meter point is subsequently set to something else,
4991 * and then back to custom, we can put the meter back where it was last time
4992 * custom was enabled.
4994 * Must be called with the _processor_lock held.
4997 Route::maybe_note_meter_position ()
4999 if (_meter_point != MeterCustom) {
5003 _custom_meter_position_noted = true;
5004 /* custom meter points range from after trim to before panner/main_outs
5005 * this is a limitation by the current processor UI
5007 bool seen_trim = false;
5008 _processor_after_last_custom_meter.reset();
5009 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
5010 if ((*i) == _trim) {
5013 if ((*i) == _main_outs) {
5014 _processor_after_last_custom_meter = *i;
5017 if (boost::dynamic_pointer_cast<PeakMeter> (*i)) {
5019 _processor_after_last_custom_meter = _trim;
5021 ProcessorList::iterator j = i;
5023 assert(j != _processors.end ()); // main_outs should be before
5024 _processor_after_last_custom_meter = *j;
5029 assert(_processor_after_last_custom_meter.lock());
5032 boost::shared_ptr<Processor>
5033 Route::processor_by_id (PBD::ID id) const
5035 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5036 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5037 if ((*i)->id() == id) {
5042 return boost::shared_ptr<Processor> ();
5045 /** @return the monitoring state, or in other words what data we are pushing
5046 * into the route (data from the inputs, data from disk or silence)
5049 Route::monitoring_state () const
5051 return MonitoringInput;
5054 /** @return what we should be metering; either the data coming from the input
5055 * IO or the data that is flowing through the route.
5058 Route::metering_state () const
5060 return MeteringRoute;
5064 Route::has_external_redirects () const
5066 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5068 /* ignore inactive processors and obviously ignore the main
5069 * outs since everything has them and we don't care.
5072 if ((*i)->active() && (*i) != _main_outs && (*i)->does_routing()) {
5080 boost::shared_ptr<Processor>
5081 Route::the_instrument () const
5083 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5084 return the_instrument_unlocked ();
5087 boost::shared_ptr<Processor>
5088 Route::the_instrument_unlocked () const
5090 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
5091 if (boost::dynamic_pointer_cast<PluginInsert>(*i)) {
5092 if ((*i)->input_streams().n_midi() > 0 &&
5093 (*i)->output_streams().n_audio() > 0) {
5098 return boost::shared_ptr<Processor>();
5104 Route::non_realtime_locate (framepos_t pos)
5107 _pannable->transport_located (pos);
5110 if (_delayline.get()) {
5111 _delayline.get()->flush();
5115 //Glib::Threads::Mutex::Lock lx (AudioEngine::instance()->process_lock ());
5116 Glib::Threads::RWLock::ReaderLock lm (_processor_lock);
5118 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
5119 (*i)->transport_located (pos);
5122 _roll_delay = _initial_delay;
5126 Route::fill_buffers_with_input (BufferSet& bufs, boost::shared_ptr<IO> io, pframes_t nframes)
5133 * We don't currently mix MIDI input together, so we don't need the
5134 * complex logic of the audio case.
5137 n_buffers = bufs.count().n_midi ();
5139 for (i = 0; i < n_buffers; ++i) {
5141 boost::shared_ptr<MidiPort> source_port = io->midi (i);
5142 MidiBuffer& buf (bufs.get_midi (i));
5145 buf.copy (source_port->get_midi_buffer(nframes));
5147 buf.silence (nframes);
5153 n_buffers = bufs.count().n_audio();
5155 size_t n_ports = io->n_ports().n_audio();
5156 float scaling = 1.0f;
5158 if (n_ports > n_buffers) {
5159 scaling = ((float) n_buffers) / n_ports;
5162 for (i = 0; i < n_ports; ++i) {
5164 /* if there are more ports than buffers, map them onto buffers
5165 * in a round-robin fashion
5168 boost::shared_ptr<AudioPort> source_port = io->audio (i);
5169 AudioBuffer& buf (bufs.get_audio (i%n_buffers));
5172 if (i < n_buffers) {
5174 /* first time through just copy a channel into
5178 buf.read_from (source_port->get_audio_buffer (nframes), nframes);
5180 if (scaling != 1.0f) {
5181 buf.apply_gain (scaling, nframes);
5186 /* on subsequent times around, merge data from
5187 * the port with what is already there
5190 if (scaling != 1.0f) {
5191 buf.accumulate_with_gain_from (source_port->get_audio_buffer (nframes), nframes, 0, scaling);
5193 buf.accumulate_from (source_port->get_audio_buffer (nframes), nframes);
5198 /* silence any remaining buffers */
5200 for (; i < n_buffers; ++i) {
5201 AudioBuffer& buf (bufs.get_audio (i));
5202 buf.silence (nframes);
5205 /* establish the initial setup of the buffer set, reflecting what was
5206 copied into it. unless, of course, we are the auditioner, in which
5207 case nothing was fed into it from the inputs at all.
5210 if (!is_auditioner()) {
5211 bufs.set_count (io->n_ports());
5215 boost::shared_ptr<AutomationControl>
5216 Route::pan_azimuth_control() const
5219 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5221 return boost::shared_ptr<AutomationControl>();
5223 const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
5224 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
5226 if (!_pannable || !panner()) {
5227 return boost::shared_ptr<AutomationControl>();
5229 return _pannable->pan_azimuth_control;
5233 boost::shared_ptr<AutomationControl>
5234 Route::pan_elevation_control() const
5236 if (Profile->get_mixbus() || !_pannable || !panner()) {
5237 return boost::shared_ptr<AutomationControl>();
5240 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5242 if (c.find (PanElevationAutomation) != c.end()) {
5243 return _pannable->pan_elevation_control;
5245 return boost::shared_ptr<AutomationControl>();
5248 boost::shared_ptr<AutomationControl>
5249 Route::pan_width_control() const
5251 if (Profile->get_mixbus() || !_pannable || !panner()) {
5252 return boost::shared_ptr<AutomationControl>();
5255 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5257 if (c.find (PanWidthAutomation) != c.end()) {
5258 return _pannable->pan_width_control;
5260 return boost::shared_ptr<AutomationControl>();
5263 boost::shared_ptr<AutomationControl>
5264 Route::pan_frontback_control() const
5266 if (Profile->get_mixbus() || !_pannable || !panner()) {
5267 return boost::shared_ptr<AutomationControl>();
5270 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5272 if (c.find (PanFrontBackAutomation) != c.end()) {
5273 return _pannable->pan_frontback_control;
5275 return boost::shared_ptr<AutomationControl>();
5278 boost::shared_ptr<AutomationControl>
5279 Route::pan_lfe_control() const
5281 if (Profile->get_mixbus() || !_pannable || !panner()) {
5282 return boost::shared_ptr<AutomationControl>();
5285 set<Evoral::Parameter> c = panner()->what_can_be_automated ();
5287 if (c.find (PanLFEAutomation) != c.end()) {
5288 return _pannable->pan_lfe_control;
5290 return boost::shared_ptr<AutomationControl>();
5295 Route::eq_band_cnt () const
5297 if (Profile->get_mixbus()) {
5300 /* Ardour has no well-known EQ object */
5305 boost::shared_ptr<AutomationControl>
5306 Route::eq_gain_controllable (uint32_t band) const
5309 boost::shared_ptr<PluginInsert> eq = ch_eq();
5312 return boost::shared_ptr<AutomationControl>();
5315 uint32_t port_number;
5318 if (is_master() || mixbus()) {
5325 if (is_master() || mixbus()) {
5332 if (is_master() || mixbus()) {
5339 return boost::shared_ptr<AutomationControl>();
5342 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
5344 return boost::shared_ptr<AutomationControl>();
5347 boost::shared_ptr<AutomationControl>
5348 Route::eq_freq_controllable (uint32_t band) const
5352 if (mixbus() || is_master()) {
5353 /* no frequency controls for mixbusses or master */
5354 return boost::shared_ptr<AutomationControl>();
5357 boost::shared_ptr<PluginInsert> eq = ch_eq();
5360 return boost::shared_ptr<AutomationControl>();
5363 uint32_t port_number;
5375 return boost::shared_ptr<AutomationControl>();
5378 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_number)));
5380 return boost::shared_ptr<AutomationControl>();
5384 boost::shared_ptr<AutomationControl>
5385 Route::eq_q_controllable (uint32_t band) const
5387 return boost::shared_ptr<AutomationControl>();
5390 boost::shared_ptr<AutomationControl>
5391 Route::eq_shape_controllable (uint32_t band) const
5393 return boost::shared_ptr<AutomationControl>();
5396 boost::shared_ptr<AutomationControl>
5397 Route::eq_enable_controllable () const
5400 boost::shared_ptr<PluginInsert> eq = ch_eq();
5403 return boost::shared_ptr<AutomationControl>();
5406 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 1)));
5408 return boost::shared_ptr<AutomationControl>();
5412 boost::shared_ptr<AutomationControl>
5413 Route::eq_hpf_controllable () const
5416 boost::shared_ptr<PluginInsert> eq = ch_eq();
5419 return boost::shared_ptr<AutomationControl>();
5422 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5424 return boost::shared_ptr<AutomationControl>();
5429 Route::eq_band_name (uint32_t band) const
5431 if (Profile->get_mixbus()) {
5447 boost::shared_ptr<AutomationControl>
5448 Route::comp_enable_controllable () const
5451 boost::shared_ptr<PluginInsert> comp = ch_comp();
5454 return boost::shared_ptr<AutomationControl>();
5457 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 1)));
5459 return boost::shared_ptr<AutomationControl>();
5462 boost::shared_ptr<AutomationControl>
5463 Route::comp_threshold_controllable () const
5466 boost::shared_ptr<PluginInsert> comp = ch_comp();
5469 return boost::shared_ptr<AutomationControl>();
5472 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2)));
5475 return boost::shared_ptr<AutomationControl>();
5478 boost::shared_ptr<AutomationControl>
5479 Route::comp_speed_controllable () const
5482 boost::shared_ptr<PluginInsert> comp = ch_comp();
5485 return boost::shared_ptr<AutomationControl>();
5488 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 3)));
5490 return boost::shared_ptr<AutomationControl>();
5493 boost::shared_ptr<AutomationControl>
5494 Route::comp_mode_controllable () const
5497 boost::shared_ptr<PluginInsert> comp = ch_comp();
5500 return boost::shared_ptr<AutomationControl>();
5503 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 4)));
5505 return boost::shared_ptr<AutomationControl>();
5508 boost::shared_ptr<AutomationControl>
5509 Route::comp_makeup_controllable () const
5512 boost::shared_ptr<PluginInsert> comp = ch_comp();
5515 return boost::shared_ptr<AutomationControl>();
5518 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 5)));
5520 return boost::shared_ptr<AutomationControl>();
5523 boost::shared_ptr<AutomationControl>
5524 Route::comp_redux_controllable () const
5527 boost::shared_ptr<PluginInsert> comp = ch_comp();
5530 return boost::shared_ptr<AutomationControl>();
5533 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (comp->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 6)));
5535 return boost::shared_ptr<AutomationControl>();
5540 Route::comp_mode_name (uint32_t mode) const
5545 return _("Leveler");
5547 return _("Compressor");
5549 return _("Limiter");
5551 return mixbus() ? _("Sidechain") : _("Limiter");
5561 Route::comp_speed_name (uint32_t mode) const
5579 boost::shared_ptr<AutomationControl>
5580 Route::send_level_controllable (uint32_t n) const
5583 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5585 return boost::shared_ptr<AutomationControl>();
5590 return boost::shared_ptr<AutomationControl>();
5593 const uint32_t port_id = port_channel_post_aux1_level + (2*n); // gtk2_ardour/mixbus_ports.h
5594 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_id)));
5596 boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(nth_send (n));
5598 return boost::shared_ptr<AutomationControl>();
5600 return s->gain_control ();
5604 boost::shared_ptr<AutomationControl>
5605 Route::send_enable_controllable (uint32_t n) const
5608 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5610 return boost::shared_ptr<AutomationControl>();
5615 return boost::shared_ptr<AutomationControl>();
5618 const uint32_t port_id = port_channel_post_aux1_asgn + (2*n); // gtk2_ardour/mixbus_ports.h
5619 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_id)));
5621 /* although Ardour sends have enable/disable as part of the Processor
5622 API, it is not exposed as a controllable.
5624 XXX: we should fix this.
5626 return boost::shared_ptr<AutomationControl>();
5631 Route::send_name (uint32_t n) const
5637 boost::shared_ptr<Route> r = _session.get_mixbus (n);
5641 boost::shared_ptr<Processor> p = nth_send (n);
5650 boost::shared_ptr<AutomationControl>
5651 Route::master_send_enable_controllable () const
5654 boost::shared_ptr<ARDOUR::PluginInsert> plug = ch_post();
5656 return boost::shared_ptr<AutomationControl>();
5658 return boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_mstr_assign)));
5660 return boost::shared_ptr<AutomationControl>();