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.
24 #include <sigc++/bind.h>
25 #include <pbd/xml++.h>
26 #include <pbd/enumwriter.h>
28 #include <ardour/timestamps.h>
29 #include <ardour/buffer.h>
30 #include <ardour/audioengine.h>
31 #include <ardour/route.h>
32 #include <ardour/insert.h>
33 #include <ardour/send.h>
34 #include <ardour/session.h>
35 #include <ardour/utils.h>
36 #include <ardour/configuration.h>
37 #include <ardour/cycle_timer.h>
38 #include <ardour/route_group.h>
39 #include <ardour/port.h>
40 #include <ardour/ladspa_plugin.h>
41 #include <ardour/panner.h>
42 #include <ardour/dB.h>
43 #include <ardour/mix.h>
48 using namespace ARDOUR;
52 uint32_t Route::order_key_cnt = 0;
55 Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg, DataType default_type)
56 : IO (sess, name, input_min, input_max, output_min, output_max, default_type),
58 _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
59 _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
64 Route::Route (Session& sess, const XMLNode& node, DataType default_type)
65 : IO (sess, *node.child ("IO"), default_type),
66 _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
67 _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
70 _set_state (node, false);
76 redirect_max_outs = 0;
80 _phase_invert = false;
81 order_keys[strdup (N_("signal"))] = order_key_cnt++;
84 _meter_point = MeterPostFader;
88 _have_internal_generator = false;
90 _pending_declick = true;
91 _remote_control_id = 0;
92 _ignore_gain_on_deliver = true;
97 _mute_affects_pre_fader = Config->get_mute_affects_pre_fader();
98 _mute_affects_post_fader = Config->get_mute_affects_post_fader();
99 _mute_affects_control_outs = Config->get_mute_affects_control_outs();
100 _mute_affects_main_outs = Config->get_mute_affects_main_outs();
103 desired_solo_gain = 1.0;
105 desired_mute_gain = 1.0;
109 input_changed.connect (mem_fun (this, &Route::input_change_handler));
110 output_changed.connect (mem_fun (this, &Route::output_change_handler));
115 clear_redirects (this);
117 for (OrderKeys::iterator i = order_keys.begin(); i != order_keys.end(); ++i) {
118 free ((void*)(i->first));
122 delete _control_outs;
127 Route::set_remote_control_id (uint32_t id)
129 if (id != _remote_control_id) {
130 _remote_control_id = id;
131 RemoteControlIDChanged ();
136 Route::remote_control_id() const
138 return _remote_control_id;
142 Route::order_key (const char* name) const
144 OrderKeys::const_iterator i;
146 for (i = order_keys.begin(); i != order_keys.end(); ++i) {
147 if (!strcmp (name, i->first)) {
156 Route::set_order_key (const char* name, long n)
158 order_keys[strdup(name)] = n;
159 _session.set_dirty ();
163 Route::inc_gain (gain_t fraction, void *src)
165 IO::inc_gain (fraction, src);
169 Route::set_gain (gain_t val, void *src)
171 if (src != 0 && _mix_group && src != _mix_group && _mix_group->is_active()) {
173 if (_mix_group->is_relative()) {
176 gain_t usable_gain = gain();
177 if (usable_gain < 0.000001f) {
178 usable_gain=0.000001f;
182 if (delta < 0.000001f) {
186 delta -= usable_gain;
188 if (delta == 0.0f) return;
190 gain_t factor = delta / usable_gain;
193 factor = _mix_group->get_max_factor(factor);
194 if (factor == 0.0f) {
199 factor = _mix_group->get_min_factor(factor);
200 if (factor == 0.0f) {
206 _mix_group->apply (&Route::inc_gain, factor, _mix_group);
210 _mix_group->apply (&Route::set_gain, val, _mix_group);
220 IO::set_gain (val, src);
224 Route::process_output_buffers (vector<Sample*>& bufs, uint32_t nbufs,
225 nframes_t start_frame, nframes_t end_frame,
226 nframes_t nframes, nframes_t offset, bool with_redirects, int declick,
230 RedirectList::iterator i;
231 bool post_fader_work = false;
232 bool mute_declick_applied = false;
234 vector<Sample*>::iterator bufiter;
239 gain_t* gab = _session.gain_automation_buffer();
241 switch (Config->get_monitoring_model()) {
242 case HardwareMonitoring:
243 case ExternalMonitoring:
250 declick = _pending_declick;
253 Glib::Mutex::Lock cm (control_outs_lock, Glib::TRY_LOCK);
263 Glib::Mutex::Lock dm (declick_lock, Glib::TRY_LOCK);
266 dmg = desired_mute_gain;
267 dsg = desired_solo_gain;
276 /* ----------------------------------------------------------------------------------------------------
277 GLOBAL DECLICK (for transport changes etc.)
278 -------------------------------------------------------------------------------------------------- */
281 apply_declick (bufs, nbufs, nframes, 0.0, 1.0, false);
282 _pending_declick = 0;
283 } else if (declick < 0) {
284 apply_declick (bufs, nbufs, nframes, 1.0, 0.0, false);
285 _pending_declick = 0;
288 /* no global declick */
290 if (solo_gain != dsg) {
291 apply_declick (bufs, nbufs, nframes, solo_gain, dsg, false);
297 /* ----------------------------------------------------------------------------------------------------
298 INPUT METERING & MONITORING
299 -------------------------------------------------------------------------------------------------- */
301 if (meter && (_meter_point == MeterInput)) {
302 for (n = 0; n < nbufs; ++n) {
303 _peak_power[n] = Session::compute_peak (bufs[n], nframes, _peak_power[n]);
307 if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
308 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false);
310 mute_declick_applied = true;
313 if ((_meter_point == MeterInput) && co) {
315 solo_audible = dsg > 0;
316 mute_audible = dmg > 0;// || !_mute_affects_pre_fader;
318 if ( // muted by solo of another track
322 // muted by mute of this track
326 // rec-enabled but not s/w monitoring
328 // TODO: this is probably wrong
330 (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording()))
334 co->silence (nframes, offset);
338 co->deliver_output (bufs, nbufs, nframes, offset);
343 /* ----------------------------------------------------------------------------------------------------
345 -------------------------------------------------------------------------------------------------- */
347 if (with_redirects) {
348 Glib::RWLock::ReaderLock rm (redirect_lock, Glib::TRY_LOCK);
350 if (mute_gain > 0 || !_mute_affects_pre_fader) {
351 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
352 switch ((*i)->placement()) {
355 if (boost::dynamic_pointer_cast<Send>(*i) || boost::dynamic_pointer_cast<PortInsert>(*i)) {
356 (*i)->silence (nframes, offset);
359 (*i)->run (bufs, nbufs, nframes, offset);
363 post_fader_work = true;
368 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
369 switch ((*i)->placement()) {
371 (*i)->silence (nframes, offset);
374 post_fader_work = true;
383 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
384 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false);
386 mute_declick_applied = true;
389 /* ----------------------------------------------------------------------------------------------------
390 PRE-FADER METERING & MONITORING
391 -------------------------------------------------------------------------------------------------- */
393 if (meter && (_meter_point == MeterPreFader)) {
394 for (n = 0; n < nbufs; ++n) {
395 _peak_power[n] = Session::compute_peak (bufs[n], nframes, _peak_power[n]);
400 if ((_meter_point == MeterPreFader) && co) {
402 solo_audible = dsg > 0;
403 mute_audible = dmg > 0 || !_mute_affects_pre_fader;
405 if ( // muted by solo of another track
409 // muted by mute of this track
413 // rec-enabled but not s/w monitoring
415 (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording()))
419 co->silence (nframes, offset);
423 co->deliver_output (bufs, nbufs, nframes, offset);
428 /* ----------------------------------------------------------------------------------------------------
430 -------------------------------------------------------------------------------------------------- */
432 /* if not recording or recording and requiring any monitor signal, then apply gain */
434 if ( // not recording
436 !(record_enabled() && _session.actively_recording()) ||
440 // h/w monitoring not in use
442 (!Config->get_monitoring_model() == HardwareMonitoring &&
444 // AND software monitoring required
446 Config->get_monitoring_model() == SoftwareMonitoring)) {
448 if (apply_gain_automation) {
451 for (n = 0; n < nbufs; ++n) {
452 Sample *sp = bufs[n];
454 for (nframes_t nx = 0; nx < nframes; ++nx) {
459 for (n = 0; n < nbufs; ++n) {
460 Sample *sp = bufs[n];
462 for (nframes_t nx = 0; nx < nframes; ++nx) {
468 if (apply_gain_automation && _session.transport_rolling() && nframes > 0) {
469 _effective_gain = gab[nframes-1];
474 /* manual (scalar) gain */
478 apply_declick (bufs, nbufs, nframes, _gain, dg, _phase_invert);
481 } else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
483 /* no need to interpolate current gain value,
484 but its non-unity, so apply it. if the gain
485 is zero, do nothing because we'll ship silence
497 for (n = 0; n < nbufs; ++n) {
498 Sample *sp = bufs[n];
499 Session::apply_gain_to_buffer(sp,nframes,this_gain);
502 } else if (_gain == 0) {
503 for (n = 0; n < nbufs; ++n) {
504 memset (bufs[n], 0, sizeof (Sample) * nframes);
511 /* actively recording, no monitoring required; leave buffers as-is to save CPU cycles */
515 /* ----------------------------------------------------------------------------------------------------
517 -------------------------------------------------------------------------------------------------- */
519 /* note that post_fader_work cannot be true unless with_redirects was also true, so don't test both */
521 if (post_fader_work) {
523 Glib::RWLock::ReaderLock rm (redirect_lock, Glib::TRY_LOCK);
525 if (mute_gain > 0 || !_mute_affects_post_fader) {
526 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
527 switch ((*i)->placement()) {
532 if (boost::dynamic_pointer_cast<Send>(*i) || boost::dynamic_pointer_cast<PortInsert>(*i)) {
533 (*i)->silence (nframes, offset);
536 (*i)->run (bufs, nbufs, nframes, offset);
542 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
543 switch ((*i)->placement()) {
547 (*i)->silence (nframes, offset);
555 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
556 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false);
558 mute_declick_applied = true;
561 /* ----------------------------------------------------------------------------------------------------
563 -------------------------------------------------------------------------------------------------- */
565 if ((_meter_point == MeterPostFader) && co) {
567 solo_audible = solo_gain > 0;
568 mute_audible = dmg > 0 || !_mute_affects_control_outs;
570 if ( // silent anyway
572 (_gain == 0 && !apply_gain_automation) ||
574 // muted by solo of another track
578 // muted by mute of this track
582 // recording but not s/w monitoring
584 (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording()))
588 co->silence (nframes, offset);
592 co->deliver_output_no_pan (bufs, nbufs, nframes, offset);
596 /* ----------------------------------------------------------------------
598 ----------------------------------------------------------------------*/
600 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
601 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, false);
603 mute_declick_applied = true;
606 /* ----------------------------------------------------------------------------------------------------
608 -------------------------------------------------------------------------------------------------- */
610 solo_audible = dsg > 0;
611 mute_audible = dmg > 0 || !_mute_affects_main_outs;
613 if (n_outputs() == 0) {
617 } else if (no_monitor && record_enabled() && (!Config->get_auto_input() || _session.actively_recording())) {
619 IO::silence (nframes, offset);
623 if ( // silent anyway
625 (_gain == 0 && !apply_gain_automation) ||
627 // muted by solo of another track, but not using control outs for solo
629 (!solo_audible && (Config->get_solo_model() != SoloBus)) ||
631 // muted by mute of this track
637 /* don't use Route::silence() here, because that causes
638 all outputs (sends, port inserts, etc. to be silent).
641 if (_meter_point == MeterPostFader) {
642 reset_peak_meters ();
645 IO::silence (nframes, offset);
649 if ((_session.transport_speed() > 1.5f ||
650 _session.transport_speed() < -1.5f) &&
651 Config->get_quieten_at_speed()) {
652 pan (bufs, nbufs, nframes, offset, speed_quietning);
654 // cerr << _name << " panner state = " << _panner->automation_state() << endl;
655 if (!_panner->empty() &&
656 (_panner->automation_state() & Play ||
657 ((_panner->automation_state() & Touch) && !_panner->touching()))) {
658 pan_automated (bufs, nbufs, start_frame, end_frame, nframes, offset);
660 pan (bufs, nbufs, nframes, offset, 1.0);
667 /* ----------------------------------------------------------------------------------------------------
669 -------------------------------------------------------------------------------------------------- */
671 if (meter && (_meter_point == MeterPostFader)) {
672 // cerr << "meter post" << endl;
674 if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
675 uint32_t no = n_outputs();
676 for (n = 0; n < no; ++n) {
680 uint32_t no = n_outputs();
681 for (n = 0; n < no; ++n) {
682 _peak_power[n] = Session::compute_peak (output(n)->get_buffer (nframes) + offset, nframes, _peak_power[n]);
689 Route::n_process_buffers ()
691 return max (n_inputs(), redirect_max_outs);
696 Route::passthru (nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset, int declick, bool meter_first)
698 vector<Sample*>& bufs = _session.get_passthru_buffers();
699 uint32_t limit = n_process_buffers ();
703 collect_input (bufs, limit, nframes, offset);
705 #define meter_stream meter_first
708 for (uint32_t n = 0; n < limit; ++n) {
709 _peak_power[n] = Session::compute_peak (bufs[n], nframes, _peak_power[n]);
711 meter_stream = false;
716 process_output_buffers (bufs, limit, start_frame, end_frame, nframes, offset, true, declick, meter_stream);
722 Route::set_phase_invert (bool yn, void *src)
724 if (_phase_invert != yn) {
727 // phase_invert_changed (src); /* EMIT SIGNAL */
731 Route::set_solo (bool yn, void *src)
737 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
738 _mix_group->apply (&Route::set_solo, yn, _mix_group);
744 solo_changed (src); /* EMIT SIGNAL */
745 _solo_control.Changed (); /* EMIT SIGNAL */
750 Route::set_solo_mute (bool yn)
752 Glib::Mutex::Lock lm (declick_lock);
754 /* Called by Session in response to another Route being soloed.
757 desired_solo_gain = (yn?0.0:1.0);
761 Route::set_solo_safe (bool yn, void *src)
763 if (_solo_safe != yn) {
765 solo_safe_changed (src); /* EMIT SIGNAL */
770 Route::set_mute (bool yn, void *src)
773 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
774 _mix_group->apply (&Route::set_mute, yn, _mix_group);
780 mute_changed (src); /* EMIT SIGNAL */
782 _mute_control.Changed (); /* EMIT SIGNAL */
784 Glib::Mutex::Lock lm (declick_lock);
785 desired_mute_gain = (yn?0.0f:1.0f);
790 Route::add_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams)
792 uint32_t old_rmo = redirect_max_outs;
794 if (!_session.engine().connected()) {
799 Glib::RWLock::WriterLock lm (redirect_lock);
801 boost::shared_ptr<PluginInsert> pi;
802 boost::shared_ptr<PortInsert> porti;
804 uint32_t potential_max_streams = 0;
806 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(redirect)) != 0) {
809 if (pi->input_streams() == 0) {
810 /* instrument plugin */
811 _have_internal_generator = true;
814 potential_max_streams = max(pi->input_streams(), pi->output_streams());
816 } else if ((porti = boost::dynamic_pointer_cast<PortInsert>(redirect)) != 0) {
818 /* force new port inserts to start out with an i/o configuration
819 that matches this route's i/o configuration.
821 the "inputs" for the port are supposed to match the output
824 the "outputs" of the route should match the inputs of this
825 route. XXX shouldn't they match the number of active signal
826 streams at the point of insertion?
830 porti->ensure_io (n_outputs (), n_inputs(), false, this);
833 // Ensure peak vector sizes before the plugin is activated
834 while (_peak_power.size() < potential_max_streams) {
835 _peak_power.push_back(0);
837 while (_visible_peak_power.size() < potential_max_streams) {
838 _visible_peak_power.push_back(-INFINITY);
840 while (_max_peak_power.size() < potential_max_streams) {
841 _max_peak_power.push_back(-INFINITY);
844 _redirects.push_back (redirect);
846 if (_reset_plugin_counts (err_streams)) {
847 _redirects.pop_back ();
848 _reset_plugin_counts (0); // it worked before we tried to add it ...
852 redirect->activate ();
853 redirect->active_changed.connect (mem_fun (*this, &Route::redirect_active_proxy));
856 if (redirect_max_outs != old_rmo || old_rmo == 0) {
861 redirects_changed (src); /* EMIT SIGNAL */
866 Route::add_redirects (const RedirectList& others, void *src, uint32_t* err_streams)
868 uint32_t old_rmo = redirect_max_outs;
870 if (!_session.engine().connected()) {
875 Glib::RWLock::WriterLock lm (redirect_lock);
877 RedirectList::iterator existing_end = _redirects.end();
880 uint32_t potential_max_streams = 0;
882 for (RedirectList::const_iterator i = others.begin(); i != others.end(); ++i) {
884 boost::shared_ptr<PluginInsert> pi;
886 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
889 uint32_t m = max(pi->input_streams(), pi->output_streams());
890 if (m > potential_max_streams)
891 potential_max_streams = m;
894 // Ensure peak vector sizes before the plugin is activated
895 while (_peak_power.size() < potential_max_streams) {
896 _peak_power.push_back(0);
898 while (_visible_peak_power.size() < potential_max_streams) {
899 _visible_peak_power.push_back(-INFINITY);
901 while (_max_peak_power.size() < potential_max_streams) {
902 _max_peak_power.push_back(-INFINITY);
905 _redirects.push_back (*i);
907 if (_reset_plugin_counts (err_streams)) {
909 _redirects.erase (existing_end, _redirects.end());
910 _reset_plugin_counts (0); // it worked before we tried to add it ...
915 (*i)->active_changed.connect (mem_fun (*this, &Route::redirect_active_proxy));
919 if (redirect_max_outs != old_rmo || old_rmo == 0) {
923 redirects_changed (src); /* EMIT SIGNAL */
928 Route::clear_redirects (void *src)
930 uint32_t old_rmo = redirect_max_outs;
932 if (!_session.engine().connected()) {
937 Glib::RWLock::WriterLock lm (redirect_lock);
938 RedirectList::iterator i;
939 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
940 (*i)->drop_references ();
945 if (redirect_max_outs != old_rmo) {
949 redirect_max_outs = 0;
950 _have_internal_generator = false;
951 redirects_changed (src); /* EMIT SIGNAL */
955 Route::remove_redirect (boost::shared_ptr<Redirect> redirect, void *src, uint32_t* err_streams)
957 uint32_t old_rmo = redirect_max_outs;
959 if (!_session.engine().connected()) {
963 redirect_max_outs = 0;
966 Glib::RWLock::WriterLock lm (redirect_lock);
967 RedirectList::iterator i;
968 bool removed = false;
970 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
971 if (*i == redirect) {
973 RedirectList::iterator tmp;
975 /* move along, see failure case for reset_plugin_counts()
976 where we may need to reinsert the redirect.
982 /* stop redirects that send signals to JACK ports
983 from causing noise as a result of no longer being
987 boost::shared_ptr<Send> send;
988 boost::shared_ptr<PortInsert> port_insert;
990 if ((send = boost::dynamic_pointer_cast<Send> (*i)) != 0) {
991 send->disconnect_inputs (this);
992 send->disconnect_outputs (this);
993 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (*i)) != 0) {
994 port_insert->disconnect_inputs (this);
995 port_insert->disconnect_outputs (this);
998 _redirects.erase (i);
1011 if (_reset_plugin_counts (err_streams)) {
1012 /* get back to where we where */
1013 _redirects.insert (i, redirect);
1014 /* we know this will work, because it worked before :) */
1015 _reset_plugin_counts (0);
1021 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
1022 boost::shared_ptr<PluginInsert> pi;
1024 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(*i)) != 0) {
1025 if (pi->is_generator()) {
1031 _have_internal_generator = foo;
1034 if (old_rmo != redirect_max_outs) {
1038 redirect->drop_references ();
1040 redirects_changed (src); /* EMIT SIGNAL */
1045 Route::reset_plugin_counts (uint32_t* lpc)
1047 Glib::RWLock::WriterLock lm (redirect_lock);
1048 return _reset_plugin_counts (lpc);
1053 Route::_reset_plugin_counts (uint32_t* err_streams)
1055 RedirectList::iterator r;
1058 map<Placement,list<InsertCount> > insert_map;
1059 nframes_t initial_streams;
1061 redirect_max_outs = 0;
1065 /* divide inserts up by placement so we get the signal flow
1066 properly modelled. we need to do this because the _redirects
1067 list is not sorted by placement, and because other reasons may
1068 exist now or in the future for this separate treatment.
1071 for (r = _redirects.begin(); r != _redirects.end(); ++r) {
1073 boost::shared_ptr<Insert> insert;
1075 /* do this here in case we bomb out before we get to the end of
1079 redirect_max_outs = max ((*r)->output_streams (), redirect_max_outs);
1081 if ((insert = boost::dynamic_pointer_cast<Insert>(*r)) != 0) {
1083 insert_map[insert->placement()].push_back (InsertCount (insert));
1085 /* reset plugin counts back to one for now so
1086 that we have a predictable, controlled
1087 state to try to configure.
1090 boost::shared_ptr<PluginInsert> pi;
1092 if ((pi = boost::dynamic_pointer_cast<PluginInsert>(insert)) != 0) {
1096 } else if (boost::dynamic_pointer_cast<Send> (*r) != 0) {
1109 /* Now process each placement in order, checking to see if we
1110 can really do what has been requested.
1115 if (check_some_plugin_counts (insert_map[PreFader], n_inputs (), err_streams)) {
1119 /* figure out the streams that will feed into PreFader */
1121 if (!insert_map[PreFader].empty()) {
1122 InsertCount& ic (insert_map[PreFader].back());
1123 initial_streams = ic.insert->compute_output_streams (ic.cnt);
1125 initial_streams = n_inputs ();
1130 if (check_some_plugin_counts (insert_map[PostFader], initial_streams, err_streams)) {
1134 /* OK, everything can be set up correctly, so lets do it */
1136 apply_some_plugin_counts (insert_map[PreFader]);
1137 apply_some_plugin_counts (insert_map[PostFader]);
1139 /* recompute max outs of any redirect */
1143 redirect_max_outs = 0;
1144 RedirectList::iterator prev = _redirects.end();
1146 for (r = _redirects.begin(); r != _redirects.end(); prev = r, ++r) {
1147 boost::shared_ptr<Send> s;
1149 if ((s = boost::dynamic_pointer_cast<Send> (*r)) != 0) {
1150 if (r == _redirects.begin()) {
1151 s->expect_inputs (n_inputs());
1153 s->expect_inputs ((*prev)->output_streams());
1158 /* don't pay any attention to send output configuration, since it doesn't
1162 redirect_max_outs = max ((*r)->output_streams (), redirect_max_outs);
1173 Route::apply_some_plugin_counts (list<InsertCount>& iclist)
1175 list<InsertCount>::iterator i;
1177 for (i = iclist.begin(); i != iclist.end(); ++i) {
1179 if ((*i).insert->configure_io ((*i).cnt, (*i).in, (*i).out)) {
1182 /* make sure that however many we have, they are all active */
1183 (*i).insert->activate ();
1190 Route::check_some_plugin_counts (list<InsertCount>& iclist, int32_t required_inputs, uint32_t* err_streams)
1192 list<InsertCount>::iterator i;
1194 for (i = iclist.begin(); i != iclist.end(); ++i) {
1196 if (((*i).cnt = (*i).insert->can_support_input_configuration (required_inputs)) < 0) {
1198 *err_streams = required_inputs;
1203 (*i).in = required_inputs;
1204 (*i).out = (*i).insert->compute_output_streams ((*i).cnt);
1206 required_inputs = (*i).out;
1213 Route::copy_redirects (const Route& other, Placement placement, uint32_t* err_streams)
1215 uint32_t old_rmo = redirect_max_outs;
1221 RedirectList to_be_deleted;
1224 Glib::RWLock::WriterLock lm (redirect_lock);
1225 RedirectList::iterator tmp;
1226 RedirectList the_copy;
1228 the_copy = _redirects;
1230 /* remove all relevant redirects */
1232 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ) {
1236 if ((*i)->placement() == placement) {
1237 to_be_deleted.push_back (*i);
1238 _redirects.erase (i);
1244 /* now copy the relevant ones from "other" */
1246 for (RedirectList::const_iterator i = other._redirects.begin(); i != other._redirects.end(); ++i) {
1247 if ((*i)->placement() == placement) {
1248 _redirects.push_back (Redirect::clone (*i));
1252 /* reset plugin stream handling */
1254 if (_reset_plugin_counts (err_streams)) {
1256 /* FAILED COPY ATTEMPT: we have to restore order */
1258 /* delete all cloned redirects */
1260 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ) {
1265 if ((*i)->placement() == placement) {
1266 _redirects.erase (i);
1272 /* restore the natural order */
1274 _redirects = the_copy;
1275 redirect_max_outs = old_rmo;
1277 /* we failed, even though things are OK again */
1283 /* SUCCESSFUL COPY ATTEMPT: delete the redirects we removed pre-copy */
1284 to_be_deleted.clear ();
1288 if (redirect_max_outs != old_rmo || old_rmo == 0) {
1292 redirects_changed (this); /* EMIT SIGNAL */
1297 Route::all_redirects_flip ()
1299 Glib::RWLock::ReaderLock lm (redirect_lock);
1301 if (_redirects.empty()) {
1305 bool first_is_on = _redirects.front()->active();
1307 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1308 (*i)->set_active (!first_is_on, this);
1313 Route::all_redirects_active (bool state)
1315 Glib::RWLock::ReaderLock lm (redirect_lock);
1317 if (_redirects.empty()) {
1321 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1322 (*i)->set_active (state, this);
1326 struct RedirectSorter {
1327 bool operator() (boost::shared_ptr<const Redirect> a, boost::shared_ptr<const Redirect> b) {
1328 return a->sort_key() < b->sort_key();
1333 Route::sort_redirects (uint32_t* err_streams)
1336 RedirectSorter comparator;
1337 Glib::RWLock::WriterLock lm (redirect_lock);
1338 uint32_t old_rmo = redirect_max_outs;
1340 /* the sweet power of C++ ... */
1342 RedirectList as_it_was_before = _redirects;
1344 _redirects.sort (comparator);
1346 if (_reset_plugin_counts (err_streams)) {
1347 _redirects = as_it_was_before;
1348 redirect_max_outs = old_rmo;
1354 redirects_changed (this); /* EMIT SIGNAL */
1366 Route::get_template()
1368 return state(false);
1372 Route::state(bool full_state)
1374 XMLNode *node = new XMLNode("Route");
1375 RedirectList:: iterator i;
1379 node->add_property("flags", enum_2_string (_flags));
1382 node->add_property("default-type", _default_type.to_string());
1384 node->add_property("active", _active?"yes":"no");
1385 node->add_property("muted", _muted?"yes":"no");
1386 node->add_property("soloed", _soloed?"yes":"no");
1387 node->add_property("phase-invert", _phase_invert?"yes":"no");
1388 node->add_property("mute-affects-pre-fader", _mute_affects_pre_fader?"yes":"no");
1389 node->add_property("mute-affects-post-fader", _mute_affects_post_fader?"yes":"no");
1390 node->add_property("mute-affects-control-outs", _mute_affects_control_outs?"yes":"no");
1391 node->add_property("mute-affects-main-outs", _mute_affects_main_outs?"yes":"no");
1394 node->add_property("edit-group", _edit_group->name());
1397 node->add_property("mix-group", _mix_group->name());
1400 string order_string;
1401 OrderKeys::iterator x = order_keys.begin();
1403 while (x != order_keys.end()) {
1404 order_string += string ((*x).first);
1405 order_string += '=';
1406 snprintf (buf, sizeof(buf), "%ld", (*x).second);
1407 order_string += buf;
1411 if (x == order_keys.end()) {
1415 order_string += ':';
1417 node->add_property ("order-keys", order_string);
1419 node->add_child_nocopy (IO::state (full_state));
1420 node->add_child_nocopy (_solo_control.get_state ());
1421 node->add_child_nocopy (_mute_control.get_state ());
1423 XMLNode* remote_control_node = new XMLNode (X_("remote_control"));
1424 snprintf (buf, sizeof (buf), "%d", _remote_control_id);
1425 remote_control_node->add_property (X_("id"), buf);
1426 node->add_child_nocopy (*remote_control_node);
1428 if (_control_outs) {
1429 XMLNode* cnode = new XMLNode (X_("ControlOuts"));
1430 cnode->add_child_nocopy (_control_outs->state (full_state));
1431 node->add_child_nocopy (*cnode);
1434 if (_comment.length()) {
1435 XMLNode *cmt = node->add_child ("Comment");
1436 cmt->add_content (_comment);
1439 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
1440 node->add_child_nocopy((*i)->state (full_state));
1444 node->add_child_copy (*_extra_xml);
1451 Route::set_deferred_state ()
1454 XMLNodeConstIterator niter;
1456 if (!deferred_state) {
1460 nlist = deferred_state->children();
1462 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1463 add_redirect_from_xml (**niter);
1466 delete deferred_state;
1471 Route::add_redirect_from_xml (const XMLNode& node)
1473 const XMLProperty *prop;
1475 if (node.name() == "Send") {
1479 boost::shared_ptr<Send> send (new Send (_session, node));
1480 add_redirect (send, this);
1483 catch (failed_constructor &err) {
1484 error << _("Send construction failed") << endmsg;
1488 } else if (node.name() == "Insert") {
1491 if ((prop = node.property ("type")) != 0) {
1493 boost::shared_ptr<Insert> insert;
1495 if (prop->value() == "ladspa" || prop->value() == "Ladspa" || prop->value() == "vst") {
1497 insert.reset (new PluginInsert(_session, node));
1499 } else if (prop->value() == "port") {
1502 insert.reset (new PortInsert (_session, node));
1506 error << string_compose(_("unknown Insert type \"%1\"; ignored"), prop->value()) << endmsg;
1509 add_redirect (insert, this);
1512 error << _("Insert XML node has no type property") << endmsg;
1516 catch (failed_constructor &err) {
1517 warning << _("insert could not be created. Ignored.") << endmsg;
1524 Route::set_state (const XMLNode& node)
1526 return _set_state (node, true);
1530 Route::_set_state (const XMLNode& node, bool call_base)
1533 XMLNodeConstIterator niter;
1535 XMLPropertyList plist;
1536 const XMLProperty *prop;
1538 if (node.name() != "Route"){
1539 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1543 if ((prop = node.property (X_("flags"))) != 0) {
1544 _flags = Flag (string_2_enum (prop->value(), _flags));
1549 if ((prop = node.property (X_("default-type"))) != 0) {
1550 _default_type = DataType(prop->value());
1551 assert(_default_type != DataType::NIL);
1554 if ((prop = node.property (X_("phase-invert"))) != 0) {
1555 set_phase_invert(prop->value()=="yes"?true:false, this);
1558 if ((prop = node.property (X_("active"))) != 0) {
1559 set_active (prop->value() == "yes");
1562 if ((prop = node.property (X_("muted"))) != 0) {
1563 bool yn = prop->value()=="yes"?true:false;
1565 /* force reset of mute status */
1569 mute_gain = desired_mute_gain;
1572 if ((prop = node.property (X_("soloed"))) != 0) {
1573 bool yn = prop->value()=="yes"?true:false;
1575 /* force reset of solo status */
1578 set_solo (yn, this);
1579 solo_gain = desired_solo_gain;
1582 if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
1583 _mute_affects_pre_fader = (prop->value()=="yes")?true:false;
1586 if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
1587 _mute_affects_post_fader = (prop->value()=="yes")?true:false;
1590 if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
1591 _mute_affects_control_outs = (prop->value()=="yes")?true:false;
1594 if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
1595 _mute_affects_main_outs = (prop->value()=="yes")?true:false;
1598 if ((prop = node.property (X_("edit-group"))) != 0) {
1599 RouteGroup* edit_group = _session.edit_group_by_name(prop->value());
1600 if(edit_group == 0) {
1601 error << string_compose(_("Route %1: unknown edit group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
1603 set_edit_group(edit_group, this);
1607 if ((prop = node.property (X_("order-keys"))) != 0) {
1611 string::size_type colon, equal;
1612 string remaining = prop->value();
1614 while (remaining.length()) {
1616 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
1617 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1620 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
1621 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1624 set_order_key (remaining.substr (0, equal).c_str(), n);
1628 colon = remaining.find_first_of (':');
1630 if (colon != string::npos) {
1631 remaining = remaining.substr (colon+1);
1638 nlist = node.children();
1640 if (deferred_state) {
1641 delete deferred_state;
1644 deferred_state = new XMLNode(X_("deferred state"));
1646 /* set parent class properties before anything else */
1648 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1652 if (child->name() == IO::state_node_name && call_base) {
1654 IO::set_state (*child);
1659 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1663 if (child->name() == X_("Send")) {
1666 if (!IO::ports_legal) {
1668 deferred_state->add_child_copy (*child);
1671 add_redirect_from_xml (*child);
1674 } else if (child->name() == X_("Insert")) {
1676 if (!IO::ports_legal) {
1678 deferred_state->add_child_copy (*child);
1682 add_redirect_from_xml (*child);
1685 } else if (child->name() == X_("Automation")) {
1687 if ((prop = child->property (X_("path"))) != 0) {
1688 load_automation (prop->value());
1691 } else if (child->name() == X_("ControlOuts")) {
1693 string coutname = _name;
1694 coutname += _("[control]");
1696 _control_outs = new IO (_session, coutname);
1697 _control_outs->set_state (**(child->children().begin()));
1699 } else if (child->name() == X_("Comment")) {
1701 /* XXX this is a terrible API design in libxml++ */
1703 XMLNode *cmt = *(child->children().begin());
1704 _comment = cmt->content();
1706 } else if (child->name() == X_("extra")) {
1708 _extra_xml = new XMLNode (*child);
1710 } else if (child->name() == X_("controllable") && (prop = child->property("name")) != 0) {
1712 if (prop->value() == "solo") {
1713 _solo_control.set_state (*child);
1714 _session.add_controllable (&_solo_control);
1716 else if (prop->value() == "mute") {
1717 _mute_control.set_state (*child);
1718 _session.add_controllable (&_mute_control);
1721 else if (child->name() == X_("remote_control")) {
1722 if ((prop = child->property (X_("id"))) != 0) {
1724 sscanf (prop->value().c_str(), "%d", &x);
1725 set_remote_control_id (x);
1730 if ((prop = node.property (X_("mix-group"))) != 0) {
1731 RouteGroup* mix_group = _session.mix_group_by_name(prop->value());
1732 if (mix_group == 0) {
1733 error << string_compose(_("Route %1: unknown mix group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
1735 set_mix_group(mix_group, this);
1743 Route::curve_reallocate ()
1745 // _gain_automation_curve.finish_resize ();
1746 // _pan_automation_curve.finish_resize ();
1750 Route::silence (nframes_t nframes, nframes_t offset)
1754 // reset_peak_meters ();
1756 IO::silence (nframes, offset);
1758 if (_control_outs) {
1759 _control_outs->silence (nframes, offset);
1763 Glib::RWLock::ReaderLock lm (redirect_lock, Glib::TRY_LOCK);
1766 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1767 boost::shared_ptr<PluginInsert> pi;
1768 if (!_active && (pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
1769 // skip plugins, they don't need anything when we're not active
1773 (*i)->silence (nframes, offset);
1776 if (nframes == _session.get_block_size() && offset == 0) {
1786 Route::set_control_outs (const vector<string>& ports)
1788 Glib::Mutex::Lock lm (control_outs_lock);
1789 vector<string>::const_iterator i;
1791 if (_control_outs) {
1792 delete _control_outs;
1796 if (ports.empty()) {
1800 string coutname = _name;
1801 coutname += _("[control]");
1803 _control_outs = new IO (_session, coutname);
1805 /* our control outs need as many outputs as we
1806 have outputs. we track the changes in ::output_change_handler().
1809 _control_outs->ensure_io (0, n_outputs(), true, this);
1815 Route::set_edit_group (RouteGroup *eg, void *src)
1818 if (eg == _edit_group) {
1823 _edit_group->remove (this);
1826 if ((_edit_group = eg) != 0) {
1827 _edit_group->add (this);
1830 _session.set_dirty ();
1831 edit_group_changed (src); /* EMIT SIGNAL */
1835 Route::drop_edit_group (void *src)
1838 _session.set_dirty ();
1839 edit_group_changed (src); /* EMIT SIGNAL */
1843 Route::set_mix_group (RouteGroup *mg, void *src)
1846 if (mg == _mix_group) {
1851 _mix_group->remove (this);
1854 if ((_mix_group = mg) != 0) {
1855 _mix_group->add (this);
1858 _session.set_dirty ();
1859 mix_group_changed (src); /* EMIT SIGNAL */
1863 Route::drop_mix_group (void *src)
1866 _session.set_dirty ();
1867 mix_group_changed (src); /* EMIT SIGNAL */
1871 Route::set_comment (string cmt, void *src)
1874 comment_changed (src);
1875 _session.set_dirty ();
1879 Route::feeds (boost::shared_ptr<Route> other)
1884 uint32_t no = self.n_outputs();
1885 uint32_t ni = other->n_inputs ();
1887 for (i = 0; i < no; ++i) {
1888 for (j = 0; j < ni; ++j) {
1889 if (self.output(i)->connected_to (other->input(j)->name())) {
1895 /* check Redirects which may also interconnect Routes */
1897 for (RedirectList::iterator r = _redirects.begin(); r != _redirects.end(); r++) {
1899 no = (*r)->n_outputs();
1901 for (i = 0; i < no; ++i) {
1902 for (j = 0; j < ni; ++j) {
1903 if ((*r)->output(i)->connected_to (other->input (j)->name())) {
1910 /* check for control room outputs which may also interconnect Routes */
1912 if (_control_outs) {
1914 no = _control_outs->n_outputs();
1916 for (i = 0; i < no; ++i) {
1917 for (j = 0; j < ni; ++j) {
1918 if (_control_outs->output(i)->connected_to (other->input (j)->name())) {
1929 Route::set_mute_config (mute_type t, bool onoff, void *src)
1933 _mute_affects_pre_fader = onoff;
1934 pre_fader_changed(src); /* EMIT SIGNAL */
1938 _mute_affects_post_fader = onoff;
1939 post_fader_changed(src); /* EMIT SIGNAL */
1943 _mute_affects_control_outs = onoff;
1944 control_outs_changed(src); /* EMIT SIGNAL */
1948 _mute_affects_main_outs = onoff;
1949 main_outs_changed(src); /* EMIT SIGNAL */
1955 Route::get_mute_config (mute_type t)
1961 onoff = _mute_affects_pre_fader;
1964 onoff = _mute_affects_post_fader;
1967 onoff = _mute_affects_control_outs;
1970 onoff = _mute_affects_main_outs;
1978 Route::set_active (bool yn)
1981 active_changed(); /* EMIT SIGNAL */
1985 Route::handle_transport_stopped (bool abort_ignored, bool did_locate, bool can_flush_redirects)
1987 nframes_t now = _session.transport_frame();
1990 Glib::RWLock::ReaderLock lm (redirect_lock);
1993 automation_snapshot (now);
1996 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1998 if (Config->get_plugins_stop_with_transport() && can_flush_redirects) {
1999 (*i)->deactivate ();
2003 (*i)->transport_stopped (now);
2007 IO::transport_stopped (now);
2009 _roll_delay = _initial_delay;
2013 Route::input_change_handler (IOChange change, void *ignored)
2015 if (change & ConfigurationChanged) {
2016 reset_plugin_counts (0);
2021 Route::output_change_handler (IOChange change, void *ignored)
2023 if (change & ConfigurationChanged) {
2024 if (_control_outs) {
2025 _control_outs->ensure_io (0, n_outputs(), true, this);
2028 reset_plugin_counts (0);
2033 Route::pans_required () const
2035 if (n_outputs() < 2) {
2039 return max (n_inputs (), redirect_max_outs);
2043 Route::no_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nframes_t offset,
2044 bool session_state_changing, bool can_record, bool rec_monitors_input)
2046 if (n_outputs() == 0) {
2050 if (session_state_changing || !_active) {
2051 silence (nframes, offset);
2055 apply_gain_automation = false;
2058 passthru (start_frame, end_frame, nframes, offset, 0, false);
2060 silence (nframes, offset);
2067 Route::check_initial_delay (nframes_t nframes, nframes_t& offset, nframes_t& transport_frame)
2069 if (_roll_delay > nframes) {
2071 _roll_delay -= nframes;
2072 silence (nframes, offset);
2073 /* transport frame is not legal for caller to use */
2076 } else if (_roll_delay > 0) {
2078 nframes -= _roll_delay;
2080 silence (_roll_delay, offset);
2082 offset += _roll_delay;
2083 transport_frame += _roll_delay;
2092 Route::roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nframes_t offset, int declick,
2093 bool can_record, bool rec_monitors_input)
2096 Glib::RWLock::ReaderLock lm (redirect_lock, Glib::TRY_LOCK);
2098 // automation snapshot can also be called from the non-rt context
2099 // and it uses the redirect list, so we take the lock out here
2100 automation_snapshot (_session.transport_frame());
2104 if ((n_outputs() == 0 && _redirects.empty()) || n_inputs() == 0 || !_active) {
2105 silence (nframes, offset);
2109 nframes_t unused = 0;
2111 if ((nframes = check_initial_delay (nframes, offset, unused)) == 0) {
2117 apply_gain_automation = false;
2120 Glib::Mutex::Lock am (automation_lock, Glib::TRY_LOCK);
2122 if (am.locked() && _session.transport_rolling()) {
2124 nframes_t start_frame = end_frame - nframes;
2126 if (gain_automation_playback()) {
2127 apply_gain_automation = _gain_automation_curve.rt_safe_get_vector (start_frame, end_frame, _session.gain_automation_buffer(), nframes);
2132 passthru (start_frame, end_frame, nframes, offset, declick, false);
2138 Route::silent_roll (nframes_t nframes, nframes_t start_frame, nframes_t end_frame, nframes_t offset,
2139 bool can_record, bool rec_monitors_input)
2141 silence (nframes, offset);
2146 Route::toggle_monitor_input ()
2148 for (vector<Port*>::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
2149 (*i)->ensure_monitor_input(!(*i)->monitoring_input());
2154 Route::has_external_redirects () const
2156 boost::shared_ptr<const PortInsert> pi;
2158 for (RedirectList::const_iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2159 if ((pi = boost::dynamic_pointer_cast<const PortInsert>(*i)) != 0) {
2161 uint32_t no = pi->n_outputs();
2163 for (uint32_t n = 0; n < no; ++n) {
2165 string port_name = pi->output(n)->name();
2166 string client_name = port_name.substr (0, port_name.find(':'));
2168 /* only say "yes" if the redirect is actually in use */
2170 if (client_name != "ardour" && pi->active()) {
2181 Route::flush_redirects ()
2183 /* XXX shouldn't really try to take this lock, since
2184 this is called from the RT audio thread.
2187 Glib::RWLock::ReaderLock lm (redirect_lock);
2189 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2190 (*i)->deactivate ();
2196 Route::set_meter_point (MeterPoint p, void *src)
2198 if (_meter_point != p) {
2200 meter_change (src); /* EMIT SIGNAL */
2201 _session.set_dirty ();
2206 Route::update_total_latency ()
2210 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2211 if ((*i)->active ()) {
2212 _own_latency += (*i)->latency ();
2216 set_port_latency (_own_latency);
2218 /* this (virtual) function is used for pure Routes,
2219 not derived classes like AudioTrack. this means
2220 that the data processed here comes from an input
2221 port, not prerecorded material, and therefore we
2222 have to take into account any input latency.
2225 _own_latency += input_latency ();
2227 return _own_latency;
2231 Route::set_latency_delay (nframes_t longest_session_latency)
2233 _initial_delay = longest_session_latency - _own_latency;
2235 if (_session.transport_stopped()) {
2236 _roll_delay = _initial_delay;
2241 Route::automation_snapshot (nframes_t now)
2243 IO::automation_snapshot (now);
2245 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2246 (*i)->automation_snapshot (now);
2250 Route::ToggleControllable::ToggleControllable (std::string name, Route& s, ToggleType tp)
2251 : Controllable (name), route (s), type(tp)
2257 Route::ToggleControllable::set_value (float val)
2259 bool bval = ((val >= 0.5f) ? true: false);
2263 route.set_mute (bval, this);
2266 route.set_solo (bval, this);
2274 Route::ToggleControllable::get_value (void) const
2280 val = route.muted() ? 1.0f : 0.0f;
2283 val = route.soloed() ? 1.0f : 0.0f;
2293 Route::set_block_size (nframes_t nframes)
2295 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2296 (*i)->set_block_size (nframes);
2301 Route::redirect_active_proxy (Redirect* ignored, void* ignored_src)
2303 _session.update_latency_compensation (false, false);
2307 Route::protect_automation ()
2309 switch (gain_automation_state()) {
2311 set_gain_automation_state (Off);
2313 set_gain_automation_state (Play);
2319 switch (panner().automation_state ()) {
2321 panner().set_automation_state (Off);
2324 panner().set_automation_state (Play);
2330 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2331 boost::shared_ptr<PluginInsert> pi;
2332 if ((pi = boost::dynamic_pointer_cast<PluginInsert> (*i)) != 0) {
2333 pi->protect_automation ();
2339 Route::set_pending_declick (int declick)
2342 /* this call is not allowed to turn off a pending declick unless "force" is true */
2344 _pending_declick = declick;
2346 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
2348 _pending_declick = 0;