#include <sigc++/bind.h>
#include <pbd/xml++.h>
+#include <pbd/enumwriter.h>
#include <ardour/timestamps.h>
#include <ardour/buffer.h>
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 (*this, ToggleControllable::SoloControl),
- _mute_control (*this, ToggleControllable::MuteControl)
+ _solo_control (X_("solo"), *this, ToggleControllable::SoloControl),
+ _mute_control (X_("mute"), *this, ToggleControllable::MuteControl)
{
init ();
}
-Route::Route (Session& sess, const XMLNode& node)
- : IO (sess, "route"),
- _solo_control (*this, ToggleControllable::SoloControl),
- _mute_control (*this, ToggleControllable::MuteControl)
+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)
{
init ();
- set_state (node);
+ _set_state (node, false);
}
void
_declickable = false;
_pending_declick = true;
_remote_control_id = 0;
-
+ _ignore_gain_on_deliver = true;
+
_edit_group = 0;
_mix_group = 0;
for (i = _redirects.begin(); i != _redirects.end(); ++i) {
switch ((*i)->placement()) {
case PreFader:
- (*i)->run (bufs, nbufs, nframes, offset);
+ if (dsg == 0) {
+ if (boost::dynamic_pointer_cast<Send>(*i) || boost::dynamic_pointer_cast<PortInsert>(*i)) {
+ (*i)->silence (nframes, offset);
+ }
+ } else {
+ (*i)->run (bufs, nbufs, nframes, offset);
+ }
break;
case PostFader:
post_fader_work = true;
for (n = 0; n < nbufs; ++n) {
Sample *sp = bufs[n];
- apply_gain_to_buffer(sp,nframes,this_gain);
+ Session::apply_gain_to_buffer(sp,nframes,this_gain);
}
} else if (_gain == 0) {
case PreFader:
break;
case PostFader:
- (*i)->run (bufs, nbufs, nframes, offset);
+ if (dsg == 0) {
+ if (boost::dynamic_pointer_cast<Send>(*i) || boost::dynamic_pointer_cast<PortInsert>(*i)) {
+ (*i)->silence (nframes, offset);
+ }
+ } else {
+ (*i)->run (bufs, nbufs, nframes, offset);
+ }
break;
}
}
} else {
- if (_session.transport_speed() > 1.5f || _session.transport_speed() < -1.5f) {
+ if ((_session.transport_speed() > 1.5f ||
+ _session.transport_speed() < -1.5f) &&
+ Config->get_quieten_at_speed()) {
pan (bufs, nbufs, nframes, offset, speed_quietning);
} else {
// cerr << _name << " panner state = " << _panner->automation_state() << endl;
_peak_power.push_back(0);
}
while (_visible_peak_power.size() < potential_max_streams) {
- _visible_peak_power.push_back(0);
+ _visible_peak_power.push_back(-INFINITY);
+ }
+ while (_max_peak_power.size() < potential_max_streams) {
+ _max_peak_power.push_back(-INFINITY);
}
_redirects.push_back (redirect);
_peak_power.push_back(0);
}
while (_visible_peak_power.size() < potential_max_streams) {
- _visible_peak_power.push_back(0);
+ _visible_peak_power.push_back(-INFINITY);
+ }
+ while (_max_peak_power.size() < potential_max_streams) {
+ _max_peak_power.push_back(-INFINITY);
}
_redirects.push_back (*i);
{
Glib::RWLock::WriterLock lm (redirect_lock);
+ RedirectList::iterator i;
+ for (i = _redirects.begin(); i != _redirects.end(); ++i) {
+ (*i)->drop_references ();
+ }
_redirects.clear ();
}
reset_panner ();
}
+ redirect->drop_references ();
+
redirects_changed (src); /* EMIT SIGNAL */
return 0;
}
Route::state(bool full_state)
{
XMLNode *node = new XMLNode("Route");
- XMLNode *aevents;
RedirectList:: iterator i;
char buf[32];
if (_flags) {
- snprintf (buf, sizeof (buf), "0x%x", _flags);
- node->add_property("flags", buf);
+ node->add_property("flags", enum_2_string (_flags));
}
node->add_property("default-type", _default_type.to_string());
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 ());
if (_control_outs) {
XMLNode* cnode = new XMLNode (X_("ControlOuts"));
cmt->add_content (_comment);
}
- if (full_state) {
- string path;
-
- path = _session.snap_name();
- path += "-gain-";
- path += legalize_for_path (_name);
- path += ".automation";
-
- /* XXX we didn't ask for a state save, we asked for the current state.
- FIX ME!
- */
-
- if (save_automation (path)) {
- error << _("Could not get state of route. Problem with save_automation") << endmsg;
- }
-
- aevents = node->add_child ("Automation");
- aevents->add_property ("path", path);
- }
-
for (i = _redirects.begin(); i != _redirects.end(); ++i) {
node->add_child_nocopy((*i)->state (full_state));
}
int
Route::set_state (const XMLNode& node)
+{
+ return _set_state (node, true);
+}
+
+int
+Route::_set_state (const XMLNode& node, bool call_base)
{
XMLNodeList nlist;
XMLNodeConstIterator niter;
return -1;
}
- if ((prop = node.property ("flags")) != 0) {
- int x;
- sscanf (prop->value().c_str(), "0x%x", &x);
- _flags = Flag (x);
+ if ((prop = node.property (X_("flags"))) != 0) {
+ _flags = Flag (string_2_enum (prop->value(), _flags));
} else {
_flags = Flag (0);
}
- if ((prop = node.property ("default-type")) != 0) {
+ if ((prop = node.property (X_("default-type"))) != 0) {
_default_type = DataType(prop->value());
assert(_default_type != DataType::NIL);
}
- if ((prop = node.property ("phase-invert")) != 0) {
+ if ((prop = node.property (X_("phase-invert"))) != 0) {
set_phase_invert(prop->value()=="yes"?true:false, this);
}
- if ((prop = node.property ("active")) != 0) {
+ if ((prop = node.property (X_("active"))) != 0) {
set_active (prop->value() == "yes");
}
- if ((prop = node.property ("muted")) != 0) {
+ if ((prop = node.property (X_("muted"))) != 0) {
bool yn = prop->value()=="yes"?true:false;
/* force reset of mute status */
mute_gain = desired_mute_gain;
}
- if ((prop = node.property ("soloed")) != 0) {
+ if ((prop = node.property (X_("soloed"))) != 0) {
bool yn = prop->value()=="yes"?true:false;
/* force reset of solo status */
solo_gain = desired_solo_gain;
}
- if ((prop = node.property ("mute-affects-pre-fader")) != 0) {
+ if ((prop = node.property (X_("mute-affects-pre-fader"))) != 0) {
_mute_affects_pre_fader = (prop->value()=="yes")?true:false;
}
- if ((prop = node.property ("mute-affects-post-fader")) != 0) {
+ if ((prop = node.property (X_("mute-affects-post-fader"))) != 0) {
_mute_affects_post_fader = (prop->value()=="yes")?true:false;
}
- if ((prop = node.property ("mute-affects-control-outs")) != 0) {
+ if ((prop = node.property (X_("mute-affects-control-outs"))) != 0) {
_mute_affects_control_outs = (prop->value()=="yes")?true:false;
}
- if ((prop = node.property ("mute-affects-main-outs")) != 0) {
+ if ((prop = node.property (X_("mute-affects-main-outs"))) != 0) {
_mute_affects_main_outs = (prop->value()=="yes")?true:false;
}
- if ((prop = node.property ("edit-group")) != 0) {
+ if ((prop = node.property (X_("edit-group"))) != 0) {
RouteGroup* edit_group = _session.edit_group_by_name(prop->value());
if(edit_group == 0) {
error << string_compose(_("Route %1: unknown edit group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
}
}
- if ((prop = node.property ("order-keys")) != 0) {
+ if ((prop = node.property (X_("order-keys"))) != 0) {
long n;
delete deferred_state;
}
- deferred_state = new XMLNode("deferred state");
+ deferred_state = new XMLNode(X_("deferred state"));
/* set parent class properties before anything else */
child = *niter;
- if (child->name() == IO::state_node_name) {
+ if (child->name() == IO::state_node_name && call_base) {
IO::set_state (*child);
break;
child = *niter;
- if (child->name() == "Send") {
+ if (child->name() == X_("Send")) {
if (!IO::ports_legal) {
add_redirect_from_xml (*child);
}
- } else if (child->name() == "Insert") {
+ } else if (child->name() == X_("Insert")) {
if (!IO::ports_legal) {
add_redirect_from_xml (*child);
}
- } else if (child->name() == "Automation") {
-
- XMLPropertyList plist;
- XMLPropertyConstIterator piter;
- XMLProperty *prop;
+ } else if (child->name() == X_("Automation")) {
- plist = child->properties();
- for (piter = plist.begin(); piter != plist.end(); ++piter) {
- prop = *piter;
- if (prop->name() == "path") {
- load_automation (prop->value());
- }
+ if ((prop = child->property (X_("path"))) != 0) {
+ load_automation (prop->value());
}
- } else if (child->name() == "ControlOuts") {
+ } else if (child->name() == X_("ControlOuts")) {
string coutname = _name;
coutname += _("[control]");
_control_outs = new IO (_session, coutname);
_control_outs->set_state (**(child->children().begin()));
- } else if (child->name() == "Comment") {
+ } else if (child->name() == X_("Comment")) {
/* XXX this is a terrible API design in libxml++ */
XMLNode *cmt = *(child->children().begin());
_comment = cmt->content();
- } else if (child->name() == "extra") {
+ } else if (child->name() == X_("extra")) {
_extra_xml = new XMLNode (*child);
+ } else if (child->name() == X_("solo")) {
+ _solo_control.set_state (*child);
+ _session.add_controllable (&_solo_control);
+ } else if (child->name() == X_("mute")) {
+ _mute_control.set_state (*child);
+ _session.add_controllable (&_mute_control);
}
}
- if ((prop = node.property ("mix-group")) != 0) {
+ if ((prop = node.property (X_("mix-group"))) != 0) {
RouteGroup* mix_group = _session.mix_group_by_name(prop->value());
if (mix_group == 0) {
error << string_compose(_("Route %1: unknown mix group \"%2 in saved state (ignored)"), _name, prop->value()) << endmsg;
_roll_delay = _initial_delay;
}
-UndoAction
-Route::get_memento() const
-{
- void (Route::*pmf)(state_id_t) = &Route::set_state;
- return sigc::bind (mem_fun (*(const_cast<Route *>(this)), pmf), _current_state_id);
-}
-
-void
-Route::set_state (state_id_t id)
-{
- return;
-}
-
void
Route::input_change_handler (IOChange change, void *ignored)
{
automation_snapshot (_session.transport_frame());
}
}
-
+
if ((n_outputs() == 0 && _redirects.empty()) || n_inputs() == 0 || !_active) {
silence (nframes, offset);
return 0;
}
}
-Route::ToggleControllable::ToggleControllable (Route& s, ToggleType tp)
- : route (s), type(tp)
+Route::ToggleControllable::ToggleControllable (std::string name, Route& s, ToggleType tp)
+ : Controllable (name), route (s), type(tp)
{
}