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>
27 #include <ardour/timestamps.h>
28 #include <ardour/audioengine.h>
29 #include <ardour/route.h>
30 #include <ardour/insert.h>
31 #include <ardour/send.h>
32 #include <ardour/session.h>
33 #include <ardour/utils.h>
34 #include <ardour/configuration.h>
35 #include <ardour/cycle_timer.h>
36 #include <ardour/route_group.h>
37 #include <ardour/port.h>
38 #include <ardour/ladspa_plugin.h>
39 #include <ardour/panner.h>
40 #include <ardour/dB.h>
41 #include <ardour/mix.h>
46 using namespace ARDOUR;
47 //using namespace sigc;
50 uint32_t Route::order_key_cnt = 0;
53 Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg)
54 : IO (sess, name, input_min, input_max, output_min, output_max),
56 _midi_solo_control (*this, MIDIToggleControl::SoloControl, _session.midi_port()),
57 _midi_mute_control (*this, MIDIToggleControl::MuteControl, _session.midi_port())
62 Route::Route (Session& sess, const XMLNode& node)
64 _midi_solo_control (*this, MIDIToggleControl::SoloControl, _session.midi_port()),
65 _midi_mute_control (*this, MIDIToggleControl::MuteControl, _session.midi_port())
74 redirect_max_outs = 0;
78 _phase_invert = false;
79 order_keys[N_("signal")] = order_key_cnt++;
82 _meter_point = MeterPostFader;
86 _have_internal_generator = false;
88 _pending_declick = true;
93 _mute_affects_pre_fader = Config->get_mute_affects_pre_fader();
94 _mute_affects_post_fader = Config->get_mute_affects_post_fader();
95 _mute_affects_control_outs = Config->get_mute_affects_control_outs();
96 _mute_affects_main_outs = Config->get_mute_affects_main_outs();
99 desired_solo_gain = 1.0;
101 desired_mute_gain = 1.0;
105 input_changed.connect (mem_fun (this, &Route::input_change_handler));
106 output_changed.connect (mem_fun (this, &Route::output_change_handler));
108 reset_midi_control (_session.midi_port(), _session.get_midi_control());
113 GoingAway (); /* EMIT SIGNAL */
114 clear_redirects (this);
117 delete _control_outs;
122 Route::order_key (string name) const
124 OrderKeys::const_iterator i;
126 if ((i = order_keys.find (name)) == order_keys.end()) {
134 Route::set_order_key (string name, long n)
136 order_keys[name] = n;
137 _session.set_dirty ();
141 Route::inc_gain (gain_t fraction, void *src)
143 IO::inc_gain (fraction, src);
147 Route::set_gain (gain_t val, void *src)
149 if (src != 0 && _mix_group && src != _mix_group && _mix_group->is_active()) {
151 if (_mix_group->is_relative()) {
154 gain_t usable_gain = gain();
155 if (usable_gain < 0.000001f) {
156 usable_gain=0.000001f;
160 if (delta < 0.000001f) {
164 delta -= usable_gain;
166 if (delta == 0.0f) return;
168 gain_t factor = delta / usable_gain;
171 factor = _mix_group->get_max_factor(factor);
172 if (factor == 0.0f) {
177 factor = _mix_group->get_min_factor(factor);
178 if (factor == 0.0f) {
184 _mix_group->apply (&Route::inc_gain, factor, _mix_group);
188 _mix_group->apply (&Route::set_gain, val, _mix_group);
198 IO::set_gain (val, src);
202 Route::process_output_buffers (vector<Sample*>& bufs, uint32_t nbufs,
203 jack_nframes_t start_frame, jack_nframes_t end_frame,
204 jack_nframes_t nframes, jack_nframes_t offset, bool with_redirects, int declick,
208 RedirectList::iterator i;
209 bool post_fader_work = false;
210 bool mute_declick_applied = false;
212 vector<Sample*>::iterator bufiter;
216 bool no_monitor = (Config->get_use_hardware_monitoring() || Config->get_no_sw_monitoring ());
217 gain_t* gab = _session.gain_automation_buffer();
219 declick = _pending_declick;
222 TentativeLockMonitor cm (control_outs_lock, __LINE__, __FILE__);
232 TentativeLockMonitor dm (declick_lock, __LINE__, __FILE__);
235 dmg = desired_mute_gain;
236 dsg = desired_solo_gain;
245 /* ----------------------------------------------------------------------------------------------------
246 GLOBAL DECLICK (for transport changes etc.)
247 -------------------------------------------------------------------------------------------------- */
250 apply_declick (bufs, nbufs, nframes, 0.0, 1.0, _phase_invert);
251 _pending_declick = 0;
252 } else if (declick < 0) {
253 apply_declick (bufs, nbufs, nframes, 1.0, 0.0, _phase_invert);
254 _pending_declick = 0;
257 /* no global declick */
259 if (solo_gain != dsg) {
260 apply_declick (bufs, nbufs, nframes, solo_gain, dsg, _phase_invert);
266 /* ----------------------------------------------------------------------------------------------------
267 INPUT METERING & MONITORING
268 -------------------------------------------------------------------------------------------------- */
270 if (meter && (_meter_point == MeterInput)) {
271 for (n = 0; n < nbufs; ++n) {
272 _peak_power[n] = Session::compute_peak (bufs[n], nframes, _peak_power[n]);
276 if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
277 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert);
279 mute_declick_applied = true;
282 if ((_meter_point == MeterInput) && co) {
284 solo_audible = dsg > 0;
285 mute_audible = dmg > 0;// || !_mute_affects_pre_fader;
287 if ( // muted by solo of another track
291 // muted by mute of this track
295 // rec-enabled but not s/w monitoring
297 // TODO: this is probably wrong
299 (no_monitor && record_enabled() && (!_session.get_auto_input() || _session.actively_recording()))
303 co->silence (nframes, offset);
307 co->deliver_output (bufs, nbufs, nframes, offset);
312 /* ----------------------------------------------------------------------------------------------------
314 -------------------------------------------------------------------------------------------------- */
316 if (with_redirects) {
317 TentativeLockMonitor rm (redirect_lock, __LINE__, __FILE__);
319 if (mute_gain > 0 || !_mute_affects_pre_fader) {
320 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
321 switch ((*i)->placement()) {
323 (*i)->run (bufs, nbufs, nframes, offset);
326 post_fader_work = true;
331 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
332 switch ((*i)->placement()) {
334 (*i)->silence (nframes, offset);
337 post_fader_work = true;
346 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
347 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert);
349 mute_declick_applied = true;
352 /* ----------------------------------------------------------------------------------------------------
353 PRE-FADER METERING & MONITORING
354 -------------------------------------------------------------------------------------------------- */
356 if (meter && (_meter_point == MeterPreFader)) {
357 for (n = 0; n < nbufs; ++n) {
358 _peak_power[n] = Session::compute_peak (bufs[n], nframes, _peak_power[n]);
363 if ((_meter_point == MeterPreFader) && co) {
365 solo_audible = dsg > 0;
366 mute_audible = dmg > 0 || !_mute_affects_pre_fader;
368 if ( // muted by solo of another track
372 // muted by mute of this track
376 // rec-enabled but not s/w monitoring
378 (no_monitor && record_enabled() && (!_session.get_auto_input() || _session.actively_recording()))
382 co->silence (nframes, offset);
386 co->deliver_output (bufs, nbufs, nframes, offset);
391 /* ----------------------------------------------------------------------------------------------------
393 -------------------------------------------------------------------------------------------------- */
395 /* if not recording or recording and requiring any monitor signal, then apply gain */
397 if ( // not recording
399 !(record_enabled() && _session.actively_recording()) ||
403 // h/w monitoring not in use
405 (!Config->get_use_hardware_monitoring() &&
407 // AND software monitoring required
409 !Config->get_no_sw_monitoring())) {
411 if (apply_gain_automation) {
414 for (n = 0; n < nbufs; ++n) {
415 Sample *sp = bufs[n];
417 for (jack_nframes_t nx = 0; nx < nframes; ++nx) {
422 for (n = 0; n < nbufs; ++n) {
423 Sample *sp = bufs[n];
425 for (jack_nframes_t nx = 0; nx < nframes; ++nx) {
431 if (apply_gain_automation) {
432 _effective_gain = gab[nframes-1];
437 /* manual (scalar) gain */
441 apply_declick (bufs, nbufs, nframes, _gain, dg, _phase_invert);
444 } else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
446 /* no need to interpolate current gain value,
447 but its non-unity, so apply it. if the gain
448 is zero, do nothing because we'll ship silence
460 for (n = 0; n < nbufs; ++n) {
461 Sample *sp = bufs[n];
462 apply_gain_to_buffer(sp,nframes,this_gain);
465 } else if (_gain == 0) {
466 for (n = 0; n < nbufs; ++n) {
467 memset (bufs[n], 0, sizeof (Sample) * nframes);
474 /* actively recording, no monitoring required; leave buffers as-is to save CPU cycles */
478 /* ----------------------------------------------------------------------------------------------------
480 -------------------------------------------------------------------------------------------------- */
482 /* note that post_fader_work cannot be true unless with_redirects was also true, so don't test both */
484 if (post_fader_work) {
486 TentativeLockMonitor rm (redirect_lock, __LINE__, __FILE__);
488 if (mute_gain > 0 || !_mute_affects_post_fader) {
489 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
490 switch ((*i)->placement()) {
494 (*i)->run (bufs, nbufs, nframes, offset);
499 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
500 switch ((*i)->placement()) {
504 (*i)->silence (nframes, offset);
512 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
513 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert);
515 mute_declick_applied = true;
518 /* ----------------------------------------------------------------------------------------------------
520 -------------------------------------------------------------------------------------------------- */
522 if ((_meter_point == MeterPostFader) && co) {
524 solo_audible = solo_gain > 0;
525 mute_audible = dmg > 0 || !_mute_affects_control_outs;
527 if ( // silent anyway
529 (_gain == 0 && !apply_gain_automation) ||
531 // muted by solo of another track
535 // muted by mute of this track
539 // recording but not s/w monitoring
541 (no_monitor && record_enabled() && (!_session.get_auto_input() || _session.actively_recording()))
545 co->silence (nframes, offset);
549 co->deliver_output_no_pan (bufs, nbufs, nframes, offset);
553 /* ----------------------------------------------------------------------
555 ----------------------------------------------------------------------*/
557 if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
558 apply_declick (bufs, nbufs, nframes, mute_gain, dmg, _phase_invert);
560 mute_declick_applied = true;
563 /* ----------------------------------------------------------------------------------------------------
565 -------------------------------------------------------------------------------------------------- */
567 solo_audible = dsg > 0;
568 mute_audible = dmg > 0 || !_mute_affects_main_outs;
570 if (n_outputs() == 0) {
574 } else if (no_monitor && record_enabled() && (!_session.get_auto_input() || _session.actively_recording())) {
576 IO::silence (nframes, offset);
580 if ( // silent anyway
582 (_gain == 0 && !apply_gain_automation) ||
584 // muted by solo of another track, but not using control outs for solo
586 (!solo_audible && (_session.solo_model() != Session::SoloBus)) ||
588 // muted by mute of this track
594 /* don't use Route::silence() here, because that causes
595 all outputs (sends, port inserts, etc. to be silent).
598 if (_meter_point == MeterPostFader) {
599 reset_peak_meters ();
602 IO::silence (nframes, offset);
606 if (_session.transport_speed() > 1.5f || _session.transport_speed() < -1.5f) {
607 pan (bufs, nbufs, nframes, offset, speed_quietning);
609 if (!_panner->empty() &&
610 (_panner->automation_state() & Play ||
611 ((_panner->automation_state() & Touch) && !_panner->touching()))) {
612 pan_automated (bufs, nbufs, start_frame, end_frame, nframes, offset);
614 pan (bufs, nbufs, nframes, offset, 1.0);
621 /* ----------------------------------------------------------------------------------------------------
623 -------------------------------------------------------------------------------------------------- */
625 if (meter && (_meter_point == MeterPostFader)) {
626 // cerr << "meter post" << endl;
628 if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
629 uint32_t no = n_outputs();
630 for (n = 0; n < no; ++n) {
634 uint32_t no = n_outputs();
635 for (n = 0; n < no; ++n) {
636 _peak_power[n] = Session::compute_peak (output(n)->get_buffer (nframes) + offset, nframes, _peak_power[n]);
643 Route::n_process_buffers ()
645 return max (n_inputs(), redirect_max_outs);
650 Route::passthru (jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t nframes, jack_nframes_t offset, int declick, bool meter_first)
652 vector<Sample*>& bufs = _session.get_passthru_buffers();
653 uint32_t limit = n_process_buffers ();
657 collect_input (bufs, limit, nframes, offset);
659 #define meter_stream meter_first
662 for (uint32_t n = 0; n < limit; ++n) {
663 _peak_power[n] = Session::compute_peak (bufs[n], nframes, _peak_power[n]);
665 meter_stream = false;
670 process_output_buffers (bufs, limit, start_frame, end_frame, nframes, offset, true, declick, meter_stream);
676 Route::set_phase_invert (bool yn, void *src)
678 if (_phase_invert != yn) {
681 // phase_invert_changed (src); /* EMIT SIGNAL */
685 Route::set_solo (bool yn, void *src)
691 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
692 _mix_group->apply (&Route::set_solo, yn, _mix_group);
698 solo_changed (src); /* EMIT SIGNAL */
700 if (_session.get_midi_feedback()) {
701 _midi_solo_control.send_feedback (_soloed);
707 Route::set_solo_mute (bool yn)
709 LockMonitor lm (declick_lock, __LINE__, __FILE__);
711 /* Called by Session in response to another Route being soloed.
714 desired_solo_gain = (yn?0.0:1.0);
718 Route::set_solo_safe (bool yn, void *src)
720 if (_solo_safe != yn) {
722 solo_safe_changed (src); /* EMIT SIGNAL */
727 Route::set_mute (bool yn, void *src)
730 if (_mix_group && src != _mix_group && _mix_group->is_active()) {
731 _mix_group->apply (&Route::set_mute, yn, _mix_group);
737 mute_changed (src); /* EMIT SIGNAL */
739 if (_session.get_midi_feedback()) {
740 _midi_mute_control.send_feedback (_muted);
743 LockMonitor lm (declick_lock, __LINE__, __FILE__);
744 desired_mute_gain = (yn?0.0f:1.0f);
749 Route::add_redirect (Redirect *redirect, void *src, uint32_t* err_streams)
751 uint32_t old_rmo = redirect_max_outs;
753 if (!_session.engine().connected()) {
758 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
763 if ((pi = dynamic_cast<PluginInsert*>(redirect)) != 0) {
766 if (pi->input_streams() == 0) {
767 /* instrument plugin */
768 _have_internal_generator = true;
771 } else if ((porti = dynamic_cast<PortInsert*>(redirect)) != 0) {
773 /* force new port inserts to start out with an i/o configuration
774 that matches this route's i/o configuration.
776 the "inputs" for the port are supposed to match the output
779 the "outputs" of the route should match the inputs of this
780 route. XXX shouldn't they match the number of active signal
781 streams at the point of insertion?
785 porti->ensure_io (n_outputs (), n_inputs(), false, this);
788 _redirects.push_back (redirect);
790 if (_reset_plugin_counts (err_streams)) {
791 _redirects.pop_back ();
792 _reset_plugin_counts (0); // it worked before we tried to add it ...
796 redirect->activate ();
797 redirect->active_changed.connect (mem_fun (*this, &Route::redirect_active_proxy));
800 if (redirect_max_outs != old_rmo || old_rmo == 0) {
805 redirects_changed (src); /* EMIT SIGNAL */
810 Route::add_redirects (const RedirectList& others, void *src, uint32_t* err_streams)
812 uint32_t old_rmo = redirect_max_outs;
814 if (!_session.engine().connected()) {
819 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
821 RedirectList::iterator existing_end = _redirects.end();
824 for (RedirectList::const_iterator i = others.begin(); i != others.end(); ++i) {
828 if ((pi = dynamic_cast<PluginInsert*>(*i)) != 0) {
832 _redirects.push_back (*i);
834 if (_reset_plugin_counts (err_streams)) {
836 _redirects.erase (existing_end, _redirects.end());
837 _reset_plugin_counts (0); // it worked before we tried to add it ...
842 (*i)->active_changed.connect (mem_fun (*this, &Route::redirect_active_proxy));
846 if (redirect_max_outs != old_rmo || old_rmo == 0) {
850 redirects_changed (src); /* EMIT SIGNAL */
855 Route::clear_redirects (void *src)
857 uint32_t old_rmo = redirect_max_outs;
859 if (!_session.engine().connected()) {
864 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
866 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
873 if (redirect_max_outs != old_rmo) {
877 redirect_max_outs = 0;
878 _have_internal_generator = false;
879 redirects_changed (src); /* EMIT SIGNAL */
883 Route::remove_redirect (Redirect *redirect, void *src, uint32_t* err_streams)
885 uint32_t old_rmo = redirect_max_outs;
887 if (!_session.engine().connected()) {
891 redirect_max_outs = 0;
894 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
895 RedirectList::iterator i;
896 bool removed = false;
898 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
899 if (*i == redirect) {
901 RedirectList::iterator tmp;
903 /* move along, see failure case for reset_plugin_counts()
904 where we may need to reinsert the redirect.
910 /* stop redirects that send signals to JACK ports
911 from causing noise as a result of no longer being
916 PortInsert* port_insert;
918 if ((send = dynamic_cast<Send*> (*i)) != 0) {
919 send->disconnect_inputs (this);
920 send->disconnect_outputs (this);
921 } else if ((port_insert = dynamic_cast<PortInsert*> (*i)) != 0) {
922 port_insert->disconnect_inputs (this);
923 port_insert->disconnect_outputs (this);
926 _redirects.erase (i);
939 if (_reset_plugin_counts (err_streams)) {
940 /* get back to where we where */
941 _redirects.insert (i, redirect);
942 /* we know this will work, because it worked before :) */
943 _reset_plugin_counts (0);
949 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
952 if ((pi = dynamic_cast<PluginInsert*>(*i)) != 0) {
953 if (pi->is_generator()) {
959 _have_internal_generator = foo;
962 if (old_rmo != redirect_max_outs) {
966 redirects_changed (src); /* EMIT SIGNAL */
971 Route::reset_plugin_counts (uint32_t* lpc)
973 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
974 return _reset_plugin_counts (lpc);
979 Route::_reset_plugin_counts (uint32_t* err_streams)
981 RedirectList::iterator r;
984 map<Placement,list<InsertCount> > insert_map;
985 jack_nframes_t initial_streams;
987 redirect_max_outs = 0;
991 /* divide inserts up by placement so we get the signal flow
992 properly modelled. we need to do this because the _redirects
993 list is not sorted by placement, and because other reasons may
994 exist now or in the future for this separate treatment.
997 for (r = _redirects.begin(); r != _redirects.end(); ++r) {
1001 /* do this here in case we bomb out before we get to the end of
1005 redirect_max_outs = max ((*r)->output_streams (), redirect_max_outs);
1007 if ((insert = dynamic_cast<Insert*>(*r)) != 0) {
1009 insert_map[insert->placement()].push_back (InsertCount (*insert));
1011 /* reset plugin counts back to one for now so
1012 that we have a predictable, controlled
1013 state to try to configure.
1018 if ((pi = dynamic_cast<PluginInsert*>(insert)) != 0) {
1022 } else if (dynamic_cast<Send*> (*r) != 0) {
1035 /* Now process each placement in order, checking to see if we
1036 can really do what has been requested.
1041 if (check_some_plugin_counts (insert_map[PreFader], n_inputs (), err_streams)) {
1045 /* figure out the streams that will feed into PreFader */
1047 if (!insert_map[PreFader].empty()) {
1048 InsertCount& ic (insert_map[PreFader].back());
1049 initial_streams = ic.insert.compute_output_streams (ic.cnt);
1051 initial_streams = n_inputs ();
1056 if (check_some_plugin_counts (insert_map[PostFader], initial_streams, err_streams)) {
1060 /* OK, everything can be set up correctly, so lets do it */
1062 apply_some_plugin_counts (insert_map[PreFader]);
1063 apply_some_plugin_counts (insert_map[PostFader]);
1065 /* recompute max outs of any redirect */
1069 redirect_max_outs = 0;
1070 RedirectList::iterator prev = _redirects.end();
1072 for (r = _redirects.begin(); r != _redirects.end(); prev = r, ++r) {
1075 if ((s = dynamic_cast<Send*> (*r)) != 0) {
1076 if (r == _redirects.begin()) {
1077 s->expect_inputs (n_inputs());
1079 s->expect_inputs ((*prev)->output_streams());
1083 redirect_max_outs = max ((*r)->output_streams (), redirect_max_outs);
1092 Route::apply_some_plugin_counts (list<InsertCount>& iclist)
1094 list<InsertCount>::iterator i;
1096 for (i = iclist.begin(); i != iclist.end(); ++i) {
1098 if ((*i).insert.configure_io ((*i).cnt, (*i).in, (*i).out)) {
1101 /* make sure that however many we have, they are all active */
1102 (*i).insert.activate ();
1109 Route::check_some_plugin_counts (list<InsertCount>& iclist, int32_t required_inputs, uint32_t* err_streams)
1111 list<InsertCount>::iterator i;
1113 for (i = iclist.begin(); i != iclist.end(); ++i) {
1115 if (((*i).cnt = (*i).insert.can_support_input_configuration (required_inputs)) < 0) {
1117 *err_streams = required_inputs;
1122 (*i).in = required_inputs;
1123 (*i).out = (*i).insert.compute_output_streams ((*i).cnt);
1125 required_inputs = (*i).out;
1132 Route::copy_redirects (const Route& other, Placement placement, uint32_t* err_streams)
1134 uint32_t old_rmo = redirect_max_outs;
1140 RedirectList to_be_deleted;
1143 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
1144 RedirectList::iterator tmp;
1145 RedirectList the_copy;
1147 the_copy = _redirects;
1149 /* remove all relevant redirects */
1151 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ) {
1155 if ((*i)->placement() == placement) {
1156 to_be_deleted.push_back (*i);
1157 _redirects.erase (i);
1163 /* now copy the relevant ones from "other" */
1165 for (RedirectList::const_iterator i = other._redirects.begin(); i != other._redirects.end(); ++i) {
1166 if ((*i)->placement() == placement) {
1167 _redirects.push_back (Redirect::clone (**i));
1171 /* reset plugin stream handling */
1173 if (_reset_plugin_counts (err_streams)) {
1175 /* FAILED COPY ATTEMPT: we have to restore order */
1177 /* delete all cloned redirects */
1179 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ) {
1184 if ((*i)->placement() == placement) {
1186 _redirects.erase (i);
1192 /* restore the natural order */
1194 _redirects = the_copy;
1195 redirect_max_outs = old_rmo;
1197 /* we failed, even though things are OK again */
1203 /* SUCCESSFUL COPY ATTEMPT: delete the redirects we removed pre-copy */
1205 for (RedirectList::iterator i = to_be_deleted.begin(); i != to_be_deleted.end(); ++i) {
1211 if (redirect_max_outs != old_rmo || old_rmo == 0) {
1215 redirects_changed (this); /* EMIT SIGNAL */
1220 Route::all_redirects_flip ()
1222 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
1224 if (_redirects.empty()) {
1228 bool first_is_on = _redirects.front()->active();
1230 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1231 (*i)->set_active (!first_is_on, this);
1236 Route::all_redirects_active (bool state)
1238 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
1240 if (_redirects.empty()) {
1244 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1245 (*i)->set_active (state, this);
1249 struct RedirectSorter {
1250 bool operator() (const Redirect *a, const Redirect *b) {
1251 return a->sort_key() < b->sort_key();
1256 Route::sort_redirects (uint32_t* err_streams)
1259 RedirectSorter comparator;
1260 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
1261 uint32_t old_rmo = redirect_max_outs;
1263 /* the sweet power of C++ ... */
1265 RedirectList as_it_was_before = _redirects;
1267 _redirects.sort (comparator);
1269 if (_reset_plugin_counts (err_streams)) {
1270 _redirects = as_it_was_before;
1271 redirect_max_outs = old_rmo;
1277 redirects_changed (this); /* EMIT SIGNAL */
1289 Route::get_template()
1291 return state(false);
1295 Route::state(bool full_state)
1297 XMLNode *node = new XMLNode("Route");
1299 RedirectList:: iterator i;
1303 snprintf (buf, sizeof (buf), "0x%x", _flags);
1304 node->add_property("flags", buf);
1306 node->add_property("active", _active?"yes":"no");
1307 node->add_property("muted", _muted?"yes":"no");
1308 node->add_property("soloed", _soloed?"yes":"no");
1309 node->add_property("phase-invert", _phase_invert?"yes":"no");
1310 node->add_property("mute-affects-pre-fader", _mute_affects_pre_fader?"yes":"no");
1311 node->add_property("mute-affects-post-fader", _mute_affects_post_fader?"yes":"no");
1312 node->add_property("mute-affects-control-outs", _mute_affects_control_outs?"yes":"no");
1313 node->add_property("mute-affects-main-outs", _mute_affects_main_outs?"yes":"no");
1316 node->add_property("edit-group", _edit_group->name());
1319 node->add_property("mix-group", _mix_group->name());
1324 MIDI::channel_t chn;
1326 MIDI::byte additional;
1327 XMLNode* midi_node = 0;
1330 midi_node = node->add_child ("MIDI");
1332 if (_midi_mute_control.get_control_info (chn, ev, additional)) {
1333 child = midi_node->add_child ("mute");
1334 set_midi_node_info (child, ev, chn, additional);
1336 if (_midi_solo_control.get_control_info (chn, ev, additional)) {
1337 child = midi_node->add_child ("solo");
1338 set_midi_node_info (child, ev, chn, additional);
1342 string order_string;
1343 OrderKeys::iterator x = order_keys.begin();
1345 while (x != order_keys.end()) {
1346 order_string += (*x).first;
1347 order_string += '=';
1348 snprintf (buf, sizeof(buf), "%ld", (*x).second);
1349 order_string += buf;
1353 if (x == order_keys.end()) {
1357 order_string += ':';
1359 node->add_property ("order-keys", order_string);
1361 node->add_child_nocopy (IO::state (full_state));
1363 if (_control_outs) {
1364 XMLNode* cnode = new XMLNode (X_("ControlOuts"));
1365 cnode->add_child_nocopy (_control_outs->state (full_state));
1366 node->add_child_nocopy (*cnode);
1369 if (_comment.length()) {
1370 XMLNode *cmt = node->add_child ("Comment");
1371 cmt->add_content (_comment);
1377 path = _session.snap_name();
1379 path += legalize_for_path (_name);
1380 path += ".automation";
1382 /* XXX we didn't ask for a state save, we asked for the current state.
1386 if (save_automation (path)) {
1387 error << _("Could not get state of route. Problem with save_automation") << endmsg;
1390 aevents = node->add_child ("Automation");
1391 aevents->add_property ("path", path);
1394 for (i = _redirects.begin(); i != _redirects.end(); ++i) {
1395 node->add_child_nocopy((*i)->state (full_state));
1399 node->add_child_copy (*_extra_xml);
1406 Route::set_deferred_state ()
1409 XMLNodeConstIterator niter;
1411 if (!deferred_state) {
1415 nlist = deferred_state->children();
1417 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1418 add_redirect_from_xml (**niter);
1421 delete deferred_state;
1426 Route::add_redirect_from_xml (const XMLNode& node)
1428 const XMLProperty *prop;
1432 if (node.name() == "Send") {
1435 send = new Send (_session, node);
1438 catch (failed_constructor &err) {
1439 error << _("Send construction failed") << endmsg;
1443 add_redirect (send, this);
1445 } else if (node.name() == "Insert") {
1448 if ((prop = node.property ("type")) != 0) {
1450 if (prop->value() == "ladspa" || prop->value() == "Ladspa" || prop->value() == "vst") {
1452 insert = new PluginInsert(_session, node);
1454 } else if (prop->value() == "port") {
1457 insert = new PortInsert (_session, node);
1461 error << string_compose(_("unknown Insert type \"%1\"; ignored"), prop->value()) << endmsg;
1464 add_redirect (insert, this);
1467 error << _("Insert XML node has no type property") << endmsg;
1471 catch (failed_constructor &err) {
1472 warning << _("insert could not be created. Ignored.") << endmsg;
1479 Route::set_state (const XMLNode& node)
1482 XMLNodeConstIterator niter;
1484 XMLPropertyList plist;
1485 const XMLProperty *prop;
1486 XMLNodeList midi_kids;
1489 if (node.name() != "Route"){
1490 error << string_compose(_("Bad node sent to Route::set_state() [%1]"), node.name()) << endmsg;
1494 if ((prop = node.property ("flags")) != 0) {
1496 sscanf (prop->value().c_str(), "0x%x", &x);
1502 if ((prop = node.property ("phase-invert")) != 0) {
1503 set_phase_invert(prop->value()=="yes"?true:false, this);
1506 if ((prop = node.property ("active")) != 0) {
1507 set_active (prop->value() == "yes");
1510 if ((prop = node.property ("muted")) != 0) {
1511 bool yn = prop->value()=="yes"?true:false;
1513 /* force reset of mute status */
1517 mute_gain = desired_mute_gain;
1520 if ((prop = node.property ("soloed")) != 0) {
1521 bool yn = prop->value()=="yes"?true:false;
1523 /* force reset of solo status */
1526 set_solo (yn, this);
1527 solo_gain = desired_solo_gain;
1530 if ((prop = node.property ("mute-affects-pre-fader")) != 0) {
1531 _mute_affects_pre_fader = (prop->value()=="yes")?true:false;
1534 if ((prop = node.property ("mute-affects-post-fader")) != 0) {
1535 _mute_affects_post_fader = (prop->value()=="yes")?true:false;
1538 if ((prop = node.property ("mute-affects-control-outs")) != 0) {
1539 _mute_affects_control_outs = (prop->value()=="yes")?true:false;
1542 if ((prop = node.property ("mute-affects-main-outs")) != 0) {
1543 _mute_affects_main_outs = (prop->value()=="yes")?true:false;
1546 if ((prop = node.property ("edit-group")) != 0) {
1547 RouteGroup* edit_group = _session.edit_group_by_name(prop->value());
1548 if(edit_group == 0) {
1549 error << string_compose(_("Route %1: unknown edit group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
1551 set_edit_group(edit_group, this);
1555 if ((prop = node.property ("order-keys")) != 0) {
1559 string::size_type colon, equal;
1560 string remaining = prop->value();
1562 while (remaining.length()) {
1564 if ((equal = remaining.find_first_of ('=')) == string::npos || equal == remaining.length()) {
1565 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1568 if (sscanf (remaining.substr (equal+1).c_str(), "%ld", &n) != 1) {
1569 error << string_compose (_("badly formed order key string in state file! [%1] ... ignored."), remaining)
1572 set_order_key (remaining.substr (0, equal), n);
1576 colon = remaining.find_first_of (':');
1578 if (colon != string::npos) {
1579 remaining = remaining.substr (colon+1);
1586 nlist = node.children();
1588 if (deferred_state) {
1589 delete deferred_state;
1592 deferred_state = new XMLNode("deferred state");
1594 /* set parent class properties before anything else */
1596 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1600 if (child->name() == IO::state_node_name) {
1602 IO::set_state (*child);
1607 for (niter = nlist.begin(); niter != nlist.end(); ++niter){
1611 if (child->name() == "Send") {
1614 if (!IO::ports_legal) {
1616 deferred_state->add_child_copy (*child);
1619 add_redirect_from_xml (*child);
1622 } else if (child->name() == "Insert") {
1624 if (!IO::ports_legal) {
1626 deferred_state->add_child_copy (*child);
1630 add_redirect_from_xml (*child);
1633 } else if (child->name() == "Automation") {
1635 XMLPropertyList plist;
1636 XMLPropertyConstIterator piter;
1639 plist = child->properties();
1640 for (piter = plist.begin(); piter != plist.end(); ++piter) {
1642 if (prop->name() == "path") {
1643 load_automation (prop->value());
1647 } else if (child->name() == "ControlOuts") {
1649 string coutname = _name;
1650 coutname += _("[control]");
1652 _control_outs = new IO (_session, coutname);
1653 _control_outs->set_state (**(child->children().begin()));
1655 } else if (child->name() == "Comment") {
1657 /* XXX this is a terrible API design in libxml++ */
1659 XMLNode *cmt = *(child->children().begin());
1660 _comment = cmt->content();
1662 } else if (child->name() == "extra") {
1663 _extra_xml = new XMLNode (*child);
1667 if ((prop = node.property ("mix-group")) != 0) {
1668 RouteGroup* mix_group = _session.mix_group_by_name(prop->value());
1669 if (mix_group == 0) {
1670 error << string_compose(_("Route %1: unknown mix group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
1672 set_mix_group(mix_group, this);
1676 midi_kids = node.children ("MIDI");
1678 for (niter = midi_kids.begin(); niter != midi_kids.end(); ++niter) {
1681 XMLNodeConstIterator miter;
1684 kids = (*niter)->children ();
1686 for (miter = kids.begin(); miter != kids.end(); ++miter) {
1690 MIDI::eventType ev = MIDI::on; /* initialize to keep gcc happy */
1691 MIDI::byte additional = 0; /* ditto */
1692 MIDI::channel_t chn = 0; /* ditto */
1694 if (child->name() == "mute") {
1696 if (get_midi_node_info (child, ev, chn, additional)) {
1697 _midi_mute_control.set_control_type (chn, ev, additional);
1699 error << string_compose(_("MIDI mute control specification for %1 is incomplete, so it has been ignored"), _name) << endmsg;
1702 else if (child->name() == "solo") {
1704 if (get_midi_node_info (child, ev, chn, additional)) {
1705 _midi_solo_control.set_control_type (chn, ev, additional);
1707 error << string_compose(_("MIDI mute control specification for %1 is incomplete, so it has been ignored"), _name) << endmsg;
1719 Route::curve_reallocate ()
1721 // _gain_automation_curve.finish_resize ();
1722 // _pan_automation_curve.finish_resize ();
1726 Route::silence (jack_nframes_t nframes, jack_nframes_t offset)
1730 // reset_peak_meters ();
1732 IO::silence (nframes, offset);
1734 if (_control_outs) {
1735 _control_outs->silence (nframes, offset);
1739 TentativeLockMonitor lm (redirect_lock, __LINE__, __FILE__);
1742 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1743 (*i)->silence (nframes, offset);
1746 if (nframes == _session.get_block_size() && offset == 0) {
1756 Route::set_control_outs (const vector<string>& ports)
1758 LockMonitor lm (control_outs_lock, __LINE__, __FILE__);
1759 vector<string>::const_iterator i;
1761 if (_control_outs) {
1762 delete _control_outs;
1766 if (ports.empty()) {
1770 string coutname = _name;
1771 coutname += _("[control]");
1773 _control_outs = new IO (_session, coutname);
1775 /* our control outs need as many outputs as we
1776 have outputs. we track the changes in ::output_change_handler().
1779 _control_outs->ensure_io (0, n_outputs(), true, this);
1785 Route::set_edit_group (RouteGroup *eg, void *src)
1789 _edit_group->remove (this);
1792 if ((_edit_group = eg)) {
1793 _edit_group->add (this);
1796 _session.set_dirty ();
1798 edit_group_changed (src); /* EMIT SIGNAL */
1802 Route::set_mix_group (RouteGroup *mg, void *src)
1806 _mix_group->remove (this);
1809 if ((_mix_group = mg)) {
1810 _mix_group->add (this);
1813 _session.set_dirty ();
1815 mix_group_changed (src); /* EMIT SIGNAL */
1819 Route::set_comment (string cmt, void *src)
1822 comment_changed (src);
1823 _session.set_dirty ();
1827 Route::feeds (Route *o)
1833 uint32_t no = self.n_outputs();
1834 uint32_t ni = other.n_inputs ();
1836 for (i = 0; i < no; ++i) {
1837 for (j = 0; j < ni; ++j) {
1838 if (self.output(i)->connected_to (other.input(j)->name())) {
1844 /* check Redirects which may also interconnect Routes */
1846 for (RedirectList::iterator r = _redirects.begin(); r != _redirects.end(); r++) {
1848 no = (*r)->n_outputs();
1850 for (i = 0; i < no; ++i) {
1851 for (j = 0; j < ni; ++j) {
1852 if ((*r)->output(i)->connected_to (other.input (j)->name())) {
1859 /* check for control room outputs which may also interconnect Routes */
1861 if (_control_outs) {
1863 no = _control_outs->n_outputs();
1865 for (i = 0; i < no; ++i) {
1866 for (j = 0; j < ni; ++j) {
1867 if (_control_outs->output(i)->connected_to (other.input (j)->name())) {
1878 Route::set_mute_config (mute_type t, bool onoff, void *src)
1882 _mute_affects_pre_fader = onoff;
1883 pre_fader_changed(src); /* EMIT SIGNAL */
1887 _mute_affects_post_fader = onoff;
1888 post_fader_changed(src); /* EMIT SIGNAL */
1892 _mute_affects_control_outs = onoff;
1893 control_outs_changed(src); /* EMIT SIGNAL */
1897 _mute_affects_main_outs = onoff;
1898 main_outs_changed(src); /* EMIT SIGNAL */
1904 Route::get_mute_config (mute_type t)
1910 onoff = _mute_affects_pre_fader;
1913 onoff = _mute_affects_post_fader;
1916 onoff = _mute_affects_control_outs;
1919 onoff = _mute_affects_main_outs;
1927 Route::set_active (bool yn)
1930 active_changed(); /* EMIT SIGNAL */
1934 Route::transport_stopped (bool abort_ignored, bool did_locate, bool can_flush_redirects)
1936 jack_nframes_t now = _session.transport_frame();
1939 automation_snapshot (now);
1943 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
1944 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
1946 if (Config->get_plugins_stop_with_transport() && can_flush_redirects) {
1947 (*i)->deactivate ();
1951 (*i)->transport_stopped (now);
1955 IO::transport_stopped (now);
1957 _roll_delay = _initial_delay;
1961 Route::get_memento() const
1963 void (Route::*pmf)(state_id_t) = &Route::set_state;
1964 return sigc::bind (mem_fun (*(const_cast<Route *>(this)), pmf), _current_state_id);
1968 Route::set_state (state_id_t id)
1974 Route::input_change_handler (IOChange change, void *ignored)
1976 if (change & ConfigurationChanged) {
1977 reset_plugin_counts (0);
1982 Route::output_change_handler (IOChange change, void *ignored)
1984 if (change & ConfigurationChanged) {
1985 if (_control_outs) {
1986 _control_outs->ensure_io (0, n_outputs(), true, this);
1989 reset_plugin_counts (0);
1994 Route::pans_required () const
1996 if (n_outputs() < 2) {
2000 return max (n_inputs (), redirect_max_outs);
2004 Route::no_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t offset,
2005 bool session_state_changing, bool can_record, bool rec_monitors_input)
2007 if (n_outputs() == 0) {
2011 if (session_state_changing || !_active) {
2012 silence (nframes, offset);
2016 apply_gain_automation = false;
2019 passthru (start_frame, end_frame, nframes, offset, 0, false);
2021 silence (nframes, offset);
2028 Route::check_initial_delay (jack_nframes_t nframes, jack_nframes_t& offset, jack_nframes_t& transport_frame)
2030 if (_roll_delay > nframes) {
2032 _roll_delay -= nframes;
2033 silence (nframes, offset);
2034 /* transport frame is not legal for caller to use */
2037 } else if (_roll_delay > 0) {
2039 nframes -= _roll_delay;
2041 silence (_roll_delay, offset);
2043 offset += _roll_delay;
2044 transport_frame += _roll_delay;
2053 Route::roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t offset, int declick,
2054 bool can_record, bool rec_monitors_input)
2056 automation_snapshot (_session.transport_frame());
2058 if ((n_outputs() == 0 && _redirects.empty()) || n_inputs() == 0 || !_active) {
2059 silence (nframes, offset);
2063 jack_nframes_t unused = 0;
2065 if ((nframes = check_initial_delay (nframes, offset, unused)) == 0) {
2070 apply_gain_automation = false;
2073 TentativeLockMonitor am (automation_lock, __LINE__, __FILE__);
2077 jack_nframes_t start_frame = end_frame - nframes;
2079 if (gain_automation_playback()) {
2080 apply_gain_automation = _gain_automation_curve.rt_safe_get_vector (start_frame, end_frame, _session.gain_automation_buffer(), nframes);
2085 passthru (start_frame, end_frame, nframes, offset, declick, false);
2091 Route::silent_roll (jack_nframes_t nframes, jack_nframes_t start_frame, jack_nframes_t end_frame, jack_nframes_t offset,
2092 bool can_record, bool rec_monitors_input)
2094 silence (nframes, offset);
2099 Route::toggle_monitor_input ()
2101 for (vector<Port*>::iterator i = _inputs.begin(); i != _inputs.end(); ++i) {
2102 (*i)->request_monitor_input(!(*i)->monitoring_input());
2107 Route::has_external_redirects () const
2109 const PortInsert* pi;
2111 for (RedirectList::const_iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2112 if ((pi = dynamic_cast<const PortInsert*>(*i)) != 0) {
2114 uint32_t no = pi->n_outputs();
2116 for (uint32_t n = 0; n < no; ++n) {
2118 string port_name = pi->output(n)->name();
2119 string client_name = port_name.substr (0, port_name.find(':'));
2121 /* only say "yes" if the redirect is actually in use */
2123 if (client_name != "ardour" && pi->active()) {
2134 Route::reset_midi_control (MIDI::Port* port, bool on)
2136 MIDI::channel_t chn;
2140 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2141 (*i)->reset_midi_control (port, on);
2144 IO::reset_midi_control (port, on);
2146 _midi_solo_control.get_control_info (chn, ev, extra);
2150 _midi_solo_control.midi_rebind (port, chn);
2152 _midi_mute_control.get_control_info (chn, ev, extra);
2156 _midi_mute_control.midi_rebind (port, chn);
2160 Route::send_all_midi_feedback ()
2162 if (_session.get_midi_feedback()) {
2165 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
2166 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2167 (*i)->send_all_midi_feedback ();
2171 IO::send_all_midi_feedback();
2173 _midi_solo_control.send_feedback (_soloed);
2174 _midi_mute_control.send_feedback (_muted);
2179 Route::write_midi_feedback (MIDI::byte* buf, int32_t& bufsize)
2181 buf = _midi_solo_control.write_feedback (buf, bufsize, _soloed);
2182 buf = _midi_mute_control.write_feedback (buf, bufsize, _muted);
2185 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
2186 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2187 buf = (*i)->write_midi_feedback (buf, bufsize);
2191 return IO::write_midi_feedback (buf, bufsize);
2195 Route::flush_redirects ()
2197 /* XXX shouldn't really try to take this lock, since
2198 this is called from the RT audio thread.
2201 LockMonitor lm (redirect_lock, __LINE__, __FILE__);
2203 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2204 (*i)->deactivate ();
2210 Route::set_meter_point (MeterPoint p, void *src)
2212 if (_meter_point != p) {
2214 meter_change (src); /* EMIT SIGNAL */
2215 _session.set_dirty ();
2220 Route::update_total_latency ()
2224 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2225 if ((*i)->active ()) {
2226 _own_latency += (*i)->latency ();
2230 set_port_latency (_own_latency);
2232 /* this (virtual) function is used for pure Routes,
2233 not derived classes like AudioTrack. this means
2234 that the data processed here comes from an input
2235 port, not prerecorded material, and therefore we
2236 have to take into account any input latency.
2239 _own_latency += input_latency ();
2241 return _own_latency;
2245 Route::set_latency_delay (jack_nframes_t longest_session_latency)
2247 _initial_delay = longest_session_latency - _own_latency;
2249 if (_session.transport_stopped()) {
2250 _roll_delay = _initial_delay;
2255 Route::automation_snapshot (jack_nframes_t now)
2257 IO::automation_snapshot (now);
2259 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2260 (*i)->automation_snapshot (now);
2264 Route::MIDIToggleControl::MIDIToggleControl (Route& s, ToggleType tp, MIDI::Port* port)
2265 : MIDI::Controllable (port, true), route (s), type(tp), setting(false)
2267 last_written = false; /* XXX need a good out-of-bound-value */
2271 Route::MIDIToggleControl::set_value (float val)
2274 MIDI::channel_t chn;
2275 MIDI::byte additional;
2277 get_control_info (chn, et, additional);
2281 #ifdef HOLD_TOGGLE_VALUES
2282 if (et == MIDI::off || et == MIDI::on) {
2284 /* literal toggle */
2288 route.set_mute (!route.muted(), this);
2291 route.set_solo (!route.soloed(), this);
2300 /* map full control range to a boolean */
2302 bool bval = ((val >= 0.5f) ? true: false);
2306 route.set_mute (bval, this);
2309 route.set_solo (bval, this);
2315 #ifdef HOLD_TOGGLE_VALUES
2323 Route::MIDIToggleControl::send_feedback (bool value)
2326 if (!setting && get_midi_feedback()) {
2327 MIDI::byte val = (MIDI::byte) (value ? 127: 0);
2328 MIDI::channel_t ch = 0;
2329 MIDI::eventType ev = MIDI::none;
2330 MIDI::byte additional = 0;
2331 MIDI::EventTwoBytes data;
2333 if (get_control_info (ch, ev, additional)) {
2334 data.controller_number = additional;
2337 route._session.send_midi_message (get_port(), ev, ch, data);
2344 Route::MIDIToggleControl::write_feedback (MIDI::byte* buf, int32_t& bufsize, bool val, bool force)
2346 if (get_midi_feedback() && bufsize > 2) {
2347 MIDI::channel_t ch = 0;
2348 MIDI::eventType ev = MIDI::none;
2349 MIDI::byte additional = 0;
2351 if (get_control_info (ch, ev, additional)) {
2352 if (val != last_written || force) {
2353 *buf++ = (0xF0 & ev) | (0xF & ch);
2354 *buf++ = additional; /* controller number */
2355 *buf++ = (MIDI::byte) (val ? 127 : 0);
2366 Route::set_block_size (jack_nframes_t nframes)
2368 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2369 (*i)->set_block_size (nframes);
2374 Route::redirect_active_proxy (Redirect* ignored, void* ignored_src)
2376 _session.update_latency_compensation (false, false);
2380 Route::protect_automation ()
2382 switch (gain_automation_state()) {
2385 set_gain_automation_state (Off);
2391 switch (panner().automation_state ()) {
2394 panner().set_automation_state (Off);
2400 for (RedirectList::iterator i = _redirects.begin(); i != _redirects.end(); ++i) {
2402 if ((pi = dynamic_cast<PluginInsert*> (*i)) != 0) {
2403 pi->protect_automation ();
2409 Route::set_pending_declick (int declick)
2412 /* this call is not allowed to turn off a pending declick unless "force" is true */
2414 _pending_declick = declick;
2416 // cerr << _name << ": after setting to " << declick << " pending declick = " << _pending_declick << endl;
2418 _pending_declick = 0;