Add API to run automation only (emit Changed signal).
[ardour.git] / libs / ardour / track.cc
index cb23943f2af6e4b9a4ff451b68e40c81c9e0a7e3..d7d9a0a9d14686b04ba78f8aba3521367b4d36e1 100644 (file)
@@ -21,6 +21,7 @@
 #include "ardour/debug.h"
 #include "ardour/delivery.h"
 #include "ardour/diskstream.h"
+#include "ardour/event_type_map.h"
 #include "ardour/io_processor.h"
 #include "ardour/meter.h"
 #include "ardour/monitor_control.h"
@@ -34,6 +35,7 @@
 #include "ardour/session.h"
 #include "ardour/session_playlists.h"
 #include "ardour/track.h"
+#include "ardour/types_convert.h"
 #include "ardour/utils.h"
 
 #include "pbd/i18n.h"
@@ -63,16 +65,16 @@ Track::init ()
                 return -1;
         }
 
-       boost::shared_ptr<Route> rp (shared_from_this());
+        boost::shared_ptr<Route> rp (boost::dynamic_pointer_cast<Route> (shared_from_this()));
        boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
 
-       _record_enable_control.reset (new RecordEnableControl (_session, X_("recenable"), *this));
+       _record_enable_control.reset (new RecordEnableControl (_session, EventTypeMap::instance().to_symbol (RecEnableAutomation), *this));
        add_control (_record_enable_control);
 
-       _record_safe_control.reset (new RecordSafeControl (_session, X_("recsafe"), *this));
+       _record_safe_control.reset (new RecordSafeControl (_session, EventTypeMap::instance().to_symbol (RecSafeAutomation), *this));
        add_control (_record_safe_control);
 
-       _monitoring_control.reset (new MonitorControl (_session, X_("monitoring"), *this));
+       _monitoring_control.reset (new MonitorControl (_session, EventTypeMap::instance().to_symbol (MonitoringAutomation), *this));
        add_control (_monitoring_control);
 
        _session.config.ParameterChanged.connect_same_thread (*this, boost::bind (&Track::parameter_changed, this, _1));
@@ -111,7 +113,7 @@ Track::state (bool full)
        root.add_child_nocopy (_record_safe_control->get_state ());
        root.add_child_nocopy (_record_enable_control->get_state ());
 
-       root.add_property (X_("saved-meter-point"), enum_2_string (_saved_meter_point));
+       root.set_property (X_("saved-meter-point"), _saved_meter_point);
        root.add_child_nocopy (_diskstream->get_state ());
 
        return root;
@@ -146,28 +148,32 @@ Track::set_state (const XMLNode& node, int version)
        for (XMLNodeConstIterator niter = nlist.begin(); niter != nlist.end(); ++niter) {
                child = *niter;
 
-               XMLProperty const * prop;
-
                if (child->name() == Controllable::xml_node_name) {
-                       if ((prop = child->property ("name")) == 0) {
+                       std::string name;
+                       if (!child->get_property ("name", name)) {
                                continue;
                        }
 
-                       if (prop->value() == _record_enable_control->name()) {
+                       if (name == _record_enable_control->name()) {
                                _record_enable_control->set_state (*child, version);
-                       } else if (prop->value() == _record_safe_control->name()) {
+                       } else if (name == _record_safe_control->name()) {
                                _record_safe_control->set_state (*child, version);
-                       } else if (prop->value() == _monitoring_control->name()) {
+                       } else if (name == _monitoring_control->name()) {
                                _monitoring_control->set_state (*child, version);
                        }
                }
        }
 
-       XMLProperty const * prop;
+       /* convert old 3001 state */
+       MonitorChoice monitoring;
+       if (node.get_property (X_("monitoring"), monitoring)) {
+               XMLNode mon_node ("backwardscompat");
+               mon_node.set_property (X_("monitoring"), monitoring);
+               mon_node.set_property (X_("value"), (int) monitoring);
+               _monitoring_control->set_state (mon_node, version);
+       }
 
-       if ((prop = node.property (X_("saved-meter-point"))) != 0) {
-               _saved_meter_point = MeterPoint (string_2_enum (prop->value(), _saved_meter_point));
-       } else {
+       if (!node.get_property (X_("saved-meter-point"), _saved_meter_point)) {
                _saved_meter_point = _meter_point;
        }
 
@@ -293,8 +299,12 @@ Track::set_name (const string& str)
 {
        bool ret;
 
-       if (_record_enable_control->get_value() && _session.actively_recording()) {
-               /* this messes things up if done while recording */
+       if (str.empty ()) {
+               return false;
+       }
+
+       if (_record_enable_control->get_value()) {
+               /* when re-arm'ed the file (named after the track) is already ready to rolll */
                return false;
        }
 
@@ -955,9 +965,11 @@ Track::monitoring_state () const
         * time, but just to keep the semantics the same as they were before
         * sept 26th 2012, we differentiate between the cases where punch is
         * enabled and those where it is not.
+        *
+        * rg: I suspect this is not the case: monitoring may differ
         */
 
-       if (_session.config.get_punch_in() || _session.config.get_punch_out()) {
+       if (_session.config.get_punch_in() || _session.config.get_punch_out() || _session.preroll_record_punch_enabled ()) {
                session_rec = _session.actively_recording ();
        } else {
                session_rec = _session.get_record_enabled();