Ardour  9.0-pre0-582-g084a23a80d
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 <glibmm/threads.h>
32 
33 #include "evoral/ControlList.h"
34 #include "evoral/Parameter.h"
35 
36 #include "pbd/undo.h"
37 #include "pbd/xml++.h"
39 #include "pbd/properties.h"
40 
41 #include "ardour/ardour.h"
42 
43 namespace ARDOUR {
44 
45 class AutomationList;
46 
49 {
50 public:
51  AutomationListProperty (PBD::PropertyDescriptor<std::shared_ptr<AutomationList> > d, Ptr p)
52  : PBD::SharedStatefulProperty<AutomationList> (d.property_id, p)
53  {}
54 
55  AutomationListProperty (PBD::PropertyDescriptor<std::shared_ptr<AutomationList> > d, Ptr o, Ptr c)
56  : PBD::SharedStatefulProperty<AutomationList> (d.property_id, o, c)
57  {}
58 
60 
61 private:
62  /* No copy-construction nor assignment */
65 };
66 
72 {
73 public:
78  AutomationList (const AutomationList&, timepos_t const & start, timepos_t const & end);
80 
81  virtual std::shared_ptr<ControlList> create(const Evoral::Parameter& id,
82  const Evoral::ParameterDescriptor& desc,
84 
85  AutomationList& operator= (const AutomationList&);
86 
87  void thaw ();
88 
92 
93  bool automation_playback() const {
94  return (_state & Play) || ((_state & (Touch | Latch)) && !touching());
95  }
96  bool automation_write () const {
97  return ((_state & Write) || ((_state & (Touch | Latch)) && touching()));
98  }
99 
101 
103 
104  void start_write_pass (timepos_t const & when);
105  void write_pass_finished (timepos_t const & when, double thinning_factor=0.0);
106 
107  void start_touch (timepos_t const & when);
108  void stop_touch (timepos_t const & when);
109 
110  bool touching () const { return _touching.load() != 0; }
111  bool writing () const { return _state == Write; }
112  bool touch_enabled () const { return _state & (Touch | Latch); }
113 
114  XMLNode& get_state () const;
115  int set_state (const XMLNode &, int version);
116 
118 
119  bool operator!= (const AutomationList &) const;
120 
121  XMLNode* before () { XMLNode* rv = _before; _before = 0; return rv; }
122  void clear_history ();
123  void snapshot_history (bool need_lock);
124 
125  ControlList::InterpolationStyle default_interpolation () const;
126 
127 private:
130 
131  XMLNode& state (bool save_auto_state, bool need_lock) const;
132  XMLNode& serialize_events (bool need_lock) const;
133 
135 
137  std::atomic<int> _touching;
138 
140 
141  bool operator== (const AutomationList&) const { /* not called */ abort(); return false; }
142  XMLNode* _before; //used for undo of touch start/stop pairs.
143 
144 };
145 
146 } // namespace
147 
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)