2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include "libardour-config.h"
29 #include "pbd/xml++.h"
30 #include "pbd/enumwriter.h"
31 #include "pbd/memento_command.h"
32 #include "pbd/stacktrace.h"
33 #include "pbd/convert.h"
34 #include "pbd/boost_debug.h"
36 #include "ardour/amp.h"
37 #include "ardour/audio_buffer.h"
38 #include "ardour/audioengine.h"
39 #include "ardour/buffer.h"
40 #include "ardour/buffer_set.h"
41 #include "ardour/capturing_processor.h"
42 #include "ardour/debug.h"
43 #include "ardour/delivery.h"
44 #include "ardour/internal_return.h"
45 #include "ardour/internal_send.h"
46 #include "ardour/meter.h"
47 #include "ardour/monitor_processor.h"
48 #include "ardour/pannable.h"
49 #include "ardour/panner_shell.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/route.h"
55 #include "ardour/route_group.h"
56 #include "ardour/send.h"
57 #include "ardour/session.h"
58 #include "ardour/unknown_processor.h"
59 #include "ardour/utils.h"
64 using namespace ARDOUR;
67 uint32_t Route::order_key_cnt = 0;
68 PBD::Signal1<void,string const&> Route::SyncOrderKeys;
69 PBD::Signal0<void> Route::RemoteControlIDChange;
71 Route::Route (Session& sess, string name, Flag flg, DataType default_type)
72 : SessionObject (sess, name)
74 , GraphNode (sess._process_graph)
80 , _pending_declick (true)
81 , _meter_point (MeterPostFader)
83 , _soloed_by_others_upstream (0)
84 , _soloed_by_others_downstream (0)
86 , _denormal_protection (false)
89 , _declickable (false)
90 , _mute_master (new MuteMaster (sess, name))
91 , _have_internal_generator (false)
93 , _default_type (default_type)
94 , _remote_control_id (0)
95 , _in_configure_processors (false)
96 , _custom_meter_position_noted (false)
97 , _last_custom_meter_was_at_end (false)
99 processor_max_streams.reset();
100 order_keys[N_("signal")] = order_key_cnt++;
103 set_remote_control_id (MasterBusRemoteControlID);
104 } else if (is_monitor()) {
105 set_remote_control_id (MonitorBusRemoteControlID);
113 /* add standard controls */
115 _solo_control.reset (new SoloControllable (X_("solo"), shared_from_this ()));
116 _mute_control.reset (new MuteControllable (X_("mute"), shared_from_this ()));
118 _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
119 _mute_control->set_flags (Controllable::Flag (_mute_control->flags() | Controllable::Toggle));
121 add_control (_solo_control);
122 add_control (_mute_control);
126 if (!(_flags & Route::MonitorOut)) {
127 _pannable.reset (new Pannable (_session));
130 /* input and output objects */
132 _input.reset (new IO (_session, _name, IO::Input, _default_type));
133 _output.reset (new IO (_session, _name, IO::Output, _default_type));
135 _input->changed.connect_same_thread (*this, boost::bind (&Route::input_change_handler, this, _1, _2));
136 _input->PortCountChanging.connect_same_thread (*this, boost::bind (&Route::input_port_count_changing, this, _1));
138 _output->changed.connect_same_thread (*this, boost::bind (&Route::output_change_handler, this, _1, _2));
140 /* add amp processor */
142 _amp.reset (new Amp (_session));
143 add_processor (_amp, PostFader);
145 /* create standard processors: meter, main outs, monitor out;
146 they will be added to _processors by setup_invisible_processors ()
149 _meter.reset (new PeakMeter (_session));
150 _meter->set_display_to_user (false);
153 _main_outs.reset (new Delivery (_session, _output, _pannable, _mute_master, _name, Delivery::Main));
154 _main_outs->activate ();
157 /* where we listen to tracks */
158 _intreturn.reset (new InternalReturn (_session));
159 _intreturn->activate ();
161 /* the thing that provides proper control over a control/monitor/listen bus
162 (such as per-channel cut, dim, solo, invert, etc).
164 _monitor_control.reset (new MonitorProcessor (_session));
165 _monitor_control->activate ();
168 if (is_master() || is_monitor() || is_hidden()) {
169 _mute_master->set_solo_ignore (true);
172 /* now that we have _meter, its safe to connect to this */
174 Metering::Meter.connect_same_thread (*this, (boost::bind (&Route::meter, this)));
177 /* run a configure so that the invisible processors get set up */
178 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
179 configure_processors (0);
187 DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
189 /* do this early so that we don't get incoming signals as we are going through destruction
194 /* don't use clear_processors here, as it depends on the session which may
195 be half-destroyed by now
198 Glib::RWLock::WriterLock lm (_processor_lock);
199 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
200 (*i)->drop_references ();
203 _processors.clear ();
207 Route::set_remote_control_id (uint32_t id, bool notify_class_listeners)
209 /* force IDs for master/monitor busses and prevent
210 any other route from accidentally getting these IDs
211 (i.e. legacy sessions)
214 if (is_master() && id != MasterBusRemoteControlID) {
215 id = MasterBusRemoteControlID;
218 if (is_monitor() && id != MonitorBusRemoteControlID) {
219 id = MonitorBusRemoteControlID;
222 /* don't allow it to collide */
224 if (!is_master () && !is_monitor() &&
225 (id == MasterBusRemoteControlID || id == MonitorBusRemoteControlID)) {
226 id += MonitorBusRemoteControlID;
229 if (id != _remote_control_id) {
230 _remote_control_id = id;
231 RemoteControlIDChanged ();
232 if (notify_class_listeners) {
233 RemoteControlIDChange ();
239 Route::remote_control_id() const
241 return _remote_control_id;
245 Route::order_key (std::string const & name) const
247 OrderKeys::const_iterator i = order_keys.find (name);
248 if (i == order_keys.end()) {
256 Route::set_order_key (std::string const & name, int32_t n)
258 bool changed = false;
260 /* This method looks more complicated than it should, but
261 it's important that we don't emit order_key_changed unless
262 it actually has, as expensive things happen on receipt of that
266 if (order_keys.find(name) == order_keys.end() || order_keys[name] != n) {
267 order_keys[name] = n;
271 if (Config->get_sync_all_route_ordering()) {
272 for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
273 if (x->second != n) {
281 order_key_changed (); /* EMIT SIGNAL */
282 _session.set_dirty ();
286 /** Set all order keys to be the same as that for `base', if such a key
287 * exists in this route.
288 * @param base Base key.
291 Route::sync_order_keys (std::string const & base)
293 if (order_keys.empty()) {
297 OrderKeys::iterator i;
300 if ((i = order_keys.find (base)) == order_keys.end()) {
301 /* key doesn't exist, use the first existing key (during session initialization) */
302 i = order_keys.begin();
306 /* key exists - use it and reset all others (actually, itself included) */
308 i = order_keys.begin();
311 bool changed = false;
313 for (; i != order_keys.end(); ++i) {
314 if (i->second != key) {
321 order_key_changed (); /* EMIT SIGNAL */
326 Route::ensure_track_or_route_name(string name, Session &session)
328 string newname = name;
330 while (!session.io_name_is_legal (newname)) {
331 newname = bump_name_once (newname, '.');
339 Route::inc_gain (gain_t fraction, void *src)
341 _amp->inc_gain (fraction, src);
345 Route::set_gain (gain_t val, void *src)
347 if (src != 0 && _route_group && src != _route_group && _route_group->is_active() && _route_group->is_gain()) {
349 if (_route_group->is_relative()) {
351 gain_t usable_gain = _amp->gain();
352 if (usable_gain < 0.000001f) {
353 usable_gain = 0.000001f;
357 if (delta < 0.000001f) {
361 delta -= usable_gain;
366 gain_t factor = delta / usable_gain;
369 factor = _route_group->get_max_factor(factor);
370 if (factor == 0.0f) {
371 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
375 factor = _route_group->get_min_factor(factor);
376 if (factor == 0.0f) {
377 _amp->gain_control()->Changed(); /* EMIT SIGNAL */
382 _route_group->foreach_route (boost::bind (&Route::inc_gain, _1, factor, _route_group));
386 _route_group->foreach_route (boost::bind (&Route::set_gain, _1, val, _route_group));
392 if (val == _amp->gain()) {
396 _amp->set_gain (val, src);
400 Route::maybe_declick (BufferSet&, framecnt_t, int)
402 /* this is the "bus" implementation and they never declick.
407 /** Process this route for one (sub) cycle (process thread)
409 * @param bufs Scratch buffers to use for the signal path
410 * @param start_frame Initial transport frame
411 * @param end_frame Final transport frame
412 * @param nframes Number of frames to output (to ports)
414 * Note that (end_frame - start_frame) may not be equal to nframes when the
415 * transport speed isn't 1.0 (eg varispeed).
418 Route::process_output_buffers (BufferSet& bufs,
419 framepos_t start_frame, framepos_t end_frame, pframes_t nframes,
420 int declick, bool gain_automation_ok)
422 bufs.set_is_silent (false);
424 /* figure out if we're going to use gain automation */
425 if (gain_automation_ok) {
426 _amp->setup_gain_automation (start_frame, end_frame, nframes);
428 _amp->apply_gain_automation (false);
431 /* Tell main outs what to do about monitoring. We do this so that
432 on a transition between monitoring states we get a de-clicking gain
433 change in the _main_outs delivery.
435 _main_outs->no_outs_cuz_we_no_monitor (monitoring_state () == MonitoringSilence);
438 /* -------------------------------------------------------------------------------------------
439 GLOBAL DECLICK (for transport changes etc.)
440 ----------------------------------------------------------------------------------------- */
442 maybe_declick (bufs, nframes, declick);
443 _pending_declick = 0;
445 /* -------------------------------------------------------------------------------------------
446 DENORMAL CONTROL/PHASE INVERT
447 ----------------------------------------------------------------------------------------- */
449 if (_phase_invert.any ()) {
453 if (_denormal_protection || Config->get_denormal_protection()) {
455 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
456 Sample* const sp = i->data();
458 if (_phase_invert[chn]) {
459 for (pframes_t nx = 0; nx < nframes; ++nx) {
464 for (pframes_t nx = 0; nx < nframes; ++nx) {
472 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i, ++chn) {
473 Sample* const sp = i->data();
475 if (_phase_invert[chn]) {
476 for (pframes_t nx = 0; nx < nframes; ++nx) {
485 if (_denormal_protection || Config->get_denormal_protection()) {
487 for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
488 Sample* const sp = i->data();
489 for (pframes_t nx = 0; nx < nframes; ++nx) {
497 /* -------------------------------------------------------------------------------------------
499 ----------------------------------------------------------------------------------------- */
501 /* set this to be true if the meter will already have been ::run() earlier */
502 bool const meter_already_run = metering_state() == MeteringInput;
504 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
506 if (meter_already_run && boost::dynamic_pointer_cast<PeakMeter> (*i)) {
507 /* don't ::run() the meter, otherwise it will have its previous peak corrupted */
512 /* if it has any inputs, make sure they match */
513 if (boost::dynamic_pointer_cast<UnknownProcessor> (*i) == 0 && (*i)->input_streams() != ChanCount::ZERO) {
514 if (bufs.count() != (*i)->input_streams()) {
516 DEBUG::Processors, string_compose (
517 "%1 bufs = %2 input for %3 = %4\n",
518 _name, bufs.count(), (*i)->name(), (*i)->input_streams()
526 /* should we NOT run plugins here if the route is inactive?
527 do we catch route != active somewhere higher?
530 (*i)->run (bufs, start_frame, end_frame, nframes, *i != _processors.back());
531 bufs.set_count ((*i)->output_streams());
536 Route::n_process_buffers ()
538 return max (_input->n_ports(), processor_max_streams);
542 Route::passthru (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
544 BufferSet& bufs = _session.get_scratch_buffers (n_process_buffers());
548 assert (bufs.available() >= input_streams());
550 if (_input->n_ports() == ChanCount::ZERO) {
551 silence_unlocked (nframes);
554 bufs.set_count (input_streams());
556 if (is_monitor() && _session.listening() && !_session.is_auditioning()) {
558 /* control/monitor bus ignores input ports when something is
559 feeding the listen "stream". data will "arrive" into the
560 route from the intreturn processor element.
562 bufs.silence (nframes, 0);
566 for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
568 BufferSet::iterator o = bufs.begin(*t);
569 PortSet& ports (_input->ports());
571 for (PortSet::iterator i = ports.begin(*t); i != ports.end(*t); ++i, ++o) {
572 o->read_from (i->get_buffer(nframes), nframes);
577 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
578 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, true);
582 Route::passthru_silence (framepos_t start_frame, framepos_t end_frame, pframes_t nframes, int declick)
584 BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
586 bufs.set_count (_input->n_ports());
587 write_out_of_band_data (bufs, start_frame, end_frame, nframes);
588 process_output_buffers (bufs, start_frame, end_frame, nframes, declick, false);
592 Route::set_listen (bool yn, void* src)
598 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
599 _route_group->foreach_route (boost::bind (&Route::set_listen, _1, yn, _route_group));
604 if (yn != _monitor_send->active()) {
606 _monitor_send->activate ();
607 _mute_master->set_soloed (true);
609 _monitor_send->deactivate ();
610 _mute_master->set_soloed (false);
613 listen_changed (src); /* EMIT SIGNAL */
619 Route::listening_via_monitor () const
622 return _monitor_send->active ();
629 Route::set_solo_safe (bool yn, void *src)
631 if (_solo_safe != yn) {
633 solo_safe_changed (src);
638 Route::solo_safe() const
644 Route::set_solo (bool yn, void *src)
650 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
651 _route_group->foreach_route (boost::bind (&Route::set_solo, _1, yn, _route_group));
655 if (self_soloed() != yn) {
657 set_mute_master_solo ();
658 solo_changed (true, src); /* EMIT SIGNAL */
659 _solo_control->Changed (); /* EMIT SIGNAL */
664 Route::set_self_solo (bool yn)
670 Route::mod_solo_by_others_upstream (int32_t delta)
676 uint32_t old_sbu = _soloed_by_others_upstream;
679 if (_soloed_by_others_upstream >= (uint32_t) abs (delta)) {
680 _soloed_by_others_upstream += delta;
682 _soloed_by_others_upstream = 0;
685 _soloed_by_others_upstream += delta;
688 DEBUG_TRACE (DEBUG::Solo, string_compose (
689 "%1 SbU delta %2 = %3 old = %4 sbd %5 ss %6 exclusive %7\n",
690 name(), delta, _soloed_by_others_upstream, old_sbu,
691 _soloed_by_others_downstream, _self_solo, Config->get_exclusive_solo()));
693 /* push the inverse solo change to everything that feeds us.
695 This is important for solo-within-group. When we solo 1 track out of N that
696 feed a bus, that track will cause mod_solo_by_upstream (+1) to be called
697 on the bus. The bus then needs to call mod_solo_by_downstream (-1) on all
698 tracks that feed it. This will silence them if they were audible because
699 of a bus solo, but the newly soloed track will still be audible (because
702 but .. do this only when we are being told to solo-by-upstream (i.e delta = +1),
706 if ((_self_solo || _soloed_by_others_downstream) &&
707 ((old_sbu == 0 && _soloed_by_others_upstream > 0) ||
708 (old_sbu > 0 && _soloed_by_others_upstream == 0))) {
710 if (delta > 0 || !Config->get_exclusive_solo()) {
711 DEBUG_TRACE (DEBUG::Solo, "\t ... INVERT push\n");
712 for (FedBy::iterator i = _fed_by.begin(); i != _fed_by.end(); ++i) {
713 boost::shared_ptr<Route> sr = i->r.lock();
715 sr->mod_solo_by_others_downstream (-delta);
721 set_mute_master_solo ();
722 solo_changed (false, this);
726 Route::mod_solo_by_others_downstream (int32_t delta)
733 if (_soloed_by_others_downstream >= (uint32_t) abs (delta)) {
734 _soloed_by_others_downstream += delta;
736 _soloed_by_others_downstream = 0;
739 _soloed_by_others_downstream += delta;
742 DEBUG_TRACE (DEBUG::Solo, string_compose ("%1 SbD delta %2 = %3\n", name(), delta, _soloed_by_others_downstream));
744 set_mute_master_solo ();
745 solo_changed (false, this);
749 Route::set_mute_master_solo ()
751 _mute_master->set_soloed (self_soloed() || soloed_by_others_downstream() || soloed_by_others_upstream());
755 Route::set_solo_isolated (bool yn, void *src)
757 if (is_master() || is_monitor() || is_hidden()) {
761 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_solo()) {
762 _route_group->foreach_route (boost::bind (&Route::set_solo_isolated, _1, yn, _route_group));
766 /* forward propagate solo-isolate status to everything fed by this route, but not those via sends only */
768 boost::shared_ptr<RouteList> routes = _session.get_routes ();
769 for (RouteList::iterator i = routes->begin(); i != routes->end(); ++i) {
771 if ((*i).get() == this || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
776 bool does_feed = direct_feeds_according_to_graph (*i, &sends_only); // we will recurse anyway, so don't use ::feeds()
778 if (does_feed && !sends_only) {
779 (*i)->set_solo_isolated (yn, (*i)->route_group());
783 /* XXX should we back-propagate as well? (April 2010: myself and chris goddard think not) */
785 bool changed = false;
788 if (_solo_isolated == 0) {
789 _mute_master->set_solo_ignore (true);
794 if (_solo_isolated > 0) {
796 if (_solo_isolated == 0) {
797 _mute_master->set_solo_ignore (false);
804 solo_isolated_changed (src);
809 Route::solo_isolated () const
811 return _solo_isolated > 0;
815 Route::set_mute_points (MuteMaster::MutePoint mp)
817 _mute_master->set_mute_points (mp);
818 mute_points_changed (); /* EMIT SIGNAL */
820 if (_mute_master->muted_by_self()) {
821 mute_changed (this); /* EMIT SIGNAL */
822 _mute_control->Changed (); /* EMIT SIGNAL */
827 Route::set_mute (bool yn, void *src)
829 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_mute()) {
830 _route_group->foreach_route (boost::bind (&Route::set_mute, _1, yn, _route_group));
835 _mute_master->set_muted_by_self (yn);
836 /* allow any derived classes to respond to the mute change
837 before anybody else knows about it.
840 /* tell everyone else */
841 mute_changed (src); /* EMIT SIGNAL */
842 _mute_control->Changed (); /* EMIT SIGNAL */
847 Route::muted () const
849 return _mute_master->muted_by_self();
854 dump_processors(const string& name, const list<boost::shared_ptr<Processor> >& procs)
856 cerr << name << " {" << endl;
857 for (list<boost::shared_ptr<Processor> >::const_iterator p = procs.begin();
858 p != procs.end(); ++p) {
859 cerr << "\t" << (*p)->name() << " ID = " << (*p)->id() << " @ " << (*p) << endl;
865 /** Supposing that we want to insert a Processor at a given Placement, return
866 * the processor to add the new one before (or 0 to add at the end).
868 boost::shared_ptr<Processor>
869 Route::before_processor_for_placement (Placement p)
871 Glib::RWLock::ReaderLock lm (_processor_lock);
873 ProcessorList::iterator loc;
876 /* generic pre-fader: insert immediately before the amp */
877 loc = find (_processors.begin(), _processors.end(), _amp);
879 /* generic post-fader: insert right before the main outs */
880 loc = find (_processors.begin(), _processors.end(), _main_outs);
883 return loc != _processors.end() ? *loc : boost::shared_ptr<Processor> ();
886 /** Supposing that we want to insert a Processor at a given index, return
887 * the processor to add the new one before (or 0 to add at the end).
889 boost::shared_ptr<Processor>
890 Route::before_processor_for_index (int index)
893 return boost::shared_ptr<Processor> ();
896 Glib::RWLock::ReaderLock lm (_processor_lock);
898 ProcessorList::iterator i = _processors.begin ();
900 while (i != _processors.end() && j < index) {
901 if ((*i)->display_to_user()) {
908 return (i != _processors.end() ? *i : boost::shared_ptr<Processor> ());
911 /** Add a processor either pre- or post-fader
912 * @return 0 on success, non-0 on failure.
915 Route::add_processor (boost::shared_ptr<Processor> processor, Placement placement, ProcessorStreams* err, bool activation_allowed)
917 return add_processor (processor, before_processor_for_placement (placement), err, activation_allowed);
921 /** Add a processor to a route such that it ends up with a given index into the visible processors.
922 * @param index Index to add the processor at, or -1 to add at the end of the list.
923 * @return 0 on success, non-0 on failure.
926 Route::add_processor_by_index (boost::shared_ptr<Processor> processor, int index, ProcessorStreams* err, bool activation_allowed)
928 return add_processor (processor, before_processor_for_index (index), err, activation_allowed);
931 /** Add a processor to the route.
932 * @param before An existing processor in the list, or 0; the new processor will be inserted immediately before it (or at the end).
933 * @return 0 on success, non-0 on failure.
936 Route::add_processor (boost::shared_ptr<Processor> processor, boost::shared_ptr<Processor> before, ProcessorStreams* err, bool activation_allowed)
938 assert (processor != _meter);
939 assert (processor != _main_outs);
941 DEBUG_TRACE (DEBUG::Processors, string_compose (
942 "%1 adding processor %2\n", name(), processor->name()));
944 if (!_session.engine().connected() || !processor) {
949 Glib::RWLock::WriterLock lm (_processor_lock);
950 ProcessorState pstate (this);
952 boost::shared_ptr<PluginInsert> pi;
953 boost::shared_ptr<PortInsert> porti;
955 if (processor == _amp) {
956 /* Ensure that only one amp is in the list at any time */
957 ProcessorList::iterator check = find (_processors.begin(), _processors.end(), processor);
958 if (check != _processors.end()) {
959 if (before == _amp) {
960 /* Already in position; all is well */
963 _processors.erase (check);
968 assert (find (_processors.begin(), _processors.end(), processor) == _processors.end ());
970 ProcessorList::iterator loc;
972 /* inserting before a processor; find it */
973 loc = find (_processors.begin(), _processors.end(), before);
974 if (loc == _processors.end ()) {
979 /* inserting at end */
980 loc = _processors.end ();
983 _processors.insert (loc, processor);
985 // Set up processor list channels. This will set processor->[input|output]_streams(),
986 // configure redirect ports properly, etc.
989 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
991 if (configure_processors_unlocked (err)) {
993 configure_processors_unlocked (0); // it worked before we tried to add it ...
998 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(processor)) != 0) {
1000 if (pi->has_no_inputs ()) {
1001 /* generator plugin */
1002 _have_internal_generator = true;
1007 if (activation_allowed) {
1008 processor->activate ();
1011 processor->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1013 _output->set_user_latency (0);
1016 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1017 set_processor_positions ();
1023 Route::add_processor_from_xml_2X (const XMLNode& node, int version)
1025 const XMLProperty *prop;
1028 boost::shared_ptr<Processor> processor;
1030 /* bit of a hack: get the `placement' property from the <Redirect> tag here
1031 so that we can add the processor in the right place (pre/post-fader)
1034 XMLNodeList const & children = node.children ();
1035 XMLNodeList::const_iterator i = children.begin ();
1037 while (i != children.end() && (*i)->name() != X_("Redirect")) {
1041 Placement placement = PreFader;
1043 if (i != children.end()) {
1044 if ((prop = (*i)->property (X_("placement"))) != 0) {
1045 placement = Placement (string_2_enum (prop->value(), placement));
1049 if (node.name() == "Insert") {
1051 if ((prop = node.property ("type")) != 0) {
1053 if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
1054 prop->value() == "lv2" ||
1055 prop->value() == "vst" ||
1056 prop->value() == "lxvst" ||
1057 prop->value() == "audiounit") {
1059 processor.reset (new PluginInsert (_session));
1063 processor.reset (new PortInsert (_session, _pannable, _mute_master));
1068 } else if (node.name() == "Send") {
1070 processor.reset (new Send (_session, _pannable, _mute_master));
1074 error << string_compose(_("unknown Processor type \"%1\"; ignored"), node.name()) << endmsg;
1078 if (processor->set_state (node, version)) {
1082 return (add_processor (processor, placement) == 0);
1085 catch (failed_constructor &err) {
1086 warning << _("processor could not be created. Ignored.") << endmsg;
1092 Route::add_processors (const ProcessorList& others, boost::shared_ptr<Processor> before, ProcessorStreams* err)
1094 /* NOTE: this is intended to be used ONLY when copying
1095 processors from another Route. Hence the subtle
1096 differences between this and ::add_processor()
1099 ProcessorList::iterator loc;
1102 loc = find(_processors.begin(), _processors.end(), before);
1104 /* nothing specified - at end */
1105 loc = _processors.end ();
1108 if (!_session.engine().connected()) {
1112 if (others.empty()) {
1117 Glib::RWLock::WriterLock lm (_processor_lock);
1118 ProcessorState pstate (this);
1120 for (ProcessorList::const_iterator i = others.begin(); i != others.end(); ++i) {
1126 boost::shared_ptr<PluginInsert> pi;
1128 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1132 _processors.insert (loc, *i);
1134 if ((*i)->active()) {
1139 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
1140 if (configure_processors_unlocked (err)) {
1142 configure_processors_unlocked (0); // it worked before we tried to add it ...
1147 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
1150 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
1151 boost::shared_ptr<PluginInsert> pi;
1153 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1154 if (pi->has_no_inputs ()) {
1155 _have_internal_generator = true;
1161 _output->set_user_latency (0);
1164 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1165 set_processor_positions ();
1171 Route::placement_range(Placement p, ProcessorList::iterator& start, ProcessorList::iterator& end)
1173 if (p == PreFader) {
1174 start = _processors.begin();
1175 end = find(_processors.begin(), _processors.end(), _amp);
1177 start = find(_processors.begin(), _processors.end(), _amp);
1179 end = _processors.end();
1183 /** Turn off all processors with a given placement
1184 * @param p Placement of processors to disable
1187 Route::disable_processors (Placement p)
1189 Glib::RWLock::ReaderLock lm (_processor_lock);
1191 ProcessorList::iterator start, end;
1192 placement_range(p, start, end);
1194 for (ProcessorList::iterator i = start; i != end; ++i) {
1195 (*i)->deactivate ();
1198 _session.set_dirty ();
1201 /** Turn off all redirects
1204 Route::disable_processors ()
1206 Glib::RWLock::ReaderLock lm (_processor_lock);
1208 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1209 (*i)->deactivate ();
1212 _session.set_dirty ();
1215 /** Turn off all redirects with a given placement
1216 * @param p Placement of redirects to disable
1219 Route::disable_plugins (Placement p)
1221 Glib::RWLock::ReaderLock lm (_processor_lock);
1223 ProcessorList::iterator start, end;
1224 placement_range(p, start, end);
1226 for (ProcessorList::iterator i = start; i != end; ++i) {
1227 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1228 (*i)->deactivate ();
1232 _session.set_dirty ();
1235 /** Turn off all plugins
1238 Route::disable_plugins ()
1240 Glib::RWLock::ReaderLock lm (_processor_lock);
1242 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1243 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1244 (*i)->deactivate ();
1248 _session.set_dirty ();
1253 Route::ab_plugins (bool forward)
1255 Glib::RWLock::ReaderLock lm (_processor_lock);
1259 /* forward = turn off all active redirects, and mark them so that the next time
1260 we go the other way, we will revert them
1263 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1264 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1268 if ((*i)->active()) {
1269 (*i)->deactivate ();
1270 (*i)->set_next_ab_is_active (true);
1272 (*i)->set_next_ab_is_active (false);
1278 /* backward = if the redirect was marked to go active on the next ab, do so */
1280 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1282 if (!boost::dynamic_pointer_cast<PluginInsert> (*i)) {
1286 if ((*i)->get_next_ab_is_active()) {
1289 (*i)->deactivate ();
1294 _session.set_dirty ();
1298 /** Remove processors with a given placement.
1299 * @param p Placement of processors to remove.
1302 Route::clear_processors (Placement p)
1304 if (!_session.engine().connected()) {
1308 bool already_deleting = _session.deletion_in_progress();
1309 if (!already_deleting) {
1310 _session.set_deletion_in_progress();
1314 Glib::RWLock::WriterLock lm (_processor_lock);
1315 ProcessorList new_list;
1316 ProcessorStreams err;
1317 bool seen_amp = false;
1319 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1325 if ((*i) == _amp || (*i) == _meter || (*i) == _main_outs) {
1327 /* you can't remove these */
1329 new_list.push_back (*i);
1336 new_list.push_back (*i);
1339 (*i)->drop_references ();
1347 (*i)->drop_references ();
1350 new_list.push_back (*i);
1357 _processors = new_list;
1360 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
1361 configure_processors_unlocked (&err); // this can't fail
1365 processor_max_streams.reset();
1366 _have_internal_generator = false;
1367 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1368 set_processor_positions ();
1370 if (!already_deleting) {
1371 _session.clear_deletion_in_progress();
1376 Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStreams* err, bool need_process_lock)
1378 /* these can never be removed */
1380 if (processor == _amp || processor == _meter || processor == _main_outs) {
1384 if (!_session.engine().connected()) {
1388 processor_max_streams.reset();
1391 Glib::RWLock::WriterLock lm (_processor_lock);
1392 ProcessorState pstate (this);
1394 ProcessorList::iterator i;
1395 bool removed = false;
1397 for (i = _processors.begin(); i != _processors.end(); ) {
1398 if (*i == processor) {
1400 /* move along, see failure case for configure_processors()
1401 where we may need to reconfigure the processor.
1404 /* stop redirects that send signals to JACK ports
1405 from causing noise as a result of no longer being
1409 boost::shared_ptr<IOProcessor> iop;
1411 if ((iop = boost::dynamic_pointer_cast<IOProcessor> (*i)) != 0) {
1413 iop->input()->disconnect (this);
1415 if (iop->output()) {
1416 iop->output()->disconnect (this);
1420 i = _processors.erase (i);
1428 _output->set_user_latency (0);
1436 if (need_process_lock) {
1437 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
1439 if (configure_processors_unlocked (err)) {
1441 /* we know this will work, because it worked before :) */
1442 configure_processors_unlocked (0);
1446 if (configure_processors_unlocked (err)) {
1448 /* we know this will work, because it worked before :) */
1449 configure_processors_unlocked (0);
1454 _have_internal_generator = false;
1456 for (i = _processors.begin(); i != _processors.end(); ++i) {
1457 boost::shared_ptr<PluginInsert> pi;
1459 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1460 if (pi->has_no_inputs ()) {
1461 _have_internal_generator = true;
1468 processor->drop_references ();
1469 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1470 set_processor_positions ();
1476 Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams* err)
1478 ProcessorList deleted;
1480 if (!_session.engine().connected()) {
1484 processor_max_streams.reset();
1487 Glib::RWLock::WriterLock lm (_processor_lock);
1488 ProcessorState pstate (this);
1490 ProcessorList::iterator i;
1491 boost::shared_ptr<Processor> processor;
1493 for (i = _processors.begin(); i != _processors.end(); ) {
1497 /* these can never be removed */
1499 if (processor == _amp || processor == _meter || processor == _main_outs) {
1504 /* see if its in the list of processors to delete */
1506 if (find (to_be_deleted.begin(), to_be_deleted.end(), processor) == to_be_deleted.end()) {
1511 /* stop IOProcessors that send to JACK ports
1512 from causing noise as a result of no longer being
1516 boost::shared_ptr<IOProcessor> iop;
1518 if ((iop = boost::dynamic_pointer_cast<IOProcessor> (processor)) != 0) {
1522 deleted.push_back (processor);
1523 i = _processors.erase (i);
1526 if (deleted.empty()) {
1527 /* none of those in the requested list were found */
1531 _output->set_user_latency (0);
1534 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
1536 if (configure_processors_unlocked (err)) {
1538 /* we know this will work, because it worked before :) */
1539 configure_processors_unlocked (0);
1544 _have_internal_generator = false;
1546 for (i = _processors.begin(); i != _processors.end(); ++i) {
1547 boost::shared_ptr<PluginInsert> pi;
1549 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1550 if (pi->has_no_inputs ()) {
1551 _have_internal_generator = true;
1558 /* now try to do what we need to so that those that were removed will be deleted */
1560 for (ProcessorList::iterator i = deleted.begin(); i != deleted.end(); ++i) {
1561 (*i)->drop_references ();
1564 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1565 set_processor_positions ();
1570 /** Caller must hold process lock */
1572 Route::configure_processors (ProcessorStreams* err)
1574 assert (!AudioEngine::instance()->process_lock().trylock());
1576 if (!_in_configure_processors) {
1577 Glib::RWLock::WriterLock lm (_processor_lock);
1578 return configure_processors_unlocked (err);
1585 Route::input_streams () const
1587 return _input->n_ports ();
1590 list<pair<ChanCount, ChanCount> >
1591 Route::try_configure_processors (ChanCount in, ProcessorStreams* err)
1593 Glib::RWLock::ReaderLock lm (_processor_lock);
1595 return try_configure_processors_unlocked (in, err);
1598 list<pair<ChanCount, ChanCount> >
1599 Route::try_configure_processors_unlocked (ChanCount in, ProcessorStreams* err)
1601 // Check each processor in order to see if we can configure as requested
1603 list<pair<ChanCount, ChanCount> > configuration;
1606 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configure processors\n", _name));
1607 DEBUG_TRACE (DEBUG::Processors, "{\n");
1609 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++index) {
1611 if (boost::dynamic_pointer_cast<UnknownProcessor> (*p)) {
1612 DEBUG_TRACE (DEBUG::Processors, "--- CONFIGURE ABORTED due to unknown processor.\n");
1616 if ((*p)->can_support_io_configuration(in, out)) {
1617 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1 ID=%2 in=%3 out=%4\n",(*p)->name(), (*p)->id(), in, out));
1618 configuration.push_back(make_pair(in, out));
1625 DEBUG_TRACE (DEBUG::Processors, "---- CONFIGURATION FAILED.\n");
1626 DEBUG_TRACE (DEBUG::Processors, string_compose ("---- %1 cannot support in=%2 out=%3\n", (*p)->name(), in, out));
1627 DEBUG_TRACE (DEBUG::Processors, "}\n");
1628 return list<pair<ChanCount, ChanCount> > ();
1632 DEBUG_TRACE (DEBUG::Processors, "}\n");
1634 return configuration;
1637 /** Set the input/output configuration of each processor in the processors list.
1638 * Caller must hold process lock.
1639 * Return 0 on success, otherwise configuration is impossible.
1642 Route::configure_processors_unlocked (ProcessorStreams* err)
1644 assert (!AudioEngine::instance()->process_lock().trylock());
1646 if (_in_configure_processors) {
1650 /* put invisible processors where they should be */
1651 setup_invisible_processors ();
1653 _in_configure_processors = true;
1655 list<pair<ChanCount, ChanCount> > configuration = try_configure_processors_unlocked (input_streams (), err);
1657 if (configuration.empty ()) {
1658 _in_configure_processors = false;
1664 list< pair<ChanCount,ChanCount> >::iterator c = configuration.begin();
1665 for (ProcessorList::iterator p = _processors.begin(); p != _processors.end(); ++p, ++c) {
1667 if (boost::dynamic_pointer_cast<UnknownProcessor> (*p)) {
1671 (*p)->configure_io(c->first, c->second);
1672 processor_max_streams = ChanCount::max(processor_max_streams, c->first);
1673 processor_max_streams = ChanCount::max(processor_max_streams, c->second);
1678 _meter->reset_max_channels (processor_max_streams);
1681 /* make sure we have sufficient scratch buffers to cope with the new processor
1684 _session.ensure_buffers (n_process_buffers ());
1686 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: configuration complete\n", _name));
1688 _in_configure_processors = false;
1692 /** Set all visible processors to a given active state (except Fader, whose state is not changed)
1693 * @param state New active state for those processors.
1696 Route::all_visible_processors_active (bool state)
1698 Glib::RWLock::ReaderLock lm (_processor_lock);
1700 if (_processors.empty()) {
1704 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
1705 if (!(*i)->display_to_user() || boost::dynamic_pointer_cast<Amp> (*i)) {
1712 (*i)->deactivate ();
1716 _session.set_dirty ();
1720 Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err)
1722 /* "new_order" is an ordered list of processors to be positioned according to "placement".
1723 NOTE: all processors in "new_order" MUST be marked as display_to_user(). There maybe additional
1724 processors in the current actual processor list that are hidden. Any visible processors
1725 in the current list but not in "new_order" will be assumed to be deleted.
1729 Glib::RWLock::WriterLock lm (_processor_lock);
1730 ProcessorState pstate (this);
1732 ProcessorList::iterator oiter;
1733 ProcessorList::const_iterator niter;
1734 ProcessorList as_it_will_be;
1736 oiter = _processors.begin();
1737 niter = new_order.begin();
1739 while (niter != new_order.end()) {
1741 /* if the next processor in the old list is invisible (i.e. should not be in the new order)
1742 then append it to the temp list.
1744 Otherwise, see if the next processor in the old list is in the new list. if not,
1745 its been deleted. If its there, append it to the temp list.
1748 if (oiter == _processors.end()) {
1750 /* no more elements in the old list, so just stick the rest of
1751 the new order onto the temp list.
1754 as_it_will_be.insert (as_it_will_be.end(), niter, new_order.end());
1755 while (niter != new_order.end()) {
1762 if (!(*oiter)->display_to_user()) {
1764 as_it_will_be.push_back (*oiter);
1768 /* visible processor: check that its in the new order */
1770 if (find (new_order.begin(), new_order.end(), (*oiter)) == new_order.end()) {
1771 /* deleted: do nothing, shared_ptr<> will clean up */
1773 /* ignore this one, and add the next item from the new order instead */
1774 as_it_will_be.push_back (*niter);
1779 /* now remove from old order - its taken care of no matter what */
1780 oiter = _processors.erase (oiter);
1785 _processors.insert (oiter, as_it_will_be.begin(), as_it_will_be.end());
1787 /* If the meter is in a custom position, find it and make a rough note of its position */
1788 maybe_note_meter_position ();
1791 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
1793 if (configure_processors_unlocked (err)) {
1800 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
1801 set_processor_positions ();
1813 Route::get_template()
1815 return state(false);
1819 Route::state(bool full_state)
1821 XMLNode *node = new XMLNode("Route");
1822 ProcessorList::iterator i;
1825 id().print (buf, sizeof (buf));
1826 node->add_property("id", buf);
1827 node->add_property ("name", _name);
1828 node->add_property("default-type", _default_type.to_string());
1831 node->add_property("flags", enum_2_string (_flags));
1834 node->add_property("active", _active?"yes":"no");
1836 boost::to_string (_phase_invert, p);
1837 node->add_property("phase-invert", p);
1838 node->add_property("denormal-protection", _denormal_protection?"yes":"no");
1839 node->add_property("meter-point", enum_2_string (_meter_point));
1842 node->add_property("route-group", _route_group->name());
1845 string order_string;
1846 OrderKeys::iterator x = order_keys.begin();
1848 while (x != order_keys.end()) {
1849 order_string += string ((*x).first);
1850 order_string += '=';
1851 snprintf (buf, sizeof(buf), "%ld", (*x).second);
1852 order_string += buf;
1856 if (x == order_keys.end()) {
1860 order_string += ':';
1862 node->add_property ("order-keys", order_string);
1863 node->add_property ("self-solo", (_self_solo ? "yes" : "no"));
1864 snprintf (buf, sizeof (buf), "%d", _soloed_by_others_upstream);
1865 node->add_property ("soloed-by-upstream", buf);
1866 snprintf (buf, sizeof (buf), "%d", _soloed_by_others_downstream);
1867 node->add_property ("soloed-by-downstream", buf);
1868 node->add_property ("solo-isolated", solo_isolated() ? "yes" : "no");
1869 node->add_property ("solo-safe", _solo_safe ? "yes" : "no");
1871 node->add_child_nocopy (_input->state (full_state));
1872 node->add_child_nocopy (_output->state (full_state));
1873 node->add_child_nocopy (_solo_control->get_state ());
1874 node->add_child_nocopy (_mute_control->get_state ());
1875 node->add_child_nocopy (_mute_master->get_state ());
1877 XMLNode* remote_control_node = new XMLNode (X_("RemoteControl"));
1878 snprintf (buf, sizeof (buf), "%d", _remote_control_id);
1879 remote_control_node->add_property (X_("id"), buf);
1880 node->add_child_nocopy (*remote_control_node);
1882 if (_comment.length()) {
1883 XMLNode *cmt = node->add_child ("Comment");
1884 cmt->add_content (_comment);
1888 node->add_child_nocopy (_pannable->state (full_state));
1891 for (i = _processors.begin(); i != _processors.end(); ++i) {
1893 /* template save: do not include internal sends functioning as
1894 aux sends because the chance of the target ID
1895 in the session where this template is used
1898 similarly, do not save listen sends which connect to
1899 the monitor section, because these will always be
1902 boost::shared_ptr<InternalSend> is;
1904 if ((is = boost::dynamic_pointer_cast<InternalSend> (*i)) != 0) {
1905 if (is->role() == Delivery::Aux || is->role() == Delivery::Listen) {
1910 node->add_child_nocopy((*i)->state (full_state));
1914 node->add_child_copy (*_extra_xml);
1917 if (_custom_meter_position_noted) {
1918 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
1920 after->id().print (buf, sizeof (buf));
1921 node->add_property (X_("processor-after-last-custom-meter"), buf);
1924 node->add_property (X_("last-custom-meter-was-at-end"), _last_custom_meter_was_at_end ? "yes" : "no");
1931 Route::set_state (const XMLNode& node, int version)
1933 if (version < 3000) {
1934 return set_state_2X (node, version);
1938 XMLNodeConstIterator niter;
1940 const XMLProperty *prop;
1942 if (node.name() != "Route"){
1943 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1947 if ((prop = node.property (X_("name"))) != 0) {
1948 Route::set_name (prop->value());
1953 if ((prop = node.property (X_("flags"))) != 0) {
1954 _flags = Flag (string_2_enum (prop->value(), _flags));
1959 if (is_master() || is_monitor() || is_hidden()) {
1960 _mute_master->set_solo_ignore (true);
1964 /* monitor bus does not get a panner, but if (re)created
1965 via XML, it will already have one by the time we
1966 call ::set_state(). so ... remove it.
1971 /* add all processors (except amp, which is always present) */
1973 nlist = node.children();
1974 XMLNode processor_state (X_("processor_state"));
1976 Stateful::save_extra_xml (node);
1978 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1982 if (child->name() == IO::state_node_name) {
1983 if ((prop = child->property (X_("direction"))) == 0) {
1987 if (prop->value() == "Input") {
1988 _input->set_state (*child, version);
1989 } else if (prop->value() == "Output") {
1990 _output->set_state (*child, version);
1994 if (child->name() == X_("Processor")) {
1995 processor_state.add_child_copy (*child);
1999 if (child->name() == X_("Pannable")) {
2001 _pannable->set_state (*child, version);
2003 warning << string_compose (_("Pannable state found for route (%1) without a panner!"), name()) << endmsg;
2008 if ((prop = node.property (X_("meter-point"))) != 0) {
2009 MeterPoint mp = MeterPoint (string_2_enum (prop->value (), _meter_point));
2010 set_meter_point (mp, true);
2012 _meter->set_display_to_user (_meter_point == MeterCustom);
2016 set_processor_state (processor_state);
2018 if ((prop = node.property ("self-solo")) != 0) {
2019 set_self_solo (string_is_affirmative (prop->value()));
2022 if ((prop = node.property ("soloed-by-upstream")) != 0) {
2023 _soloed_by_others_upstream = 0; // needed for mod_.... () to work
2024 mod_solo_by_others_upstream (atoi (prop->value()));
2027 if ((prop = node.property ("soloed-by-downstream")) != 0) {
2028 _soloed_by_others_downstream = 0; // needed for mod_.... () to work
2029 mod_solo_by_others_downstream (atoi (prop->value()));
2032 if ((prop = node.property ("solo-isolated")) != 0) {
2033 set_solo_isolated (string_is_affirmative (prop->value()), this);
2036 if ((prop = node.property ("solo-safe")) != 0) {
2037 set_solo_safe (string_is_affirmative (prop->value()), this);
2040 if ((prop = node.property (X_("phase-invert"))) != 0) {
2041 set_phase_invert (boost::dynamic_bitset<> (prop->value ()));
2044 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2045 set_denormal_protection (string_is_affirmative (prop->value()));
2048 if ((prop = node.property (X_("active"))) != 0) {
2049 bool yn = string_is_affirmative (prop->value());
2050 _active = !yn; // force switch
2051 set_active (yn, this);
2054 if ((prop = node.property (X_("order-keys"))) != 0) {
2058 string::size_type colon, equal;
2059 string remaining = prop->value();
2061 while (remaining.length()) {
2063 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
2064 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2067 if (sscanf (remaining.substr (equal+1).c_str(), "%d", &n) != 1) {
2068 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2071 set_order_key (remaining.substr (0, equal), n);
2075 colon = remaining.find_first_of (':');
2077 if (colon != string::npos) {
2078 remaining = remaining.substr (colon+1);
2085 if ((prop = node.property (X_("processor-after-last-custom-meter"))) != 0) {
2086 PBD::ID id (prop->value ());
2087 Glib::RWLock::ReaderLock lm (_processor_lock);
2088 ProcessorList::const_iterator i = _processors.begin ();
2089 while (i != _processors.end() && (*i)->id() != id) {
2093 if (i != _processors.end ()) {
2094 _processor_after_last_custom_meter = *i;
2095 _custom_meter_position_noted = true;
2099 if ((prop = node.property (X_("last-custom-meter-was-at-end"))) != 0) {
2100 _last_custom_meter_was_at_end = string_is_affirmative (prop->value ());
2103 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2106 if (child->name() == X_("Comment")) {
2108 /* XXX this is a terrible API design in libxml++ */
2110 XMLNode *cmt = *(child->children().begin());
2111 _comment = cmt->content();
2113 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
2114 if (prop->value() == "solo") {
2115 _solo_control->set_state (*child, version);
2118 } else if (child->name() == X_("RemoteControl")) {
2119 if ((prop = child->property (X_("id"))) != 0) {
2121 sscanf (prop->value().c_str(), "%d", &x);
2122 set_remote_control_id (x);
2125 } else if (child->name() == X_("MuteMaster")) {
2126 _mute_master->set_state (*child, version);
2134 Route::set_state_2X (const XMLNode& node, int version)
2137 XMLNodeConstIterator niter;
2139 const XMLProperty *prop;
2141 /* 2X things which still remain to be handled:
2147 if (node.name() != "Route") {
2148 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
2152 if ((prop = node.property (X_("flags"))) != 0) {
2153 _flags = Flag (string_2_enum (prop->value(), _flags));
2158 if ((prop = node.property (X_("phase-invert"))) != 0) {
2159 boost::dynamic_bitset<> p (_input->n_ports().n_audio ());
2160 if (string_is_affirmative (prop->value ())) {
2163 set_phase_invert (p);
2166 if ((prop = node.property (X_("denormal-protection"))) != 0) {
2167 set_denormal_protection (string_is_affirmative (prop->value()));
2170 if ((prop = node.property (X_("soloed"))) != 0) {
2171 bool yn = string_is_affirmative (prop->value());
2173 /* XXX force reset of solo status */
2175 set_solo (yn, this);
2178 if ((prop = node.property (X_("muted"))) != 0) {
2181 bool muted = string_is_affirmative (prop->value());
2187 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
2189 if (string_is_affirmative (prop->value())){
2190 mute_point = mute_point + "PreFader";
2195 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
2197 if (string_is_affirmative (prop->value())){
2200 mute_point = mute_point + ",";
2203 mute_point = mute_point + "PostFader";
2208 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
2210 if (string_is_affirmative (prop->value())){
2213 mute_point = mute_point + ",";
2216 mute_point = mute_point + "Listen";
2221 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
2223 if (string_is_affirmative (prop->value())){
2226 mute_point = mute_point + ",";
2229 mute_point = mute_point + "Main";
2233 _mute_master->set_mute_points (mute_point);
2234 _mute_master->set_muted_by_self (true);
2238 if ((prop = node.property (X_("meter-point"))) != 0) {
2239 _meter_point = MeterPoint (string_2_enum (prop->value (), _meter_point));
2242 /* do not carry over edit/mix groups from 2.X because (a) its hard (b) they
2243 don't mean the same thing.
2246 if ((prop = node.property (X_("order-keys"))) != 0) {
2250 string::size_type colon, equal;
2251 string remaining = prop->value();
2253 while (remaining.length()) {
2255 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
2256 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2259 if (sscanf (remaining.substr (equal+1).c_str(), "%d", &n) != 1) {
2260 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
2263 set_order_key (remaining.substr (0, equal), n);
2267 colon = remaining.find_first_of (':');
2269 if (colon != string::npos) {
2270 remaining = remaining.substr (colon+1);
2279 nlist = node.children ();
2280 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2284 if (child->name() == IO::state_node_name) {
2286 /* there is a note in IO::set_state_2X() about why we have to call
2290 _input->set_state_2X (*child, version, true);
2291 _output->set_state_2X (*child, version, false);
2293 if ((prop = child->property (X_("name"))) != 0) {
2294 Route::set_name (prop->value ());
2299 if ((prop = child->property (X_("active"))) != 0) {
2300 bool yn = string_is_affirmative (prop->value());
2301 _active = !yn; // force switch
2302 set_active (yn, this);
2305 if ((prop = child->property (X_("gain"))) != 0) {
2308 if (sscanf (prop->value().c_str(), "%f", &val) == 1) {
2309 _amp->gain_control()->set_value (val);
2313 /* Set up Panners in the IO */
2314 XMLNodeList io_nlist = child->children ();
2316 XMLNodeConstIterator io_niter;
2319 for (io_niter = io_nlist.begin(); io_niter != io_nlist.end(); ++io_niter) {
2321 io_child = *io_niter;
2323 if (io_child->name() == X_("Panner")) {
2324 _main_outs->panner_shell()->set_state(*io_child, version);
2325 } else if (io_child->name() == X_("Automation")) {
2326 /* IO's automation is for the fader */
2327 _amp->set_automation_xml_state (*io_child, Evoral::Parameter (GainAutomation));
2333 XMLNodeList redirect_nodes;
2335 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2339 if (child->name() == X_("Send") || child->name() == X_("Insert")) {
2340 redirect_nodes.push_back(child);
2345 set_processor_state_2X (redirect_nodes, version);
2347 Stateful::save_extra_xml (node);
2349 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
2352 if (child->name() == X_("Comment")) {
2354 /* XXX this is a terrible API design in libxml++ */
2356 XMLNode *cmt = *(child->children().begin());
2357 _comment = cmt->content();
2359 } else if (child->name() == Controllable::xml_node_name && (prop = child->property("name")) != 0) {
2360 if (prop->value() == X_("solo")) {
2361 _solo_control->set_state (*child, version);
2362 } else if (prop->value() == X_("mute")) {
2363 _mute_control->set_state (*child, version);
2366 } else if (child->name() == X_("RemoteControl")) {
2367 if ((prop = child->property (X_("id"))) != 0) {
2369 sscanf (prop->value().c_str(), "%d", &x);
2370 set_remote_control_id (x);
2380 Route::get_processor_state ()
2382 XMLNode* root = new XMLNode (X_("redirects"));
2383 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2384 root->add_child_nocopy ((*i)->state (true));
2391 Route::set_processor_state_2X (XMLNodeList const & nList, int version)
2393 /* We don't bother removing existing processors not in nList, as this
2394 method will only be called when creating a Route from scratch, not
2395 for undo purposes. Just put processors in at the appropriate place
2399 for (XMLNodeConstIterator i = nList.begin(); i != nList.end(); ++i) {
2400 add_processor_from_xml_2X (**i, version);
2405 Route::set_processor_state (const XMLNode& node)
2407 const XMLNodeList &nlist = node.children();
2408 XMLNodeConstIterator niter;
2409 ProcessorList new_order;
2410 bool must_configure = false;
2412 for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
2414 XMLProperty* prop = (*niter)->property ("type");
2416 if (prop->value() == "amp") {
2417 _amp->set_state (**niter, Stateful::current_state_version);
2418 new_order.push_back (_amp);
2419 } else if (prop->value() == "meter") {
2420 _meter->set_state (**niter, Stateful::current_state_version);
2421 new_order.push_back (_meter);
2422 } else if (prop->value() == "main-outs") {
2423 _main_outs->set_state (**niter, Stateful::current_state_version);
2424 } else if (prop->value() == "intreturn") {
2426 _intreturn.reset (new InternalReturn (_session));
2427 must_configure = true;
2429 _intreturn->set_state (**niter, Stateful::current_state_version);
2430 } else if (is_monitor() && prop->value() == "monitor") {
2431 if (!_monitor_control) {
2432 _monitor_control.reset (new MonitorProcessor (_session));
2433 must_configure = true;
2435 _monitor_control->set_state (**niter, Stateful::current_state_version);
2436 } else if (prop->value() == "capture") {
2437 _capturing_processor.reset (new CapturingProcessor (_session));
2439 ProcessorList::iterator o;
2441 for (o = _processors.begin(); o != _processors.end(); ++o) {
2442 XMLProperty* id_prop = (*niter)->property(X_("id"));
2443 if (id_prop && (*o)->id() == id_prop->value()) {
2444 (*o)->set_state (**niter, Stateful::current_state_version);
2445 new_order.push_back (*o);
2450 // If the processor (*niter) is not on the route then create it
2452 if (o == _processors.end()) {
2454 boost::shared_ptr<Processor> processor;
2456 if (prop->value() == "intsend") {
2458 processor.reset (new InternalSend (_session, _pannable, _mute_master, boost::shared_ptr<Route>(), Delivery::Role (0)));
2460 } else if (prop->value() == "ladspa" || prop->value() == "Ladspa" ||
2461 prop->value() == "lv2" ||
2462 prop->value() == "vst" ||
2463 prop->value() == "lxvst" ||
2464 prop->value() == "audiounit") {
2466 processor.reset (new PluginInsert(_session));
2468 } else if (prop->value() == "port") {
2470 processor.reset (new PortInsert (_session, _pannable, _mute_master));
2472 } else if (prop->value() == "send") {
2474 processor.reset (new Send (_session, _pannable, _mute_master));
2477 error << string_compose(_("unknown Processor type \"%1\"; ignored"), prop->value()) << endmsg;
2481 if (processor->set_state (**niter, Stateful::current_state_version) != 0) {
2482 /* This processor could not be configured. Turn it into a UnknownProcessor */
2483 processor.reset (new UnknownProcessor (_session, **niter));
2486 /* we have to note the monitor send here, otherwise a new one will be created
2487 and the state of this one will be lost.
2489 boost::shared_ptr<InternalSend> isend = boost::dynamic_pointer_cast<InternalSend> (processor);
2490 if (isend && isend->role() == Delivery::Listen) {
2491 _monitor_send = isend;
2494 /* it doesn't matter if invisible processors are added here, as they
2495 will be sorted out by setup_invisible_processors () shortly.
2498 new_order.push_back (processor);
2499 must_configure = true;
2505 Glib::RWLock::WriterLock lm (_processor_lock);
2506 _processors = new_order;
2508 if (must_configure) {
2509 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
2510 configure_processors_unlocked (0);
2513 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
2515 (*i)->ActiveChanged.connect_same_thread (*this, boost::bind (&Session::update_latency_compensation, &_session, false));
2517 boost::shared_ptr<PluginInsert> pi;
2519 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
2520 if (pi->has_no_inputs ()) {
2521 _have_internal_generator = true;
2528 processors_changed (RouteProcessorChange ());
2529 set_processor_positions ();
2533 Route::curve_reallocate ()
2535 // _gain_automation_curve.finish_resize ();
2536 // _pan_automation_curve.finish_resize ();
2540 Route::silence (framecnt_t nframes)
2542 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2547 silence_unlocked (nframes);
2551 Route::silence_unlocked (framecnt_t nframes)
2553 /* Must be called with the processor lock held */
2557 _output->silence (nframes);
2559 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2560 boost::shared_ptr<PluginInsert> pi;
2562 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
2563 // skip plugins, they don't need anything when we're not active
2567 (*i)->silence (nframes);
2570 if (nframes == _session.get_block_size()) {
2577 Route::add_internal_return ()
2580 _intreturn.reset (new InternalReturn (_session));
2581 add_processor (_intreturn, PreFader);
2586 Route::add_send_to_internal_return (InternalSend* send)
2588 Glib::RWLock::ReaderLock rm (_processor_lock);
2590 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
2591 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
2594 return d->add_send (send);
2600 Route::remove_send_from_internal_return (InternalSend* send)
2602 Glib::RWLock::ReaderLock rm (_processor_lock);
2604 for (ProcessorList::const_iterator x = _processors.begin(); x != _processors.end(); ++x) {
2605 boost::shared_ptr<InternalReturn> d = boost::dynamic_pointer_cast<InternalReturn>(*x);
2608 return d->remove_send (send);
2614 Route::enable_monitor_send ()
2616 /* Caller must hold process lock */
2617 assert (!AudioEngine::instance()->process_lock().trylock());
2619 /* master never sends to monitor section via the normal mechanism */
2620 assert (!is_master ());
2622 /* make sure we have one */
2623 if (!_monitor_send) {
2624 _monitor_send.reset (new InternalSend (_session, _pannable, _mute_master, _session.monitor_out(), Delivery::Listen));
2625 _monitor_send->set_display_to_user (false);
2629 configure_processors (0);
2632 /** Add an aux send to a route.
2633 * @param route route to send to.
2634 * @param before Processor to insert before, or 0 to insert at the end.
2637 Route::add_aux_send (boost::shared_ptr<Route> route, boost::shared_ptr<Processor> before)
2639 assert (route != _session.monitor_out ());
2642 Glib::RWLock::ReaderLock rm (_processor_lock);
2644 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
2646 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend> (*x);
2648 if (d && d->target_route() == route) {
2649 /* already listening via the specified IO: do nothing */
2657 boost::shared_ptr<InternalSend> listener;
2660 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
2661 listener.reset (new InternalSend (_session, _pannable, _mute_master, route, Delivery::Aux));
2664 add_processor (listener, before);
2666 } catch (failed_constructor& err) {
2674 Route::remove_aux_or_listen (boost::shared_ptr<Route> route)
2676 ProcessorStreams err;
2677 ProcessorList::iterator tmp;
2680 Glib::RWLock::ReaderLock rl(_processor_lock);
2682 /* have to do this early because otherwise processor reconfig
2683 * will put _monitor_send back in the list
2686 if (route == _session.monitor_out()) {
2687 _monitor_send.reset ();
2691 for (ProcessorList::iterator x = _processors.begin(); x != _processors.end(); ++x) {
2693 boost::shared_ptr<InternalSend> d = boost::dynamic_pointer_cast<InternalSend>(*x);
2695 if (d && d->target_route() == route) {
2697 remove_processor (*x, &err, false);
2700 /* list could have been demolished while we dropped the lock
2711 Route::set_comment (string cmt, void *src)
2714 comment_changed (src);
2715 _session.set_dirty ();
2719 Route::add_fed_by (boost::shared_ptr<Route> other, bool via_sends_only)
2721 FeedRecord fr (other, via_sends_only);
2723 pair<FedBy::iterator,bool> result = _fed_by.insert (fr);
2725 if (!result.second) {
2727 /* already a record for "other" - make sure sends-only information is correct */
2728 if (!via_sends_only && result.first->sends_only) {
2729 FeedRecord* frp = const_cast<FeedRecord*>(&(*result.first));
2730 frp->sends_only = false;
2734 return result.second;
2738 Route::clear_fed_by ()
2744 Route::feeds (boost::shared_ptr<Route> other, bool* via_sends_only)
2746 const FedBy& fed_by (other->fed_by());
2748 for (FedBy::iterator f = fed_by.begin(); f != fed_by.end(); ++f) {
2749 boost::shared_ptr<Route> sr = f->r.lock();
2751 if (sr && (sr.get() == this)) {
2753 if (via_sends_only) {
2754 *via_sends_only = f->sends_only;
2765 Route::direct_feeds_according_to_reality (boost::shared_ptr<Route> other, bool* via_send_only)
2767 DEBUG_TRACE (DEBUG::Graph, string_compose ("Feeds? %1\n", _name));
2769 if (_output->connected_to (other->input())) {
2770 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdirect FEEDS %2\n", other->name()));
2771 if (via_send_only) {
2772 *via_send_only = false;
2779 for (ProcessorList::iterator r = _processors.begin(); r != _processors.end(); ++r) {
2781 boost::shared_ptr<IOProcessor> iop;
2783 if ((iop = boost::dynamic_pointer_cast<IOProcessor>(*r)) != 0) {
2784 if (iop->feeds (other)) {
2785 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does feed %2\n", iop->name(), other->name()));
2786 if (via_send_only) {
2787 *via_send_only = true;
2791 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tIOP %1 does NOT feed %2\n", iop->name(), other->name()));
2794 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tPROC %1 is not an IOP\n", (*r)->name()));
2799 DEBUG_TRACE (DEBUG::Graph, string_compose ("\tdoes NOT feed %1\n", other->name()));
2804 Route::direct_feeds_according_to_graph (boost::shared_ptr<Route> other, bool* via_send_only)
2806 return _session._current_route_graph.has (shared_from_this (), other, via_send_only);
2809 /** Called from the (non-realtime) butler thread when the transport is stopped */
2811 Route::nonrealtime_handle_transport_stopped (bool /*abort_ignored*/, bool did_locate, bool can_flush_processors)
2813 framepos_t now = _session.transport_frame();
2816 Glib::RWLock::ReaderLock lm (_processor_lock);
2819 automation_snapshot (now, true);
2822 Automatable::transport_stopped (now);
2824 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2826 if (!_have_internal_generator && (Config->get_plugins_stop_with_transport() && can_flush_processors)) {
2830 (*i)->transport_stopped (now);
2834 _roll_delay = _initial_delay;
2838 Route::input_change_handler (IOChange change, void * /*src*/)
2840 bool need_to_queue_solo_change = true;
2842 if ((change.type & IOChange::ConfigurationChanged)) {
2843 /* This is called with the process lock held if change
2844 contains ConfigurationChanged
2846 need_to_queue_solo_change = false;
2847 configure_processors (0);
2848 _phase_invert.resize (_input->n_ports().n_audio ());
2849 io_changed (); /* EMIT SIGNAL */
2852 if (!_input->connected() && _soloed_by_others_upstream) {
2853 if (need_to_queue_solo_change) {
2854 _session.cancel_solo_after_disconnect (shared_from_this(), true);
2856 cancel_solo_after_disconnect (true);
2862 Route::output_change_handler (IOChange change, void * /*src*/)
2864 bool need_to_queue_solo_change = true;
2866 if ((change.type & IOChange::ConfigurationChanged)) {
2867 /* This is called with the process lock held if change
2868 contains ConfigurationChanged
2870 need_to_queue_solo_change = false;
2873 if (!_output->connected() && _soloed_by_others_downstream) {
2874 if (need_to_queue_solo_change) {
2875 _session.cancel_solo_after_disconnect (shared_from_this(), false);
2877 cancel_solo_after_disconnect (false);
2883 Route::cancel_solo_after_disconnect (bool upstream)
2886 _soloed_by_others_upstream = 0;
2888 _soloed_by_others_downstream = 0;
2890 set_mute_master_solo ();
2891 solo_changed (false, this);
2895 Route::pans_required () const
2897 if (n_outputs().n_audio() < 2) {
2901 return max (n_inputs ().n_audio(), processor_max_streams.n_audio());
2905 Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, bool session_state_changing)
2907 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2912 if (n_outputs().n_total() == 0) {
2916 if (!_active || n_inputs() == ChanCount::ZERO) {
2917 silence_unlocked (nframes);
2920 if (session_state_changing) {
2921 if (_session.transport_speed() != 0.0f) {
2922 /* we're rolling but some state is changing (e.g. our diskstream contents)
2923 so we cannot use them. Be silent till this is over.
2925 XXX note the absurdity of ::no_roll() being called when we ARE rolling!
2927 silence_unlocked (nframes);
2930 /* we're really not rolling, so we're either delivery silence or actually
2931 monitoring, both of which are safe to do while session_state_changing is true.
2935 _amp->apply_gain_automation (false);
2936 passthru (start_frame, end_frame, nframes, 0);
2942 Route::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, int declick, bool& /* need_butler */)
2944 Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
2949 automation_snapshot (_session.transport_frame(), false);
2951 if (n_outputs().n_total() == 0) {
2955 if (!_active || n_inputs().n_total() == 0) {
2956 silence_unlocked (nframes);
2960 framepos_t unused = 0;
2962 if ((nframes = check_initial_delay (nframes, unused)) == 0) {
2968 passthru (start_frame, end_frame, nframes, declick);
2974 Route::silent_roll (pframes_t nframes, framepos_t /*start_frame*/, framepos_t /*end_frame*/, bool& /* need_butler */)
2981 Route::flush_processors ()
2983 /* XXX shouldn't really try to take this lock, since
2984 this is called from the RT audio thread.
2987 Glib::RWLock::ReaderLock lm (_processor_lock);
2989 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
2995 Route::set_meter_point (MeterPoint p, bool force)
2997 /* CAN BE CALLED FROM PROCESS CONTEXT */
2999 if (_meter_point == p && !force) {
3003 bool meter_was_visible_to_user = _meter->display_to_user ();
3006 Glib::RWLock::WriterLock lm (_processor_lock);
3008 maybe_note_meter_position ();
3012 if (_meter_point != MeterCustom) {
3014 _meter->set_display_to_user (false);
3016 setup_invisible_processors ();
3020 _meter->set_display_to_user (true);
3022 /* If we have a previous position for the custom meter, try to put it there */
3023 if (_custom_meter_position_noted) {
3024 boost::shared_ptr<Processor> after = _processor_after_last_custom_meter.lock ();
3027 ProcessorList::iterator i = find (_processors.begin(), _processors.end(), after);
3028 if (i != _processors.end ()) {
3029 _processors.remove (_meter);
3030 _processors.insert (i, _meter);
3032 } else if (_last_custom_meter_was_at_end) {
3033 _processors.remove (_meter);
3034 _processors.push_back (_meter);
3039 /* Set up the meter for its new position */
3041 ProcessorList::iterator loc = find (_processors.begin(), _processors.end(), _meter);
3045 if (loc == _processors.begin()) {
3046 m_in = _input->n_ports();
3048 ProcessorList::iterator before = loc;
3050 m_in = (*before)->output_streams ();
3053 _meter->reflect_inputs (m_in);
3055 /* we do not need to reconfigure the processors, because the meter
3056 (a) is always ready to handle processor_max_streams
3057 (b) is always an N-in/N-out processor, and thus moving
3058 it doesn't require any changes to the other processors.
3062 meter_change (); /* EMIT SIGNAL */
3064 bool const meter_visibly_changed = (_meter->display_to_user() != meter_was_visible_to_user);
3066 processors_changed (RouteProcessorChange (RouteProcessorChange::MeterPointChange, meter_visibly_changed)); /* EMIT SIGNAL */
3070 Route::listen_position_changed ()
3073 Glib::RWLock::WriterLock lm (_processor_lock);
3074 ProcessorState pstate (this);
3077 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
3079 if (configure_processors_unlocked (0)) {
3081 configure_processors_unlocked (0); // it worked before we tried to add it ...
3087 processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
3088 _session.set_dirty ();
3091 boost::shared_ptr<CapturingProcessor>
3092 Route::add_export_point()
3094 if (!_capturing_processor) {
3096 _capturing_processor.reset (new CapturingProcessor (_session));
3097 _capturing_processor->activate ();
3100 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
3101 configure_processors (0);
3106 return _capturing_processor;
3110 Route::update_signal_latency ()
3112 framecnt_t l = _output->user_latency();
3114 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3115 if ((*i)->active ()) {
3116 l += (*i)->signal_latency ();
3120 DEBUG_TRACE (DEBUG::Latency, string_compose ("%1: internal signal latency = %2\n", _name, l));
3122 if (_signal_latency != l) {
3123 _signal_latency = l;
3124 signal_latency_changed (); /* EMIT SIGNAL */
3127 return _signal_latency;
3131 Route::set_user_latency (framecnt_t nframes)
3133 _output->set_user_latency (nframes);
3134 _session.update_latency_compensation ();
3138 Route::set_latency_compensation (framecnt_t longest_session_latency)
3140 framecnt_t old = _initial_delay;
3142 if (_signal_latency < longest_session_latency) {
3143 _initial_delay = longest_session_latency - _signal_latency;
3148 DEBUG_TRACE (DEBUG::Latency, string_compose (
3149 "%1: compensate for maximum latency of %2,"
3150 "given own latency of %3, using initial delay of %4\n",
3151 name(), longest_session_latency, _signal_latency, _initial_delay));
3153 if (_initial_delay != old) {
3154 initial_delay_changed (); /* EMIT SIGNAL */
3157 if (_session.transport_stopped()) {
3158 _roll_delay = _initial_delay;
3163 Route::automation_snapshot (framepos_t now, bool force)
3166 _pannable->automation_snapshot (now, force);
3169 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3170 (*i)->automation_snapshot (now, force);
3174 Route::SoloControllable::SoloControllable (std::string name, boost::shared_ptr<Route> r)
3175 : AutomationControl (r->session(), Evoral::Parameter (SoloAutomation),
3176 boost::shared_ptr<AutomationList>(), name)
3179 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(SoloAutomation)));
3184 Route::SoloControllable::set_value (double val)
3186 bool bval = ((val >= 0.5f) ? true: false);
3188 boost::shared_ptr<RouteList> rl (new RouteList);
3190 boost::shared_ptr<Route> r = _route.lock ();
3197 if (Config->get_solo_control_is_listen_control()) {
3198 _session.set_listen (rl, bval);
3200 _session.set_solo (rl, bval);
3205 Route::SoloControllable::get_value () const
3207 boost::shared_ptr<Route> r = _route.lock ();
3212 if (Config->get_solo_control_is_listen_control()) {
3213 return r->listening_via_monitor() ? 1.0f : 0.0f;
3215 return r->self_soloed() ? 1.0f : 0.0f;
3219 Route::MuteControllable::MuteControllable (std::string name, boost::shared_ptr<Route> r)
3220 : AutomationControl (r->session(), Evoral::Parameter (MuteAutomation),
3221 boost::shared_ptr<AutomationList>(), name)
3224 boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(MuteAutomation)));
3229 Route::MuteControllable::set_value (double val)
3231 bool bval = ((val >= 0.5f) ? true: false);
3233 boost::shared_ptr<RouteList> rl (new RouteList);
3235 boost::shared_ptr<Route> r = _route.lock ();
3241 _session.set_mute (rl, bval);
3245 Route::MuteControllable::get_value () const
3247 boost::shared_ptr<Route> r = _route.lock ();
3252 return r->muted() ? 1.0f : 0.0f;
3256 Route::set_block_size (pframes_t nframes)
3258 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3259 (*i)->set_block_size (nframes);
3262 _session.ensure_buffers (n_process_buffers ());
3266 Route::protect_automation ()
3268 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i)
3269 (*i)->protect_automation();
3273 Route::set_pending_declick (int declick)
3276 /* this call is not allowed to turn off a pending declick unless "force" is true */
3278 _pending_declick = declick;
3280 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
3282 _pending_declick = 0;
3287 /** Shift automation forwards from a particular place, thereby inserting time.
3288 * Adds undo commands for any shifts that are performed.
3290 * @param pos Position to start shifting from.
3291 * @param frames Amount to shift forwards by.
3295 Route::shift (framepos_t pos, framecnt_t frames)
3297 /* gain automation */
3299 boost::shared_ptr<AutomationControl> gc = _amp->gain_control();
3301 XMLNode &before = gc->alist()->get_state ();
3302 gc->alist()->shift (pos, frames);
3303 XMLNode &after = gc->alist()->get_state ();
3304 _session.add_command (new MementoCommand<AutomationList> (*gc->alist().get(), &before, &after));
3307 /* pan automation */
3309 ControlSet::Controls& c (_pannable->controls());
3311 for (ControlSet::Controls::const_iterator ci = c.begin(); ci != c.end(); ++ci) {
3312 boost::shared_ptr<AutomationControl> pc = boost::dynamic_pointer_cast<AutomationControl> (ci->second);
3314 boost::shared_ptr<AutomationList> al = pc->alist();
3315 XMLNode& before = al->get_state ();
3316 al->shift (pos, frames);
3317 XMLNode& after = al->get_state ();
3318 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
3323 /* redirect automation */
3325 Glib::RWLock::ReaderLock lm (_processor_lock);
3326 for (ProcessorList::iterator i = _processors.begin (); i != _processors.end (); ++i) {
3328 set<Evoral::Parameter> parameters = (*i)->what_can_be_automated();
3330 for (set<Evoral::Parameter>::const_iterator p = parameters.begin (); p != parameters.end (); ++p) {
3331 boost::shared_ptr<AutomationControl> ac = (*i)->automation_control (*p);
3333 boost::shared_ptr<AutomationList> al = ac->alist();
3334 XMLNode &before = al->get_state ();
3335 al->shift (pos, frames);
3336 XMLNode &after = al->get_state ();
3337 _session.add_command (new MementoCommand<AutomationList> (*al.get(), &before, &after));
3346 Route::save_as_template (const string& path, const string& name)
3348 XMLNode& node (state (false));
3351 IO::set_name_in_state (*node.children().front(), name);
3353 tree.set_root (&node);
3354 return tree.write (path.c_str());
3359 Route::set_name (const string& str)
3365 name = Route::ensure_track_or_route_name (str, _session);
3366 SessionObject::set_name (name);
3368 ret = (_input->set_name(name) && _output->set_name(name));
3371 /* rename the main outs. Leave other IO processors
3372 * with whatever name they already have, because its
3373 * just fine as it is (it will not contain the route
3374 * name if its a port insert, port send or port return).
3378 if (_main_outs->set_name (name)) {
3379 /* XXX returning false here is stupid because
3380 we already changed the route name.
3390 /** Set the name of a route in an XML description.
3391 * @param node XML <Route> node to set the name in.
3392 * @param name New name.
3395 Route::set_name_in_state (XMLNode& node, string const & name)
3397 node.add_property (X_("name"), name);
3399 XMLNodeList children = node.children();
3400 for (XMLNodeIterator i = children.begin(); i != children.end(); ++i) {
3402 if ((*i)->name() == X_("IO")) {
3404 IO::set_name_in_state (**i, name);
3406 } else if ((*i)->name() == X_("Processor")) {
3408 XMLProperty* role = (*i)->property (X_("role"));
3409 if (role && role->value() == X_("Main")) {
3410 (*i)->add_property (X_("name"), name);
3413 } else if ((*i)->name() == X_("Diskstream")) {
3415 (*i)->add_property (X_("playlist"), string_compose ("%1.1", name).c_str());
3416 (*i)->add_property (X_("name"), name);
3422 boost::shared_ptr<Send>
3423 Route::internal_send_for (boost::shared_ptr<const Route> target) const
3425 Glib::RWLock::ReaderLock lm (_processor_lock);
3427 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3428 boost::shared_ptr<InternalSend> send;
3430 if ((send = boost::dynamic_pointer_cast<InternalSend>(*i)) != 0) {
3431 if (send->target_route() == target) {
3437 return boost::shared_ptr<Send>();
3440 /** @param c Audio channel index.
3441 * @param yn true to invert phase, otherwise false.
3444 Route::set_phase_invert (uint32_t c, bool yn)
3446 if (_phase_invert[c] != yn) {
3447 _phase_invert[c] = yn;
3448 phase_invert_changed (); /* EMIT SIGNAL */
3449 _session.set_dirty ();
3454 Route::set_phase_invert (boost::dynamic_bitset<> p)
3456 if (_phase_invert != p) {
3458 phase_invert_changed (); /* EMIT SIGNAL */
3459 _session.set_dirty ();
3464 Route::phase_invert (uint32_t c) const
3466 return _phase_invert[c];
3469 boost::dynamic_bitset<>
3470 Route::phase_invert () const
3472 return _phase_invert;
3476 Route::set_denormal_protection (bool yn)
3478 if (_denormal_protection != yn) {
3479 _denormal_protection = yn;
3480 denormal_protection_changed (); /* EMIT SIGNAL */
3485 Route::denormal_protection () const
3487 return _denormal_protection;
3491 Route::set_active (bool yn, void* src)
3493 if (_route_group && src != _route_group && _route_group->is_active() && _route_group->is_route_active()) {
3494 _route_group->foreach_route (boost::bind (&Route::set_active, _1, yn, _route_group));
3498 if (_active != yn) {
3500 _input->set_active (yn);
3501 _output->set_active (yn);
3502 active_changed (); // EMIT SIGNAL
3509 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
3515 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3517 boost::shared_ptr<Send> s;
3518 boost::shared_ptr<Return> r;
3520 if ((s = boost::dynamic_pointer_cast<Send> (*i)) != 0) {
3521 s->meter()->meter();
3522 } else if ((r = boost::dynamic_pointer_cast<Return> (*i)) != 0) {
3523 r->meter()->meter ();
3528 boost::shared_ptr<Pannable>
3529 Route::pannable() const
3534 boost::shared_ptr<Panner>
3535 Route::panner() const
3538 return _main_outs->panner_shell()->panner();
3541 boost::shared_ptr<PannerShell>
3542 Route::panner_shell() const
3544 return _main_outs->panner_shell();
3547 boost::shared_ptr<AutomationControl>
3548 Route::gain_control() const
3550 return _amp->gain_control();
3553 boost::shared_ptr<AutomationControl>
3554 Route::get_control (const Evoral::Parameter& param)
3556 /* either we own the control or .... */
3558 boost::shared_ptr<AutomationControl> c = boost::dynamic_pointer_cast<AutomationControl>(control (param));
3562 /* maybe one of our processors does or ... */
3564 Glib::RWLock::ReaderLock rm (_processor_lock, Glib::TRY_LOCK);
3565 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3566 if ((c = boost::dynamic_pointer_cast<AutomationControl>((*i)->control (param))) != 0) {
3574 /* nobody does so we'll make a new one */
3576 c = boost::dynamic_pointer_cast<AutomationControl>(control_factory(param));
3583 boost::shared_ptr<Processor>
3584 Route::nth_plugin (uint32_t n)
3586 Glib::RWLock::ReaderLock lm (_processor_lock);
3587 ProcessorList::iterator i;
3589 for (i = _processors.begin(); i != _processors.end(); ++i) {
3590 if (boost::dynamic_pointer_cast<PluginInsert> (*i)) {
3597 return boost::shared_ptr<Processor> ();
3600 boost::shared_ptr<Processor>
3601 Route::nth_send (uint32_t n)
3603 Glib::RWLock::ReaderLock lm (_processor_lock);
3604 ProcessorList::iterator i;
3606 for (i = _processors.begin(); i != _processors.end(); ++i) {
3607 if (boost::dynamic_pointer_cast<Send> (*i)) {
3614 return boost::shared_ptr<Processor> ();
3618 Route::has_io_processor_named (const string& name)
3620 Glib::RWLock::ReaderLock lm (_processor_lock);
3621 ProcessorList::iterator i;
3623 for (i = _processors.begin(); i != _processors.end(); ++i) {
3624 if (boost::dynamic_pointer_cast<Send> (*i) ||
3625 boost::dynamic_pointer_cast<PortInsert> (*i)) {
3626 if ((*i)->name() == name) {
3635 MuteMaster::MutePoint
3636 Route::mute_points () const
3638 return _mute_master->mute_points ();
3642 Route::set_processor_positions ()
3644 Glib::RWLock::ReaderLock lm (_processor_lock);
3646 bool had_amp = false;
3647 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3648 (*i)->set_pre_fader (!had_amp);
3649 if (boost::dynamic_pointer_cast<Amp> (*i)) {
3655 /** Called when there is a proposed change to the input port count */
3657 Route::input_port_count_changing (ChanCount to)
3659 list<pair<ChanCount, ChanCount> > c = try_configure_processors (to, 0);
3661 /* The processors cannot be configured with the new input arrangement, so
3667 /* The change is ok */
3672 Route::unknown_processors () const
3676 Glib::RWLock::ReaderLock lm (_processor_lock);
3677 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3678 if (boost::dynamic_pointer_cast<UnknownProcessor const> (*i)) {
3679 p.push_back ((*i)->name ());
3688 Route::update_port_latencies (PortSet& from, PortSet& to, bool playback, framecnt_t our_latency) const
3690 /* we assume that all our input ports feed all our output ports. its not
3691 universally true, but the alternative is way too corner-case to worry about.
3694 jack_latency_range_t all_connections;
3697 all_connections.min = 0;
3698 all_connections.max = 0;
3700 all_connections.min = ~((jack_nframes_t) 0);
3701 all_connections.max = 0;
3703 /* iterate over all "from" ports and determine the latency range for all of their
3704 connections to the "outside" (outside of this Route).
3707 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
3709 jack_latency_range_t range;
3711 p->get_connected_latency_range (range, playback);
3713 all_connections.min = min (all_connections.min, range.min);
3714 all_connections.max = max (all_connections.max, range.max);
3718 /* set the "from" port latencies to the max/min range of all their connections */
3720 for (PortSet::iterator p = from.begin(); p != from.end(); ++p) {
3721 p->set_private_latency_range (all_connections, playback);
3724 /* set the ports "in the direction of the flow" to the same value as above plus our own signal latency */
3726 all_connections.min += our_latency;
3727 all_connections.max += our_latency;
3729 for (PortSet::iterator p = to.begin(); p != to.end(); ++p) {
3730 p->set_private_latency_range (all_connections, playback);
3733 return all_connections.max;
3737 Route::set_private_port_latencies (bool playback) const
3739 framecnt_t own_latency = 0;
3741 /* Processor list not protected by lock: MUST BE CALLED FROM PROCESS THREAD
3742 OR LATENCY CALLBACK.
3744 This is called (early) from the latency callback. It computes the REAL
3745 latency associated with each port and stores the result as the "private"
3746 latency of the port. A later call to Route::set_public_port_latencies()
3747 sets all ports to the same value to reflect the fact that we do latency
3748 compensation and so all signals are delayed by the same amount as they
3749 flow through ardour.
3752 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
3753 if ((*i)->active ()) {
3754 own_latency += (*i)->signal_latency ();
3759 /* playback: propagate latency from "outside the route" to outputs to inputs */
3760 return update_port_latencies (_output->ports (), _input->ports (), true, own_latency);
3762 /* capture: propagate latency from "outside the route" to inputs to outputs */
3763 return update_port_latencies (_input->ports (), _output->ports (), false, own_latency);
3768 Route::set_public_port_latencies (framecnt_t value, bool playback) const
3770 /* this is called to set the JACK-visible port latencies, which take
3771 latency compensation into account.
3774 jack_latency_range_t range;
3780 const PortSet& ports (_input->ports());
3781 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
3782 p->set_public_latency_range (range, playback);
3787 const PortSet& ports (_output->ports());
3788 for (PortSet::const_iterator p = ports.begin(); p != ports.end(); ++p) {
3789 p->set_public_latency_range (range, playback);
3794 /** Put the invisible processors in the right place in _processors.
3795 * Must be called with a writer lock on _processor_lock held.
3798 Route::setup_invisible_processors ()
3801 Glib::RWLock::WriterLock lm (_processor_lock, Glib::TRY_LOCK);
3802 assert (!lm.locked ());
3806 /* too early to be doing this stuff */
3810 /* we'll build this new list here and then use it */
3812 ProcessorList new_processors;
3814 /* find visible processors */
3816 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3817 if ((*i)->display_to_user ()) {
3818 new_processors.push_back (*i);
3824 ProcessorList::iterator amp = new_processors.begin ();
3825 while (amp != new_processors.end() && boost::dynamic_pointer_cast<Amp> (*amp) == 0) {
3829 assert (amp != _processors.end ());
3831 /* and the processor after the amp */
3833 ProcessorList::iterator after_amp = amp;
3839 switch (_meter_point) {
3841 assert (!_meter->display_to_user ());
3842 new_processors.push_front (_meter);
3845 assert (!_meter->display_to_user ());
3846 new_processors.insert (amp, _meter);
3848 case MeterPostFader:
3849 /* do nothing here */
3852 /* do nothing here */
3855 /* the meter is visible, so we don't touch it here */
3862 assert (_main_outs);
3863 assert (!_main_outs->display_to_user ());
3864 new_processors.push_back (_main_outs);
3866 /* iterator for the main outs */
3868 ProcessorList::iterator main = new_processors.end();
3871 /* OUTPUT METERING */
3873 if (_meter && (_meter_point == MeterOutput || _meter_point == MeterPostFader)) {
3874 assert (!_meter->display_to_user ());
3876 /* add the processor just before or just after the main outs */
3878 ProcessorList::iterator meter_point = main;
3880 if (_meter_point == MeterOutput) {
3883 new_processors.insert (meter_point, _meter);
3888 if (_monitor_send && !is_monitor ()) {
3889 assert (!_monitor_send->display_to_user ());
3890 if (Config->get_solo_control_is_listen_control()) {
3891 switch (Config->get_listen_position ()) {
3892 case PreFaderListen:
3893 switch (Config->get_pfl_position ()) {
3894 case PFLFromBeforeProcessors:
3895 new_processors.push_front (_monitor_send);
3897 case PFLFromAfterProcessors:
3898 new_processors.insert (amp, _monitor_send);
3901 _monitor_send->set_can_pan (false);
3903 case AfterFaderListen:
3904 switch (Config->get_afl_position ()) {
3905 case AFLFromBeforeProcessors:
3906 new_processors.insert (after_amp, _monitor_send);
3908 case AFLFromAfterProcessors:
3909 new_processors.insert (new_processors.end(), _monitor_send);
3912 _monitor_send->set_can_pan (true);
3916 new_processors.insert (new_processors.end(), _monitor_send);
3917 _monitor_send->set_can_pan (false);
3921 /* MONITOR CONTROL */
3923 if (_monitor_control && is_monitor ()) {
3924 assert (!_monitor_control->display_to_user ());
3925 new_processors.push_front (_monitor_control);
3928 /* INTERNAL RETURN */
3930 /* doing this here means that any monitor control will come just after
3935 assert (!_intreturn->display_to_user ());
3936 new_processors.push_front (_intreturn);
3939 /* EXPORT PROCESSOR */
3941 if (_capturing_processor) {
3942 assert (!_capturing_processor->display_to_user ());
3943 new_processors.push_front (_capturing_processor);
3946 _processors = new_processors;
3948 DEBUG_TRACE (DEBUG::Processors, string_compose ("%1: setup_invisible_processors\n", _name));
3949 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3950 DEBUG_TRACE (DEBUG::Processors, string_compose ("\t%1\n", (*i)->name ()));
3957 Glib::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
3958 Glib::RWLock::ReaderLock lp (_processor_lock);
3962 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3963 boost::shared_ptr<Delivery> d = boost::dynamic_pointer_cast<Delivery>(*i);
3970 /** If the meter point is `Custom', make a note of where the meter is.
3971 * This is so that if the meter point is subsequently set to something else,
3972 * and then back to custom, we can put the meter back where it was last time
3973 * custom was enabled.
3975 * Must be called with the _processor_lock held.
3978 Route::maybe_note_meter_position ()
3980 if (_meter_point != MeterCustom) {
3984 _custom_meter_position_noted = true;
3985 for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
3986 if (boost::dynamic_pointer_cast<PeakMeter> (*i)) {
3987 ProcessorList::iterator j = i;
3989 if (j != _processors.end ()) {
3990 _processor_after_last_custom_meter = *j;
3991 _last_custom_meter_was_at_end = false;
3993 _last_custom_meter_was_at_end = true;
3999 boost::shared_ptr<Processor>
4000 Route::processor_by_id (PBD::ID id) const
4002 Glib::RWLock::ReaderLock lm (_processor_lock);
4003 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4004 if ((*i)->id() == id) {
4009 return boost::shared_ptr<Processor> ();
4012 /** @return the monitoring state, or in other words what data we are pushing
4013 * into the route (data from the inputs, data from disk or silence)
4016 Route::monitoring_state () const
4018 return MonitoringInput;
4021 /** @return what we should be metering; either the data coming from the input
4022 * IO or the data that is flowing through the route.
4025 Route::metering_state () const
4027 return MeteringRoute;
4031 Route::has_external_redirects () const
4033 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4035 /* ignore inactive processors and obviously ignore the main
4036 * outs since everything has them and we don't care.
4039 if ((*i)->active() && (*i) != _main_outs && (*i)->does_routing()) {
4047 boost::shared_ptr<Processor>
4048 Route::the_instrument () const
4050 Glib::RWLock::WriterLock lm (_processor_lock);
4051 for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
4052 if ((*i)->input_streams().n_midi() > 0 &&
4053 (*i)->output_streams().n_audio() > 0) {
4057 return boost::shared_ptr<Processor>();