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 "pbd/signals.h"
28 #include "evoral/ControlSet.hpp"
29 #include "ardour/types.h"
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&);
46 Automatable (const Automatable& other);
49 virtual ~Automatable() {}
51 boost::shared_ptr<Evoral::Control>
52 control_factory(const Evoral::Parameter& id);
54 boost::shared_ptr<AutomationControl>
55 automation_control (const Evoral::Parameter& id, bool create_if_missing=false);
57 boost::shared_ptr<const AutomationControl>
58 automation_control (const Evoral::Parameter& id) const;
60 virtual void add_control(boost::shared_ptr<Evoral::Control>);
61 void clear_controls ();
63 virtual void automation_snapshot(nframes_t now, bool force);
64 virtual void transport_stopped (framepos_t now);
66 virtual std::string describe_parameter(Evoral::Parameter param);
68 AutoState get_parameter_automation_state (Evoral::Parameter param);
69 virtual void set_parameter_automation_state (Evoral::Parameter param, AutoState);
71 AutoStyle get_parameter_automation_style (Evoral::Parameter param);
72 void set_parameter_automation_style (Evoral::Parameter param, AutoStyle);
74 void protect_automation ();
76 void what_has_visible_data(std::set<Evoral::Parameter>&) const;
77 const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; }
79 void mark_automation_visible(Evoral::Parameter, bool);
81 inline bool should_snapshot (nframes_t now) {
82 return (_last_automation_snapshot > now
83 || (now - _last_automation_snapshot) > _automation_interval);
86 static void set_automation_interval (jack_nframes_t frames) {
87 _automation_interval = frames;
90 static jack_nframes_t automation_interval() {
91 return _automation_interval;
94 typedef Evoral::ControlSet::Controls Controls;
96 int set_automation_xml_state (const XMLNode&, Evoral::Parameter default_param);
97 XMLNode& get_automation_xml_state();
102 void can_automate(Evoral::Parameter);
104 virtual void automation_list_automation_state_changed (Evoral::Parameter, AutoState) {}
106 int load_automation (const std::string& path);
107 int old_set_automation_state(const XMLNode&);
109 std::set<Evoral::Parameter> _visible_controls;
110 std::set<Evoral::Parameter> _can_automate_list;
112 nframes_t _last_automation_snapshot;
113 static nframes_t _automation_interval;
116 PBD::ScopedConnectionList _control_connections; ///< connections to our controls' signals
120 } // namespace ARDOUR
122 #endif /* __ardour_automatable_h__ */