Inrease the export "chunk size" to speed it up over 10% at least in some situations
[ardour.git] / libs / ardour / automation_control.cc
1 /*
2     Copyright (C) 2007 Paul Davis
3     Author: David 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
23 #include "ardour/automation_control.h"
24 #include "ardour/event_type_map.h"
25 #include "ardour/session.h"
26
27 using namespace std;
28 using namespace ARDOUR;
29 using namespace PBD;
30
31 AutomationControl::AutomationControl(
32                 ARDOUR::Session& session,
33                 const Evoral::Parameter& parameter,
34                 boost::shared_ptr<ARDOUR::AutomationList> list,
35                 const string& name)
36         : Controllable (name.empty() ? EventTypeMap::instance().to_symbol(parameter) : name)
37         , Evoral::Control(parameter, list)
38         , _session(session)
39 {
40 }
41
42 /** Get the current effective `user' value based on automation state */
43 double
44 AutomationControl::get_value() const
45 {
46         bool from_list = _list && ((AutomationList*)_list.get())->automation_playback();
47         return Control::get_double (from_list, _session.transport_frame());
48 }
49
50 /** Set the value and do the right thing based on automation state
51  *  (e.g. record if necessary, etc.)
52  *  @param value `user' value
53  */
54 void
55 AutomationControl::set_value(double value)
56 {
57         bool to_list = _list && _session.transport_stopped()
58                 && ((AutomationList*)_list.get())->automation_write();
59
60         if (to_list && parameter().toggled()) {
61
62                 // store the previous value just before this so any
63                 // interpolation works right
64
65                 _list->add (get_double(), _session.transport_frame()-1);
66         }
67
68         Control::set_double (value, to_list, _session.transport_frame());
69
70         Changed(); /* EMIT SIGNAL */
71 }
72
73
74 void
75 AutomationControl::set_list(boost::shared_ptr<Evoral::ControlList> list)
76 {
77         Control::set_list(list);
78         Changed();  /* EMIT SIGNAL */
79 }
80