2016-01-22 14:42:25 -05:00
|
|
|
/*
|
2019-08-02 22:01:25 -04:00
|
|
|
* Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
|
|
|
|
* Copyright (C) 2017 Robin Gareus <robin@gareus.org>
|
|
|
|
*
|
|
|
|
* 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.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
2016-01-22 14:42:25 -05:00
|
|
|
|
2016-02-29 15:52:27 -05:00
|
|
|
#include "pbd/convert.h"
|
|
|
|
|
2016-01-22 14:42:25 -05:00
|
|
|
#include "ardour/automation_control.h"
|
2016-04-29 11:07:27 -04:00
|
|
|
#include "ardour/debug.h"
|
2016-01-22 14:42:25 -05:00
|
|
|
#include "ardour/gain_control.h"
|
2016-04-25 12:30:34 -04:00
|
|
|
#include "ardour/monitor_control.h"
|
2016-03-04 14:15:12 -05:00
|
|
|
#include "ardour/rc_configuration.h"
|
2016-01-22 14:42:25 -05:00
|
|
|
#include "ardour/route.h"
|
2016-03-04 14:15:12 -05:00
|
|
|
#include "ardour/session.h"
|
2016-01-22 14:42:25 -05:00
|
|
|
#include "ardour/vca.h"
|
|
|
|
|
2016-07-14 14:44:52 -04:00
|
|
|
#include "pbd/i18n.h"
|
2016-02-29 14:44:25 -05:00
|
|
|
|
2016-01-22 14:42:25 -05:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace PBD;
|
|
|
|
using std::string;
|
|
|
|
|
2016-05-21 07:39:28 -04:00
|
|
|
Glib::Threads::Mutex VCA::number_lock;
|
2016-07-08 11:43:34 -04:00
|
|
|
int32_t VCA::next_number = 1;
|
2016-02-29 15:52:27 -05:00
|
|
|
string VCA::xml_node_name (X_("VCA"));
|
2016-02-29 14:44:25 -05:00
|
|
|
|
|
|
|
string
|
|
|
|
VCA::default_name_template ()
|
|
|
|
{
|
|
|
|
return _("VCA %n");
|
|
|
|
}
|
|
|
|
|
2016-07-08 11:43:34 -04:00
|
|
|
int32_t
|
2016-02-29 14:44:25 -05:00
|
|
|
VCA::next_vca_number ()
|
|
|
|
{
|
2016-05-21 07:39:28 -04:00
|
|
|
/* we could use atomic inc here, but elsewhere we need more complete
|
|
|
|
mutex semantics, so we have to do it here also.
|
|
|
|
*/
|
|
|
|
Glib::Threads::Mutex::Lock lm (number_lock);
|
|
|
|
return next_number++;
|
2016-03-07 16:25:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-07-08 11:43:34 -04:00
|
|
|
VCA::set_next_vca_number (int32_t n)
|
2016-03-07 16:25:50 -05:00
|
|
|
{
|
2016-05-21 07:39:28 -04:00
|
|
|
Glib::Threads::Mutex::Lock lm (number_lock);
|
|
|
|
next_number = n;
|
2016-02-29 14:44:25 -05:00
|
|
|
}
|
|
|
|
|
2016-07-08 11:43:34 -04:00
|
|
|
int32_t
|
2016-03-07 16:46:36 -05:00
|
|
|
VCA::get_next_vca_number ()
|
|
|
|
{
|
2016-05-21 07:39:28 -04:00
|
|
|
Glib::Threads::Mutex::Lock lm (number_lock);
|
|
|
|
return next_number;
|
2016-03-07 16:46:36 -05:00
|
|
|
}
|
|
|
|
|
2017-01-28 10:06:28 -05:00
|
|
|
VCA::VCA (Session& s, int32_t num, const string& name)
|
2016-05-16 07:30:28 -04:00
|
|
|
: Stripable (s, name, PresentationInfo (num, PresentationInfo::VCA))
|
2016-04-08 16:49:47 -04:00
|
|
|
, Muteable (s, name)
|
2016-02-29 14:44:25 -05:00
|
|
|
, _number (num)
|
2023-02-16 18:33:28 -05:00
|
|
|
, _gain_control (new GainControl (s, Evoral::Parameter (GainAutomation), std::shared_ptr<AutomationList> ()))
|
2016-01-22 14:42:25 -05:00
|
|
|
{
|
2016-02-29 18:12:13 -05:00
|
|
|
}
|
|
|
|
|
2016-03-07 14:59:40 -05:00
|
|
|
int
|
|
|
|
VCA::init ()
|
2016-02-29 18:12:13 -05:00
|
|
|
{
|
2023-07-21 11:56:42 -04:00
|
|
|
_solo_control.reset (new SoloControl (_session, X_("solo"), *this, *this, *this));
|
|
|
|
_mute_control.reset (new MuteControl (_session, X_("mute"), *this, *this));
|
2016-02-29 18:12:13 -05:00
|
|
|
|
2016-03-07 14:59:40 -05:00
|
|
|
add_control (_gain_control);
|
|
|
|
add_control (_solo_control);
|
|
|
|
add_control (_mute_control);
|
|
|
|
|
|
|
|
return 0;
|
2016-01-22 14:42:25 -05:00
|
|
|
}
|
|
|
|
|
2016-03-02 12:09:24 -05:00
|
|
|
VCA::~VCA ()
|
|
|
|
{
|
2016-04-29 11:07:27 -04:00
|
|
|
DEBUG_TRACE (DEBUG::Destruction, string_compose ("delete VCA %1\n", number()));
|
2017-06-09 16:54:09 -04:00
|
|
|
{
|
|
|
|
Glib::Threads::Mutex::Lock lm (_control_lock);
|
|
|
|
for (Controls::const_iterator li = _controls.begin(); li != _controls.end(); ++li) {
|
2023-02-16 18:33:28 -05:00
|
|
|
std::dynamic_pointer_cast<AutomationControl>(li->second)->drop_references ();
|
2017-06-09 16:54:09 -04:00
|
|
|
}
|
|
|
|
}
|
2016-05-21 07:39:28 -04:00
|
|
|
{
|
|
|
|
Glib::Threads::Mutex::Lock lm (number_lock);
|
|
|
|
if (_number == next_number - 1) {
|
|
|
|
/* this was the "last" VCA added, so rewind the next number so
|
|
|
|
* that future VCAs get numbered as intended
|
|
|
|
*/
|
|
|
|
next_number--;
|
|
|
|
}
|
|
|
|
}
|
2016-02-29 15:52:27 -05:00
|
|
|
}
|
|
|
|
|
2017-01-28 10:06:28 -05:00
|
|
|
string
|
|
|
|
VCA::full_name() const
|
|
|
|
{
|
|
|
|
/* name() is never empty - default is VCA %n */
|
|
|
|
return string_compose (_("VCA %1 : %2"), _number, name());
|
|
|
|
}
|
|
|
|
|
2016-02-29 15:52:27 -05:00
|
|
|
XMLNode&
|
2022-04-06 23:56:32 -04:00
|
|
|
VCA::get_state () const
|
2016-02-29 15:52:27 -05:00
|
|
|
{
|
|
|
|
XMLNode* node = new XMLNode (xml_node_name);
|
2016-08-28 08:07:50 -04:00
|
|
|
node->set_property (X_("name"), name());
|
|
|
|
node->set_property (X_("number"), _number);
|
2016-02-29 18:12:13 -05:00
|
|
|
|
2016-06-05 15:11:43 -04:00
|
|
|
node->add_child_nocopy (_presentation_info.get_state());
|
2016-05-16 07:30:28 -04:00
|
|
|
|
2016-03-07 14:59:40 -05:00
|
|
|
node->add_child_nocopy (_gain_control->get_state());
|
2016-04-11 16:37:51 -04:00
|
|
|
node->add_child_nocopy (_solo_control->get_state());
|
|
|
|
node->add_child_nocopy (_mute_control->get_state());
|
2016-02-29 18:12:13 -05:00
|
|
|
node->add_child_nocopy (get_automation_xml_state());
|
|
|
|
|
2016-04-25 11:03:08 -04:00
|
|
|
node->add_child_nocopy (Slavable::get_state());
|
|
|
|
|
2016-02-29 15:52:27 -05:00
|
|
|
return *node;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2016-02-29 18:12:13 -05:00
|
|
|
VCA::set_state (XMLNode const& node, int version)
|
2016-02-29 15:52:27 -05:00
|
|
|
{
|
2016-05-16 07:30:28 -04:00
|
|
|
Stripable::set_state (node, version);
|
|
|
|
|
2016-08-28 08:07:50 -04:00
|
|
|
std::string str;
|
|
|
|
if (node.get_property ("name", str)) {
|
|
|
|
set_name (str);
|
2016-02-29 15:52:27 -05:00
|
|
|
}
|
|
|
|
|
2016-08-28 08:07:50 -04:00
|
|
|
node.get_property ("number", _number);
|
2016-02-29 15:52:27 -05:00
|
|
|
|
2016-02-29 18:12:13 -05:00
|
|
|
XMLNodeList const &children (node.children());
|
|
|
|
for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) {
|
|
|
|
if ((*i)->name() == Controllable::xml_node_name) {
|
2016-04-11 16:37:51 -04:00
|
|
|
|
2016-08-28 08:07:50 -04:00
|
|
|
if (!(*i)->get_property ("name", str)) {
|
2016-04-11 16:37:51 -04:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-08-28 08:07:50 -04:00
|
|
|
if (str == _gain_control->name()) {
|
2016-03-07 14:59:40 -05:00
|
|
|
_gain_control->set_state (**i, version);
|
2016-02-29 18:12:13 -05:00
|
|
|
}
|
2016-08-28 08:07:50 -04:00
|
|
|
if (str == _solo_control->name()) {
|
2016-04-11 16:37:51 -04:00
|
|
|
_solo_control->set_state (**i, version);
|
|
|
|
}
|
2016-08-28 08:07:50 -04:00
|
|
|
if (str == _mute_control->name()) {
|
2016-04-11 16:37:51 -04:00
|
|
|
_mute_control->set_state (**i, version);
|
|
|
|
}
|
2016-04-25 11:03:08 -04:00
|
|
|
} else if ((*i)->name() == Slavable::xml_node_name) {
|
|
|
|
Slavable::set_state (**i, version);
|
2017-06-10 08:37:23 -04:00
|
|
|
} else if ((*i)->name() == Automatable::xml_node_name) {
|
|
|
|
set_automation_xml_state (**i, Evoral::Parameter(NullAutomation));
|
2016-02-29 18:12:13 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-29 15:52:27 -05:00
|
|
|
return 0;
|
|
|
|
}
|
2016-04-21 11:08:47 -04:00
|
|
|
|
|
|
|
void
|
|
|
|
VCA::clear_all_solo_state ()
|
|
|
|
{
|
|
|
|
_solo_control->clear_all_solo_state ();
|
|
|
|
}
|
2016-04-24 21:47:52 -04:00
|
|
|
|
2016-04-25 12:30:34 -04:00
|
|
|
MonitorState
|
|
|
|
VCA::monitoring_state () const
|
|
|
|
{
|
|
|
|
/* XXX this has to get more complex but not clear how */
|
|
|
|
return MonitoringInput;
|
|
|
|
}
|
2016-05-19 10:44:09 -04:00
|
|
|
|
|
|
|
bool
|
|
|
|
VCA::slaved () const
|
|
|
|
{
|
|
|
|
if (!_gain_control) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
/* just test one particular control, not all of them */
|
|
|
|
return _gain_control->slaved ();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2023-02-16 18:33:28 -05:00
|
|
|
VCA::slaved_to (std::shared_ptr<VCA> vca) const
|
2016-05-19 10:44:09 -04:00
|
|
|
{
|
|
|
|
if (!vca || !_gain_control) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* just test one particular control, not all of them */
|
|
|
|
|
|
|
|
return _gain_control->slaved_to (vca->gain_control());
|
|
|
|
}
|
2017-06-22 15:06:12 -04:00
|
|
|
|
2017-10-19 20:13:23 -04:00
|
|
|
void
|
2023-02-16 18:33:28 -05:00
|
|
|
VCA::assign (std::shared_ptr<VCA> v)
|
2017-10-19 20:13:23 -04:00
|
|
|
{
|
|
|
|
/* prevent recursive assignments */
|
|
|
|
if (assigned_to (_session.vca_manager_ptr (), v)) {
|
2020-04-13 10:09:53 -04:00
|
|
|
warning << _("Master assignment ignored to prevent recursion") << endmsg;
|
2017-10-19 20:13:23 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
Slavable::assign (v);
|
|
|
|
}
|
|
|
|
|
2023-07-19 19:24:45 -04:00
|
|
|
SlavableAutomationControlList
|
2017-06-22 15:06:12 -04:00
|
|
|
VCA::slavables () const
|
|
|
|
{
|
2023-07-19 19:24:45 -04:00
|
|
|
SlavableAutomationControlList rv;
|
2017-06-22 15:06:12 -04:00
|
|
|
rv.push_back (_gain_control);
|
|
|
|
rv.push_back (_mute_control);
|
|
|
|
rv.push_back (_solo_control);
|
|
|
|
return rv;
|
|
|
|
}
|