2 Copyright (C) 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 #include "ardour/phase_control.h"
20 #include "ardour/session.h"
26 using namespace ARDOUR;
28 PhaseControl::PhaseControl (Session& session, std::string const & name)
29 : AutomationControl (session, PhaseAutomation, ParameterDescriptor (PhaseAutomation),
30 boost::shared_ptr<AutomationList>(new AutomationList(Evoral::Parameter(PhaseAutomation))),
36 PhaseControl::actually_set_value (double val, Controllable::GroupControlDisposition gcd)
38 _phase_invert = boost::dynamic_bitset<> (std::numeric_limits<double>::digits, (unsigned long) val);
40 AutomationControl::actually_set_value (val, gcd);
43 /** @param c Audio channel index.
44 * @param yn true to invert phase, otherwise false.
47 PhaseControl::set_phase_invert (uint32_t c, bool yn)
49 if (_phase_invert[c] != yn) {
50 _phase_invert[c] = yn;
51 AutomationControl::actually_set_value (_phase_invert.to_ulong(), Controllable::NoGroup);
56 PhaseControl::set_phase_invert (boost::dynamic_bitset<> p)
58 if (_phase_invert != p) {
60 AutomationControl::actually_set_value (_phase_invert.to_ulong(), Controllable::NoGroup);
65 PhaseControl::resize (uint32_t n)
67 _phase_invert.resize (n);
71 PhaseControl::get_state ()
73 XMLNode& node (AutomationControl::get_state ());
76 boost::to_string (_phase_invert, p);
77 node.set_property ("phase-invert", p);
83 PhaseControl::set_state (XMLNode const & node, int version)
85 AutomationControl::set_state (node, version);
88 if (node.get_property (X_("phase-invert"), str)) {
89 set_phase_invert (boost::dynamic_bitset<> (str));