add a bit of state to VCAs
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Feb 2016 20:52:27 +0000 (15:52 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:38 +0000 (15:30 -0400)
libs/ardour/ardour/vca.h
libs/ardour/vca.cc

index a4e2e9f4df8199cdfe7ee7aab43bbd204a55297e..b168a8cef9425798fc3e5dbb9bef97451a6c4bdc 100644 (file)
@@ -23,6 +23,7 @@
 #include <boost/shared_ptr.hpp>
 
 #include "pbd/controllable.h"
+#include "pbd/statefuldestructible.h"
 
 #include "ardour/session_handle.h"
 
@@ -31,13 +32,15 @@ namespace ARDOUR {
 class GainControl;
 class Route;
 
-class LIBARDOUR_API VCA : public SessionHandleRef {
+class LIBARDOUR_API VCA : public SessionHandleRef, public PBD::StatefulDestructible  {
   public:
        VCA (Session& session, const std::string& name, uint32_t num);
 
        std::string name() const { return _name; }
        uint32_t number () const { return _number; }
 
+       void set_name (std::string const&);
+
        void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
        double get_value () const;
 
@@ -46,8 +49,13 @@ class LIBARDOUR_API VCA : public SessionHandleRef {
        void add (boost::shared_ptr<Route>);
        void remove (boost::shared_ptr<Route>);
 
+       XMLNode& get_state();
+       int set_state (XMLNode const&, int version);
+
        static std::string default_name_template ();
        static int next_vca_number ();
+       static std::string xml_node_name;
+
   private:
        uint32_t    _number;
        std::string _name;
index 67ca4733cb94fa60f6c6cc7a2081b33c8024be21..f4737e433a0e8f262dc94ffff95b3c6b24fe5fe6 100644 (file)
@@ -16,6 +16,8 @@
     675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#include "pbd/convert.h"
+
 #include "ardour/automation_control.h"
 #include "ardour/gain_control.h"
 #include "ardour/route.h"
@@ -28,6 +30,7 @@ using namespace PBD;
 using std::string;
 
 gint VCA::next_number = 0;
+string VCA::xml_node_name (X_("VCA"));
 
 string
 VCA::default_name_template ()
@@ -74,3 +77,34 @@ VCA::remove (boost::shared_ptr<Route> r)
 {
        r->gain_control()->remove_master (_control);
 }
+
+void
+VCA::set_name (string const& str)
+{
+       _name = str;
+}
+
+XMLNode&
+VCA::get_state ()
+{
+       XMLNode* node = new XMLNode (xml_node_name);
+       node->add_property (X_("name"), _name);
+       node->add_property (X_("number"), _number);
+       return *node;
+}
+
+int
+VCA::set_state (XMLNode const& node, int /*version*/)
+{
+       XMLProperty const* prop;
+
+       if ((prop = node.property ("name")) != 0) {
+               set_name (prop->value());
+       }
+
+       if ((prop = node.property ("number")) != 0) {
+               _number = atoi (prop->value());
+       }
+
+       return 0;
+}