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_event.h>
28 #include <ardour/automation_control.h>
29 #include <ardour/parameter.h>
34 class AutomationControl;
36 class Automatable : public SessionObject
39 Automatable(Session&, const std::string& name);
41 virtual ~Automatable() {}
43 // shorthand for gain, pan, etc
44 inline boost::shared_ptr<AutomationControl>
45 control(AutomationType type, bool create_if_missing=false) {
46 return control(Parameter(type), create_if_missing);
49 virtual boost::shared_ptr<AutomationControl> control(Parameter id, bool create_if_missing=false);
50 virtual boost::shared_ptr<const AutomationControl> control(Parameter id) const;
52 boost::shared_ptr<AutomationControl> control_factory(boost::shared_ptr<AutomationList> list);
54 typedef std::map<Parameter,boost::shared_ptr<AutomationControl> > Controls;
55 Controls& controls() { return _controls; }
56 const Controls& controls() const { return _controls; }
58 virtual void add_control(boost::shared_ptr<AutomationControl>);
60 virtual void automation_snapshot(nframes_t now, bool force);
61 bool should_snapshot (nframes_t now) {
62 return (_last_automation_snapshot > now || (now - _last_automation_snapshot) > _automation_interval);
64 virtual void transport_stopped(nframes_t now);
66 virtual bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const;
68 virtual string describe_parameter(Parameter param);
69 static string get_name_for_cc_number (uint32_t cc_number);
70 virtual float default_parameter_value(Parameter param) { return 1.0f; }
72 virtual void clear_automation();
74 AutoState get_parameter_automation_state (Parameter param, bool lock = true);
75 virtual void set_parameter_automation_state (Parameter param, AutoState);
77 AutoStyle get_parameter_automation_style (Parameter param);
78 void set_parameter_automation_style (Parameter param, AutoStyle);
80 void protect_automation ();
82 void what_has_automation(std::set<Parameter>&) const;
83 void what_has_visible_automation(std::set<Parameter>&) const;
84 const std::set<Parameter>& what_can_be_automated() const { return _can_automate_list; }
86 void mark_automation_visible(Parameter, bool);
88 Glib::Mutex& automation_lock() const { return _automation_lock; }
90 static void set_automation_interval (jack_nframes_t frames) {
91 _automation_interval = frames;
94 static jack_nframes_t automation_interval() {
95 return _automation_interval;
100 void can_automate(Parameter);
102 virtual void auto_state_changed (Parameter which) {}
104 int set_automation_state(const XMLNode&, Parameter default_param);
105 XMLNode& get_automation_state();
107 int load_automation (const std::string& path);
108 int old_set_automation_state(const XMLNode&);
110 mutable Glib::Mutex _automation_lock;
113 std::set<Parameter> _visible_controls;
114 std::set<Parameter> _can_automate_list;
116 nframes_t _last_automation_snapshot;
117 static nframes_t _automation_interval;
120 } // namespace ARDOUR
122 #endif /* __ardour_automatable_h__ */