2 Copyright (C) 2007 Paul Davis
3 Author: David Robillard
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
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include "ardour/automation_control.h"
24 #include "ardour/automation_watch.h"
25 #include "ardour/event_type_map.h"
26 #include "ardour/session.h"
29 using namespace ARDOUR;
32 AutomationControl::AutomationControl(ARDOUR::Session& session,
33 const Evoral::Parameter& parameter,
34 const ParameterDescriptor& desc,
35 boost::shared_ptr<ARDOUR::AutomationList> list,
37 : Controllable (name.empty() ? EventTypeMap::instance().to_symbol(parameter) : name)
38 , Evoral::Control(parameter, desc, list)
44 AutomationControl::~AutomationControl ()
48 /** Get the current effective `user' value based on automation state */
50 AutomationControl::get_value() const
52 bool from_list = _list && ((AutomationList*)_list.get())->automation_playback();
53 return Control::get_double (from_list, _session.transport_frame());
56 /** Set the value and do the right thing based on automation state
57 * (e.g. record if necessary, etc.)
58 * @param value `user' value
61 AutomationControl::set_value (double value)
63 bool to_list = _list && ((AutomationList*)_list.get())->automation_write();
65 Control::set_double (value, _session.transport_frame(), to_list);
67 Changed(); /* EMIT SIGNAL */
71 AutomationControl::set_list (boost::shared_ptr<Evoral::ControlList> list)
73 Control::set_list (list);
74 Changed(); /* EMIT SIGNAL */
78 AutomationControl::set_automation_state (AutoState as)
80 if (_list && as != alist()->automation_state()) {
82 alist()->set_automation_state (as);
85 AutomationWatch::instance().add_automation_watch (shared_from_this());
86 } else if (as == Touch) {
88 AutomationWatch::instance().remove_automation_watch (shared_from_this());
90 /* this seems unlikely, but the combination of
91 * a control surface and the mouse could make
92 * it possible to put the control into Touch
93 * mode *while* touching it.
95 AutomationWatch::instance().add_automation_watch (shared_from_this());
98 AutomationWatch::instance().remove_automation_watch (shared_from_this());
104 AutomationControl::set_automation_style (AutoStyle as)
106 alist()->set_automation_style (as);
110 AutomationControl::start_touch(double when)
114 if (alist()->automation_state() == Touch) {
115 alist()->start_touch (when);
116 AutomationWatch::instance().add_automation_watch (shared_from_this());
123 AutomationControl::stop_touch(bool mark, double when)
127 set_touching (false);
128 if (alist()->automation_state() == Touch) {
129 alist()->stop_touch (mark, when);
130 AutomationWatch::instance().remove_automation_watch (shared_from_this());