Ardour  9.2-567-gf42f34d25f
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 #pragma once
23 
24 #include <map>
25 #include <memory>
26 #include <set>
27 #include <string>
28 
29 
30 #include "pbd/rcu.h"
31 #include "pbd/signals.h"
32 #include "pbd/controllable.h"
33 
34 #include "evoral/ControlSet.h"
35 
37 
39 #include "ardour/slavable.h"
40 #include "ardour/types.h"
41 
42 class XMLNode;
43 
44 namespace ARDOUR {
45 
46 class Session;
47 class AutomationControl;
48 
49 /* The inherited ControlSet is virtual because AutomatableSequence inherits
50  * from this AND EvoralSequence, which is also a ControlSet
51  */
53 {
54 public:
56  Automatable (const Automatable& other);
57 
58  virtual ~Automatable();
59 
60  virtual void automatables (PBD::ControllableSet&) const;
61 
62  static bool skip_saving_automation; // to be used only by session-state
63 
64  std::shared_ptr<Evoral::Control> control_factory(const Evoral::Parameter& id);
65 
66  std::shared_ptr<AutomationControl> automation_control (PBD::ID const & id) const;
67  /* derived classes need to provide some way to search their own child
68  automatable's for a control. normally, we'd just make the method
69  above virtual, and let them override it. But that wouldn't
70  differentiate the "check children" and "just your own" cases.
71 
72  We could theoretically just overload the above method with an extra
73  "bool recurse = default", but the rules of name hiding for C++ mean
74  that making a method virtual will hide other overloaded versions of
75  the same name. This means that virtual automation_control (PBD::ID
76  const &) would hide automation_control (Evoral::Parameter const &
77  id).
78 
79  So, skip around all that with a different name.
80  */
81  virtual std::shared_ptr<AutomationControl> automation_control_recurse (PBD::ID const & id) const {
82  return automation_control (id);
83  }
84 
85  std::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id) {
86  return automation_control (id, false);
87  }
88  std::shared_ptr<AutomationControl> automation_control (const Evoral::Parameter& id, bool create_if_missing);
89  std::shared_ptr<const AutomationControl> automation_control (const Evoral::Parameter& id) const;
90 
91  virtual void add_control(std::shared_ptr<Evoral::Control>);
92  virtual bool find_next_event (Temporal::timepos_t const & start, Temporal::timepos_t const & end, Evoral::ControlEvent& ev, bool only_active = true) const;
93  void clear_controls ();
94 
95  virtual void non_realtime_locate (samplepos_t now);
96  virtual void non_realtime_transport_stop (samplepos_t now, bool flush);
97 
98  virtual void automation_run (samplepos_t, pframes_t, bool only_active = false);
99 
100  virtual std::string describe_parameter(Evoral::Parameter param);
101  std::string get_parameter_name (Evoral::Parameter param) const;
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 
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  std::string get_parameter_string (Evoral::Parameter param, bool just_name) const;
129 
130 protected:
132 
134 
137 
138  int load_automation (const std::string& path);
140 
141  std::set<Evoral::Parameter> _can_automate_list;
142 
144 
146 
147 private:
149 };
150 
151 
152 } // namespace ARDOUR
153 
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:145
static const std::string xml_node_name
Definition: automatable.h:115
PBD::ScopedConnectionList _control_connections
connections to our controls' signals
Definition: automatable.h:148
std::string get_parameter_name(Evoral::Parameter param) const
int old_set_automation_state(const XMLNode &)
SerializedRCUManager< AutomationControlList > _automated_controls
Definition: automatable.h:136
PBD::Signal< void()> AutomationStateChanged
Definition: automatable.h:120
std::string get_parameter_string(Evoral::Parameter param, bool just_name) const
const std::set< Evoral::Parameter > & what_can_be_automated() const
Definition: automatable.h:108
std::set< Evoral::Parameter > _can_automate_list
Definition: automatable.h:141
std::shared_ptr< AutomationControl > automation_control(const Evoral::Parameter &id)
Definition: automatable.h:85
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:143
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:131
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)
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:81
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:62
Automatable(Session &, Temporal::TimeDomainProvider const &)
Definition: id.h:33
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:39