2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_automation_event_h__
21 #define __ardour_automation_event_h__
28 #include <glibmm/threads.h>
30 #include "evoral/ControlList.hpp"
31 #include "evoral/Parameter.hpp"
34 #include "pbd/xml++.h"
35 #include "pbd/statefuldestructible.h"
36 #include "pbd/properties.h"
38 #include "ardour/ardour.h"
43 class DoubleBeatsFramesConverter;
45 /** A SharedStatefulProperty for AutomationLists */
46 class LIBARDOUR_API AutomationListProperty : public PBD::SharedStatefulProperty<AutomationList>
49 AutomationListProperty (PBD::PropertyDescriptor<boost::shared_ptr<AutomationList> > d, Ptr p)
50 : PBD::SharedStatefulProperty<AutomationList> (d.property_id, p)
53 AutomationListProperty (PBD::PropertyDescriptor<boost::shared_ptr<AutomationList> > d, Ptr o, Ptr c)
54 : PBD::SharedStatefulProperty<AutomationList> (d.property_id, o, c)
57 PBD::PropertyBase* clone () const;
60 /* No copy-construction nor assignment */
61 AutomationListProperty (AutomationListProperty const &);
62 AutomationListProperty& operator= (AutomationListProperty const &);
65 /** AutomationList is a stateful wrapper around Evoral::ControlList.
66 * It includes session-specifics (such as automation state), control logic (e.g. touch, signals)
67 * and acts as proxy to the underlying ControlList which holds the actual data.
69 class LIBARDOUR_API AutomationList : public Evoral::ControlList, public PBD::StatefulDestructible
72 AutomationList (const Evoral::Parameter& id, const Evoral::ParameterDescriptor& desc);
73 AutomationList (const Evoral::Parameter& id);
74 AutomationList (const XMLNode&, Evoral::Parameter id);
75 AutomationList (const AutomationList&);
76 AutomationList (const AutomationList&, double start, double end);
79 virtual boost::shared_ptr<ControlList> create(const Evoral::Parameter& id,
80 const Evoral::ParameterDescriptor& desc);
82 AutomationList& operator= (const AutomationList&);
85 bool paste (const ControlList&, double, DoubleBeatsFramesConverter const&);
87 void set_automation_state (AutoState);
88 AutoState automation_state() const { return _state; }
89 PBD::Signal1<void, AutoState> automation_state_changed;
91 void set_automation_style (AutoStyle m);
92 AutoStyle automation_style() const { return _style; }
93 PBD::Signal0<void> automation_style_changed;
95 bool automation_playback() const {
96 return (_state & Play) || ((_state & Touch) && !touching());
98 bool automation_write () const {
99 return ((_state & Write) || ((_state & Touch) && touching()));
102 PBD::Signal0<void> StateChanged;
104 static PBD::Signal1<void,AutomationList*> AutomationListCreated;
106 void start_write_pass (double when);
107 void write_pass_finished (double when, double thinning_factor=0.0);
109 void start_touch (double when);
110 void stop_touch (bool mark, double when);
111 bool touching() const { return g_atomic_int_get (const_cast<gint*>(&_touching)); }
112 bool writing() const { return _state == Write; }
113 bool touch_enabled() const { return _state == Touch; }
115 XMLNode& get_state ();
116 int set_state (const XMLNode &, int version);
117 XMLNode& state (bool full);
118 XMLNode& serialize_events ();
120 Command* memento_command (XMLNode* before, XMLNode* after);
122 bool operator!= (const AutomationList &) const;
124 XMLNode* before () { XMLNode* rv = _before; _before = 0; return rv; }
125 void clear_history ();
127 void create_curve_if_necessary ();
128 int deserialize_events (const XMLNode&);
130 void maybe_signal_changed ();
136 bool operator== (const AutomationList&) const { /* not called */ abort(); return false; }
137 XMLNode* _before; //used for undo of touch start/stop pairs.
143 #endif /* __ardour_automation_event_h__ */