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.
25 #include "pbd/xml++.h"
26 #include "pbd/enumwriter.h"
27 #include "pbd/memento_command.h"
28 #include "pbd/stacktrace.h"
29 #include "pbd/convert.h"
31 #include "evoral/Curve.hpp"
33 #include "ardour/amp.h"
34 #include "ardour/audio_port.h"
35 #include "ardour/audioengine.h"
36 #include "ardour/buffer.h"
37 #include "ardour/buffer_set.h"
38 #include "ardour/configuration.h"
39 #include "ardour/cycle_timer.h"
40 #include "ardour/debug.h"
41 #include "ardour/delivery.h"
42 #include "ardour/dB.h"
43 #include "ardour/internal_send.h"
44 #include "ardour/internal_return.h"
45 #include "ardour/ladspa_plugin.h"
46 #include "ardour/meter.h"
47 #include "ardour/mix.h"
48 #include "ardour/monitor_processor.h"
49 #include "ardour/panner.h"
50 #include "ardour/plugin_insert.h"
51 #include "ardour/port.h"
52 #include "ardour/port_insert.h"
53 #include "ardour/processor.h"
54 #include "ardour/profile.h"
55 #include "ardour/route.h"
56 #include "ardour/route_group.h"
57 #include "ardour/send.h"
58 #include "ardour/session.h"
59 #include "ardour/timestamps.h"
60 #include "ardour/utils.h"
65 using namespace ARDOUR;
68 uint32_t Route::order_key_cnt = 0;
69 PBD::Signal1<void,string const&> Route::SyncOrderKeys;
70 PBD::Signal0<void> Route::RemoteControlIDChange;
72 Route::Route (Session& sess, string name, Flag flg, DataType default_type)
73 : SessionObject (sess, name)
74 , AutomatableControls (sess)
79 , _pending_declick (true)
80 , _meter_point (MeterPostFader)
83 , _soloed_by_others (0)
85 , _denormal_protection (false)
88 , _declickable (false)
89 , _solo_control (new SoloControllable (X_("solo"), *this))
90 , _mute_control (new MuteControllable (X_("mute"), *this))
91 , _mute_master (new MuteMaster (sess, name))
92 , _mute_points (MuteMaster::AllPoints)
93 , _have_internal_generator (false)
95 , _default_type (default_type)
96 , _remote_control_id (0)
97 , _in_configure_processors (false)
99 processor_max_streams.reset();
100 order_keys[N_("signal")] = order_key_cnt++;
106 /* add standard controls */
108 _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
109 _mute_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
111 add_control (_solo_control);
112 add_control (_mute_control);
114 /* input and output objects */
116 _input.reset (new IO (_session, _name, IO::Input, _default_type));
117 _output.reset (new IO (_session, _name, IO::Output, _default_type));
119 _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2));
120 _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
122 /* add amp processor */
124 _amp.reset (new Amp (_session, _mute_master));
125 add_processor (_amp, PostFader);
127 /* add standard processors: meter, main outs, monitor out */
129 _meter.reset (new PeakMeter (_session));
130 _meter->set_display_to_user (false);
132 add_processor (_meter, PostFader);
134 _main_outs.reset (new Delivery (_session, _output, _mute_master, _name, Delivery::Main));
136 add_processor (_main_outs, PostFader);
139 /* where we listen to tracks */
140 _intreturn.reset (new InternalReturn (_session));
141 add_processor (_intreturn, PreFader);
143 ProcessorList::iterator i;
145 for (i = _processors.begin(); i != _processors.end(); ++i) {
146 if (*i == _intreturn) {
152 /* the thing that provides proper control over a control/monitor/listen bus
153 (such as per-channel cut, dim, solo, invert, etc).
154 It always goes right after the internal return;
156 _monitor_control.reset (new MonitorProcessor (_session));
157 add_processor (_monitor_control, i);
159 /* no panning on the monitor main outs */
161 _main_outs->panner()->set_bypassed (true);
164 markup_solo_ignore ();
166 /* now that we have _meter, its safe to connect to this */
168 Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this)));
175 DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
177 /* do this early so that we don't get incoming signals as we are going through destruction
182 /* don't use clear_processors here, as it depends on the session which may
183 be half-destroyed by now
186 Glib::RWLock::WriterLock lm (_processor_lock);
187 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
188 (*i)->drop_references ();
191 _processors.clear ();
195 Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
197 if (id != _remote_control_id) {
198 _remote_control_id = id;
199 RemoteControlIDChanged ();
200 if (notify_class_listeners) {
201 RemoteControlIDChange ();
207 Route::remote_control_id() const
209 return _remote_control_id;
213 Route::order_key (std::string const & name) const
215 OrderKeys::const_iterator i = order_keys.find (name);
216 if (i == order_keys.end()) {
224 Route::set_order_key (std::string const & name, long n)
226 order_keys[name] = n;
228 if (Config->get_sync_all_route_ordering()) {
229 for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
234 _session.set_dirty ();
237 /** Set all order keys to be the same as that for `base', if such a key
238 * exists in this route.
239 * @param base Base key.
242 Route::sync_order_keys (std::string const & base)
244 if (order_keys.empty()) {
248 OrderKeys::iterator i;
251 if ((i = order_keys.find (base)) == order_keys.end()) {
252 /* key doesn't exist, use the first existing key (during session initialization) */
253 i = order_keys.begin();
257 /* key exists - use it and reset all others (actually, itself included) */
259 i = order_keys.begin();
262 for (; i != order_keys.end(); ++i) {
268 Route::ensure_track_or_route_name(string name, Session &session)
270 string newname = name;
272 while (session.route_by_name (newname) != NULL) {
273 newname = bump_name_once (newname);
281 Route::inc_gain (gain_t fraction, void *src)
283 _amp->inc_gain (fraction, src);
287 Route::set_gain (gain_t val, void *src)
289 if (src != 0 && _route_group && src != _route_group && _route_group->is_active() && _route_group->is_gain()) {
291 if (_route_group->is_relative()) {
293 gain_t usable_gain = _amp->gain();
294 if (usable_gain < 0.000001f) {
295 usable_gain = 0.000001f;
299 if (delta < 0.000001f) {
303 delta -= usable_gain;
308 gain_t factor = delta / usable_gain;
311 factor = _route_group->get_max_factor(factor);
312 if (factor == 0.0f) {
313 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
317 factor = _route_group->get_min_factor(factor);
318 if (factor == 0.0f) {
319 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
324 _route_group->apply (&Route::inc_gain, factor, _route_group);
328 _route_group->apply (&Route::set_gain, val, _route_group);
334 if (val == _amp->gain()) {
338 _amp->set_gain (val, src);
341 /** Process this route for one (sub) cycle (process thread)
343 * @param bufs Scratch buffers to use for the signal path
344 * @param start_frame Initial transport frame
345 * @param end_frame Final transport frame
346 * @param nframes Number of frames to output (to ports)
348 * Note that (end_frame - start_frame) may not be equal to nframes when the
349 * transport speed isn't 1.0 (eg varispeed).
352 Route::process_output_buffers (BufferSet& bufs,
353 sframes_t start_frame, sframes_t end_frame, nframes_t nframes,
354 bool /*with_processors*/, int declick)
358 bufs.is_silent (false);
360 switch (Config->get_monitoring_model()) {
361 case HardwareMonitoring:
362 case ExternalMonitoring:
363 monitor = !record_enabled() || (_session.config.get_auto_input() && !_session.actively_recording());
370 declick = _pending_declick;
373 /* figure out if we're going to use gain automation */
374 _amp->setup_gain_automation (start_frame, end_frame, nframes);
377 /* tell main outs what to do about monitoring */
378 _main_outs->no_outs_cuz_we_no_monitor (!monitor);
381 /* -------------------------------------------------------------------------------------------
382 GLOBAL DECLICK (for transport changes etc.)
383 ----------------------------------------------------------------------------------------- */
386 Amp::apply_gain (bufs, nframes, 0.0, 1.0);
387 } else if (declick < 0) {
388 Amp::apply_gain (bufs, nframes, 1.0, 0.0);
391 _pending_declick = 0;
393 /* -------------------------------------------------------------------------------------------
394 DENORMAL CONTROL/PHASE INVERT
395 ----------------------------------------------------------------------------------------- */
401 if (_denormal_protection || Config->get_denormal_protection()) {
403 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
404 Sample* const sp = i->data();
406 if (_phase_invert & chn) {
407 for (nframes_t nx = 0; nx < nframes; ++nx) {
412 for (nframes_t nx = 0; nx < nframes; ++nx) {
420 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
421 Sample* const sp = i->data();
423 if (_phase_invert & (1<<chn)) {
424 for (nframes_t nx = 0; nx < nframes; ++nx) {
433 if (_denormal_protection || Config->get_denormal_protection()) {
435 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
436 Sample* const sp = i->data();
437 for (nframes_t nx = 0; nx < nframes; ++nx) {
445 /* -------------------------------------------------------------------------------------------
447 ----------------------------------------------------------------------------------------- */
449 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
452 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
454 if (bufs.count() != (*i)->input_streams()) {
455 cerr << _name << " bufs = " << bufs.count()
456 << " input for " << (*i)->name() << " = " << (*i)->input_streams()
459 assert (bufs.count() == (*i)->input_streams());
461 (*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back());
462 bufs.set_count ((*i)->output_streams());
468 Route::n_process_buffers ()
470 return max (_input->n_ports(), processor_max_streams);
474 Route::passthru (sframes_t start_frame, sframes_t end_frame, nframes_t nframes, int declick)
476 BufferSet& bufs = _session.get_scratch_buffers (n_process_buffers());
480 assert (bufs.available() >= input_streams());
482 if (_input->n_ports() == ChanCount::ZERO) {
486 bufs.set_count (input_streams());
488 if (is_monitor() && _session.listening() && !_session.is_auditioning()) {
490 /* control/monitor bus ignores input ports when something is
491 feeding the listen "stream". data will "arrive" into the
492 route from the intreturn processor element.
494 bufs.silence (nframes, 0);
498 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
500 BufferSet::iterator o = bufs.begin(*t);
501 PortSet& ports (_input->ports());
503 for (PortSet::iterator i = ports.begin(*t); i != ports.end(*t); ++i, ++o) {
504 o->read_from (i->get_buffer(nframes), nframes);
509 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
510 process_output_buffers (bufs, start_frame, end_frame, nframes, true, declick);
514 Route::passthru_silence (sframes_t start_frame, sframes_t end_frame, nframes_t nframes, int declick)
516 BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
517 bufs.set_count (_input->n_ports());
518 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
519 process_output_buffers (bufs, start_frame, end_frame, nframes, true, declick);
523 Route::set_listen (bool yn, void* src)
530 if (yn != _monitor_send->active()) {
532 _monitor_send->set_solo_level (1);
533 _monitor_send->activate ();
535 _monitor_send->set_solo_level (0);
536 _monitor_send->deactivate ();
539 listen_changed (src); /* EMIT SIGNAL */
545 Route::listening () const
548 return _monitor_send->active ();
555 Route::set_solo_safe (bool yn, void *src)
557 if (_solo_safe != yn) {
559 solo_safe_changed (src);
564 Route::solo_safe() const
570 Route::set_solo (bool yn, void *src)
576 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
577 _route_group->apply (&Route::set_solo, yn, _route_group);
581 if (self_soloed() != yn) {
583 set_delivery_solo ();
584 solo_changed (src); /* EMIT SIGNAL */
585 _solo_control->Changed (); /* EMIT SIGNAL */
590 Route::set_self_solo (bool yn)
596 Route::mod_solo_by_others (int32_t delta)
603 if (_soloed_by_others >= (uint32_t) abs (delta)) {
604 _soloed_by_others += delta;
606 _soloed_by_others = 0;
609 _soloed_by_others += delta;
612 set_delivery_solo ();
617 Route::set_delivery_solo ()
619 /* tell all delivery processors what the solo situation is, so that they keep
620 delivering even though Session::soloing() is true and they were not
624 Glib::RWLock::ReaderLock rm (_processor_lock);
625 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
626 boost::shared_ptr<Delivery> d;
628 if ((d = boost::dynamic_pointer_cast<Delivery> (*i)) != 0) {
629 d->set_solo_level (soloed ());
630 d->set_solo_isolated (solo_isolated());
636 Route::set_solo_isolated (bool yn, void *src)
638 if (is_master() || is_monitor() || is_hidden()) {
642 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
643 _route_group->apply (&Route::set_solo_isolated, yn, _route_group);
647 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
649 boost::shared_ptr<RouteList> routes = _session.get_routes ();
650 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
652 bool does_feed = feeds (*i, &sends_only);
654 if (does_feed && !sends_only) {
655 (*i)->set_solo_isolated (yn, (*i)->route_group());
659 /* XXX should we back-propagate as well? */
661 bool changed = false;
664 if (_solo_isolated == 0) {
669 changed = (_solo_isolated == 1);
670 if (_solo_isolated > 0) {
676 set_delivery_solo ();
677 solo_isolated_changed (src);
682 Route::solo_isolated () const
684 return _solo_isolated > 0;
688 Route::set_mute_points (MuteMaster::MutePoint mp)
691 mute_points_changed (); /* EMIT SIGNAL */
693 if (_mute_master->muted()) {
694 _mute_master->mute_at (_mute_points);
695 mute_changed (this); /* EMIT SIGNAL */
700 Route::set_mute (bool yn, void *src)
702 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_mute()) {
703 _route_group->apply (&Route::set_mute, yn, _route_group);
709 _mute_master->mute_at (_mute_points);
711 _mute_master->clear_mute ();
714 mute_changed (src); /* EMIT SIGNAL */
721 return _mute_master->muted ();
726 dump_processors(const string& name, const list<boost::shared_ptr<Processor> >& procs)
728 cerr << name << " {" << endl;
729 for (list<boost::shared_ptr<Processor> >::const_iterator p = procs.begin();
730 p != procs.end(); ++p) {
731 cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << endl;
738 Route::add_processor (boost::shared_ptr<Processor> processor, Placement placement, ProcessorStreams* err)
740 ProcessorList::iterator loc;
742 /* XXX this is not thread safe - we don't hold the lock across determining the iter
743 to add before and actually doing the insertion. dammit.
746 if (placement == PreFader) {
747 /* generic pre-fader: insert immediately before the amp */
748 loc = find (_processors.begin(), _processors.end(), _amp);
750 /* generic post-fader: insert right before the main outs */
751 loc = find (_processors.begin(), _processors.end(), _main_outs);
754 return add_processor (processor, loc, err);
758 /** Add a processor to the route.
759 * @a iter must point to an iterator in _processors and the new
760 * processor will be inserted immediately before this location. Otherwise,
761 * @a position is used.
764 Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::iterator iter, ProcessorStreams* err, bool activation_allowed)
766 ChanCount old_pms = processor_max_streams;
768 if (!_session.engine().connected() || !processor) {
773 Glib::RWLock::WriterLock lm (_processor_lock);
775 boost::shared_ptr<PluginInsert> pi;
776 boost::shared_ptr<PortInsert> porti;
778 ProcessorList::iterator loc = find(_processors.begin(), _processors.end(), processor);
780 if (processor == _amp || processor == _meter || processor == _main_outs) {
781 // Ensure only one of these are in the list at any time
782 if (loc != _processors.end()) {
783 if (iter == loc) { // Already in place, do nothing
785 } else { // New position given, relocate
786 _processors.erase (loc);
791 if (loc != _processors.end()) {
792 cerr << "ERROR: Processor added to route twice!" << endl;
799 _processors.insert (loc, processor);
801 // Set up processor list channels. This will set processor->[input|output]_streams(),
802 // configure redirect ports properly, etc.
804 if (configure_processors_unlocked (err)) {
805 ProcessorList::iterator ploc = loc;
807 _processors.erase(ploc);
808 configure_processors_unlocked (0); // it worked before we tried to add it ...
809 cerr << "configure failed\n";
813 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
815 if (pi->natural_input_streams() == ChanCount::ZERO) {
816 /* generator plugin */
817 _have_internal_generator = true;
822 /* is this the monitor send ? if so, make sure we keep track of it */
824 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
826 if (isend && _session.monitor_out() && (isend->target_id() == _session.monitor_out()->id())) {
827 _monitor_send = isend;
829 if (_monitor_send->active()) {
830 _monitor_send->set_solo_level (1);
832 _monitor_send->set_solo_level (0);
836 if (activation_allowed && (processor != _monitor_send)) {
837 processor->activate ();
840 processor->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false));
842 _output->set_user_latency (0);
845 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
851 Route::add_processor_from_xml_2X (const XMLNode& node, int version, ProcessorList::iterator iter)
853 const XMLProperty *prop;
856 boost::shared_ptr<Processor> processor;
858 if (node.name() == "Insert") {
860 if ((prop = node.property ("type")) != 0) {
862 if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
863 prop->value() == "lv2" ||
864 prop->value() == "vst" ||
865 prop->value() == "audiounit") {
867 processor.reset (new PluginInsert (_session));
871 processor.reset (new PortInsert (_session, _mute_master));
876 } else if (node.name() == "Send") {
878 processor.reset (new Send (_session, _mute_master));
882 error << string_compose(_("unknown Processor type \"%1\"; ignored"), node.name()) << endmsg;
886 if (processor->set_state (node, version)) {
890 if (iter == _processors.end() && processor->display_to_user() && !_processors.empty()) {
891 /* check for invisible processors stacked at the end and leave them there */
892 ProcessorList::iterator p;
893 p = _processors.end();
895 while (!(*p)->display_to_user() && p != _processors.begin()) {
902 return (add_processor (processor, iter) == 0);
905 catch (failed_constructor &err) {
906 warning << _("processor could not be created. Ignored.") << endmsg;
912 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
914 ProcessorList::iterator loc;
917 loc = find(_processors.begin(), _processors.end(), before);
919 /* nothing specified - at end but before main outs */
920 loc = find (_processors.begin(), _processors.end(), _main_outs);
923 return add_processors (others, loc, err);
927 Route::add_processors (const ProcessorList& others, ProcessorList::iterator iter, ProcessorStreams* err)
929 /* NOTE: this is intended to be used ONLY when copying
930 processors from another Route. Hence the subtle
931 differences between this and ::add_processor()
934 ChanCount old_pms = processor_max_streams;
936 if (!_session.engine().connected()) {
940 if (others.empty()) {
945 Glib::RWLock::WriterLock lm (_processor_lock);
947 ChanCount potential_max_streams = ChanCount::max (_input->n_ports(), _output->n_ports());
949 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
951 // Ensure meter only appears in the list once
953 ProcessorList::iterator m = find(_processors.begin(), _processors.end(), *i);
954 if (m != _processors.end()) {
955 _processors.erase(m);
959 boost::shared_ptr<PluginInsert> pi;
961 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
964 ChanCount m = max (pi->input_streams(), pi->output_streams());
966 if (m > potential_max_streams) {
967 potential_max_streams = m;
971 ProcessorList::iterator inserted = _processors.insert (iter, *i);
973 if ((*i)->active()) {
977 if (configure_processors_unlocked (err)) {
978 _processors.erase (inserted);
979 configure_processors_unlocked (0); // it worked before we tried to add it ...
983 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false));
986 _output->set_user_latency (0);
989 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
995 Route::placement_range(Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end)
998 start = _processors.begin();
999 end = find(_processors.begin(), _processors.end(), _amp);
1001 start = find(_processors.begin(), _processors.end(), _amp);
1003 end = _processors.end();
1007 /** Turn off all processors with a given placement
1008 * @param p Placement of processors to disable
1011 Route::disable_processors (Placement p)
1013 Glib::RWLock::ReaderLock lm (_processor_lock);
1015 ProcessorList::iterator start, end;
1016 placement_range(p, start, end);
1018 for (ProcessorList::iterator i = start; i != end; ++i) {
1019 (*i)->deactivate ();
1022 _session.set_dirty ();
1025 /** Turn off all redirects
1028 Route::disable_processors ()
1030 Glib::RWLock::ReaderLock lm (_processor_lock);
1032 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1033 (*i)->deactivate ();
1036 _session.set_dirty ();
1039 /** Turn off all redirects with a given placement
1040 * @param p Placement of redirects to disable
1043 Route::disable_plugins (Placement p)
1045 Glib::RWLock::ReaderLock lm (_processor_lock);
1047 ProcessorList::iterator start, end;
1048 placement_range(p, start, end);
1050 for (ProcessorList::iterator i = start; i != end; ++i) {
1051 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1052 (*i)->deactivate ();
1056 _session.set_dirty ();
1059 /** Turn off all plugins
1062 Route::disable_plugins ()
1064 Glib::RWLock::ReaderLock lm (_processor_lock);
1066 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1067 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1068 (*i)->deactivate ();
1072 _session.set_dirty ();
1077 Route::ab_plugins (bool forward)
1079 Glib::RWLock::ReaderLock lm (_processor_lock);
1083 /* forward = turn off all active redirects, and mark them so that the next time
1084 we go the other way, we will revert them
1087 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1088 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1092 if ((*i)->active()) {
1093 (*i)->deactivate ();
1094 (*i)->set_next_ab_is_active (true);
1096 (*i)->set_next_ab_is_active (false);
1102 /* backward = if the redirect was marked to go active on the next ab, do so */
1104 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1106 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1110 if ((*i)->get_next_ab_is_active()) {
1113 (*i)->deactivate ();
1118 _session.set_dirty ();
1122 /** Remove processors with a given placement.
1123 * @param p Placement of processors to remove.
1126 Route::clear_processors (Placement p)
1128 const ChanCount old_pms = processor_max_streams;
1130 if (!_session.engine().connected()) {
1134 bool already_deleting = _session.deletion_in_progress();
1135 if (!already_deleting) {
1136 _session.set_deletion_in_progress();
1140 Glib::RWLock::WriterLock lm (_processor_lock);
1141 ProcessorList new_list;
1142 ProcessorStreams err;
1143 bool seen_amp = false;
1145 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1151 if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs) {
1153 /* you can't remove these */
1155 new_list.push_back (*i);
1162 new_list.push_back (*i);
1165 (*i)->drop_references ();
1173 (*i)->drop_references ();
1176 new_list.push_back (*i);
1183 _processors = new_list;
1184 configure_processors_unlocked (&err); // this can't fail
1187 processor_max_streams.reset();
1188 _have_internal_generator = false;
1189 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1191 if (!already_deleting) {
1192 _session.clear_deletion_in_progress();
1197 Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStreams* err)
1199 /* these can never be removed */
1201 if (processor == _amp || processor == _meter || processor == _main_outs) {
1205 ChanCount old_pms = processor_max_streams;
1207 if (!_session.engine().connected()) {
1211 processor_max_streams.reset();
1214 Glib::RWLock::WriterLock lm (_processor_lock);
1215 ProcessorList::iterator i;
1216 bool removed = false;
1218 for (i = _processors.begin(); i != _processors.end(); ) {
1219 if (*i == processor) {
1221 /* move along, see failure case for configure_processors()
1222 where we may need to reconfigure the processor.
1225 /* stop redirects that send signals to JACK ports
1226 from causing noise as a result of no longer being
1230 boost::shared_ptr<IOProcessor> iop;
1232 if ((iop = boost::dynamic_pointer_cast<IOProcessor> (*i)) != 0) {
1234 iop->input()->disconnect (this);
1236 if (iop->output()) {
1237 iop->output()->disconnect (this);
1241 i = _processors.erase (i);
1249 _output->set_user_latency (0);
1257 if (configure_processors_unlocked (err)) {
1258 /* get back to where we where */
1259 _processors.insert (i, processor);
1260 /* we know this will work, because it worked before :) */
1261 configure_processors_unlocked (0);
1265 _have_internal_generator = false;
1267 for (i = _processors.begin(); i != _processors.end(); ++i) {
1268 boost::shared_ptr<PluginInsert> pi;
1270 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1271 if (pi->is_generator()) {
1272 _have_internal_generator = true;
1279 processor->drop_references ();
1280 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1286 Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err)
1288 ProcessorList deleted;
1290 if (!_session.engine().connected()) {
1294 processor_max_streams.reset();
1297 Glib::RWLock::WriterLock lm (_processor_lock);
1298 ProcessorList::iterator i;
1299 boost::shared_ptr<Processor> processor;
1301 ProcessorList as_we_were = _processors;
1303 for (i = _processors.begin(); i != _processors.end(); ) {
1307 /* these can never be removed */
1309 if (processor == _amp || processor == _meter || processor == _main_outs) {
1314 /* see if its in the list of processors to delete */
1316 if (find (to_be_deleted.begin(), to_be_deleted.end(), processor) == to_be_deleted.end()) {
1321 /* stop IOProcessors that send to JACK ports
1322 from causing noise as a result of no longer being
1326 boost::shared_ptr<IOProcessor> iop;
1328 if ((iop = boost::dynamic_pointer_cast<IOProcessor> (processor)) != 0) {
1332 deleted.push_back (processor);
1333 i = _processors.erase (i);
1336 if (deleted.empty()) {
1337 /* none of those in the requested list were found */
1341 _output->set_user_latency (0);
1343 if (configure_processors_unlocked (err)) {
1344 /* get back to where we where */
1345 _processors = as_we_were;
1346 /* we know this will work, because it worked before :) */
1347 configure_processors_unlocked (0);
1351 _have_internal_generator = false;
1353 for (i = _processors.begin(); i != _processors.end(); ++i) {
1354 boost::shared_ptr<PluginInsert> pi;
1356 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1357 if (pi->is_generator()) {
1358 _have_internal_generator = true;
1365 /* now try to do what we need to so that those that were removed will be deleted */
1367 for (ProcessorList::iterator i = deleted.begin(); i != deleted.end(); ++i) {
1368 (*i)->drop_references ();
1371 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1378 Route::configure_processors (ProcessorStreams* err)
1380 if (!_in_configure_processors) {
1381 Glib::RWLock::WriterLock lm (_processor_lock);
1382 return configure_processors_unlocked (err);
1388 Route::input_streams () const
1390 return _input->n_ports ();
1393 /** Configure the input/output configuration of each processor in the processors list.
1394 * Return 0 on success, otherwise configuration is impossible.
1397 Route::configure_processors_unlocked (ProcessorStreams* err)
1399 if (_in_configure_processors) {
1403 _in_configure_processors = true;
1405 // Check each processor in order to see if we can configure as requested
1406 ChanCount in = input_streams ();
1408 list< pair<ChanCount,ChanCount> > configuration;
1411 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configure processors\n", _name));
1413 DEBUG_TRACE (DEBUG::Processors, "{\n");
1414 for (list<boost::shared_ptr<Processor> >::const_iterator p = _processors.begin(); p != _processors.end(); ++p) {
1415 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1 ID = %2\n", (*p)->name(), (*p)->id()));
1417 DEBUG_TRACE (DEBUG::Processors, "}\n");
1420 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++index) {
1422 if ((*p)->can_support_io_configuration(in, out)) {
1423 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1in = %2 out = %3\n",(*p)->name(), in, out));
1424 configuration.push_back(make_pair(in, out));
1431 _in_configure_processors = false;
1436 // We can, so configure everything
1437 list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
1438 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
1439 (*p)->configure_io(c->first, c->second);
1440 processor_max_streams = ChanCount::max(processor_max_streams, c->first);
1441 processor_max_streams = ChanCount::max(processor_max_streams, c->second);
1446 _meter->reset_max_channels (processor_max_streams);
1449 /* make sure we have sufficient scratch buffers to cope with the new processor
1451 _session.ensure_buffers (n_process_buffers ());
1453 _in_configure_processors = false;
1458 Route::all_processors_flip ()
1460 Glib::RWLock::ReaderLock lm (_processor_lock);
1462 if (_processors.empty()) {
1466 bool first_is_on = _processors.front()->active();
1468 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1470 (*i)->deactivate ();
1476 _session.set_dirty ();
1479 /** Set all processors with a given placement to a given active state.
1480 * @param p Placement of processors to change.
1481 * @param state New active state for those processors.
1484 Route::all_processors_active (Placement p, bool state)
1486 Glib::RWLock::ReaderLock lm (_processor_lock);
1488 if (_processors.empty()) {
1491 ProcessorList::iterator start, end;
1492 placement_range(p, start, end);
1494 bool before_amp = true;
1495 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1500 if (p == PreFader && before_amp) {
1504 (*i)->deactivate ();
1509 _session.set_dirty ();
1513 Route::processor_is_prefader (boost::shared_ptr<Processor> p)
1515 bool pre_fader = true;
1516 Glib::RWLock::ReaderLock lm (_processor_lock);
1518 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1520 /* semantic note: if p == amp, we want to return true, so test
1521 for equality before checking if this is the amp
1538 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
1540 /* "new_order" is an ordered list of processors to be positioned according to "placement".
1541 NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
1542 processors in the current actual processor list that are hidden. Any visible processors
1543 in the current list but not in "new_order" will be assumed to be deleted.
1547 Glib::RWLock::WriterLock lm (_processor_lock);
1548 ChanCount old_pms = processor_max_streams;
1549 ProcessorList::iterator oiter;
1550 ProcessorList::const_iterator niter;
1551 ProcessorList as_it_was_before = _processors;
1552 ProcessorList as_it_will_be;
1554 oiter = _processors.begin();
1555 niter = new_order.begin();
1557 while (niter != new_order.end()) {
1559 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
1560 then append it to the temp list.
1562 Otherwise, see if the next processor in the old list is in the new list. if not,
1563 its been deleted. If its there, append it to the temp list.
1566 if (oiter == _processors.end()) {
1568 /* no more elements in the old list, so just stick the rest of
1569 the new order onto the temp list.
1572 as_it_will_be.insert (as_it_will_be.end(), niter, new_order.end());
1573 while (niter != new_order.end()) {
1580 if (!(*oiter)->display_to_user()) {
1582 as_it_will_be.push_back (*oiter);
1586 /* visible processor: check that its in the new order */
1588 if (find (new_order.begin(), new_order.end(), (*oiter)) == new_order.end()) {
1589 /* deleted: do nothing, shared_ptr<> will clean up */
1591 /* ignore this one, and add the next item from the new order instead */
1592 as_it_will_be.push_back (*niter);
1597 /* now remove from old order - its taken care of no matter what */
1598 oiter = _processors.erase (oiter);
1603 _processors.insert (oiter, as_it_will_be.begin(), as_it_will_be.end());
1605 if (configure_processors_unlocked (err)) {
1606 _processors = as_it_was_before;
1607 processor_max_streams = old_pms;
1613 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1626 Route::get_template()
1628 return state(false);
1632 Route::state(bool full_state)
1634 XMLNode *node = new XMLNode("Route");
1635 ProcessorList::iterator i;
1638 id().print (buf, sizeof (buf));
1639 node->add_property("id", buf);
1640 node->add_property ("name", _name);
1641 node->add_property("default-type", _default_type.to_string());
1644 node->add_property("flags", enum_2_string (_flags));
1647 node->add_property("active", _active?"yes":"no");
1648 node->add_property("phase-invert", _phase_invert?"yes":"no");
1649 node->add_property("denormal-protection", _denormal_protection?"yes":"no");
1650 node->add_property("meter-point", enum_2_string (_meter_point));
1653 node->add_property("route-group", _route_group->name());
1656 string order_string;
1657 OrderKeys::iterator x = order_keys.begin();
1659 while (x != order_keys.end()) {
1660 order_string += string ((*x).first);
1661 order_string += '=';
1662 snprintf (buf, sizeof(buf), "%ld", (*x).second);
1663 order_string += buf;
1667 if (x == order_keys.end()) {
1671 order_string += ':';
1673 node->add_property ("order-keys", order_string);
1674 node->add_property ("self-solo", (_self_solo ? "yes" : "no"));
1675 snprintf (buf, sizeof (buf), "%d", _soloed_by_others);
1676 node->add_property ("soloed-by-others", buf);
1678 node->add_child_nocopy (_input->state (full_state));
1679 node->add_child_nocopy (_output->state (full_state));
1680 node->add_child_nocopy (_solo_control->get_state ());
1681 node->add_child_nocopy (_mute_master->get_state ());
1683 XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
1684 snprintf (buf, sizeof (buf), "%d", _remote_control_id);
1685 remote_control_node->add_property (X_("id"), buf);
1686 node->add_child_nocopy (*remote_control_node);
1688 if (_comment.length()) {
1689 XMLNode *cmt = node->add_child ("Comment");
1690 cmt->add_content (_comment);
1693 for (i = _processors.begin(); i != _processors.end(); ++i) {
1694 node->add_child_nocopy((*i)->state (full_state));
1698 node->add_child_copy (*_extra_xml);
1705 Route::set_state (const XMLNode& node, int version)
1707 return _set_state (node, version, true);
1711 Route::_set_state (const XMLNode& node, int version, bool /*call_base*/)
1713 if (version < 3000) {
1714 return _set_state_2X (node, version);
1718 XMLNodeConstIterator niter;
1720 XMLPropertyList plist;
1721 const XMLProperty *prop;
1723 if (node.name() != "Route"){
1724 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1728 if ((prop = node.property (X_("name"))) != 0) {
1729 Route::set_name (prop->value());
1732 if ((prop = node.property ("id")) != 0) {
1733 _id = prop->value ();
1736 if ((prop = node.property (X_("flags"))) != 0) {
1737 _flags = Flag (string_2_enum (prop->value(), _flags));
1742 /* add all processors (except amp, which is always present) */
1744 nlist = node.children();
1745 XMLNode processor_state (X_("processor_state"));
1747 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1751 if (child->name() == IO::state_node_name) {
1752 if ((prop = child->property (X_("direction"))) == 0) {
1756 if (prop->value() == "Input") {
1757 _input->set_state (*child, version);
1758 } else if (prop->value() == "Output") {
1759 _output->set_state (*child, version);
1763 if (child->name() == X_("Processor")) {
1764 processor_state.add_child_copy (*child);
1768 set_processor_state (processor_state);
1770 if ((prop = node.property ("self-solo")) != 0) {
1771 set_self_solo (string_is_affirmative (prop->value()));
1774 if ((prop = node.property ("soloed-by-others")) != 0) {
1775 _soloed_by_others = 0; // needed for mod_solo_by_others () to work
1776 mod_solo_by_others (atoi (prop->value()));
1779 if ((prop = node.property ("solo-isolated")) != 0) {
1780 set_solo_isolated (string_is_affirmative (prop->value()), this);
1783 if ((prop = node.property (X_("phase-invert"))) != 0) {
1784 set_phase_invert (string_is_affirmative (prop->value()));
1787 if ((prop = node.property (X_("denormal-protection"))) != 0) {
1788 set_denormal_protection (string_is_affirmative (prop->value()));
1791 if ((prop = node.property (X_("active"))) != 0) {
1792 bool yn = string_is_affirmative (prop->value());
1793 _active = !yn; // force switch
1797 if ((prop = node.property (X_("meter-point"))) != 0) {
1798 MeterPoint mp = MeterPoint (string_2_enum (prop->value (), _meter_point));
1799 set_meter_point (mp);
1801 _meter->set_display_to_user (_meter_point == MeterCustom);
1805 if ((prop = node.property (X_("order-keys"))) != 0) {
1809 string::size_type colon, equal;
1810 string remaining = prop->value();
1812 while (remaining.length()) {
1814 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
1815 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1818 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
1819 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1822 set_order_key (remaining.substr (0, equal), n);
1826 colon = remaining.find_first_of (':');
1828 if (colon != string::npos) {
1829 remaining = remaining.substr (colon+1);
1836 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1839 if (child->name() == X_("Comment")) {
1841 /* XXX this is a terrible API design in libxml++ */
1843 XMLNode *cmt = *(child->children().begin());
1844 _comment = cmt->content();
1846 } else if (child->name() == X_("Extra")) {
1848 _extra_xml = new XMLNode (*child);
1850 } else if (child->name() == X_("Controllable") && (prop = child->property("name")) != 0) {
1852 if (prop->value() == "solo") {
1853 _solo_control->set_state (*child, version);
1854 _session.add_controllable (_solo_control);
1857 } else if (child->name() == X_("RemoteControl")) {
1858 if ((prop = child->property (X_("id"))) != 0) {
1860 sscanf (prop->value().c_str(), "%d", &x);
1861 set_remote_control_id (x);
1864 } else if (child->name() == X_("MuteMaster")) {
1865 _mute_master->set_state (*child, version);
1873 Route::_set_state_2X (const XMLNode& node, int version)
1876 XMLNodeConstIterator niter;
1878 XMLPropertyList plist;
1879 const XMLProperty *prop;
1881 /* 2X things which still remain to be handled:
1887 if (node.name() != "Route") {
1888 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1892 if ((prop = node.property (X_("flags"))) != 0) {
1893 _flags = Flag (string_2_enum (prop->value(), _flags));
1898 if ((prop = node.property (X_("phase-invert"))) != 0) {
1899 set_phase_invert (string_is_affirmative (prop->value()));
1902 if ((prop = node.property (X_("denormal-protection"))) != 0) {
1903 set_denormal_protection (string_is_affirmative (prop->value()));
1906 if ((prop = node.property (X_("soloed"))) != 0) {
1907 bool yn = string_is_affirmative (prop->value());
1909 /* XXX force reset of solo status */
1911 set_solo (yn, this);
1914 if ((prop = node.property (X_("muted"))) != 0) {
1917 bool muted = string_is_affirmative (prop->value());
1923 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
1925 if (string_is_affirmative (prop->value())){
1926 mute_point = mute_point + "PreFader";
1931 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
1933 if (string_is_affirmative (prop->value())){
1936 mute_point = mute_point + ",";
1939 mute_point = mute_point + "PostFader";
1944 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
1946 if (string_is_affirmative (prop->value())){
1949 mute_point = mute_point + ",";
1952 mute_point = mute_point + "Listen";
1957 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
1959 if (string_is_affirmative (prop->value())){
1962 mute_point = mute_point + ",";
1965 mute_point = mute_point + "Main";
1969 _mute_master->set_state (mute_point);
1973 if ((prop = node.property (X_("meter-point"))) != 0) {
1974 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
1977 /* do not carry over edit/mix groups from 2.X because (a) its hard (b) they
1978 don't mean the same thing.
1981 if ((prop = node.property (X_("order-keys"))) != 0) {
1985 string::size_type colon, equal;
1986 string remaining = prop->value();
1988 while (remaining.length()) {
1990 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
1991 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1994 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
1995 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1998 set_order_key (remaining.substr (0, equal), n);
2002 colon = remaining.find_first_of (':');
2004 if (colon != string::npos) {
2005 remaining = remaining.substr (colon+1);
2012 /* add standard processors */
2014 //_meter.reset (new PeakMeter (_session));
2015 //add_processor (_meter, PreFader);
2018 /* where we listen to tracks */
2019 _intreturn.reset (new InternalReturn (_session));
2020 add_processor (_intreturn, PreFader);
2022 _monitor_control.reset (new MonitorProcessor (_session));
2023 add_processor (_monitor_control, PostFader);
2026 _main_outs.reset (new Delivery (_session, _output, _mute_master, _name, Delivery::Main));
2027 add_processor (_main_outs, PostFader);
2031 nlist = node.children ();
2032 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2036 if (child->name() == IO::state_node_name) {
2038 /* there is a note in IO::set_state_2X() about why we have to call
2042 _input->set_state_2X (*child, version, true);
2043 _output->set_state_2X (*child, version, false);
2045 if ((prop = child->property (X_("name"))) != 0) {
2046 Route::set_name (prop->value ());
2049 if ((prop = child->property (X_("id"))) != 0) {
2050 _id = prop->value ();
2053 if ((prop = child->property (X_("active"))) != 0) {
2054 bool yn = string_is_affirmative (prop->value());
2055 _active = !yn; // force switch
2059 if ((prop = child->property (X_("gain"))) != 0) {
2062 if (sscanf (prop->value().c_str(), "%f", &val) == 1) {
2063 _amp->gain_control()->set_value (val);
2067 /* Set up Panners in the IO */
2068 XMLNodeList io_nlist = child->children ();
2070 XMLNodeConstIterator io_niter;
2073 for (io_niter = io_nlist.begin(); io_niter != io_nlist.end(); ++io_niter) {
2075 io_child = *io_niter;
2077 if (io_child->name() == X_("Panner")) {
2078 _main_outs->panner()->set_state(*io_child, version);
2084 XMLNodeList redirect_nodes;
2086 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2090 if (child->name() == X_("Send") || child->name() == X_("Insert")) {
2091 redirect_nodes.push_back(child);
2096 set_processor_state_2X (redirect_nodes, version);
2098 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2101 if (child->name() == X_("Comment")) {
2103 /* XXX this is a terrible API design in libxml++ */
2105 XMLNode *cmt = *(child->children().begin());
2106 _comment = cmt->content();
2108 } else if (child->name() == X_("Extra")) {
2110 _extra_xml = new XMLNode (*child);
2112 } else if (child->name() == X_("Controllable") && (prop = child->property("name")) != 0) {
2114 if (prop->value() == "solo") {
2115 _solo_control->set_state (*child, version);
2116 _session.add_controllable (_solo_control);
2119 } else if (child->name() == X_("RemoteControl")) {
2120 if ((prop = child->property (X_("id"))) != 0) {
2122 sscanf (prop->value().c_str(), "%d", &x);
2123 set_remote_control_id (x);
2133 Route::get_processor_state ()
2135 XMLNode* root = new XMLNode (X_("redirects"));
2136 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2137 root->add_child_nocopy ((*i)->state (true));
2144 Route::set_processor_state_2X (XMLNodeList const & nList, int version)
2146 /* We don't bother removing existing processors not in nList, as this
2147 method will only be called when creating a Route from scratch, not
2148 for undo purposes. Just put processors in at the appropriate place
2152 for (XMLNodeConstIterator i = nList.begin(); i != nList.end(); ++i) {
2153 add_processor_from_xml_2X (**i, version, _processors.begin ());
2158 Route::set_processor_state (const XMLNode& node)
2160 const XMLNodeList &nlist = node.children();
2161 XMLNodeConstIterator niter;
2162 ProcessorList new_order;
2163 bool must_configure = false;
2165 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2167 XMLProperty* prop = (*niter)->property ("type");
2169 if (prop->value() == "amp") {
2170 _amp->set_state (**niter, Stateful::current_state_version);
2171 new_order.push_back (_amp);
2172 } else if (prop->value() == "meter") {
2173 _meter->set_state (**niter, Stateful::current_state_version);
2174 new_order.push_back (_meter);
2175 } else if (prop->value() == "main-outs") {
2176 _main_outs->set_state (**niter, Stateful::current_state_version);
2177 new_order.push_back (_main_outs);
2178 } else if (prop->value() == "intreturn") {
2180 _intreturn.reset (new InternalReturn (_session));
2181 must_configure = true;
2183 _intreturn->set_state (**niter, Stateful::current_state_version);
2184 new_order.push_back (_intreturn);
2185 } else if (is_monitor() && prop->value() == "monitor") {
2186 if (!_monitor_control) {
2187 _monitor_control.reset (new MonitorProcessor (_session));
2188 must_configure = true;
2190 _monitor_control->set_state (**niter, Stateful::current_state_version);
2191 new_order.push_back (_monitor_control);
2193 ProcessorList::iterator o;
2195 for (o = _processors.begin(); o != _processors.end(); ++o) {
2196 XMLProperty* id_prop = (*niter)->property(X_("id"));
2197 if (id_prop && (*o)->id() == id_prop->value()) {
2198 (*o)->set_state (**niter, Stateful::current_state_version);
2199 new_order.push_back (*o);
2204 // If the processor (*niter) is not on the route then create it
2206 if (o == _processors.end()) {
2208 boost::shared_ptr<Processor> processor;
2210 if (prop->value() == "intsend") {
2212 processor.reset (new InternalSend (_session, _mute_master, boost::shared_ptr<Route>(), Delivery::Role (0)));
2214 } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
2215 prop->value() == "lv2" ||
2216 prop->value() == "vst" ||
2217 prop->value() == "audiounit") {
2219 processor.reset (new PluginInsert(_session));
2221 } else if (prop->value() == "port") {
2223 processor.reset (new PortInsert (_session, _mute_master));
2225 } else if (prop->value() == "send") {
2227 processor.reset (new Send (_session, _mute_master));
2230 error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
2234 processor->set_state (**niter, Stateful::current_state_version);
2235 new_order.push_back (processor);
2236 must_configure = true;
2242 Glib::RWLock::WriterLock lm (_processor_lock);
2243 _processors = new_order;
2244 if (must_configure) {
2245 configure_processors_unlocked (0);
2249 markup_solo_ignore ();
2251 processors_changed (RouteProcessorChange ());
2255 Route::markup_solo_ignore ()
2257 Glib::RWLock::ReaderLock lm (_processor_lock);
2259 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p) {
2261 /* all delivery processors on master, monitor and auditioner never ever pay attention to solo
2264 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery>(*p);
2266 if (d && (is_master() || is_monitor() || is_hidden())) {
2267 cerr << _name << " Found a delivery unit, mark solo ignored\n";
2268 d->set_solo_ignored (true);
2274 Route::curve_reallocate ()
2276 // _gain_automation_curve.finish_resize ();
2277 // _pan_automation_curve.finish_resize ();
2281 Route::silence (nframes_t nframes)
2285 _output->silence (nframes);
2288 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2291 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2292 boost::shared_ptr<PluginInsert> pi;
2294 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
2295 // skip plugins, they don't need anything when we're not active
2299 (*i)->silence (nframes);
2302 if (nframes == _session.get_block_size()) {
2312 Route::add_internal_return ()
2315 _intreturn.reset (new InternalReturn (_session));
2316 add_processor (_intreturn, PreFader);
2321 Route::get_return_buffer () const
2323 Glib::RWLock::ReaderLock rm (_processor_lock);
2325 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
2326 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
2329 BufferSet* bs = d->get_buffers ();
2338 Route::release_return_buffer () const
2340 Glib::RWLock::ReaderLock rm (_processor_lock);
2342 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
2343 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
2346 return d->release_buffers ();
2352 Route::listen_via (boost::shared_ptr<Route> route, Placement placement, bool /*active*/, bool aux)
2354 vector<string> ports;
2355 vector<string>::const_iterator i;
2358 Glib::RWLock::ReaderLock rm (_processor_lock);
2360 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
2362 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
2364 if (d && d->target_route() == route) {
2366 /* if the target is the control outs, then make sure
2367 we take note of which i-send is doing that.
2370 if (route == _session.monitor_out()) {
2371 _monitor_send = boost::dynamic_pointer_cast<Delivery>(d);
2372 if (_monitor_send->active()) {
2373 _monitor_send->set_solo_level (1);
2375 _monitor_send->set_solo_level (0);
2379 /* already listening via the specified IO: do nothing */
2386 boost::shared_ptr<InternalSend> listener;
2392 if (route == _session.monitor_out()) {
2393 /* master never sends to control outs */
2396 listener.reset (new InternalSend (_session, _mute_master, route, (aux ? Delivery::Aux : Delivery::Listen)));
2400 listener.reset (new InternalSend (_session, _mute_master, route, (aux ? Delivery::Aux : Delivery::Listen)));
2403 } catch (failed_constructor& err) {
2407 if (route == _session.monitor_out()) {
2408 _monitor_send = listener;
2411 if (placement == PostFader) {
2412 /* put it *really* at the end, not just after the panner (main outs)
2414 add_processor (listener, _processors.end());
2416 add_processor (listener, PreFader);
2423 Route::drop_listen (boost::shared_ptr<Route> route)
2425 ProcessorStreams err;
2426 ProcessorList::iterator tmp;
2428 Glib::RWLock::ReaderLock rl(_processor_lock);
2432 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ) {
2434 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
2436 if (d && d->target_route() == route) {
2438 remove_processor (*x, &err);
2441 /* list could have been demolished while we dropped the lock
2451 if (route == _session.monitor_out()) {
2452 _monitor_send.reset ();
2457 Route::set_comment (string cmt, void *src)
2460 comment_changed (src);
2461 _session.set_dirty ();
2465 Route::feeds (boost::shared_ptr<Route> other, bool* only_send)
2467 DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds? %1\n", _name));
2469 if (_output->connected_to (other->input())) {
2470 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS %2\n", other->name()));
2479 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
2481 boost::shared_ptr<IOProcessor> iop;
2483 if ((iop = boost::dynamic_pointer_cast<IOProcessor>(*r)) != 0) {
2484 if (iop->feeds (other)) {
2485 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name()));
2491 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does NOT feed %2\n", iop->name(), other->name()));
2494 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tPROC %1 is not an IOP\n", (*r)->name()));
2499 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdoes NOT feed %1\n", other->name()));
2504 Route::handle_transport_stopped (bool /*abort_ignored*/, bool did_locate, bool can_flush_processors)
2506 nframes_t now = _session.transport_frame();
2509 Glib::RWLock::ReaderLock lm (_processor_lock);
2512 automation_snapshot (now, true);
2515 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2517 if (Config->get_plugins_stop_with_transport() && can_flush_processors) {
2518 (*i)->deactivate ();
2522 (*i)->transport_stopped (now);
2526 _roll_delay = _initial_delay;
2530 Route::input_change_handler (IOChange change, void * /*src*/)
2532 if ((change & ConfigurationChanged)) {
2533 configure_processors (0);
2538 Route::output_change_handler (IOChange change, void * /*src*/)
2540 if ((change & ConfigurationChanged)) {
2542 /* XXX resize all listeners to match _main_outs? */
2544 // configure_processors (0);
2549 Route::pans_required () const
2551 if (n_outputs().n_audio() < 2) {
2555 return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
2559 Route::no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
2560 bool session_state_changing, bool /*can_record*/, bool /*rec_monitors_input*/)
2562 if (n_outputs().n_total() == 0) {
2566 if (!_active || n_inputs() == ChanCount::ZERO) {
2570 if (session_state_changing) {
2571 if (_session.transport_speed() != 0.0f) {
2572 /* we're rolling but some state is changing (e.g. our diskstream contents)
2573 so we cannot use them. Be silent till this is over.
2575 XXX note the absurdity of ::no_roll() being called when we ARE rolling!
2580 /* we're really not rolling, so we're either delivery silence or actually
2581 monitoring, both of which are safe to do while session_state_changing is true.
2585 _amp->apply_gain_automation (false);
2586 passthru (start_frame, end_frame, nframes, 0);
2592 Route::check_initial_delay (nframes_t nframes, nframes_t& transport_frame)
2594 if (_roll_delay > nframes) {
2596 _roll_delay -= nframes;
2598 /* transport frame is not legal for caller to use */
2601 } else if (_roll_delay > 0) {
2603 nframes -= _roll_delay;
2604 silence (_roll_delay);
2605 /* we've written _roll_delay of samples into the
2606 output ports, so make a note of that for
2609 _main_outs->increment_output_offset (_roll_delay);
2610 transport_frame += _roll_delay;
2619 Route::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, int declick,
2620 bool /*can_record*/, bool /*rec_monitors_input*/, bool& /* need_butler */)
2623 // automation snapshot can also be called from the non-rt context
2624 // and it uses the processor list, so we try to acquire the lock here
2625 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2628 automation_snapshot (_session.transport_frame(), false);
2632 if (n_outputs().n_total() == 0) {
2636 if (!_active || n_inputs().n_total() == 0) {
2641 nframes_t unused = 0;
2643 if ((nframes = check_initial_delay (nframes, unused)) == 0) {
2649 passthru (start_frame, end_frame, nframes, declick);
2655 Route::silent_roll (nframes_t nframes, sframes_t /*start_frame*/, sframes_t /*end_frame*/,
2656 bool /*can_record*/, bool /*rec_monitors_input*/, bool& /* need_butler */)
2663 Route::toggle_monitor_input ()
2665 for (PortSet::iterator i = _input->ports().begin(); i != _input->ports().end(); ++i) {
2666 i->ensure_monitor_input( ! i->monitoring_input());
2671 Route::has_external_redirects () const
2673 // FIXME: what about sends? - they don't return a signal back to ardour?
2675 boost::shared_ptr<const PortInsert> pi;
2677 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2679 if ((pi = boost::dynamic_pointer_cast<const PortInsert>(*i)) != 0) {
2681 for (PortSet::const_iterator port = pi->output()->ports().begin(); port != pi->output()->ports().end(); ++port) {
2683 string port_name = port->name();
2684 string client_name = port_name.substr (0, port_name.find(':'));
2686 /* only say "yes" if the redirect is actually in use */
2688 if (client_name != "ardour" && pi->active()) {
2699 Route::flush_processors ()
2701 /* XXX shouldn't really try to take this lock, since
2702 this is called from the RT audio thread.
2705 Glib::RWLock::ReaderLock lm (_processor_lock);
2707 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2708 (*i)->deactivate ();
2714 Route::set_meter_point (MeterPoint p)
2716 /* CAN BE CALLED FROM PROCESS CONTEXT */
2718 if (_meter_point == p) {
2722 bool meter_was_visible_to_user = _meter->display_to_user ();
2725 Glib::RWLock::WriterLock lm (_processor_lock);
2727 if (p != MeterCustom) {
2728 // Move meter in the processors list to reflect the new position
2729 ProcessorList::iterator loc = find (_processors.begin(), _processors.end(), _meter);
2730 _processors.erase(loc);
2733 loc = _processors.begin();
2736 loc = find (_processors.begin(), _processors.end(), _amp);
2738 case MeterPostFader:
2739 loc = _processors.end();
2747 if (loc == _processors.begin()) {
2748 m_in = _input->n_ports();
2750 ProcessorList::iterator before = loc;
2752 m_in = (*before)->output_streams ();
2755 _meter->reflect_inputs (m_in);
2757 _processors.insert (loc, _meter);
2759 /* we do not need to reconfigure the processors, because the meter
2760 (a) is always ready to handle processor_max_streams
2761 (b) is always an N-in/N-out processor, and thus moving
2762 it doesn't require any changes to the other processors.
2765 _meter->set_display_to_user (false);
2769 // just make it visible and let the user move it
2771 _meter->set_display_to_user (true);
2776 meter_change (); /* EMIT SIGNAL */
2778 bool const meter_visibly_changed = (_meter->display_to_user() != meter_was_visible_to_user);
2780 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, meter_visibly_changed)); /* EMIT SIGNAL */
2784 Route::put_monitor_send_at (Placement p)
2786 if (!_monitor_send) {
2791 Glib::RWLock::WriterLock lm (_processor_lock);
2792 ProcessorList as_it_was (_processors);
2793 ProcessorList::iterator loc = find(_processors.begin(), _processors.end(), _monitor_send);
2794 _processors.erase(loc);
2798 loc = find(_processors.begin(), _processors.end(), _amp);
2799 if (loc != _processors.begin()) {
2804 loc = _processors.end();
2808 _processors.insert (loc, _monitor_send);
2810 if (configure_processors_unlocked (0)) {
2811 _processors = as_it_was;
2812 configure_processors_unlocked (0); // it worked before we tried to add it ...
2817 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2818 _session.set_dirty ();
2822 Route::update_total_latency ()
2824 nframes_t old = _output->effective_latency();
2825 nframes_t own_latency = _output->user_latency();
2827 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2828 if ((*i)->active ()) {
2829 own_latency += (*i)->signal_latency ();
2833 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal redirect latency = %2\n", _name, own_latency));
2835 _output->set_port_latency (own_latency);
2837 if (_output->user_latency() == 0) {
2839 /* this (virtual) function is used for pure Routes,
2840 not derived classes like AudioTrack. this means
2841 that the data processed here comes from an input
2842 port, not prerecorded material, and therefore we
2843 have to take into account any input latency.
2846 own_latency += _input->signal_latency ();
2849 if (old != own_latency) {
2850 _output->set_latency_delay (own_latency);
2851 signal_latency_changed (); /* EMIT SIGNAL */
2854 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: input latency = %2 total = %3\n", _name, _input->signal_latency(), own_latency));
2856 return _output->effective_latency ();
2860 Route::set_user_latency (nframes_t nframes)
2862 _output->set_user_latency (nframes);
2863 _session.update_latency_compensation (false, false);
2867 Route::set_latency_delay (nframes_t longest_session_latency)
2869 nframes_t old = _initial_delay;
2871 if (_output->effective_latency() < longest_session_latency) {
2872 _initial_delay = longest_session_latency - _output->effective_latency();
2877 if (_initial_delay != old) {
2878 initial_delay_changed (); /* EMIT SIGNAL */
2881 if (_session.transport_stopped()) {
2882 _roll_delay = _initial_delay;
2887 Route::automation_snapshot (nframes_t now, bool force)
2889 panner()->automation_snapshot (now, force);
2891 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2892 (*i)->automation_snapshot (now, force);
2896 Route::SoloControllable::SoloControllable (std::string name, Route& r)
2897 : AutomationControl (r.session(), Evoral::Parameter (SoloAutomation),
2898 boost::shared_ptr<AutomationList>(), name)
2901 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloAutomation)));
2906 Route::SoloControllable::set_value (float val)
2908 bool bval = ((val >= 0.5f) ? true: false);
2910 this is how it should be done
2912 boost::shared_ptr<RouteList> rl (new RouteList);
2913 rl->push_back (route);
2915 if (Config->get_solo_control_is_listen_control()) {
2916 _session.set_listen (rl, bval);
2918 _session.set_solo (rl, bval);
2921 route.set_solo (bval, this);
2926 Route::SoloControllable::get_value (void) const
2928 if (Config->get_solo_control_is_listen_control()) {
2929 return route.listening() ? 1.0f : 0.0f;
2931 return route.self_soloed() ? 1.0f : 0.0f;
2935 Route::MuteControllable::MuteControllable (std::string name, Route& r)
2936 : AutomationControl (r.session(), Evoral::Parameter (MuteAutomation),
2937 boost::shared_ptr<AutomationList>(), name)
2940 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(MuteAutomation)));
2945 Route::MuteControllable::set_value (float val)
2947 bool bval = ((val >= 0.5f) ? true: false);
2949 this is how it should be done
2951 boost::shared_ptr<RouteList> rl (new RouteList);
2952 rl->push_back (route);
2953 _session.set_mute (rl, bval);
2955 route.set_mute (bval, this);
2960 Route::MuteControllable::get_value (void) const
2962 return route.muted() ? 1.0f : 0.0f;
2966 Route::set_block_size (nframes_t nframes)
2968 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2969 (*i)->set_block_size (nframes);
2972 _session.ensure_buffers (n_process_buffers ());
2976 Route::protect_automation ()
2978 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i)
2979 (*i)->protect_automation();
2983 Route::set_pending_declick (int declick)
2986 /* this call is not allowed to turn off a pending declick unless "force" is true */
2988 _pending_declick = declick;
2990 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
2992 _pending_declick = 0;
2997 /** Shift automation forwards from a particular place, thereby inserting time.
2998 * Adds undo commands for any shifts that are performed.
3000 * @param pos Position to start shifting from.
3001 * @param frames Amount to shift forwards by.
3005 Route::shift (nframes64_t /*pos*/, nframes64_t /*frames*/)
3007 #ifdef THIS_NEEDS_FIXING_FOR_V3
3009 /* gain automation */
3010 XMLNode &before = _gain_control->get_state ();
3011 _gain_control->shift (pos, frames);
3012 XMLNode &after = _gain_control->get_state ();
3013 _session.add_command (new MementoCommand<AutomationList> (_gain_automation_curve, &before, &after));
3015 /* pan automation */
3016 for (std::vector<StreamPanner*>::iterator i = _panner->begin (); i != _panner->end (); ++i) {
3017 Curve & c = (*i)->automation ();
3018 XMLNode &before = c.get_state ();
3019 c.shift (pos, frames);
3020 XMLNode &after = c.get_state ();
3021 _session.add_command (new MementoCommand<AutomationList> (c, &before, &after));
3024 /* redirect automation */
3026 Glib::RWLock::ReaderLock lm (redirect_lock);
3027 for (RedirectList::iterator i = _redirects.begin (); i != _redirects.end (); ++i) {
3030 (*i)->what_has_automation (a);
3032 for (set<uint32_t>::const_iterator j = a.begin (); j != a.end (); ++j) {
3033 AutomationList & al = (*i)->automation_list (*j);
3034 XMLNode &before = al.get_state ();
3035 al.shift (pos, frames);
3036 XMLNode &after = al.get_state ();
3037 _session.add_command (new MementoCommand<AutomationList> (al, &before, &after));
3047 Route::save_as_template (const string& path, const string& name)
3049 XMLNode& node (state (false));
3052 IO::set_name_in_state (*node.children().front(), name);
3054 tree.set_root (&node);
3055 return tree.write (path.c_str());
3060 Route::set_name (const string& str)
3066 name = Route::ensure_track_or_route_name (str, _session);
3067 SessionObject::set_name (name);
3069 ret = (_input->set_name(name) && _output->set_name(name));
3073 Glib::RWLock::ReaderLock lm (_processor_lock);
3075 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3077 /* rename all I/O processors that have inputs or outputs */
3079 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
3081 if (iop && (iop->output() || iop->input())) {
3082 if (!iop->set_name (name)) {
3093 boost::shared_ptr<Send>
3094 Route::internal_send_for (boost::shared_ptr<const Route> target) const
3096 Glib::RWLock::ReaderLock lm (_processor_lock);
3098 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3099 boost::shared_ptr<InternalSend> send;
3101 if ((send = boost::dynamic_pointer_cast<InternalSend>(*i)) != 0) {
3102 if (send->target_route() == target) {
3108 return boost::shared_ptr<Send>();
3112 Route::set_phase_invert (bool yn)
3114 if (_phase_invert != yn) {
3116 _phase_invert = 0xffff; // XXX all channels
3118 _phase_invert = 0; // XXX no channels
3121 phase_invert_changed (); /* EMIT SIGNAL */
3122 _session.set_dirty ();
3127 Route::phase_invert () const
3129 return _phase_invert != 0;
3133 Route::set_denormal_protection (bool yn)
3135 if (_denormal_protection != yn) {
3136 _denormal_protection = yn;
3137 denormal_protection_changed (); /* EMIT SIGNAL */
3142 Route::denormal_protection () const
3144 return _denormal_protection;
3148 Route::set_active (bool yn)
3150 if (_active != yn) {
3152 _input->set_active (yn);
3153 _output->set_active (yn);
3154 active_changed (); // EMIT SIGNAL
3161 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
3167 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3169 boost::shared_ptr<Send> s;
3170 boost::shared_ptr<Return> r;
3172 if ((s = boost::dynamic_pointer_cast<Send> (*i)) != 0) {
3173 s->meter()->meter();
3174 } else if ((r = boost::dynamic_pointer_cast<Return> (*i)) != 0) {
3175 r->meter()->meter ();
3180 boost::shared_ptr<Panner>
3181 Route::panner() const
3183 return _main_outs->panner();
3186 boost::shared_ptr<AutomationControl>
3187 Route::gain_control() const
3189 return _amp->gain_control();
3192 boost::shared_ptr<AutomationControl>
3193 Route::get_control (const Evoral::Parameter& param)
3195 /* either we own the control or .... */
3197 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(control (param));
3201 /* maybe one of our processors does or ... */
3203 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
3204 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3205 if ((c = boost::dynamic_pointer_cast<AutomationControl>((*i)->control (param))) != 0) {
3213 /* nobody does so we'll make a new one */
3215 c = boost::dynamic_pointer_cast<AutomationControl>(control_factory(param));
3222 boost::shared_ptr<Processor>
3223 Route::nth_plugin (uint32_t n)
3225 Glib::RWLock::ReaderLock lm (_processor_lock);
3226 ProcessorList::iterator i;
3228 for (i = _processors.begin(); i != _processors.end(); ++i) {
3229 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
3236 return boost::shared_ptr<Processor> ();
3239 boost::shared_ptr<Processor>
3240 Route::nth_send (uint32_t n)
3242 Glib::RWLock::ReaderLock lm (_processor_lock);
3243 ProcessorList::iterator i;
3245 for (i = _processors.begin(); i != _processors.end(); ++i) {
3246 if (boost::dynamic_pointer_cast<Send> (*i)) {
3253 return boost::shared_ptr<Processor> ();