2 Copyright (C) 2000-2007 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_automatable_h__
21 #define __ardour_automatable_h__
25 #include <boost/shared_ptr.hpp>
26 #include <ardour/session_object.h>
27 #include <ardour/automation_list.h>
28 #include <ardour/automation_control.h>
29 #include <ardour/parameter.h>
30 #include <evoral/ControlSet.hpp>
31 #include <evoral/Sequence.hpp>
36 class AutomationControl;
39 /** Note this class is abstract, actual objects must either be
40 * an AutomatableControls or an AutomatableSequence
42 class Automatable : virtual public Evoral::ControlSet
45 Automatable(Session&);
48 virtual ~Automatable() {}
50 boost::shared_ptr<Evoral::Control>
51 control_factory(const Evoral::Parameter& id);
53 virtual void add_control(boost::shared_ptr<Evoral::Control>);
55 virtual void automation_snapshot(nframes_t now, bool force);
56 bool should_snapshot (nframes_t now) {
57 return (_last_automation_snapshot > now || (now - _last_automation_snapshot) > _automation_interval);
59 virtual void transport_stopped(nframes_t now);
61 virtual string describe_parameter(Parameter param);
63 AutoState get_parameter_automation_state (Parameter param, bool lock = true);
64 virtual void set_parameter_automation_state (Parameter param, AutoState);
66 AutoStyle get_parameter_automation_style (Parameter param);
67 void set_parameter_automation_style (Parameter param, AutoStyle);
69 void protect_automation ();
71 void what_has_visible_data(std::set<Parameter>&) const;
72 const std::set<Parameter>& what_can_be_automated() const { return _can_automate_list; }
74 void mark_automation_visible(Parameter, bool);
76 static void set_automation_interval (jack_nframes_t frames) {
77 _automation_interval = frames;
80 static jack_nframes_t automation_interval() {
81 return _automation_interval;
84 typedef Evoral::ControlSet::Controls Controls;
86 Evoral::ControlSet& data() { return *this; }
87 const Evoral::ControlSet& data() const { return *this; }
92 void can_automate(Parameter);
94 virtual void auto_state_changed (Parameter which) {}
96 int set_automation_state(const XMLNode&, Parameter default_param);
97 XMLNode& get_automation_state();
99 int load_automation (const std::string& path);
100 int old_set_automation_state(const XMLNode&);
102 std::set<Parameter> _visible_controls;
103 std::set<Parameter> _can_automate_list;
105 nframes_t _last_automation_snapshot;
106 static nframes_t _automation_interval;
110 /** Contains notes and controllers */
111 class AutomatableSequence : public Automatable, public Evoral::Sequence {
113 AutomatableSequence(Session& s, size_t size)
114 : Evoral::ControlSet()
116 , Evoral::Sequence(size)
121 /** Contains only controllers */
122 class AutomatableControls : public Automatable {
124 AutomatableControls(Session& s) : Evoral::ControlSet(), Automatable(s) {}
128 } // namespace ARDOUR
130 #endif /* __ardour_automatable_h__ */