2 Copyright (C) 2006-2016 Paul Davis
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2 of the License, or (at your option)
9 This program is distributed in the hope that it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 675 Mass Ave, Cambridge, MA 02139, USA.
19 #ifndef __ardour_gain_control_h__
20 #define __ardour_gain_control_h__
25 #include <boost/shared_ptr.hpp>
26 #include <glibmm/threads.h>
28 #include "pbd/controllable.h"
30 #include "evoral/Parameter.hpp"
32 #include "ardour/automation_control.h"
33 #include "ardour/libardour_visibility.h"
39 class LIBARDOUR_API GainControl : public AutomationControl {
41 GainControl (Session& session, const Evoral::Parameter ¶m,
42 boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>());
44 double get_value () const;
45 void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
46 void set_value_unchecked (double);
48 double internal_to_interface (double) const;
49 double interface_to_internal (double) const;
50 double internal_to_user (double) const;
51 double user_to_internal (double) const;
52 std::string get_user_string () const;
57 gain_t get_master_gain () const;
58 void add_master (boost::shared_ptr<VCA>);
59 void remove_master (boost::shared_ptr<VCA>);
60 void clear_masters ();
61 bool slaved_to (boost::shared_ptr<VCA>) const;
63 std::vector<uint32_t> masters () const;
65 PBD::Signal0<void> VCAStatusChange;
67 int set_state (XMLNode const&, int);
73 MasterRecord (boost::shared_ptr<GainControl> gc, uint32_t n, double r)
79 boost::shared_ptr<GainControl> master() const { return _master; }
80 double ratio () const { return _ratio; }
81 uint32_t number() const { return _number; }
83 bool operator== (MasterRecord const& other) const {
84 return _number == other._number;
87 bool operator< (MasterRecord const& other) const {
88 return _number < other._number;
91 void reset_ratio (double r) { _ratio = r; }
94 const boost::shared_ptr<GainControl> _master;
95 const uint32_t _number;
99 mutable Glib::Threads::RWLock master_lock;
100 typedef std::set<MasterRecord> Masters;
102 PBD::ScopedConnectionList masters_connections;
103 std::string _masters_state_string ();
105 gain_t get_master_gain_locked () const;
106 void master_going_away (boost::weak_ptr<VCA>);
107 void recompute_masters_ratios (double val);
109 void _set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
114 #endif /* __ardour_gain_control_h__ */