summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/ardour/ardour/gain_control.h6
-rw-r--r--libs/ardour/ardour/vca.h53
-rw-r--r--libs/ardour/gain_control.cc35
-rw-r--r--libs/ardour/vca.cc62
-rw-r--r--libs/ardour/wscript1
5 files changed, 157 insertions, 0 deletions
diff --git a/libs/ardour/ardour/gain_control.h b/libs/ardour/ardour/gain_control.h
index 07a900a164..fa43b5d39f 100644
--- a/libs/ardour/ardour/gain_control.h
+++ b/libs/ardour/ardour/gain_control.h
@@ -40,6 +40,7 @@ class LIBARDOUR_API GainControl : public AutomationControl {
void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
void set_value_unchecked (double);
+ double get_value () const;
double internal_to_interface (double) const;
double interface_to_internal (double) const;
@@ -49,8 +50,13 @@ class LIBARDOUR_API GainControl : public AutomationControl {
double lower_db;
double range_db;
+
+ boost::shared_ptr<GainControl> master() const { return _master; }
+ void set_master (boost::shared_ptr<GainControl>);
+
private:
void _set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
+ boost::shared_ptr<GainControl> _master;
};
} /* namespace */
diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h
new file mode 100644
index 0000000000..a394dac35a
--- /dev/null
+++ b/libs/ardour/ardour/vca.h
@@ -0,0 +1,53 @@
+/*
+ Copyright (C) 2016 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef __ardour_vca_h__
+#define __ardour_vca_h__
+
+#include <string>
+#include <boost/shared_ptr.hpp>
+
+#include "pbd/controllable.h"
+
+#include "ardour/session_handle.h"
+
+namespace ARDOUR {
+
+class GainControl;
+class Route;
+
+class LIBARDOUR_API VCA : public SessionHandleRef {
+ public:
+ VCA (Session& session, const std::string& name);
+
+ void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
+ double get_value () const;
+
+ boost::shared_ptr<AutomationControl> control() const { return _control; }
+
+ void add (boost::shared_ptr<Route>);
+ void remove (boost::shared_ptr<Route>);
+
+ private:
+ std::string name;
+ boost::shared_ptr<GainControl> _control;
+};
+
+} /* namespace */
+
+#endif /* __ardour_vca_h__ */
diff --git a/libs/ardour/gain_control.cc b/libs/ardour/gain_control.cc
index 867edaf5a3..5af0e2d397 100644
--- a/libs/ardour/gain_control.cc
+++ b/libs/ardour/gain_control.cc
@@ -36,6 +36,15 @@ GainControl::GainControl (Session& session, const Evoral::Parameter &param, boos
range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
}
+double
+GainControl::get_value() const
+{
+ if (!_master) {
+ return AutomationControl::get_value();
+ }
+ return AutomationControl::get_value() * _master->get_value();
+}
+
void
GainControl::set_value (double val, PBD::Controllable::GroupControlDisposition group_override)
{
@@ -97,3 +106,29 @@ GainControl::get_user_string () const
return std::string(theBuf);
}
+void
+GainControl::set_master (boost::shared_ptr<GainControl> m)
+{
+ double old_master_val;
+
+ if (_master) {
+ old_master_val = _master->get_value();
+ } else {
+ old_master_val = 1.0;
+ }
+
+ _master = m;
+
+ double new_master_val;
+
+ if (_master) {
+ new_master_val = _master->get_value();
+ } else {
+ new_master_val = 1.0;
+ }
+
+ if (old_master_val != new_master_val) {
+ Changed(); /* EMIT SIGNAL */
+ }
+}
+
diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc
new file mode 100644
index 0000000000..7580d5794a
--- /dev/null
+++ b/libs/ardour/vca.cc
@@ -0,0 +1,62 @@
+/*
+ Copyright (C) 2016 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2 of the License, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ardour/automation_control.h"
+#include "ardour/gain_control.h"
+#include "ardour/route.h"
+#include "ardour/vca.h"
+
+using namespace ARDOUR;
+using namespace PBD;
+using std::string;
+
+VCA::VCA (Session& s, const string& n)
+ : SessionHandleRef (s)
+ , name (n)
+ , _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ()))
+{
+}
+
+void
+VCA::set_value (double val, Controllable::GroupControlDisposition gcd)
+{
+ _control->set_value (val, gcd);
+}
+
+double
+VCA::get_value() const
+{
+ return _control->get_value();
+}
+
+void
+VCA::add (boost::shared_ptr<Route> r)
+{
+ boost::dynamic_pointer_cast<GainControl>(r->gain_control())->set_master (_control);
+}
+
+void
+VCA::remove (boost::shared_ptr<Route> r)
+{
+ boost::shared_ptr<GainControl> route_gain = boost::dynamic_pointer_cast<GainControl>(r->gain_control());
+ boost::shared_ptr<GainControl> current_master = route_gain->master();
+
+ if (current_master == _control) {
+ route_gain->set_master (boost::shared_ptr<GainControl>());
+ }
+}
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index 80ec8e8e93..a5ef2da595 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -231,6 +231,7 @@ libardour_sources = [
'unknown_processor.cc',
'user_bundle.cc',
'utils.cc',
+ 'vca.cc',
'vumeterdsp.cc',
'worker.cc'
]