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__
26 #include <boost/shared_ptr.hpp>
27 #include "evoral/ControlSet.hpp"
28 #include "ardour/types.h"
35 class AutomationControl;
38 /** Note this class is abstract, actual objects must either be
39 * an AutomatableControls or an AutomatableSequence
41 class Automatable : virtual public Evoral::ControlSet
44 Automatable(Session&);
45 Automatable (const Automatable& other);
48 virtual ~Automatable() {}
50 boost::shared_ptr<Evoral::Control>
51 control_factory(const Evoral::Parameter& id);
53 boost::shared_ptr<AutomationControl>
54 automation_control (const Evoral::Parameter& id, bool create_if_missing=false);
56 boost::shared_ptr<const AutomationControl>
57 automation_control (const Evoral::Parameter& id) const;
59 virtual void add_control(boost::shared_ptr<Evoral::Control>);
61 virtual void automation_snapshot(nframes_t now, bool force);
62 virtual void transport_stopped (sframes_t now);
64 virtual std::string describe_parameter(Evoral::Parameter param);
66 AutoState get_parameter_automation_state (Evoral::Parameter param, bool lock = true);
67 virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
69 AutoStyle get_parameter_automation_style (Evoral::Parameter param);
70 void set_parameter_automation_style (Evoral::Parameter param, AutoStyle);
72 void protect_automation ();
74 void what_has_visible_data(std::set<Evoral::Parameter>&) const;
75 const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; }
77 void mark_automation_visible(Evoral::Parameter, bool);
79 inline bool should_snapshot (nframes_t now) {
80 return (_last_automation_snapshot > now
81 || (now - _last_automation_snapshot) > _automation_interval);
84 static void set_automation_interval (jack_nframes_t frames) {
85 _automation_interval = frames;
88 static jack_nframes_t automation_interval() {
89 return _automation_interval;
92 typedef Evoral::ControlSet::Controls Controls;
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*/) {}
104 int load_automation (const std::string& path);
105 int old_set_automation_state(const XMLNode&);
107 std::set<Evoral::Parameter> _visible_controls;
108 std::set<Evoral::Parameter> _can_automate_list;
110 nframes_t _last_automation_snapshot;
111 static nframes_t _automation_interval;
115 } // namespace ARDOUR
117 #endif /* __ardour_automatable_h__ */