2 * Copyright (C) 2016-2017 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2017 Robin Gareus <robin@gareus.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #include "pbd/convert.h"
23 #include "pbd/strsplit.h"
25 #include "evoral/Curve.hpp"
27 #include "ardour/dB.h"
28 #include "ardour/gain_control.h"
29 #include "ardour/session.h"
30 #include "ardour/vca.h"
31 #include "ardour/vca_manager.h"
35 using namespace ARDOUR;
38 GainControl::GainControl (Session& session, const Evoral::Parameter ¶m, boost::shared_ptr<AutomationList> al)
39 : SlavableAutomationControl (session, param, ParameterDescriptor(param),
40 al ? al : boost::shared_ptr<AutomationList> (new AutomationList (param)),
41 param.type() == GainAutomation ? X_("gaincontrol") : X_("trimcontrol"),
42 Controllable::GainLike)
47 GainControl::inc_gain (gain_t factor)
49 /* To be used ONLY when doing group-relative gain adjustment, from
50 * ControlGroup::set_group_values().
53 const float desired_gain = get_value ();
55 if (fabsf (desired_gain) < GAIN_COEFF_SMALL) {
56 // really?! what's the idea here?
57 actually_set_value (0.000001f + (0.000001f * factor), Controllable::ForGroup);
59 actually_set_value (desired_gain + (desired_gain * factor), Controllable::ForGroup);
64 GainControl::post_add_master (boost::shared_ptr<AutomationControl> m)
66 if (m->get_value() == 0) {
67 /* master is at -inf, which forces this ctrl to -inf on assignment */
68 Changed (false, Controllable::NoGroup); /* EMIT SIGNAL */
73 GainControl::get_masters_curve_locked (samplepos_t start, samplepos_t end, float* vec, samplecnt_t veclen) const
75 if (_masters.empty()) {
76 return list()->curve().rt_safe_get_vector (start, end, vec, veclen);
78 for (samplecnt_t i = 0; i < veclen; ++i) {
81 return SlavableAutomationControl::masters_curve_multiply (start, end, vec, veclen);