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)
76 , _solo_control (new SoloControllable (X_("solo"), *this))
77 , _mute_control (new MuteControllable (X_("mute"), *this))
78 , _mute_master (new MuteMaster (sess, name))
79 , _default_type (default_type)
84 /* add standard processors other than amp (added by ::init()) */
86 _meter.reset (new PeakMeter (_session));
87 _meter->set_display_to_user (false);
89 add_processor (_meter, PostFader);
91 _main_outs.reset (new Delivery (_session, _output, _mute_master, _name, Delivery::Main));
93 add_processor (_main_outs, PostFader);
96 /* where we listen to tracks */
97 _intreturn.reset (new InternalReturn (_session));
98 add_processor (_intreturn, PreFader);
100 ProcessorList::iterator i;
102 for (i = _processors.begin(); i != _processors.end(); ++i) {
103 if (*i == _intreturn) {
109 /* the thing that provides proper control over a control/monitor/listen bus
110 (such as per-channel cut, dim, solo, invert, etc).
111 It always goes right after the internal return;
113 _monitor_control.reset (new MonitorProcessor (_session));
114 add_processor (_monitor_control, i);
119 /* now that we have _meter, its safe to connect to this */
121 Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this)));
128 _soloed_by_others = 0;
132 processor_max_streams.reset();
134 order_keys[N_("signal")] = order_key_cnt++;
136 _meter_point = MeterPostFader;
139 _have_internal_generator = false;
140 _declickable = false;
141 _pending_declick = true;
142 _remote_control_id = 0;
143 _in_configure_processors = false;
144 _mute_points = MuteMaster::AllPoints;
147 _denormal_protection = false;
149 /* add standard controls */
151 _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
152 _mute_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
154 add_control (_solo_control);
155 add_control (_mute_control);
157 /* input and output objects */
159 _input.reset (new IO (_session, _name, IO::Input, _default_type));
160 _output.reset (new IO (_session, _name, IO::Output, _default_type));
162 _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2));
163 _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
165 /* add amp processor */
167 _amp.reset (new Amp (_session, _mute_master));
168 add_processor (_amp, PostFader);
173 DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
175 /* do this early so that we don't get incoming signals as we are going through destruction
180 /* don't use clear_processors here, as it depends on the session which may
181 be half-destroyed by now
184 Glib::RWLock::WriterLock lm (_processor_lock);
185 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
186 (*i)->drop_references ();
189 _processors.clear ();
193 Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
195 if (id != _remote_control_id) {
196 _remote_control_id = id;
197 RemoteControlIDChanged ();
198 if (notify_class_listeners) {
199 RemoteControlIDChange ();
205 Route::remote_control_id() const
207 return _remote_control_id;
211 Route::order_key (std::string const & name) const
213 OrderKeys::const_iterator i = order_keys.find (name);
214 if (i == order_keys.end()) {
222 Route::set_order_key (std::string const & name, long n)
224 order_keys[name] = n;
226 if (Config->get_sync_all_route_ordering()) {
227 for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
232 _session.set_dirty ();
235 /** Set all order keys to be the same as that for `base', if such a key
236 * exists in this route.
237 * @param base Base key.
240 Route::sync_order_keys (std::string const & base)
242 if (order_keys.empty()) {
246 OrderKeys::iterator i;
249 if ((i = order_keys.find (base)) == order_keys.end()) {
250 /* key doesn't exist, use the first existing key (during session initialization) */
251 i = order_keys.begin();
255 /* key exists - use it and reset all others (actually, itself included) */
257 i = order_keys.begin();
260 for (; i != order_keys.end(); ++i) {
266 Route::ensure_track_or_route_name(string name, Session &session)
268 string newname = name;
270 while (session.route_by_name (newname) != NULL) {
271 newname = bump_name_once (newname);
279 Route::inc_gain (gain_t fraction, void *src)
281 _amp->inc_gain (fraction, src);
285 Route::set_gain (gain_t val, void *src)
287 if (src != 0 && _route_group && src != _route_group && _route_group->is_active() && _route_group->is_gain()) {
289 if (_route_group->is_relative()) {
291 gain_t usable_gain = _amp->gain();
292 if (usable_gain < 0.000001f) {
293 usable_gain = 0.000001f;
297 if (delta < 0.000001f) {
301 delta -= usable_gain;
306 gain_t factor = delta / usable_gain;
309 factor = _route_group->get_max_factor(factor);
310 if (factor == 0.0f) {
311 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
315 factor = _route_group->get_min_factor(factor);
316 if (factor == 0.0f) {
317 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
322 _route_group->apply (&Route::inc_gain, factor, _route_group);
326 _route_group->apply (&Route::set_gain, val, _route_group);
332 if (val == _amp->gain()) {
336 _amp->set_gain (val, src);
339 /** Process this route for one (sub) cycle (process thread)
341 * @param bufs Scratch buffers to use for the signal path
342 * @param start_frame Initial transport frame
343 * @param end_frame Final transport frame
344 * @param nframes Number of frames to output (to ports)
346 * Note that (end_frame - start_frame) may not be equal to nframes when the
347 * transport speed isn't 1.0 (eg varispeed).
350 Route::process_output_buffers (BufferSet& bufs,
351 sframes_t start_frame, sframes_t end_frame, nframes_t nframes,
352 bool /*with_processors*/, int declick)
356 bufs.is_silent (false);
358 switch (Config->get_monitoring_model()) {
359 case HardwareMonitoring:
360 case ExternalMonitoring:
361 monitor = !record_enabled() || (_session.config.get_auto_input() && !_session.actively_recording());
368 declick = _pending_declick;
371 /* figure out if we're going to use gain automation */
372 _amp->setup_gain_automation (start_frame, end_frame, nframes);
375 /* tell main outs what to do about monitoring */
376 _main_outs->no_outs_cuz_we_no_monitor (!monitor);
379 /* -------------------------------------------------------------------------------------------
380 GLOBAL DECLICK (for transport changes etc.)
381 ----------------------------------------------------------------------------------------- */
384 Amp::apply_gain (bufs, nframes, 0.0, 1.0);
385 } else if (declick < 0) {
386 Amp::apply_gain (bufs, nframes, 1.0, 0.0);
389 _pending_declick = 0;
391 /* -------------------------------------------------------------------------------------------
392 DENORMAL CONTROL/PHASE INVERT
393 ----------------------------------------------------------------------------------------- */
399 if (_denormal_protection || Config->get_denormal_protection()) {
401 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
402 Sample* const sp = i->data();
404 if (_phase_invert & chn) {
405 for (nframes_t nx = 0; nx < nframes; ++nx) {
410 for (nframes_t nx = 0; nx < nframes; ++nx) {
418 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
419 Sample* const sp = i->data();
421 if (_phase_invert & chn) {
422 for (nframes_t nx = 0; nx < nframes; ++nx) {
431 if (_denormal_protection || Config->get_denormal_protection()) {
433 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
434 Sample* const sp = i->data();
435 for (nframes_t nx = 0; nx < nframes; ++nx) {
443 /* -------------------------------------------------------------------------------------------
445 ----------------------------------------------------------------------------------------- */
447 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
450 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
452 if (bufs.count() != (*i)->input_streams()) {
453 cerr << _name << " bufs = " << bufs.count()
454 << " input for " << (*i)->name() << " = " << (*i)->input_streams()
457 assert (bufs.count() == (*i)->input_streams());
459 (*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back());
460 bufs.set_count ((*i)->output_streams());
466 Route::n_process_buffers ()
468 return max (_input->n_ports(), processor_max_streams);
472 Route::passthru (sframes_t start_frame, sframes_t end_frame, nframes_t nframes, int declick)
474 BufferSet& bufs = _session.get_scratch_buffers (n_process_buffers());
478 assert (bufs.available() >= _input->n_ports());
480 if (_input->n_ports() == ChanCount::ZERO) {
484 bufs.set_count (_input->n_ports());
486 if (is_monitor() && _session.listening()) {
488 /* control/monitor bus ignores input ports when something is
489 feeding the listen "stream". data will "arrive" into the
490 route from the intreturn processor element.
492 bufs.silence (nframes, 0);
496 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
498 BufferSet::iterator o = bufs.begin(*t);
499 PortSet& ports (_input->ports());
501 for (PortSet::iterator i = ports.begin(*t); i != ports.end(*t); ++i, ++o) {
502 o->read_from (i->get_buffer(nframes), nframes);
507 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
508 process_output_buffers (bufs, start_frame, end_frame, nframes, true, declick);
512 Route::passthru_silence (sframes_t start_frame, sframes_t end_frame, nframes_t nframes, int declick)
514 BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
515 bufs.set_count (_input->n_ports());
516 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
517 process_output_buffers (bufs, start_frame, end_frame, nframes, true, declick);
521 Route::set_listen (bool yn, void* src)
524 if (yn != _monitor_send->active()) {
526 _monitor_send->set_solo_level (1);
527 _monitor_send->activate ();
529 _monitor_send->set_solo_level (0);
530 _monitor_send->deactivate ();
533 listen_changed (src); /* EMIT SIGNAL */
539 Route::listening () const
542 return _monitor_send->active ();
549 Route::set_solo_safe (bool yn, void *src)
551 if (_solo_safe != yn) {
553 solo_safe_changed (src);
558 Route::solo_safe() const
564 Route::set_solo (bool yn, void *src)
570 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
571 _route_group->apply (&Route::set_solo, yn, _route_group);
575 if (self_soloed() != yn) {
577 set_delivery_solo ();
578 solo_changed (src); /* EMIT SIGNAL */
579 _solo_control->Changed (); /* EMIT SIGNAL */
584 Route::set_self_solo (bool yn)
590 Route::mod_solo_by_others (int32_t delta)
593 if (_soloed_by_others >= (uint32_t) delta) {
594 _soloed_by_others += delta;
596 _soloed_by_others = 0;
599 _soloed_by_others += delta;
602 set_delivery_solo ();
606 Route::set_delivery_solo ()
608 /* tell all delivery processors what the solo situation is, so that they keep
609 delivering even though Session::soloing() is true and they were not
613 Glib::RWLock::ReaderLock rm (_processor_lock);
614 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
615 boost::shared_ptr<Delivery> d;
617 if ((d = boost::dynamic_pointer_cast<Delivery> (*i)) != 0) {
618 d->set_solo_level (soloed ());
619 d->set_solo_isolated (solo_isolated());
625 Route::set_solo_isolated (bool yn, void *src)
627 if (is_master() || is_monitor() || is_hidden()) {
631 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
632 _route_group->apply (&Route::set_solo_isolated, yn, _route_group);
636 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
638 boost::shared_ptr<RouteList> routes = _session.get_routes ();
639 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
641 bool does_feed = feeds (*i, &sends_only);
643 if (does_feed && !sends_only) {
644 (*i)->set_solo_isolated (yn, (*i)->route_group());
648 bool changed = false;
651 if (_solo_isolated == 0) {
656 changed = (_solo_isolated == 1);
657 if (_solo_isolated > 0) {
663 set_delivery_solo ();
664 solo_isolated_changed (src);
669 Route::solo_isolated () const
671 return _solo_isolated > 0;
675 Route::set_mute_points (MuteMaster::MutePoint mp)
678 mute_points_changed (); /* EMIT SIGNAL */
680 if (_mute_master->muted()) {
681 _mute_master->mute_at (_mute_points);
682 mute_changed (this); /* EMIT SIGNAL */
687 Route::set_mute (bool yn, void *src)
689 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_mute()) {
690 _route_group->apply (&Route::set_mute, yn, _route_group);
696 _mute_master->mute_at (_mute_points);
698 _mute_master->clear_mute ();
701 mute_changed (src); /* EMIT SIGNAL */
708 return _mute_master->muted ();
713 dump_processors(const string& name, const list<boost::shared_ptr<Processor> >& procs)
715 cerr << name << " {" << endl;
716 for (list<boost::shared_ptr<Processor> >::const_iterator p = procs.begin();
717 p != procs.end(); ++p) {
718 cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << endl;
725 Route::add_processor (boost::shared_ptr<Processor> processor, Placement placement, ProcessorStreams* err)
727 ProcessorList::iterator loc;
729 /* XXX this is not thread safe - we don't hold the lock across determining the iter
730 to add before and actually doing the insertion. dammit.
733 if (placement == PreFader) {
734 /* generic pre-fader: insert immediately before the amp */
735 loc = find (_processors.begin(), _processors.end(), _amp);
737 /* generic post-fader: insert right before the main outs */
738 loc = find (_processors.begin(), _processors.end(), _main_outs);
741 return add_processor (processor, loc, err);
745 /** Add a processor to the route.
746 * @a iter must point to an iterator in _processors and the new
747 * processor will be inserted immediately before this location. Otherwise,
748 * @a position is used.
751 Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::iterator iter, ProcessorStreams* err, bool activation_allowed)
753 ChanCount old_pms = processor_max_streams;
755 if (!_session.engine().connected() || !processor) {
760 Glib::RWLock::WriterLock lm (_processor_lock);
762 boost::shared_ptr<PluginInsert> pi;
763 boost::shared_ptr<PortInsert> porti;
765 ProcessorList::iterator loc = find(_processors.begin(), _processors.end(), processor);
767 if (processor == _amp || processor == _meter || processor == _main_outs) {
768 // Ensure only one of these are in the list at any time
769 if (loc != _processors.end()) {
770 if (iter == loc) { // Already in place, do nothing
772 } else { // New position given, relocate
773 _processors.erase (loc);
778 if (loc != _processors.end()) {
779 cerr << "ERROR: Processor added to route twice!" << endl;
786 _processors.insert (loc, processor);
788 // Set up processor list channels. This will set processor->[input|output]_streams(),
789 // configure redirect ports properly, etc.
791 if (configure_processors_unlocked (err)) {
792 ProcessorList::iterator ploc = loc;
794 _processors.erase(ploc);
795 configure_processors_unlocked (0); // it worked before we tried to add it ...
796 cerr << "configure failed\n";
800 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
802 if (pi->natural_input_streams() == ChanCount::ZERO) {
803 /* generator plugin */
804 _have_internal_generator = true;
809 /* is this the monitor send ? if so, make sure we keep track of it */
811 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
813 if (isend && _session.monitor_out() && (isend->target_id() == _session.monitor_out()->id())) {
814 _monitor_send = isend;
816 if (_monitor_send->active()) {
817 _monitor_send->set_solo_level (1);
819 _monitor_send->set_solo_level (0);
823 if (activation_allowed && (processor != _monitor_send)) {
824 processor->activate ();
827 processor->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false));
829 _output->set_user_latency (0);
832 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
838 Route::add_processor_from_xml (const XMLNode& node, ProcessorList::iterator iter)
840 const XMLProperty *prop;
842 if (node.name() != "Processor") {
847 if ((prop = node.property ("type")) != 0) {
849 boost::shared_ptr<Processor> processor;
851 /* meter, amp, monitor and intreturn are all singletons, deal with them first */
853 if (prop->value() == "meter") {
856 if (_meter->set_state (node, Stateful::loading_state_version)) {
863 PeakMeter* pm = new PeakMeter (_session);
865 if (pm->set_state (node, Stateful::loading_state_version)) {
871 _meter->set_display_to_user (_meter_point == MeterCustom);
875 } else if (prop->value() == "monitor") {
877 if (_monitor_control) {
878 if (_monitor_control->set_state (node, Stateful::loading_state_version)) {
885 MonitorProcessor* mp = new MonitorProcessor (_session);
886 if (mp->set_state (node, Stateful::loading_state_version)) {
891 _monitor_control.reset (mp);
892 processor = _monitor_control;
894 } else if (prop->value() == "amp") {
898 if (processor->set_state (node, Stateful::loading_state_version)) {
901 /* no reason to add it */
906 Amp* a = new Amp (_session, _mute_master);
907 if (_amp->set_state (node, Stateful::loading_state_version)) {
915 } else if (prop->value() == "intreturn") {
917 /* a route only has one internal return. If it exists already
918 just set its state, and return
922 if (_intreturn->set_state (node, Stateful::loading_state_version)) {
929 InternalReturn* iret = new InternalReturn (_session);
930 if (iret->set_state (node, Stateful::loading_state_version)) {
935 _intreturn.reset (iret);
936 processor = _intreturn;
938 } else if (prop->value() == "main-outs") {
941 if (_main_outs->set_state (node, Stateful::loading_state_version)) {
948 Delivery* del = new Delivery (_session, _output, _mute_master, X_("toBeResetFroXML"), Delivery::Role (0));
949 if (del->set_state (node, Stateful::loading_state_version)) {
954 _main_outs.reset (del);
955 processor = _main_outs;
957 } else if (prop->value() == "intsend") {
959 InternalSend* isend = new InternalSend (_session, _mute_master, boost::shared_ptr<Route>(), Delivery::Role (0));
960 if (isend->set_state (node, Stateful::loading_state_version)) {
965 processor.reset (isend);
967 } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
968 prop->value() == "lv2" ||
969 prop->value() == "vst" ||
970 prop->value() == "audiounit") {
972 processor.reset (new PluginInsert(_session, node));
974 } else if (prop->value() == "port") {
976 processor.reset (new PortInsert (_session, _mute_master, node));
978 } else if (prop->value() == "send") {
980 processor.reset (new Send (_session, _mute_master, node));
983 error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
987 if (iter == _processors.end() && processor->display_to_user() && !_processors.empty()) {
988 /* check for invisible processors stacked at the end and leave them there */
989 ProcessorList::iterator p;
990 p = _processors.end();
992 while (!(*p)->display_to_user() && p != _processors.begin()) {
999 return (add_processor (processor, iter, 0, false) == 0);
1002 error << _("Processor XML node has no type property") << endmsg;
1007 catch (failed_constructor &err) {
1008 warning << _("processor could not be created. Ignored.") << endmsg;
1015 Route::add_processor_from_xml_2X (const XMLNode& node, int version, ProcessorList::iterator iter)
1017 const XMLProperty *prop;
1020 boost::shared_ptr<Processor> processor;
1022 if (node.name() == "Insert") {
1024 if ((prop = node.property ("type")) != 0) {
1026 if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
1027 prop->value() == "lv2" ||
1028 prop->value() == "vst" ||
1029 prop->value() == "audiounit") {
1031 processor.reset (new PluginInsert (_session, node));
1035 processor.reset (new PortInsert (_session, _mute_master, node));
1040 } else if (node.name() == "Send") {
1042 processor.reset (new Send (_session, _mute_master, node, version));
1046 error << string_compose(_("unknown Processor type \"%1\"; ignored"), node.name()) << endmsg;
1050 if (iter == _processors.end() && processor->display_to_user() && !_processors.empty()) {
1051 /* check for invisible processors stacked at the end and leave them there */
1052 ProcessorList::iterator p;
1053 p = _processors.end();
1055 while (!(*p)->display_to_user() && p != _processors.begin()) {
1062 return (add_processor (processor, iter) == 0);
1065 catch (failed_constructor &err) {
1066 warning << _("processor could not be created. Ignored.") << endmsg;
1072 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
1074 ProcessorList::iterator loc;
1077 loc = find(_processors.begin(), _processors.end(), before);
1079 /* nothing specified - at end but before main outs */
1080 loc = find (_processors.begin(), _processors.end(), _main_outs);
1083 return add_processors (others, loc, err);
1087 Route::add_processors (const ProcessorList& others, ProcessorList::iterator iter, ProcessorStreams* err)
1089 /* NOTE: this is intended to be used ONLY when copying
1090 processors from another Route. Hence the subtle
1091 differences between this and ::add_processor()
1094 ChanCount old_pms = processor_max_streams;
1096 if (!_session.engine().connected()) {
1100 if (others.empty()) {
1105 Glib::RWLock::WriterLock lm (_processor_lock);
1107 ChanCount potential_max_streams = ChanCount::max (_input->n_ports(), _output->n_ports());
1109 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
1111 // Ensure meter only appears in the list once
1113 ProcessorList::iterator m = find(_processors.begin(), _processors.end(), *i);
1114 if (m != _processors.end()) {
1115 _processors.erase(m);
1119 boost::shared_ptr<PluginInsert> pi;
1121 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1124 ChanCount m = max (pi->input_streams(), pi->output_streams());
1126 if (m > potential_max_streams) {
1127 potential_max_streams = m;
1131 ProcessorList::iterator inserted = _processors.insert (iter, *i);
1133 if ((*i)->active()) {
1137 if (configure_processors_unlocked (err)) {
1138 _processors.erase (inserted);
1139 configure_processors_unlocked (0); // it worked before we tried to add it ...
1143 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false, false));
1146 _output->set_user_latency (0);
1149 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1155 Route::placement_range(Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end)
1157 if (p == PreFader) {
1158 start = _processors.begin();
1159 end = find(_processors.begin(), _processors.end(), _amp);
1161 start = find(_processors.begin(), _processors.end(), _amp);
1163 end = _processors.end();
1167 /** Turn off all processors with a given placement
1168 * @param p Placement of processors to disable
1171 Route::disable_processors (Placement p)
1173 Glib::RWLock::ReaderLock lm (_processor_lock);
1175 ProcessorList::iterator start, end;
1176 placement_range(p, start, end);
1178 for (ProcessorList::iterator i = start; i != end; ++i) {
1179 (*i)->deactivate ();
1182 _session.set_dirty ();
1185 /** Turn off all redirects
1188 Route::disable_processors ()
1190 Glib::RWLock::ReaderLock lm (_processor_lock);
1192 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1193 (*i)->deactivate ();
1196 _session.set_dirty ();
1199 /** Turn off all redirects with a given placement
1200 * @param p Placement of redirects to disable
1203 Route::disable_plugins (Placement p)
1205 Glib::RWLock::ReaderLock lm (_processor_lock);
1207 ProcessorList::iterator start, end;
1208 placement_range(p, start, end);
1210 for (ProcessorList::iterator i = start; i != end; ++i) {
1211 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1212 (*i)->deactivate ();
1216 _session.set_dirty ();
1219 /** Turn off all plugins
1222 Route::disable_plugins ()
1224 Glib::RWLock::ReaderLock lm (_processor_lock);
1226 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1227 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1228 (*i)->deactivate ();
1232 _session.set_dirty ();
1237 Route::ab_plugins (bool forward)
1239 Glib::RWLock::ReaderLock lm (_processor_lock);
1243 /* forward = turn off all active redirects, and mark them so that the next time
1244 we go the other way, we will revert them
1247 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1248 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1252 if ((*i)->active()) {
1253 (*i)->deactivate ();
1254 (*i)->set_next_ab_is_active (true);
1256 (*i)->set_next_ab_is_active (false);
1262 /* backward = if the redirect was marked to go active on the next ab, do so */
1264 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1266 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1270 if ((*i)->get_next_ab_is_active()) {
1273 (*i)->deactivate ();
1278 _session.set_dirty ();
1282 /** Remove processors with a given placement.
1283 * @param p Placement of processors to remove.
1286 Route::clear_processors (Placement p)
1288 const ChanCount old_pms = processor_max_streams;
1290 if (!_session.engine().connected()) {
1294 bool already_deleting = _session.deletion_in_progress();
1295 if (!already_deleting) {
1296 _session.set_deletion_in_progress();
1300 Glib::RWLock::WriterLock lm (_processor_lock);
1301 ProcessorList new_list;
1302 ProcessorStreams err;
1303 bool seen_amp = false;
1305 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1311 if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs) {
1313 /* you can't remove these */
1315 new_list.push_back (*i);
1322 new_list.push_back (*i);
1325 (*i)->drop_references ();
1333 (*i)->drop_references ();
1336 new_list.push_back (*i);
1343 _processors = new_list;
1344 configure_processors_unlocked (&err); // this can't fail
1347 processor_max_streams.reset();
1348 _have_internal_generator = false;
1349 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1351 if (!already_deleting) {
1352 _session.clear_deletion_in_progress();
1357 Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStreams* err)
1359 /* these can never be removed */
1361 if (processor == _amp || processor == _meter || processor == _main_outs) {
1365 ChanCount old_pms = processor_max_streams;
1367 if (!_session.engine().connected()) {
1371 processor_max_streams.reset();
1374 Glib::RWLock::WriterLock lm (_processor_lock);
1375 ProcessorList::iterator i;
1376 bool removed = false;
1378 for (i = _processors.begin(); i != _processors.end(); ) {
1379 if (*i == processor) {
1381 /* move along, see failure case for configure_processors()
1382 where we may need to reconfigure the processor.
1385 /* stop redirects that send signals to JACK ports
1386 from causing noise as a result of no longer being
1390 boost::shared_ptr<IOProcessor> iop;
1392 if ((iop = boost::dynamic_pointer_cast<IOProcessor> (*i)) != 0) {
1394 iop->input()->disconnect (this);
1396 if (iop->output()) {
1397 iop->output()->disconnect (this);
1401 i = _processors.erase (i);
1409 _output->set_user_latency (0);
1417 if (configure_processors_unlocked (err)) {
1418 /* get back to where we where */
1419 _processors.insert (i, processor);
1420 /* we know this will work, because it worked before :) */
1421 configure_processors_unlocked (0);
1425 _have_internal_generator = false;
1427 for (i = _processors.begin(); i != _processors.end(); ++i) {
1428 boost::shared_ptr<PluginInsert> pi;
1430 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1431 if (pi->is_generator()) {
1432 _have_internal_generator = true;
1439 processor->drop_references ();
1440 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1446 Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err)
1448 ProcessorList deleted;
1450 if (!_session.engine().connected()) {
1454 processor_max_streams.reset();
1457 Glib::RWLock::WriterLock lm (_processor_lock);
1458 ProcessorList::iterator i;
1459 boost::shared_ptr<Processor> processor;
1461 ProcessorList as_we_were = _processors;
1463 for (i = _processors.begin(); i != _processors.end(); ) {
1467 /* these can never be removed */
1469 if (processor == _amp || processor == _meter || processor == _main_outs) {
1474 /* see if its in the list of processors to delete */
1476 if (find (to_be_deleted.begin(), to_be_deleted.end(), processor) == to_be_deleted.end()) {
1481 /* stop IOProcessors that send to JACK ports
1482 from causing noise as a result of no longer being
1486 boost::shared_ptr<IOProcessor> iop;
1488 if ((iop = boost::dynamic_pointer_cast<IOProcessor> (processor)) != 0) {
1492 deleted.push_back (processor);
1493 i = _processors.erase (i);
1496 if (deleted.empty()) {
1497 /* none of those in the requested list were found */
1501 _output->set_user_latency (0);
1503 if (configure_processors_unlocked (err)) {
1504 /* get back to where we where */
1505 _processors = as_we_were;
1506 /* we know this will work, because it worked before :) */
1507 configure_processors_unlocked (0);
1511 _have_internal_generator = false;
1513 for (i = _processors.begin(); i != _processors.end(); ++i) {
1514 boost::shared_ptr<PluginInsert> pi;
1516 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1517 if (pi->is_generator()) {
1518 _have_internal_generator = true;
1525 /* now try to do what we need to so that those that were removed will be deleted */
1527 for (ProcessorList::iterator i = deleted.begin(); i != deleted.end(); ++i) {
1528 (*i)->drop_references ();
1531 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1538 Route::configure_processors (ProcessorStreams* err)
1540 if (!_in_configure_processors) {
1541 Glib::RWLock::WriterLock lm (_processor_lock);
1542 return configure_processors_unlocked (err);
1548 Route::input_streams () const
1550 cerr << "!!!!!!!!!" << _name << " ::input_streams()\n";
1551 return _input->n_ports ();
1554 /** Configure the input/output configuration of each processor in the processors list.
1555 * Return 0 on success, otherwise configuration is impossible.
1558 Route::configure_processors_unlocked (ProcessorStreams* err)
1560 if (_in_configure_processors) {
1564 _in_configure_processors = true;
1566 // Check each processor in order to see if we can configure as requested
1567 if (_name == "auditioner") {
1568 cerr << "AUD conf\n";
1570 ChanCount in = input_streams ();
1572 list< pair<ChanCount,ChanCount> > configuration;
1575 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configure processors\n", _name));
1577 DEBUG_TRACE (DEBUG::Processors, "{\n");
1578 for (list<boost::shared_ptr<Processor> >::const_iterator p = _processors.begin(); p != _processors.end(); ++p) {
1579 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1 ID = %2\n", (*p)->name(), (*p)->id()));
1581 DEBUG_TRACE (DEBUG::Processors, "}\n");
1584 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++index) {
1586 if ((*p)->can_support_io_configuration(in, out)) {
1587 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1in = %2 out = %3\n",(*p)->name(), in, out));
1588 configuration.push_back(make_pair(in, out));
1595 _in_configure_processors = false;
1600 // We can, so configure everything
1601 list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
1602 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
1603 (*p)->configure_io(c->first, c->second);
1604 processor_max_streams = ChanCount::max(processor_max_streams, c->first);
1605 processor_max_streams = ChanCount::max(processor_max_streams, c->second);
1610 _meter->reset_max_channels (processor_max_streams);
1613 /* make sure we have sufficient scratch buffers to cope with the new processor
1615 _session.ensure_buffers (n_process_buffers ());
1617 _in_configure_processors = false;
1622 Route::all_processors_flip ()
1624 Glib::RWLock::ReaderLock lm (_processor_lock);
1626 if (_processors.empty()) {
1630 bool first_is_on = _processors.front()->active();
1632 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1634 (*i)->deactivate ();
1640 _session.set_dirty ();
1643 /** Set all processors with a given placement to a given active state.
1644 * @param p Placement of processors to change.
1645 * @param state New active state for those processors.
1648 Route::all_processors_active (Placement p, bool state)
1650 Glib::RWLock::ReaderLock lm (_processor_lock);
1652 if (_processors.empty()) {
1655 ProcessorList::iterator start, end;
1656 placement_range(p, start, end);
1658 bool before_amp = true;
1659 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1664 if (p == PreFader && before_amp) {
1668 (*i)->deactivate ();
1673 _session.set_dirty ();
1677 Route::processor_is_prefader (boost::shared_ptr<Processor> p)
1679 bool pre_fader = true;
1680 Glib::RWLock::ReaderLock lm (_processor_lock);
1682 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1684 /* semantic note: if p == amp, we want to return true, so test
1685 for equality before checking if this is the amp
1702 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
1704 /* "new_order" is an ordered list of processors to be positioned according to "placement".
1705 NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
1706 processors in the current actual processor list that are hidden. Any visible processors
1707 in the current list but not in "new_order" will be assumed to be deleted.
1711 Glib::RWLock::WriterLock lm (_processor_lock);
1712 ChanCount old_pms = processor_max_streams;
1713 ProcessorList::iterator oiter;
1714 ProcessorList::const_iterator niter;
1715 ProcessorList as_it_was_before = _processors;
1716 ProcessorList as_it_will_be;
1718 oiter = _processors.begin();
1719 niter = new_order.begin();
1721 while (niter != new_order.end()) {
1723 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
1724 then append it to the temp list.
1726 Otherwise, see if the next processor in the old list is in the new list. if not,
1727 its been deleted. If its there, append it to the temp list.
1730 if (oiter == _processors.end()) {
1732 /* no more elements in the old list, so just stick the rest of
1733 the new order onto the temp list.
1736 as_it_will_be.insert (as_it_will_be.end(), niter, new_order.end());
1737 while (niter != new_order.end()) {
1744 if (!(*oiter)->display_to_user()) {
1746 as_it_will_be.push_back (*oiter);
1750 /* visible processor: check that its in the new order */
1752 if (find (new_order.begin(), new_order.end(), (*oiter)) == new_order.end()) {
1753 /* deleted: do nothing, shared_ptr<> will clean up */
1755 /* ignore this one, and add the next item from the new order instead */
1756 as_it_will_be.push_back (*niter);
1761 /* now remove from old order - its taken care of no matter what */
1762 oiter = _processors.erase (oiter);
1767 _processors.insert (oiter, as_it_will_be.begin(), as_it_will_be.end());
1769 if (configure_processors_unlocked (err)) {
1770 _processors = as_it_was_before;
1771 processor_max_streams = old_pms;
1776 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1788 Route::get_template()
1790 return state(false);
1794 Route::state(bool full_state)
1796 XMLNode *node = new XMLNode("Route");
1797 ProcessorList::iterator i;
1800 id().print (buf, sizeof (buf));
1801 node->add_property("id", buf);
1802 node->add_property ("name", _name);
1803 node->add_property("default-type", _default_type.to_string());
1806 node->add_property("flags", enum_2_string (_flags));
1809 node->add_property("active", _active?"yes":"no");
1810 node->add_property("phase-invert", _phase_invert?"yes":"no");
1811 node->add_property("denormal-protection", _denormal_protection?"yes":"no");
1812 node->add_property("meter-point", enum_2_string (_meter_point));
1815 node->add_property("route-group", _route_group->name());
1818 string order_string;
1819 OrderKeys::iterator x = order_keys.begin();
1821 while (x != order_keys.end()) {
1822 order_string += string ((*x).first);
1823 order_string += '=';
1824 snprintf (buf, sizeof(buf), "%ld", (*x).second);
1825 order_string += buf;
1829 if (x == order_keys.end()) {
1833 order_string += ':';
1835 node->add_property ("order-keys", order_string);
1836 node->add_property ("self-solo", (_self_solo ? "yes" : "no"));
1837 snprintf (buf, sizeof (buf), "%d", _soloed_by_others);
1838 node->add_property ("soloed-by-others", buf);
1840 node->add_child_nocopy (_input->state (full_state));
1841 node->add_child_nocopy (_output->state (full_state));
1842 node->add_child_nocopy (_solo_control->get_state ());
1843 node->add_child_nocopy (_mute_master->get_state ());
1845 XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
1846 snprintf (buf, sizeof (buf), "%d", _remote_control_id);
1847 remote_control_node->add_property (X_("id"), buf);
1848 node->add_child_nocopy (*remote_control_node);
1850 if (_comment.length()) {
1851 XMLNode *cmt = node->add_child ("Comment");
1852 cmt->add_content (_comment);
1855 for (i = _processors.begin(); i != _processors.end(); ++i) {
1856 node->add_child_nocopy((*i)->state (full_state));
1860 node->add_child_copy (*_extra_xml);
1867 Route::set_state (const XMLNode& node, int version)
1869 return _set_state (node, version, true);
1873 Route::_set_state (const XMLNode& node, int version, bool /*call_base*/)
1875 if (version < 3000) {
1876 return _set_state_2X (node, version);
1880 XMLNodeConstIterator niter;
1882 XMLPropertyList plist;
1883 const XMLProperty *prop;
1885 if (node.name() != "Route"){
1886 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1890 if ((prop = node.property (X_("name"))) != 0) {
1891 Route::set_name (prop->value());
1894 if ((prop = node.property ("id")) != 0) {
1895 _id = prop->value ();
1898 if ((prop = node.property (X_("flags"))) != 0) {
1899 _flags = Flag (string_2_enum (prop->value(), _flags));
1904 /* add all processors (except amp, which is always present) */
1906 nlist = node.children();
1907 XMLNode processor_state (X_("processor_state"));
1909 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1913 if (child->name() == IO::state_node_name) {
1914 if ((prop = child->property (X_("direction"))) == 0) {
1918 if (prop->value() == "Input") {
1919 _input->set_state (*child, version);
1920 } else if (prop->value() == "Output") {
1921 _output->set_state (*child, version);
1925 if (child->name() == X_("Processor")) {
1926 processor_state.add_child_copy (*child);
1930 set_processor_state (processor_state);
1932 if ((prop = node.property ("self-solo")) != 0) {
1933 set_self_solo (string_is_affirmative (prop->value()));
1936 if ((prop = node.property ("soloed-by-others")) != 0) {
1937 _soloed_by_others = 0; // needed for mod_solo_by_others () to work
1938 mod_solo_by_others (atoi (prop->value()));
1941 if ((prop = node.property ("solo-isolated")) != 0) {
1942 set_solo_isolated (string_is_affirmative (prop->value()), this);
1945 if ((prop = node.property (X_("phase-invert"))) != 0) {
1946 set_phase_invert (string_is_affirmative (prop->value()));
1949 if ((prop = node.property (X_("denormal-protection"))) != 0) {
1950 set_denormal_protection (string_is_affirmative (prop->value()));
1953 if ((prop = node.property (X_("active"))) != 0) {
1954 bool yn = string_is_affirmative (prop->value());
1955 _active = !yn; // force switch
1959 if ((prop = node.property (X_("meter-point"))) != 0) {
1960 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
1962 _meter->set_display_to_user (_meter_point == MeterCustom);
1966 if ((prop = node.property (X_("order-keys"))) != 0) {
1970 string::size_type colon, equal;
1971 string remaining = prop->value();
1973 while (remaining.length()) {
1975 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
1976 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1979 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
1980 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1983 set_order_key (remaining.substr (0, equal), n);
1987 colon = remaining.find_first_of (':');
1989 if (colon != string::npos) {
1990 remaining = remaining.substr (colon+1);
1997 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2000 if (child->name() == X_("Comment")) {
2002 /* XXX this is a terrible API design in libxml++ */
2004 XMLNode *cmt = *(child->children().begin());
2005 _comment = cmt->content();
2007 } else if (child->name() == X_("Extra")) {
2009 _extra_xml = new XMLNode (*child);
2011 } else if (child->name() == X_("Controllable") && (prop = child->property("name")) != 0) {
2013 if (prop->value() == "solo") {
2014 _solo_control->set_state (*child, version);
2015 _session.add_controllable (_solo_control);
2018 } else if (child->name() == X_("RemoteControl")) {
2019 if ((prop = child->property (X_("id"))) != 0) {
2021 sscanf (prop->value().c_str(), "%d", &x);
2022 set_remote_control_id (x);
2025 } else if (child->name() == X_("MuteMaster")) {
2026 _mute_master->set_state (*child, version);
2034 Route::_set_state_2X (const XMLNode& node, int version)
2037 XMLNodeConstIterator niter;
2039 XMLPropertyList plist;
2040 const XMLProperty *prop;
2042 /* 2X things which still remain to be handled:
2045 * mute-affects-pre-fader
2046 * mute-affects-post-fader
2047 * mute-affects-control-outs
2048 * mute-affects-main-outs
2053 if (node.name() != "Route") {
2054 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2058 if ((prop = node.property (X_("flags"))) != 0) {
2059 _flags = Flag (string_2_enum (prop->value(), _flags));
2064 /* add standard processors */
2066 _meter.reset (new PeakMeter (_session));
2067 add_processor (_meter, PreFader);
2070 /* where we listen to tracks */
2071 _intreturn.reset (new InternalReturn (_session));
2072 add_processor (_intreturn, PreFader);
2074 _monitor_control.reset (new MonitorProcessor (_session));
2075 add_processor (_monitor_control, PostFader);
2078 _main_outs.reset (new Delivery (_session, _output, _mute_master, _name, Delivery::Main));
2079 add_processor (_main_outs, PostFader);
2083 nlist = node.children ();
2084 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2088 if (child->name() == IO::state_node_name) {
2090 /* there is a note in IO::set_state_2X() about why we have to call
2094 _input->set_state_2X (*child, version, true);
2095 _output->set_state_2X (*child, version, false);
2097 if ((prop = child->property (X_("name"))) != 0) {
2098 set_name (prop->value ());
2101 if ((prop = child->property (X_("id"))) != 0) {
2102 _id = prop->value ();
2105 if ((prop = child->property (X_("active"))) != 0) {
2106 bool yn = string_is_affirmative (prop->value());
2107 _active = !yn; // force switch
2115 if ((prop = node.property (X_("phase-invert"))) != 0) {
2116 set_phase_invert (string_is_affirmative (prop->value()));
2119 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2120 set_denormal_protection (string_is_affirmative (prop->value()));
2123 if ((prop = node.property (X_("soloed"))) != 0) {
2124 bool yn = string_is_affirmative (prop->value());
2126 /* XXX force reset of solo status */
2128 set_solo (yn, this);
2131 if ((prop = node.property (X_("meter-point"))) != 0) {
2132 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
2135 /* do not carry over edit/mix groups from 2.X because (a) its hard (b) they
2136 don't mean the same thing.
2139 if ((prop = node.property (X_("order-keys"))) != 0) {
2143 string::size_type colon, equal;
2144 string remaining = prop->value();
2146 while (remaining.length()) {
2148 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
2149 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2152 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
2153 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2156 set_order_key (remaining.substr (0, equal), n);
2160 colon = remaining.find_first_of (':');
2162 if (colon != string::npos) {
2163 remaining = remaining.substr (colon+1);
2170 XMLNodeList redirect_nodes;
2172 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2176 if (child->name() == X_("Send") || child->name() == X_("Insert")) {
2177 redirect_nodes.push_back(child);
2182 set_processor_state_2X (redirect_nodes, version);
2184 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2187 if (child->name() == X_("Comment")) {
2189 /* XXX this is a terrible API design in libxml++ */
2191 XMLNode *cmt = *(child->children().begin());
2192 _comment = cmt->content();
2194 } else if (child->name() == X_("Extra")) {
2196 _extra_xml = new XMLNode (*child);
2198 } else if (child->name() == X_("Controllable") && (prop = child->property("name")) != 0) {
2200 if (prop->value() == "solo") {
2201 _solo_control->set_state (*child, version);
2202 _session.add_controllable (_solo_control);
2205 } else if (child->name() == X_("RemoteControl")) {
2206 if ((prop = child->property (X_("id"))) != 0) {
2208 sscanf (prop->value().c_str(), "%d", &x);
2209 set_remote_control_id (x);
2219 Route::get_processor_state ()
2221 XMLNode* root = new XMLNode (X_("redirects"));
2222 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2223 root->add_child_nocopy ((*i)->state (true));
2230 Route::set_processor_state_2X (XMLNodeList const & nList, int version)
2232 /* We don't bother removing existing processors not in nList, as this
2233 method will only be called when creating a Route from scratch, not
2234 for undo purposes. Just put processors in at the appropriate place
2238 for (XMLNodeConstIterator i = nList.begin(); i != nList.end(); ++i) {
2239 add_processor_from_xml_2X (**i, version, _processors.begin ());
2244 Route::set_processor_state (const XMLNode& node)
2246 const XMLNodeList &nlist = node.children();
2247 XMLNodeConstIterator niter;
2248 ProcessorList::iterator i, o;
2250 // Iterate through existing processors, remove those which are not in the state list
2252 for (i = _processors.begin(); i != _processors.end(); ) {
2254 /* leave amp alone, always */
2261 ProcessorList::iterator tmp = i;
2264 bool processorInStateList = false;
2266 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2268 XMLProperty* id_prop = (*niter)->property(X_("id"));
2270 if (id_prop && (*i)->id() == id_prop->value()) {
2271 processorInStateList = true;
2276 if (!processorInStateList) {
2277 remove_processor (*i);
2283 // Iterate through state list and make sure all processors are on the track and in the correct order,
2284 // set the state of existing processors according to the new state on the same go
2286 i = _processors.begin();
2288 for (niter = nlist.begin(); niter != nlist.end(); ++niter, ++i) {
2290 XMLProperty* prop = (*niter)->property ("type");
2294 // Check whether the next processor in the list is the right one,
2295 // except for "amp" which is always there and may not have the
2296 // old ID since it is always created anew in every Route
2298 if (prop->value() != "amp") {
2299 while (o != _processors.end()) {
2300 XMLProperty* id_prop = (*niter)->property(X_("id"));
2301 if (id_prop && (*o)->id() == id_prop->value()) {
2309 // If the processor (*niter) is not on the route,
2310 // create it and move it to the correct location
2312 if (o == _processors.end()) {
2314 if (add_processor_from_xml (**niter, i)) {
2315 --i; // move iterator to the newly inserted processor
2317 cerr << "Error restoring route: unable to restore processor" << endl;
2322 // Otherwise, the processor already exists; just
2323 // ensure it is at the location provided in the XML state
2326 boost::shared_ptr<Processor> tmp = (*o);
2327 _processors.erase (o); // remove the old copy
2328 _processors.insert (i, tmp); // insert the processor at the correct location
2329 --i; // move iterator to the correct processor
2332 // and make it (just) so
2334 (*i)->set_state (**niter, Stateful::current_state_version);
2338 /* note: there is no configure_processors() call because we figure that
2339 the XML state represents a working signal route.
2342 processors_changed (RouteProcessorChange ());
2346 Route::curve_reallocate ()
2348 // _gain_automation_curve.finish_resize ();
2349 // _pan_automation_curve.finish_resize ();
2353 Route::silence (nframes_t nframes)
2357 _output->silence (nframes);
2360 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2363 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2364 boost::shared_ptr<PluginInsert> pi;
2366 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
2367 // skip plugins, they don't need anything when we're not active
2371 (*i)->silence (nframes);
2374 if (nframes == _session.get_block_size()) {
2384 Route::add_internal_return ()
2387 _intreturn.reset (new InternalReturn (_session));
2388 add_processor (_intreturn, PreFader);
2393 Route::get_return_buffer () const
2395 Glib::RWLock::ReaderLock rm (_processor_lock);
2397 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
2398 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
2401 BufferSet* bs = d->get_buffers ();
2410 Route::release_return_buffer () const
2412 Glib::RWLock::ReaderLock rm (_processor_lock);
2414 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
2415 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
2418 return d->release_buffers ();
2424 Route::listen_via (boost::shared_ptr<Route> route, Placement placement, bool /*active*/, bool aux)
2426 vector<string> ports;
2427 vector<string>::const_iterator i;
2430 Glib::RWLock::ReaderLock rm (_processor_lock);
2432 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
2434 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
2436 if (d && d->target_route() == route) {
2438 /* if the target is the control outs, then make sure
2439 we take note of which i-send is doing that.
2442 if (route == _session.monitor_out()) {
2443 _monitor_send = boost::dynamic_pointer_cast<Delivery>(d);
2444 if (_monitor_send->active()) {
2445 _monitor_send->set_solo_level (1);
2447 _monitor_send->set_solo_level (0);
2451 /* already listening via the specified IO: do nothing */
2458 boost::shared_ptr<InternalSend> listener;
2464 if (route == _session.monitor_out()) {
2465 /* master never sends to control outs */
2468 listener.reset (new InternalSend (_session, _mute_master, route, (aux ? Delivery::Aux : Delivery::Listen)));
2472 listener.reset (new InternalSend (_session, _mute_master, route, (aux ? Delivery::Aux : Delivery::Listen)));
2473 if (route == _session.monitor_out()) {
2477 } catch (failed_constructor& err) {
2481 if (route == _session.monitor_out()) {
2482 _monitor_send = listener;
2485 if (placement == PostFader) {
2486 /* put it *really* at the end, not just after the panner (main outs)
2488 add_processor (listener, _processors.end());
2490 add_processor (listener, PreFader);
2497 Route::drop_listen (boost::shared_ptr<Route> route)
2499 ProcessorStreams err;
2500 ProcessorList::iterator tmp;
2502 Glib::RWLock::ReaderLock rl(_processor_lock);
2506 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ) {
2508 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
2510 if (d && d->target_route() == route) {
2512 remove_processor (*x, &err);
2515 /* list could have been demolished while we dropped the lock
2525 if (route == _session.monitor_out()) {
2526 _monitor_send.reset ();
2531 Route::set_comment (string cmt, void *src)
2534 comment_changed (src);
2535 _session.set_dirty ();
2539 Route::feeds (boost::shared_ptr<Route> other, bool* only_send)
2541 DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds? %1\n", _name));
2543 if (_output->connected_to (other->input())) {
2544 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS %2\n", other->name()));
2553 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
2555 boost::shared_ptr<IOProcessor> iop;
2557 if ((iop = boost::dynamic_pointer_cast<IOProcessor>(*r)) != 0) {
2558 if (iop->feeds (other)) {
2559 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name()));
2565 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does NOT feed %2\n", iop->name(), other->name()));
2568 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tPROC %1 is not an IOP\n", (*r)->name()));
2573 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdoes NOT feed %1\n", other->name()));
2578 Route::handle_transport_stopped (bool /*abort_ignored*/, bool did_locate, bool can_flush_processors)
2580 nframes_t now = _session.transport_frame();
2583 Glib::RWLock::ReaderLock lm (_processor_lock);
2586 automation_snapshot (now, true);
2589 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2591 if (Config->get_plugins_stop_with_transport() && can_flush_processors) {
2592 (*i)->deactivate ();
2596 (*i)->transport_stopped (now);
2600 _roll_delay = _initial_delay;
2604 Route::input_change_handler (IOChange change, void * /*src*/)
2606 if ((change & ConfigurationChanged)) {
2607 configure_processors (0);
2612 Route::output_change_handler (IOChange change, void * /*src*/)
2614 if ((change & ConfigurationChanged)) {
2616 /* XXX resize all listeners to match _main_outs? */
2618 // configure_processors (0);
2623 Route::pans_required () const
2625 if (n_outputs().n_audio() < 2) {
2629 return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
2633 Route::no_roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame,
2634 bool session_state_changing, bool /*can_record*/, bool /*rec_monitors_input*/)
2636 if (n_outputs().n_total() == 0) {
2640 if (!_active || n_inputs() == ChanCount::ZERO) {
2644 if (session_state_changing) {
2645 if (_session.transport_speed() != 0.0f) {
2646 /* we're rolling but some state is changing (e.g. our diskstream contents)
2647 so we cannot use them. Be silent till this is over.
2649 XXX note the absurdity of ::no_roll() being called when we ARE rolling!
2654 /* we're really not rolling, so we're either delivery silence or actually
2655 monitoring, both of which are safe to do while session_state_changing is true.
2659 _amp->apply_gain_automation (false);
2660 passthru (start_frame, end_frame, nframes, 0);
2666 Route::check_initial_delay (nframes_t nframes, nframes_t& transport_frame)
2668 if (_roll_delay > nframes) {
2670 _roll_delay -= nframes;
2672 /* transport frame is not legal for caller to use */
2675 } else if (_roll_delay > 0) {
2677 nframes -= _roll_delay;
2678 silence (_roll_delay);
2679 /* we've written _roll_delay of samples into the
2680 output ports, so make a note of that for
2683 _main_outs->increment_output_offset (_roll_delay);
2684 transport_frame += _roll_delay;
2693 Route::roll (nframes_t nframes, sframes_t start_frame, sframes_t end_frame, int declick,
2694 bool /*can_record*/, bool /*rec_monitors_input*/)
2697 // automation snapshot can also be called from the non-rt context
2698 // and it uses the processor list, so we try to acquire the lock here
2699 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2702 automation_snapshot (_session.transport_frame(), false);
2706 if (n_outputs().n_total() == 0) {
2710 if (!_active || n_inputs().n_total() == 0) {
2715 nframes_t unused = 0;
2717 if ((nframes = check_initial_delay (nframes, unused)) == 0) {
2723 passthru (start_frame, end_frame, nframes, declick);
2729 Route::silent_roll (nframes_t nframes, sframes_t /*start_frame*/, sframes_t /*end_frame*/,
2730 bool /*can_record*/, bool /*rec_monitors_input*/)
2737 Route::toggle_monitor_input ()
2739 for (PortSet::iterator i = _input->ports().begin(); i != _input->ports().end(); ++i) {
2740 i->ensure_monitor_input( ! i->monitoring_input());
2745 Route::has_external_redirects () const
2747 // FIXME: what about sends? - they don't return a signal back to ardour?
2749 boost::shared_ptr<const PortInsert> pi;
2751 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2753 if ((pi = boost::dynamic_pointer_cast<const PortInsert>(*i)) != 0) {
2755 for (PortSet::const_iterator port = pi->output()->ports().begin(); port != pi->output()->ports().end(); ++port) {
2757 string port_name = port->name();
2758 string client_name = port_name.substr (0, port_name.find(':'));
2760 /* only say "yes" if the redirect is actually in use */
2762 if (client_name != "ardour" && pi->active()) {
2773 Route::flush_processors ()
2775 /* XXX shouldn't really try to take this lock, since
2776 this is called from the RT audio thread.
2779 Glib::RWLock::ReaderLock lm (_processor_lock);
2781 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2782 (*i)->deactivate ();
2788 Route::set_meter_point (MeterPoint p, void *src)
2790 /* CAN BE CALLED FROM PROCESS CONTEXT */
2792 if (_meter_point == p) {
2796 bool meter_was_visible_to_user = _meter->display_to_user ();
2799 Glib::RWLock::WriterLock lm (_processor_lock);
2801 if (p != MeterCustom) {
2802 // Move meter in the processors list to reflect the new position
2803 ProcessorList::iterator loc = find (_processors.begin(), _processors.end(), _meter);
2804 _processors.erase(loc);
2807 loc = _processors.begin();
2810 loc = find (_processors.begin(), _processors.end(), _amp);
2812 case MeterPostFader:
2813 loc = _processors.end();
2821 if (loc == _processors.begin()) {
2822 m_in = _input->n_ports();
2824 ProcessorList::iterator before = loc;
2826 m_in = (*before)->output_streams ();
2829 _meter->reflect_inputs (m_in);
2831 _processors.insert (loc, _meter);
2833 /* we do not need to reconfigure the processors, because the meter
2834 (a) is always ready to handle processor_max_streams
2835 (b) is always an N-in/N-out processor, and thus moving
2836 it doesn't require any changes to the other processors.
2839 _meter->set_display_to_user (false);
2843 // just make it visible and let the user move it
2845 _meter->set_display_to_user (true);
2850 meter_change (src); /* EMIT SIGNAL */
2852 bool const meter_visibly_changed = (_meter->display_to_user() != meter_was_visible_to_user);
2854 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, meter_visibly_changed)); /* EMIT SIGNAL */
2858 Route::put_monitor_send_at (Placement p)
2860 if (!_monitor_send) {
2865 Glib::RWLock::WriterLock lm (_processor_lock);
2866 ProcessorList as_it_was (_processors);
2867 ProcessorList::iterator loc = find(_processors.begin(), _processors.end(), _monitor_send);
2868 _processors.erase(loc);
2872 loc = find(_processors.begin(), _processors.end(), _amp);
2873 if (loc != _processors.begin()) {
2878 loc = _processors.end();
2882 _processors.insert (loc, _monitor_send);
2884 if (configure_processors_unlocked (0)) {
2885 _processors = as_it_was;
2886 configure_processors_unlocked (0); // it worked before we tried to add it ...
2891 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
2892 _session.set_dirty ();
2896 Route::update_total_latency ()
2898 nframes_t old = _output->effective_latency();
2899 nframes_t own_latency = _output->user_latency();
2901 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2902 if ((*i)->active ()) {
2903 own_latency += (*i)->signal_latency ();
2907 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal redirect latency = %2\n", _name, own_latency));
2909 _output->set_port_latency (own_latency);
2911 if (_output->user_latency() == 0) {
2913 /* this (virtual) function is used for pure Routes,
2914 not derived classes like AudioTrack. this means
2915 that the data processed here comes from an input
2916 port, not prerecorded material, and therefore we
2917 have to take into account any input latency.
2920 own_latency += _input->signal_latency ();
2923 if (old != own_latency) {
2924 _output->set_latency_delay (own_latency);
2925 signal_latency_changed (); /* EMIT SIGNAL */
2928 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: input latency = %2 total = %3\n", _name, _input->signal_latency(), own_latency));
2930 return _output->effective_latency ();
2934 Route::set_user_latency (nframes_t nframes)
2936 _output->set_user_latency (nframes);
2937 _session.update_latency_compensation (false, false);
2941 Route::set_latency_delay (nframes_t longest_session_latency)
2943 nframes_t old = _initial_delay;
2945 if (_output->effective_latency() < longest_session_latency) {
2946 _initial_delay = longest_session_latency - _output->effective_latency();
2951 if (_initial_delay != old) {
2952 initial_delay_changed (); /* EMIT SIGNAL */
2955 if (_session.transport_stopped()) {
2956 _roll_delay = _initial_delay;
2961 Route::automation_snapshot (nframes_t now, bool force)
2963 panner()->automation_snapshot (now, force);
2965 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2966 (*i)->automation_snapshot (now, force);
2970 Route::SoloControllable::SoloControllable (std::string name, Route& r)
2971 : AutomationControl (r.session(), Evoral::Parameter (SoloAutomation),
2972 boost::shared_ptr<AutomationList>(), name)
2975 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloAutomation)));
2980 Route::SoloControllable::set_value (float val)
2982 bool bval = ((val >= 0.5f) ? true: false);
2984 this is how it should be done
2986 boost::shared_ptr<RouteList> rl (new RouteList);
2987 rl->push_back (route);
2989 if (Config->get_solo_control_is_listen_control()) {
2990 _session.set_listen (rl, bval);
2992 _session.set_solo (rl, bval);
2995 route.set_solo (bval, this);
3000 Route::SoloControllable::get_value (void) const
3002 if (Config->get_solo_control_is_listen_control()) {
3003 return route.listening() ? 1.0f : 0.0f;
3005 return route.self_soloed() ? 1.0f : 0.0f;
3009 Route::MuteControllable::MuteControllable (std::string name, Route& r)
3010 : AutomationControl (r.session(), Evoral::Parameter (MuteAutomation),
3011 boost::shared_ptr<AutomationList>(), name)
3014 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(MuteAutomation)));
3019 Route::MuteControllable::set_value (float val)
3021 bool bval = ((val >= 0.5f) ? true: false);
3023 this is how it should be done
3025 boost::shared_ptr<RouteList> rl (new RouteList);
3026 rl->push_back (route);
3027 _session.set_mute (rl, bval);
3029 route.set_mute (bval, this);
3034 Route::MuteControllable::get_value (void) const
3036 return route.muted() ? 1.0f : 0.0f;
3040 Route::set_block_size (nframes_t nframes)
3042 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3043 (*i)->set_block_size (nframes);
3046 _session.ensure_buffers (n_process_buffers ());
3050 Route::protect_automation ()
3052 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i)
3053 (*i)->protect_automation();
3057 Route::set_pending_declick (int declick)
3060 /* this call is not allowed to turn off a pending declick unless "force" is true */
3062 _pending_declick = declick;
3064 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
3066 _pending_declick = 0;
3071 /** Shift automation forwards from a particular place, thereby inserting time.
3072 * Adds undo commands for any shifts that are performed.
3074 * @param pos Position to start shifting from.
3075 * @param frames Amount to shift forwards by.
3079 Route::shift (nframes64_t /*pos*/, nframes64_t /*frames*/)
3081 #ifdef THIS_NEEDS_FIXING_FOR_V3
3083 /* gain automation */
3084 XMLNode &before = _gain_control->get_state ();
3085 _gain_control->shift (pos, frames);
3086 XMLNode &after = _gain_control->get_state ();
3087 _session.add_command (new MementoCommand<AutomationList> (_gain_automation_curve, &before, &after));
3089 /* pan automation */
3090 for (std::vector<StreamPanner*>::iterator i = _panner->begin (); i != _panner->end (); ++i) {
3091 Curve & c = (*i)->automation ();
3092 XMLNode &before = c.get_state ();
3093 c.shift (pos, frames);
3094 XMLNode &after = c.get_state ();
3095 _session.add_command (new MementoCommand<AutomationList> (c, &before, &after));
3098 /* redirect automation */
3100 Glib::RWLock::ReaderLock lm (redirect_lock);
3101 for (RedirectList::iterator i = _redirects.begin (); i != _redirects.end (); ++i) {
3104 (*i)->what_has_automation (a);
3106 for (set<uint32_t>::const_iterator j = a.begin (); j != a.end (); ++j) {
3107 AutomationList & al = (*i)->automation_list (*j);
3108 XMLNode &before = al.get_state ();
3109 al.shift (pos, frames);
3110 XMLNode &after = al.get_state ();
3111 _session.add_command (new MementoCommand<AutomationList> (al, &before, &after));
3121 Route::save_as_template (const string& path, const string& name)
3123 XMLNode& node (state (false));
3126 IO::set_name_in_state (*node.children().front(), name);
3128 tree.set_root (&node);
3129 return tree.write (path.c_str());
3134 Route::set_name (const string& str)
3140 name = Route::ensure_track_or_route_name (str, _session);
3141 SessionObject::set_name (name);
3143 ret = (_input->set_name(name) && _output->set_name(name));
3147 Glib::RWLock::ReaderLock lm (_processor_lock);
3149 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3151 /* rename all I/O processors that have inputs or outputs */
3153 boost::shared_ptr<IOProcessor> iop = boost::dynamic_pointer_cast<IOProcessor> (*i);
3155 if (iop && (iop->output() || iop->input())) {
3156 if (!iop->set_name (name)) {
3167 boost::shared_ptr<Send>
3168 Route::internal_send_for (boost::shared_ptr<const Route> target) const
3170 Glib::RWLock::ReaderLock lm (_processor_lock);
3172 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3173 boost::shared_ptr<InternalSend> send;
3175 if ((send = boost::dynamic_pointer_cast<InternalSend>(*i)) != 0) {
3176 if (send->target_route() == target) {
3182 return boost::shared_ptr<Send>();
3186 Route::set_phase_invert (bool yn)
3188 if (_phase_invert != yn) {
3189 _phase_invert = 0xffff; // XXX all channels
3190 phase_invert_changed (); /* EMIT SIGNAL */
3195 Route::phase_invert () const
3197 return _phase_invert != 0;
3201 Route::set_denormal_protection (bool yn)
3203 if (_denormal_protection != yn) {
3204 _denormal_protection = yn;
3205 denormal_protection_changed (); /* EMIT SIGNAL */
3210 Route::denormal_protection () const
3212 return _denormal_protection;
3216 Route::set_active (bool yn)
3218 if (_active != yn) {
3220 _input->set_active (yn);
3221 _output->set_active (yn);
3222 active_changed (); // EMIT SIGNAL
3229 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
3235 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3237 boost::shared_ptr<Send> s;
3238 boost::shared_ptr<Return> r;
3240 if ((s = boost::dynamic_pointer_cast<Send> (*i)) != 0) {
3241 s->meter()->meter();
3242 } else if ((r = boost::dynamic_pointer_cast<Return> (*i)) != 0) {
3243 r->meter()->meter ();
3248 boost::shared_ptr<Panner>
3249 Route::panner() const
3251 return _main_outs->panner();
3254 boost::shared_ptr<AutomationControl>
3255 Route::gain_control() const
3257 return _amp->gain_control();
3260 boost::shared_ptr<AutomationControl>
3261 Route::get_control (const Evoral::Parameter& param)
3263 /* either we own the control or .... */
3265 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(control (param));
3269 /* maybe one of our processors does or ... */
3271 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
3272 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3273 if ((c = boost::dynamic_pointer_cast<AutomationControl>((*i)->control (param))) != 0) {
3281 /* nobody does so we'll make a new one */
3283 c = boost::dynamic_pointer_cast<AutomationControl>(control_factory(param));
3290 boost::shared_ptr<Processor>
3291 Route::nth_plugin (uint32_t n)
3293 Glib::RWLock::ReaderLock lm (_processor_lock);
3294 ProcessorList::iterator i;
3296 for (i = _processors.begin(); i != _processors.end(); ++i) {
3297 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
3304 return boost::shared_ptr<Processor> ();
3307 boost::shared_ptr<Processor>
3308 Route::nth_send (uint32_t n)
3310 Glib::RWLock::ReaderLock lm (_processor_lock);
3311 ProcessorList::iterator i;
3313 for (i = _processors.begin(); i != _processors.end(); ++i) {
3314 cerr << "check " << (*i)->name() << endl;
3315 if (boost::dynamic_pointer_cast<Send> (*i)) {
3320 cerr << "\tnot a send\n";
3324 return boost::shared_ptr<Processor> ();