Ardour  9.2-129-gdf5e1050bd
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 #pragma once
24 
25 #include <atomic>
26 #include <cstdint>
27 #include <cstdlib>
28 #include <list>
29 #include <cmath>
30 
31 #include "evoral/ControlList.h"
32 #include "evoral/Parameter.h"
33 
34 #include "pbd/undo.h"
35 #include "pbd/xml++.h"
37 #include "pbd/properties.h"
38 
39 #include "ardour/ardour.h"
40 
41 namespace ARDOUR {
42 
43 class AutomationList;
44 
47 {
48 public:
49  AutomationListProperty (PBD::PropertyDescriptor<std::shared_ptr<AutomationList> > d, Ptr p)
50  : PBD::SharedStatefulProperty<AutomationList> (d.property_id, p)
51  {}
52 
53  AutomationListProperty (PBD::PropertyDescriptor<std::shared_ptr<AutomationList> > d, Ptr o, Ptr c)
54  : PBD::SharedStatefulProperty<AutomationList> (d.property_id, o, c)
55  {}
56 
58 
59 private:
60  /* No copy-construction nor assignment */
63 };
64 
70 {
71 public:
76  AutomationList (const AutomationList&, timepos_t const & start, timepos_t const & end);
78 
79  virtual std::shared_ptr<ControlList> create(const Evoral::Parameter& id,
80  const Evoral::ParameterDescriptor& desc,
82 
83  AutomationList& operator= (const AutomationList&);
84 
85  void thaw ();
86 
90 
91  bool automation_playback() const {
92  return (_state & Play) || ((_state & (Touch | Latch)) && !touching());
93  }
94  bool automation_write () const {
95  return ((_state & Write) || ((_state & (Touch | Latch)) && touching()));
96  }
97 
99 
101 
102  void start_write_pass (timepos_t const & when);
103  void write_pass_finished (timepos_t const & when, double thinning_factor=0.0);
104 
105  void start_touch (timepos_t const & when);
106  void stop_touch (timepos_t const & when);
107 
108  bool touching () const { return _touching.load() != 0; }
109  bool writing () const { return _state == Write; }
110  bool touch_enabled () const { return _state & (Touch | Latch); }
111 
112  XMLNode& get_state () const;
113  int set_state (const XMLNode &, int version);
114 
116 
117  bool operator!= (const AutomationList &) const;
118 
119  XMLNode* before () { XMLNode* rv = _before; _before = 0; return rv; }
120  void clear_history ();
121  void snapshot_history (bool need_lock);
122 
123  ControlList::InterpolationStyle default_interpolation () const;
124 
125 private:
128 
129  XMLNode& state (bool save_auto_state, bool need_lock) const;
130  XMLNode& serialize_events (bool need_lock) const;
131 
133 
135  std::atomic<int> _touching;
136 
138 
139  bool operator== (const AutomationList&) const { /* not called */ abort(); return false; }
140  XMLNode* _before; //used for undo of touch start/stop pairs.
141 
142 };
143 
144 } // namespace
145 
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 &)
std::atomic< int > _touching
ControlList::InterpolationStyle default_interpolation() const
PBD::Signal< void()> StateChanged
void snapshot_history(bool need_lock)
static PBD::Signal< void(AutomationList *)> AutomationListCreated
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)
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)
void start_touch(timepos_t const &when)
PBD::Signal< void(AutoState)> automation_state_changed
PBD::Command * memento_command(XMLNode *before, XMLNode *after)
std::shared_ptr< AutomationList > Ptr
Definition: properties.h:374
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)