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 typedef std::map<Parameter,boost::shared_ptr<AutomationControl> > Controls;
53 Controls controls() { return _controls; }
55 virtual void add_control(boost::shared_ptr<AutomationControl>);
57 virtual void automation_snapshot(nframes_t now);
58 virtual void transport_stopped(nframes_t now);
60 virtual bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const;
62 virtual string describe_parameter(Parameter param);
63 virtual float default_parameter_value(Parameter param) { return 1.0f; }
65 virtual void clear_automation();
67 AutoState get_parameter_automation_state (Parameter param, bool lock = true);
68 virtual void set_parameter_automation_state (Parameter param, AutoState);
70 AutoStyle get_parameter_automation_style (Parameter param);
71 void set_parameter_automation_style (Parameter param, AutoStyle);
73 void protect_automation ();
75 void what_has_automation(std::set<Parameter>&) const;
76 void what_has_visible_automation(std::set<Parameter>&) const;
77 const std::set<Parameter>& what_can_be_automated() const { return _can_automate_list; }
79 void mark_automation_visible(Parameter, bool);
83 void can_automate(Parameter);
85 virtual void auto_state_changed (Parameter which) {}
87 int set_automation_state(const XMLNode&, Parameter default_param);
88 XMLNode& get_automation_state();
90 int load_automation (const std::string& path);
91 int old_set_automation_state(const XMLNode&);
93 mutable Glib::Mutex _automation_lock;
96 std::set<Parameter> _visible_controls;
97 std::set<Parameter> _can_automate_list;
99 nframes_t _last_automation_snapshot;
102 } // namespace ARDOUR
104 #endif /* __ardour_automatable_h__ */