Insert/Redirect refactoring, towards better MIDI support in mixer strip, and
[ardour.git] / libs / ardour / ardour / automatable.h
1 /*
2     Copyright (C) 2000,2007 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_automatable_h__
21 #define __ardour_automatable_h__
22
23 #include <set>
24 #include <map>
25 #include <ardour/session_object.h>
26 #include <ardour/automation_event.h>
27
28 namespace ARDOUR {
29
30 class Session;
31
32 class Automatable : public SessionObject
33 {
34 public:
35         Automatable(Session&, const std::string& name);
36
37         virtual ~Automatable() {}
38
39         virtual AutomationList& automation_list(uint32_t n);
40
41         virtual void automation_snapshot (nframes_t now) {};
42
43         virtual bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const;
44         
45         virtual string describe_parameter(uint32_t which);
46         virtual float default_parameter_value(uint32_t which) { return 1.0f; }
47
48         void what_has_automation(std::set<uint32_t>&) const;
49         void what_has_visible_automation(std::set<uint32_t>&) const;
50         const std::set<uint32_t>& what_can_be_automated() const { return _can_automate_list; }
51
52         void mark_automation_visible(uint32_t, bool);
53
54 protected:
55
56         void can_automate(uint32_t);
57
58         virtual void automation_list_creation_callback(uint32_t, AutomationList&) {}
59
60         int set_automation_state(const XMLNode&);
61         XMLNode& get_automation_state();
62         
63         int load_automation (const std::string& path);
64         int old_set_automation_state(const XMLNode&);
65
66         mutable Glib::Mutex _automation_lock;
67
68         // FIXME:  map with int keys is a bit silly.  this could be O(1)
69         std::map<uint32_t,AutomationList*> _parameter_automation;
70         std::set<uint32_t> _visible_parameter_automation;
71         std::set<uint32_t> _can_automate_list;
72         
73         nframes_t _last_automation_snapshot;
74 };
75
76 } // namespace ARDOUR
77
78 #endif /* __ardour_automatable_h__ */