Ardour  8.12
automatable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2011 David Robillard <d@drobilla.net>
3  * Copyright (C) 2007-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2015-2018 Robin Gareus <robin@gareus.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef __ardour_automatable_h__
23 #define __ardour_automatable_h__
24 
25 #include <map>
26 #include <memory>
27 #include <set>
28 #include <string>
29 
30 
31 #include "pbd/rcu.h"
32 #include "pbd/signals.h"
33 #include "pbd/controllable.h"
34 
35 #include "evoral/ControlSet.h"
36 
38 
40 #include "ardour/slavable.h"
41 #include "ardour/types.h"
42 
43 class XMLNode;
44 
45 namespace ARDOUR {
46 
47 class Session;
48 class AutomationControl;
49 
50 /* The inherited ControlSet is virtual because AutomatableSequence inherits
51  * from this AND EvoralSequence, which is also a ControlSet
52  */
54 {
55 public:
57  Automatable (const Automatable& other);
58 
59  virtual ~Automatable();
60 
61  virtual void automatables (PBD::ControllableSet&) const;
62 
63  static bool skip_saving_automation; // to be used only by session-state
64 
65  std::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
66 
67  std::shared_ptr<AutomationControl> automation_control (PBD::ID const & id) const;
68  /* derived classes need to provide some way to search their own child
69  automatable's for a control. normally, we'd just make the method
70  above virtual, and let them override it. But that wouldn't
71  differentiate the "check children" and "just your own" cases.
72 
73  We could theoretically just overload the above method with an extra
74  "bool recurse = default", but the rules of name hiding for C++ mean
75  that making a method virtual will hide other overloaded versions of
76  the same name. This means that virtual automation_control (PBD::ID
77  const &) would hide automation_control (Evoral::Parameter const &
78  id).
79 
80  So, skip around all that with a different name.
81  */
82  virtual std::shared_ptr<AutomationControl> automation_control_recurse (PBD::ID const & id) const {
83  return automation_control (id);
84  }
85 
86  std::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id) {
87  return automation_control (id, false);
88  }
89  std::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id, bool create_if_missing);
90  std::shared_ptr<const AutomationControl> automation_control (const Evoral::Parameter& id) const;
91 
92  virtual void add_control(std::shared_ptr<Evoral::Control>);
93  virtual bool find_next_event (Temporal::timepos_t const & start, Temporal::timepos_t const & end, Evoral::ControlEvent& ev, bool only_active = true) const;
94  void clear_controls ();
95 
96  virtual void non_realtime_locate (samplepos_t now);
97  virtual void non_realtime_transport_stop (samplepos_t now, bool flush);
98 
99  virtual void automation_run (samplepos_t, pframes_t, bool only_active = false);
100 
101  virtual std::string describe_parameter(Evoral::Parameter param);
102 
105 
107 
108  const std::set<Evoral::Parameter>& what_can_be_automated() const { return _can_automate_list; }
109 
111  std::vector<Evoral::Parameter> all_automatable_params () const;
112 
113  void what_has_existing_automation (std::set<Evoral::Parameter>&) const;
114 
115  static const std::string xml_node_name;
116 
119 
120  PBD::Signal0<void> AutomationStateChanged;
121 
124 
125  static void find_next_ac_event (std::shared_ptr<AutomationControl>, Temporal::timepos_t const & start, Temporal::timepos_t const & end, Evoral::ControlEvent& ev);
126  static void find_prev_ac_event (std::shared_ptr<AutomationControl>, Temporal::timepos_t const & start, Temporal::timepos_t const & end, Evoral::ControlEvent& ev);
127 
128 protected:
130 
132 
135 
136  int load_automation (const std::string& path);
138 
139  std::set<Evoral::Parameter> _can_automate_list;
140 
142 
144 
145 private:
147 };
148 
149 
150 } // namespace ARDOUR
151 
152 #endif /* __ardour_automatable_h__ */
virtual bool find_next_event(Temporal::timepos_t const &start, Temporal::timepos_t const &end, Evoral::ControlEvent &ev, bool only_active=true) const
std::shared_ptr< const AutomationControl > automation_control(const Evoral::Parameter &id) const
virtual std::string describe_parameter(Evoral::Parameter param)
SlavableAutomationControlList slavables() const
Definition: automatable.h:143
static const std::string xml_node_name
Definition: automatable.h:115
PBD::ScopedConnectionList _control_connections
connections to our controls' signals
Definition: automatable.h:146
int old_set_automation_state(const XMLNode &)
SerializedRCUManager< AutomationControlList > _automated_controls
Definition: automatable.h:134
const std::set< Evoral::Parameter > & what_can_be_automated() const
Definition: automatable.h:108
std::set< Evoral::Parameter > _can_automate_list
Definition: automatable.h:139
std::shared_ptr< AutomationControl > automation_control(const Evoral::Parameter &id)
Definition: automatable.h:86
virtual void automation_run(samplepos_t, pframes_t, bool only_active=false)
virtual void set_parameter_automation_state(Evoral::Parameter param, AutoState)
virtual void automatables(PBD::ControllableSet &) const
std::vector< Evoral::Parameter > all_automatable_params() const
void start_domain_bounce(Temporal::DomainBounceInfo &)
virtual void non_realtime_transport_stop(samplepos_t now, bool flush)
std::shared_ptr< AutomationControl > automation_control(const Evoral::Parameter &id, bool create_if_missing)
void finish_domain_bounce(Temporal::DomainBounceInfo &)
virtual void automation_list_automation_state_changed(Evoral::Parameter const &, AutoState)
samplepos_t _last_automation_snapshot
Definition: automatable.h:141
virtual ~Automatable()
Automatable(const Automatable &other)
static void find_prev_ac_event(std::shared_ptr< AutomationControl >, Temporal::timepos_t const &start, Temporal::timepos_t const &end, Evoral::ControlEvent &ev)
std::shared_ptr< Evoral::Control > control_factory(const Evoral::Parameter &id)
Session & _a_session
Definition: automatable.h:129
int set_automation_xml_state(const XMLNode &, Evoral::Parameter default_param)
static void find_next_ac_event(std::shared_ptr< AutomationControl >, Temporal::timepos_t const &start, Temporal::timepos_t const &end, Evoral::ControlEvent &ev)
AutoState get_parameter_automation_state(Evoral::Parameter param)
PBD::Signal0< void > AutomationStateChanged
Definition: automatable.h:120
void can_automate(Evoral::Parameter)
virtual void non_realtime_locate(samplepos_t now)
std::shared_ptr< AutomationControl > automation_control(PBD::ID const &id) const
virtual std::shared_ptr< AutomationControl > automation_control_recurse(PBD::ID const &id) const
Definition: automatable.h:82
XMLNode & get_automation_xml_state() const
int load_automation(const std::string &path)
void what_has_existing_automation(std::set< Evoral::Parameter > &) const
virtual void add_control(std::shared_ptr< Evoral::Control >)
static bool skip_saving_automation
Definition: automatable.h:63
Automatable(Session &, Temporal::TimeDomainProvider const &)
Definition: id.h:35
Definition: xml++.h:114
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
uint32_t pframes_t
std::list< std::shared_ptr< SlavableAutomationControl > > SlavableAutomationControlList
Temporal::samplepos_t samplepos_t
void flush()
std::set< std::shared_ptr< Controllable > > ControllableSet
Definition: controllable.h:41