using namespace PBD;
uint32_t Route::order_key_cnt = 0;
-
+sigc::signal<void> Route::SyncOrderKeys;
Route::Route (Session& sess, string name, int input_min, int input_max, int output_min, int output_max, Flag flg, DataType default_type)
: IO (sess, name, input_min, input_max, output_min, output_max, default_type),
_flags (flg),
- _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
- _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
+ _solo_control (new ToggleControllable (X_("solo"), *this, ToggleControllable::SoloControl)),
+ _mute_control (new ToggleControllable (X_("mute"), *this, ToggleControllable::MuteControl))
{
init ();
}
Route::Route (Session& sess, const XMLNode& node, DataType default_type)
: IO (sess, *node.child ("IO"), default_type),
- _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
- _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
+ _solo_control (new ToggleControllable (X_("solo"), *this, ToggleControllable::SoloControl)),
+ _mute_control (new ToggleControllable (X_("mute"), *this, ToggleControllable::MuteControl))
{
init ();
_set_state (node, false);
_initial_delay = 0;
_roll_delay = 0;
_own_latency = 0;
+ _user_latency = 0;
_have_internal_generator = false;
_declickable = false;
_pending_declick = true;
Route::set_order_key (const char* name, long n)
{
order_keys[strdup(name)] = n;
+
+ if (Config->get_sync_all_route_ordering()) {
+ for (OrderKeys::iterator x = order_keys.begin(); x != order_keys.end(); ++x) {
+ x->second = n;
+ }
+ }
+
_session.set_dirty ();
}
+void
+Route::sync_order_keys ()
+{
+ uint32_t key;
+
+ if (order_keys.empty()) {
+ return;
+ }
+
+ OrderKeys::iterator x = order_keys.begin();
+ key = x->second;
+ ++x;
+
+ for (; x != order_keys.end(); ++x) {
+ x->second = key;
+ }
+}
+
void
Route::inc_gain (gain_t fraction, void *src)
{
if (_mix_group->is_relative()) {
-
- gain_t usable_gain = gain();
+ gain_t usable_gain = gain();
if (usable_gain < 0.000001f) {
- usable_gain=0.000001f;
+ usable_gain = 0.000001f;
}
gain_t delta = val;
if (delta < 0.000001f) {
- delta=0.000001f;
+ delta = 0.000001f;
}
delta -= usable_gain;
- if (delta == 0.0f) return;
+ if (delta == 0.0f)
+ return;
gain_t factor = delta / usable_gain;
if (factor > 0.0f) {
factor = _mix_group->get_max_factor(factor);
if (factor == 0.0f) {
- gain_changed (src);
+ _gain_control->Changed(); /* EMIT SIGNAL */
return;
}
} else {
factor = _mix_group->get_min_factor(factor);
if (factor == 0.0f) {
- gain_changed (src);
+ _gain_control->Changed(); /* EMIT SIGNAL */
return;
}
}
-------------------------------------------------------------------------------------------------- */
if (declick > 0) {
- Amp::run (bufs, nframes, 0.0, 1.0, false);
+ Amp::run_in_place (bufs, nframes, 0.0, 1.0, false);
_pending_declick = 0;
} else if (declick < 0) {
- Amp::run (bufs, nframes, 1.0, 0.0, false);
+ Amp::run_in_place (bufs, nframes, 1.0, 0.0, false);
_pending_declick = 0;
} else {
/* no global declick */
if (solo_gain != dsg) {
- Amp::run (bufs, nframes, solo_gain, dsg, false);
+ Amp::run_in_place (bufs, nframes, solo_gain, dsg, false);
solo_gain = dsg;
}
}
-------------------------------------------------------------------------------------------------- */
if (meter && (_meter_point == MeterInput)) {
- _meter->run(bufs, start_frame, end_frame, nframes, offset);
+ _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
}
if (!_soloed && _mute_affects_pre_fader && (mute_gain != dmg)) {
- Amp::run (bufs, nframes, mute_gain, dmg, false);
+ Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
for (i = _processors.begin(); i != _processors.end(); ++i) {
switch ((*i)->placement()) {
case PreFader:
- (*i)->run (bufs, start_frame, end_frame, nframes, offset);
+ (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
break;
case PostFader:
post_fader_work = true;
bufs.set_count(pre_fader_streams());
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_post_fader) {
- Amp::run (bufs, nframes, mute_gain, dmg, false);
+ Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
-------------------------------------------------------------------------------------------------- */
if (meter && (_meter_point == MeterPreFader)) {
- _meter->run(bufs, start_frame, end_frame, nframes, offset);
+ _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
}
// OR recording
- // h/w monitoring not in use
-
- (!Config->get_monitoring_model() == HardwareMonitoring &&
-
// AND software monitoring required
- Config->get_monitoring_model() == SoftwareMonitoring)) {
+ Config->get_monitoring_model() == SoftwareMonitoring) {
if (apply_gain_automation) {
if (_gain != dg) {
- Amp::run (bufs, nframes, _gain, dg, _phase_invert);
+ Amp::run_in_place (bufs, nframes, _gain, dg, _phase_invert);
_gain = dg;
} else if (_gain != 0 && (_phase_invert || _gain != 1.0)) {
case PreFader:
break;
case PostFader:
- (*i)->run (bufs, start_frame, end_frame, nframes, offset);
+ (*i)->run_in_place (bufs, start_frame, end_frame, nframes, offset);
break;
}
}
}
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_control_outs) {
- Amp::run (bufs, nframes, mute_gain, dmg, false);
+ Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
----------------------------------------------------------------------*/
if (!_soloed && (mute_gain != dmg) && !mute_declick_applied && _mute_affects_main_outs) {
- Amp::run (bufs, nframes, mute_gain, dmg, false);
+ Amp::run_in_place (bufs, nframes, mute_gain, dmg, false);
mute_gain = dmg;
mute_declick_applied = true;
}
if ((_gain == 0 && !apply_gain_automation) || dmg == 0) {
_meter->reset();
} else {
- _meter->run(output_buffers(), start_frame, end_frame, nframes, offset);
+ _meter->run_in_place(output_buffers(), start_frame, end_frame, nframes, offset);
}
}
}
collect_input (bufs, nframes, offset);
if (meter_first) {
- _meter->run(bufs, start_frame, end_frame, nframes, offset);
+ _meter->run_in_place(bufs, start_frame, end_frame, nframes, offset);
meter_first = false;
}
if (_soloed != yn) {
_soloed = yn;
solo_changed (src); /* EMIT SIGNAL */
- _solo_control.Changed (); /* EMIT SIGNAL */
+ _solo_control->Changed (); /* EMIT SIGNAL */
}
}
_muted = yn;
mute_changed (src); /* EMIT SIGNAL */
- _mute_control.Changed (); /* EMIT SIGNAL */
+ _mute_control->Changed (); /* EMIT SIGNAL */
Glib::Mutex::Lock lm (declick_lock);
desired_mute_gain = (yn?0.0f:1.0f);
processor->activate ();
processor->ActiveChanged.connect (bind (mem_fun (_session, &Session::update_latency_compensation), false, false));
+
+ _user_latency = 0;
}
if (processor_max_outs != old_rmo || old_rmo == ChanCount::ZERO) {
(*i)->activate ();
(*i)->ActiveChanged.connect (bind (mem_fun (_session, &Session::update_latency_compensation), false, false));
}
+
+ _user_latency = 0;
}
if (processor_max_outs != old_rmo || old_rmo == ChanCount::ZERO) {
removed = true;
break;
}
+
+ _user_latency = 0;
}
if (!removed) {
for (i = iclist.begin(); i != iclist.end(); ++i) {
+ cerr << "now applying for " << (*i).processor->name() << " in = " << (*i).in.n_audio() << " out = " << (*i).out.n_audio() << endl;
+
if ((*i).processor->configure_io ((*i).in, (*i).out)) {
return -1;
}
for (i = iclist.begin(); i != iclist.end(); ++i) {
+
+ cerr << "Checking whether " << (*i).processor->name() << " can support " << required_inputs.n_audio() << " inputs\n";
+
if ((*i).processor->can_support_input_configuration (required_inputs) < 0) {
if (err) {
err->index = index;
(*i).in = required_inputs;
(*i).out = (*i).processor->output_for_input_configuration (required_inputs);
+ cerr << "config looks like " << (*i).processor->name() << " in = " << (*i).in.n_audio() << " out = " << (*i).out.n_audio() << endl;
+
required_inputs = (*i).out;
++index;
/* SUCCESSFUL COPY ATTEMPT: delete the processors we removed pre-copy */
to_be_deleted.clear ();
+ _user_latency = 0;
}
}
Route::state(bool full_state)
{
XMLNode *node = new XMLNode("Route");
- ProcessorList:: iterator i;
+ ProcessorList::iterator i;
char buf[32];
if (_flags) {
node->add_property ("order-keys", order_string);
node->add_child_nocopy (IO::state (full_state));
- node->add_child_nocopy (_solo_control.get_state ());
- node->add_child_nocopy (_mute_control.get_state ());
+ node->add_child_nocopy (_solo_control->get_state ());
+ node->add_child_nocopy (_mute_control->get_state ());
XMLNode* remote_control_node = new XMLNode (X_("remote_control"));
snprintf (buf, sizeof (buf), "%d", _remote_control_id);
} else if (child->name() == X_("controllable") && (prop = child->property("name")) != 0) {
if (prop->value() == "solo") {
- _solo_control.set_state (*child);
- _session.add_controllable (&_solo_control);
+ _solo_control->set_state (*child);
+ _session.add_controllable (_solo_control);
}
else if (prop->value() == "mute") {
- _mute_control.set_state (*child);
- _session.add_controllable (&_mute_control);
+ _mute_control->set_state (*child);
+ _session.add_controllable (_mute_control);
}
}
else if (child->name() == X_("remote_control")) {
_control_outs = 0;
}
- if (control() || master()) {
+ if (is_control() || is_master()) {
/* no control outs for these two special busses */
return 0;
}
/* now connect to the named ports */
for (size_t n = 0; n < limit; ++n) {
- if (_control_outs->connect_output (_control_outs->output (n), ports[n], this)) {
+ if (_control_outs->connect_output (_control_outs->output (n), ports[n % ports.size()], this)) {
error << string_compose (_("could not connect %1 to %2"), _control_outs->output(n)->name(), ports[n]) << endmsg;
return -1;
}
return 0;
}
- return max (n_inputs ().n_audio(), static_cast<size_t>(processor_max_outs.n_audio()));
+ return max (n_inputs ().n_audio(), processor_max_outs.n_audio());
}
int
if (am.locked() && _session.transport_rolling()) {
- ARDOUR::AutomationList& gain_auto = gain_automation();
-
- if (gain_auto.automation_playback()) {
- apply_gain_automation = gain_auto.curve().rt_safe_get_vector (start_frame, end_frame, _session.gain_automation_buffer(), nframes);
+ if (_gain_control->list()->automation_playback()) {
+ apply_gain_automation = _gain_control->list()->curve().rt_safe_get_vector (
+ start_frame, end_frame, _session.gain_automation_buffer(), nframes);
}
}
}
nframes_t
Route::update_total_latency ()
{
- _own_latency = 0;
+ nframes_t old = _own_latency;
- for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
- if ((*i)->active ()) {
- _own_latency += (*i)->latency ();
+ if (_user_latency) {
+ _own_latency = _user_latency;
+ } else {
+ _own_latency = 0;
+
+ for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+ if ((*i)->active ()) {
+ _own_latency += (*i)->signal_latency ();
+ }
}
}
set_port_latency (_own_latency);
+
+ if (!_user_latency) {
+ /* this (virtual) function is used for pure Routes,
+ not derived classes like AudioTrack. this means
+ that the data processed here comes from an input
+ port, not prerecorded material, and therefore we
+ have to take into account any input latency.
+ */
- /* this (virtual) function is used for pure Routes,
- not derived classes like AudioTrack. this means
- that the data processed here comes from an input
- port, not prerecorded material, and therefore we
- have to take into account any input latency.
- */
- _own_latency += input_latency ();
+ _own_latency += input_latency ();
+ }
+ if (old != _own_latency) {
+ signal_latency_changed (); /* EMIT SIGNAL */
+ }
+
return _own_latency;
}
+void
+Route::set_user_latency (nframes_t nframes)
+{
+ Latent::set_user_latency (nframes);
+ _session.update_latency_compensation (false, false);
+}
+
void
Route::set_latency_delay (nframes_t longest_session_latency)
{
- _initial_delay = longest_session_latency - _own_latency;
+ nframes_t old = _initial_delay;
+
+ if (_own_latency < longest_session_latency) {
+ _initial_delay = longest_session_latency - _own_latency;
+ } else {
+ _initial_delay = 0;
+ }
+
+ if (_initial_delay != old) {
+ initial_delay_changed (); /* EMIT SIGNAL */
+ }
if (_session.transport_stopped()) {
_roll_delay = _initial_delay;