* Added filename extension definitions for export presets and format profiles
[ardour.git] / libs / ardour / ardour / automation_list.h
1 /*
2     Copyright (C) 2002 Paul Davis 
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef __ardour_automation_event_h__
21 #define __ardour_automation_event_h__
22
23 #include <stdint.h>
24 #include <list>
25 #include <cmath>
26
27 #include <sigc++/signal.h>
28 #include <glibmm/thread.h>
29
30 #include <boost/pool/pool.hpp>
31 #include <boost/pool/pool_alloc.hpp>
32
33 #include <pbd/undo.h>
34 #include <pbd/xml++.h>
35 #include <pbd/statefuldestructible.h> 
36
37 #include <ardour/ardour.h>
38 #include <ardour/parameter.h>
39
40 #include <evoral/ControlList.hpp>
41
42 using Evoral::ControlEvent;
43
44 namespace ARDOUR {
45
46 class AutomationList : public PBD::StatefulDestructible, public Evoral::ControlList
47 {
48   public:
49         AutomationList (Parameter id);
50         AutomationList (const XMLNode&, Parameter id);
51         ~AutomationList();
52
53         virtual boost::shared_ptr<Evoral::ControlList> create(Evoral::Parameter id);
54
55         AutomationList (const AutomationList&);
56         AutomationList (const AutomationList&, double start, double end);
57         AutomationList& operator= (const AutomationList&);
58         bool operator== (const AutomationList&);
59         
60         void freeze();
61         void thaw ();
62         void mark_dirty () const;
63
64         void set_automation_state (AutoState);
65         AutoState automation_state() const { return _state; }
66         sigc::signal<void> automation_state_changed;
67
68         void set_automation_style (AutoStyle m);
69         AutoStyle automation_style() const { return _style; }
70         sigc::signal<void> automation_style_changed;
71
72         bool automation_playback() const {
73                 return (_state & Play) || ((_state & Touch) && !_touching);
74         }
75         bool automation_write () const {
76                 return (_state & Write) || ((_state & Touch) && _touching);
77         }
78         
79         sigc::signal<void> StateChanged;
80         
81         static sigc::signal<void, AutomationList*> AutomationListCreated;
82         mutable sigc::signal<void> Dirty;
83
84         void start_touch ();
85         void stop_touch ();
86         bool touching() const { return _touching; }
87
88         XMLNode& get_state(void); 
89         int set_state (const XMLNode &s);
90         XMLNode& state (bool full);
91         XMLNode& serialize_events ();
92
93   private:
94         int deserialize_events (const XMLNode&);
95         
96         void maybe_signal_changed ();
97         
98         AutoState _state;
99         AutoStyle _style;
100         bool      _touching;
101 };
102
103 } // namespace
104
105 #endif /* __ardour_automation_event_h__ */