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/event_type_map.h>
27 #include <evoral/ControlSet.hpp>
28 #include <evoral/Sequence.hpp>
33 class AutomationControl;
36 /** Note this class is abstract, actual objects must either be
37 * an AutomatableControls or an AutomatableSequence
39 class Automatable : virtual public Evoral::ControlSet
42 Automatable(Session&);
45 virtual ~Automatable() {}
47 boost::shared_ptr<Evoral::Control>
48 control_factory(const Evoral::Parameter& id);
50 boost::shared_ptr<AutomationControl>
51 automation_control (const Evoral::Parameter& id, bool create_if_missing=false);
53 boost::shared_ptr<const AutomationControl>
54 automation_control (const Evoral::Parameter& id) const;
56 virtual void add_control(boost::shared_ptr<Evoral::Control>);
58 virtual void automation_snapshot(nframes_t now, bool force);
59 virtual void transport_stopped(nframes_t now);
61 virtual string describe_parameter(Evoral::Parameter param);
63 AutoState get_parameter_automation_state (Evoral::Parameter param, bool lock = true);
64 virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
66 AutoStyle get_parameter_automation_style (Evoral::Parameter param);
67 void set_parameter_automation_style (Evoral::Parameter param, AutoStyle);
69 void protect_automation ();
71 void what_has_visible_data(std::set<Evoral::Parameter>&) const;
72 const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; }
74 void mark_automation_visible(Evoral::Parameter, bool);
76 inline bool should_snapshot (nframes_t now) {
77 return (_last_automation_snapshot > now
78 || (now - _last_automation_snapshot) > _automation_interval);
81 static void set_automation_interval (jack_nframes_t frames) {
82 _automation_interval = frames;
85 static jack_nframes_t automation_interval() {
86 return _automation_interval;
89 typedef Evoral::ControlSet::Controls Controls;
91 Evoral::ControlSet& data() { return *this; }
92 const Evoral::ControlSet& data() const { return *this; }
94 int set_automation_state (const XMLNode&, Evoral::Parameter default_param);
95 XMLNode& get_automation_state();
100 void can_automate(Evoral::Parameter);
102 virtual void auto_state_changed (Evoral::Parameter which) {}
105 int load_automation (const std::string& path);
106 int old_set_automation_state(const XMLNode&);
108 std::set<Evoral::Parameter> _visible_controls;
109 std::set<Evoral::Parameter> _can_automate_list;
111 nframes_t _last_automation_snapshot;
112 static nframes_t _automation_interval;
116 /** Contains notes and controllers */
118 class AutomatableSequence : public Automatable, public Evoral::Sequence<T> {
120 AutomatableSequence(Session& s, size_t size)
121 : Evoral::ControlSet()
123 , Evoral::Sequence<T>(EventTypeMap::instance())
128 /** Contains only controllers */
129 class AutomatableControls : public Automatable {
131 AutomatableControls(Session& s) : Evoral::ControlSet(), Automatable(s) {}
135 } // namespace ARDOUR
137 #endif /* __ardour_automatable_h__ */