Ardour  8.12
automation_list.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2014 David Robillard <d@drobilla.net>
3  * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com>
4  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
5  * Copyright (C) 2015-2017 Robin Gareus <robin@gareus.org>
6  * Copyright (C) 2015 Nick Mainsbridge <mainsbridge@gmail.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 
23 #ifndef __ardour_automation_event_h__
24 #define __ardour_automation_event_h__
25 
26 #include <atomic>
27 #include <cstdint>
28 #include <cstdlib>
29 #include <list>
30 #include <cmath>
31 
32 #include <glibmm/threads.h>
33 
34 #include "evoral/ControlList.h"
35 #include "evoral/Parameter.h"
36 
37 #include "pbd/undo.h"
38 #include "pbd/xml++.h"
40 #include "pbd/properties.h"
41 
42 #include "ardour/ardour.h"
43 
44 namespace ARDOUR {
45 
46 class AutomationList;
47 class BeatsSamplesConverter;
48 
51 {
52 public:
53  AutomationListProperty (PBD::PropertyDescriptor<std::shared_ptr<AutomationList> > d, Ptr p)
54  : PBD::SharedStatefulProperty<AutomationList> (d.property_id, p)
55  {}
56 
57  AutomationListProperty (PBD::PropertyDescriptor<std::shared_ptr<AutomationList> > d, Ptr o, Ptr c)
58  : PBD::SharedStatefulProperty<AutomationList> (d.property_id, o, c)
59  {}
60 
62 
63 private:
64  /* No copy-construction nor assignment */
67 };
68 
74 {
75 public:
80  AutomationList (const AutomationList&, timepos_t const & start, timepos_t const & end);
82 
83  virtual std::shared_ptr<ControlList> create(const Evoral::Parameter& id,
84  const Evoral::ParameterDescriptor& desc,
86 
87  AutomationList& operator= (const AutomationList&);
88 
89  void thaw ();
90 
93  PBD::Signal1<void, AutoState> automation_state_changed;
94 
95  bool automation_playback() const {
96  return (_state & Play) || ((_state & (Touch | Latch)) && !touching());
97  }
98  bool automation_write () const {
99  return ((_state & Write) || ((_state & (Touch | Latch)) && touching()));
100  }
101 
102  PBD::Signal0<void> StateChanged;
103 
104  static PBD::Signal1<void,AutomationList*> AutomationListCreated;
105 
106  void start_write_pass (timepos_t const & when);
107  void write_pass_finished (timepos_t const & when, double thinning_factor=0.0);
108 
109  void start_touch (timepos_t const & when);
110  void stop_touch (timepos_t const & when);
111 
112  bool touching () const { return _touching.load() != 0; }
113  bool writing () const { return _state == Write; }
114  bool touch_enabled () const { return _state & (Touch | Latch); }
115 
116  XMLNode& get_state () const;
117  int set_state (const XMLNode &, int version);
118 
120 
121  bool operator!= (const AutomationList &) const;
122 
123  XMLNode* before () { XMLNode* rv = _before; _before = 0; return rv; }
124  void clear_history ();
125  void snapshot_history (bool need_lock);
126 
127  ControlList::InterpolationStyle default_interpolation () const;
128 
129 private:
132 
133  XMLNode& state (bool save_auto_state, bool need_lock) const;
134  XMLNode& serialize_events (bool need_lock) const;
135 
137 
139  std::atomic<int> _touching;
140 
142 
143  bool operator== (const AutomationList&) const { /* not called */ abort(); return false; }
144  XMLNode* _before; //used for undo of touch start/stop pairs.
145 
146 };
147 
148 } // namespace
149 
150 #endif /* __ardour_automation_event_h__ */
AutomationListProperty(PBD::PropertyDescriptor< std::shared_ptr< AutomationList > > d, Ptr p)
PBD::PropertyBase * clone() const
AutomationListProperty(PBD::PropertyDescriptor< std::shared_ptr< AutomationList > > d, Ptr o, Ptr c)
AutomationListProperty(AutomationListProperty const &)
PBD::Signal1< void, AutoState > automation_state_changed
std::atomic< int > _touching
ControlList::InterpolationStyle default_interpolation() const
void snapshot_history(bool need_lock)
XMLNode & serialize_events(bool need_lock) const
PBD::ScopedConnection _writepass_connection
bool automation_write() const
XMLNode & get_state() const
int set_state(const XMLNode &, int version)
void set_automation_state(AutoState)
PBD::Signal0< void > StateChanged
virtual std::shared_ptr< ControlList > create(const Evoral::Parameter &id, const Evoral::ParameterDescriptor &desc, Temporal::TimeDomainProvider const &)
void stop_touch(timepos_t const &when)
AutoState automation_state() const
AutomationList(const AutomationList &)
int deserialize_events(const XMLNode &)
void write_pass_finished(timepos_t const &when, double thinning_factor=0.0)
AutomationList(const AutomationList &, timepos_t const &start, timepos_t const &end)
XMLNode & state(bool save_auto_state, bool need_lock) const
AutomationList(const Evoral::Parameter &id, const Evoral::ParameterDescriptor &desc, Temporal::TimeDomainProvider const &)
void start_write_pass(timepos_t const &when)
bool automation_playback() const
AutomationList(const Evoral::Parameter &id, Temporal::TimeDomainProvider const &)
AutomationList(const XMLNode &, Evoral::Parameter id)
static PBD::Signal1< void, AutomationList * > AutomationListCreated
void start_touch(timepos_t const &when)
PBD::Command * memento_command(XMLNode *before, XMLNode *after)
std::shared_ptr< AutomationList > Ptr
Definition: properties.h:375
Definition: xml++.h:114
#define LIBARDOUR_API
PBD::PropertyDescriptor< timepos_t > start
Definition: axis_view.h:42
bool operator==(const ProcessorSelection &a, const ProcessorSelection &b)