summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2016-02-29 18:12:13 -0500
committerPaul Davis <paul@linuxaudiosystems.com>2016-05-31 15:30:38 -0400
commit4d14ae4e23bc58e356dcda387213d0ba4ab6364b (patch)
treecbc6fe9183a5dfe6deadb66fa1b496301afeec01
parentd2c405416c0c86d01f8b701ad2781e53d87410ae (diff)
mostly restore VCA state on session loading.
This does not restore VCA assignments
-rw-r--r--gtk2_ardour/mixer_strip.cc4
-rw-r--r--gtk2_ardour/mixer_ui.cc2
-rw-r--r--libs/ardour/ardour/vca.h4
-rw-r--r--libs/ardour/ardour/vca_manager.h6
-rw-r--r--libs/ardour/vca.cc29
-rw-r--r--libs/ardour/vca_manager.cc44
-rw-r--r--libs/pbd/controllable.cc5
7 files changed, 84 insertions, 10 deletions
diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc
index 591b4f4250..673bce61d1 100644
--- a/gtk2_ardour/mixer_strip.cc
+++ b/gtk2_ardour/mixer_strip.cc
@@ -2516,7 +2516,7 @@ MixerStrip::vca_button_release (GdkEventButton* ev, uint32_t which)
return false;
}
- VCAManager::VCAS vcas (_session->vca_manager().vcas());
+ VCAList vcas (_session->vca_manager().vcas());
if (vcas.empty()) {
/* XXX should probably show a message saying "No VCA masters" */
@@ -2527,7 +2527,7 @@ MixerStrip::vca_button_release (GdkEventButton* ev, uint32_t which)
MenuList& items = menu->items();
RadioMenuItem::Group group;
- for (VCAManager::VCAS::iterator v = vcas.begin(); v != vcas.end(); ++v) {
+ for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
items.push_back (RadioMenuElem (group, (*v)->name(), sigc::bind (sigc::mem_fun (*this, &MixerStrip::vca_menu_toggle), (*v)->number())));
}
diff --git a/gtk2_ardour/mixer_ui.cc b/gtk2_ardour/mixer_ui.cc
index 3efb1ce0f1..f847678df8 100644
--- a/gtk2_ardour/mixer_ui.cc
+++ b/gtk2_ardour/mixer_ui.cc
@@ -1286,6 +1286,8 @@ Mixer_UI::initial_track_display ()
Unwinder<bool> uw2 (ignore_reorder, true);
track_model->clear ();
+ VCAList vcas = _session->vca_manager().vcas();
+ add_masters (vcas);
add_strips (copy);
}
diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h
index b168a8cef9..a4da21e31f 100644
--- a/libs/ardour/ardour/vca.h
+++ b/libs/ardour/ardour/vca.h
@@ -25,6 +25,7 @@
#include "pbd/controllable.h"
#include "pbd/statefuldestructible.h"
+#include "ardour/automatable.h"
#include "ardour/session_handle.h"
namespace ARDOUR {
@@ -32,9 +33,10 @@ namespace ARDOUR {
class GainControl;
class Route;
-class LIBARDOUR_API VCA : public SessionHandleRef, public PBD::StatefulDestructible {
+class LIBARDOUR_API VCA : public SessionHandleRef, public PBD::StatefulDestructible, public Automatable {
public:
VCA (Session& session, const std::string& name, uint32_t num);
+ VCA (Session& session, XMLNode const&, int version);
std::string name() const { return _name; }
uint32_t number () const { return _number; }
diff --git a/libs/ardour/ardour/vca_manager.h b/libs/ardour/ardour/vca_manager.h
index 10e76db860..4e5b54f438 100644
--- a/libs/ardour/ardour/vca_manager.h
+++ b/libs/ardour/ardour/vca_manager.h
@@ -48,8 +48,7 @@ class VCAManager : public SessionHandleRef, public PBD::StatefulDestructible
boost::shared_ptr<VCA> vca_by_number(uint32_t) const;
- typedef std::list<boost::shared_ptr<VCA> > VCAS;
- VCAS vcas() const;
+ VCAList vcas() const;
PBD::Signal1<void,VCAList&> VCAAdded;
PBD::Signal1<void,VCAList&> VCARemoved;
@@ -61,8 +60,9 @@ class VCAManager : public SessionHandleRef, public PBD::StatefulDestructible
private:
mutable Glib::Threads::Mutex lock;
- VCAS _vcas;
+ VCAList _vcas;
+ void clear ();
};
} // namespace
diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc
index f4737e433a..9ae0c5a2dc 100644
--- a/libs/ardour/vca.cc
+++ b/libs/ardour/vca.cc
@@ -47,10 +47,23 @@ VCA::next_vca_number ()
VCA::VCA (Session& s, const string& name, uint32_t num)
: SessionHandleRef (s)
+ , Automatable (s)
, _number (num)
, _name (name)
, _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ()))
{
+ add_control (_control);
+}
+
+VCA::VCA (Session& s, XMLNode const & node, int version)
+ : SessionHandleRef (s)
+ , Automatable (s)
+ , _number (0)
+ , _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ()))
+{
+ add_control (_control);
+
+ set_state (node, version);
}
void
@@ -90,11 +103,15 @@ VCA::get_state ()
XMLNode* node = new XMLNode (xml_node_name);
node->add_property (X_("name"), _name);
node->add_property (X_("number"), _number);
+
+ node->add_child_nocopy (_control->get_state());
+ node->add_child_nocopy (get_automation_xml_state());
+
return *node;
}
int
-VCA::set_state (XMLNode const& node, int /*version*/)
+VCA::set_state (XMLNode const& node, int version)
{
XMLProperty const* prop;
@@ -106,5 +123,15 @@ VCA::set_state (XMLNode const& node, int /*version*/)
_number = atoi (prop->value());
}
+ XMLNodeList const &children (node.children());
+ for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
+ if ((*i)->name() == Controllable::xml_node_name) {
+ XMLProperty* prop = (*i)->property ("name");
+ if (prop && prop->value() == X_("gaincontrol")) {
+ _control->set_state (**i, version);
+ }
+ }
+ }
+
return 0;
}
diff --git a/libs/ardour/vca_manager.cc b/libs/ardour/vca_manager.cc
index 7cef8e932c..a707a9223e 100644
--- a/libs/ardour/vca_manager.cc
+++ b/libs/ardour/vca_manager.cc
@@ -38,11 +38,17 @@ VCAManager::VCAManager (Session& s)
VCAManager::~VCAManager ()
{
+ clear ();
+}
+
+void
+VCAManager::clear ()
+{
Mutex::Lock lm (lock);
_vcas.clear ();
}
-VCAManager::VCAS
+VCAList
VCAManager::vcas () const
{
Mutex::Lock lm (lock);
@@ -99,7 +105,7 @@ VCAManager::vca_by_number (uint32_t n) const
{
Mutex::Lock lm (lock);
- for (VCAS::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) {
+ for (VCAList::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) {
if ((*i)->number() == n) {
return *i;
}
@@ -112,11 +118,43 @@ XMLNode&
VCAManager::get_state ()
{
XMLNode* node = new XMLNode (xml_node_name);
+
+ {
+ Mutex::Lock lm (lock);
+
+ for (VCAList::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) {
+ node->add_child_nocopy ((*i)->get_state());
+ }
+ }
+
return *node;
}
int
-VCAManager::set_state (XMLNode const& node, int /*version*/)
+VCAManager::set_state (XMLNode const& node, int version)
{
+ if (node.name() != xml_node_name) {
+ return -1;
+ }
+
+ XMLNodeList const & children = node.children();
+ VCAList vcal;
+
+ {
+
+ Mutex::Lock lm (lock);
+
+ for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
+ if ((*i)->name() == VCA::xml_node_name) {
+ std::cerr << "Adding VCA from XML\n";
+ boost::shared_ptr<VCA> vca = boost::shared_ptr<VCA> (new VCA (_session, **i, version));
+ _vcas.push_back (vca);
+ vcal.push_back (vca);
+ }
+ }
+ }
+
+ VCAAdded (vcal); /* EMIT SIGNAL */
+
return 0;
}
diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc
index 6b92e84926..a4c097c3f0 100644
--- a/libs/pbd/controllable.cc
+++ b/libs/pbd/controllable.cc
@@ -22,6 +22,7 @@
#include "pbd/xml++.h"
#include "pbd/error.h"
#include "pbd/locale_guard.h"
+#include "pbd/stacktrace.h"
#include "i18n.h"
@@ -121,6 +122,10 @@ Controllable::get_state ()
node->add_property (X_("name"), _name);
+ if (_name == "gaincontrol") {
+ PBD::stacktrace (cerr, 20);
+ }
+
id().print (buf, sizeof (buf));
node->add_property (X_("id"), buf);
node->add_property (X_("flags"), enum_2_string (_flags));