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"
44 /** A SharedStatefulProperty for AutomationLists */
45 class LIBARDOUR_API AutomationListProperty : public PBD::SharedStatefulProperty<AutomationList>
48 AutomationListProperty (PBD::PropertyDescriptor<boost::shared_ptr<AutomationList> > d, Ptr p)
49 : PBD::SharedStatefulProperty<AutomationList> (d.property_id, p)
52 AutomationListProperty (PBD::PropertyDescriptor<boost::shared_ptr<AutomationList> > d, Ptr o, Ptr c)
53 : PBD::SharedStatefulProperty<AutomationList> (d.property_id, o, c)
56 PBD::PropertyBase* clone () const;
59 /* No copy-construction nor assignment */
60 AutomationListProperty (AutomationListProperty const &);
61 AutomationListProperty& operator= (AutomationListProperty const &);
64 /** AutomationList is a stateful wrapper around Evoral::ControlList.
65 * It includes session-specifics (such as automation state), control logic (e.g. touch, signals)
66 * and acts as proxy to the underlying ControlList which holds the actual data.
68 class LIBARDOUR_API AutomationList : public PBD::StatefulDestructible, public Evoral::ControlList
71 AutomationList (const Evoral::Parameter& id, const Evoral::ParameterDescriptor& desc);
72 AutomationList (const Evoral::Parameter& id);
73 AutomationList (const XMLNode&, Evoral::Parameter id);
74 AutomationList (const AutomationList&);
75 AutomationList (const AutomationList&, double start, double end);
78 virtual boost::shared_ptr<ControlList> create(const Evoral::Parameter& id,
79 const Evoral::ParameterDescriptor& desc);
81 AutomationList& operator= (const AutomationList&);
85 void set_automation_state (AutoState);
86 AutoState automation_state() const { return _state; }
87 PBD::Signal1<void, AutoState> automation_state_changed;
89 void set_automation_style (AutoStyle m);
90 AutoStyle automation_style() const { return _style; }
91 PBD::Signal0<void> automation_style_changed;
93 bool automation_playback() const {
94 return (_state & Play) || ((_state & Touch) && !touching());
96 bool automation_write () const {
97 return ((_state & Write) || ((_state & Touch) && touching()));
100 PBD::Signal0<void> StateChanged;
102 static PBD::Signal1<void,AutomationList*> AutomationListCreated;
104 void start_write_pass (double when);
105 void write_pass_finished (double when, double thinning_factor=0.0);
107 void start_touch (double when);
108 void stop_touch (bool mark, double when);
109 bool touching() const { return g_atomic_int_get (const_cast<gint*>(&_touching)); }
110 bool writing() const { return _state == Write; }
111 bool touch_enabled() const { return _state == Touch; }
113 XMLNode& get_state ();
114 int set_state (const XMLNode &, int version);
115 XMLNode& state (bool full);
116 XMLNode& serialize_events ();
118 Command* memento_command (XMLNode* before, XMLNode* after);
120 bool operator!= (const AutomationList &) const;
122 XMLNode* before () { XMLNode* rv = _before; _before = 0; return rv; }
123 void clear_history ();
125 void create_curve_if_necessary ();
126 int deserialize_events (const XMLNode&);
128 void maybe_signal_changed ();
134 bool operator== (const AutomationList&) const { /* not called */ abort(); return false; }
135 XMLNode* _before; //used for undo of touch start/stop pairs.
141 #endif /* __ardour_automation_event_h__ */