Factor out sequencing related things into an independant new library: "evoral".
[ardour.git] / libs / ardour / automation_control.cc
1 /*
2     Copyright (C) 2007 Paul Davis 
3     Author: Dave Robillard
4
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.
9
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.
14
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.
18
19 */
20
21 #include <iostream>
22 #include <ardour/automation_control.h>
23 #include <ardour/session.h>
24 #include <ardour/automatable.h>
25 #include <ardour/midi_track.h>
26
27 using namespace std;
28 using namespace ARDOUR;
29 using namespace PBD;
30
31
32 AutomationControl::AutomationControl(Session& session, boost::shared_ptr<AutomationList> list, string name)
33         : Controllable((name == "unnamed controllable") ? list->parameter().symbol() : name)
34         , Evoral::Control(list)
35         , _session(session)
36 {
37 }
38
39
40 /** Get the currently effective value (ie the one that corresponds to current output)
41  */
42 float
43 AutomationControl::get_value() const
44 {
45         bool from_list = ((AutomationList*)_list.get())->automation_playback();
46         return Control::get_value(from_list, _session.transport_frame());
47 }
48
49
50 void
51 AutomationControl::set_value(float value)
52 {
53         bool to_list = _session.transport_stopped()
54                 && ((AutomationList*)_list.get())->automation_playback();
55         
56         Control::set_value(value, to_list, _session.transport_frame());
57
58         Changed(); /* EMIT SIGNAL */
59 }
60
61
62 void
63 AutomationControl::set_list(boost::shared_ptr<Evoral::ControlList> list)
64 {
65         Control::set_list(list);
66         Changed();  /* EMIT SIGNAL */
67 }
68