initially pass at libardour VCA implementation

This commit is contained in:
Paul Davis 2016-01-22 14:42:25 -05:00
parent ca8ac0591f
commit 87481a2ee1
5 changed files with 157 additions and 0 deletions

View File

@ -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 */

53
libs/ardour/ardour/vca.h Normal file
View File

@ -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__ */

View File

@ -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 */
}
}

62
libs/ardour/vca.cc Normal file
View File

@ -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>());
}
}

View File

@ -231,6 +231,7 @@ libardour_sources = [
'unknown_processor.cc',
'user_bundle.cc',
'utils.cc',
'vca.cc',
'vumeterdsp.cc',
'worker.cc'
]