remove StateManager code entirely and more debugging output cruft
[ardour.git] / libs / ardour / ardour / redirect.h
1 /*
2     Copyright (C) 2001 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     $Id$
19 */
20
21 #ifndef __ardour_redirect_h__
22 #define __ardour_redirect_h__
23
24 #include <string>
25 #include <vector>
26 #include <set>
27 #include <map>
28 #include <boost/shared_ptr.hpp>
29 #include <sigc++/signal.h>
30
31 #include <glibmm/thread.h>
32
33 #include <pbd/undo.h>
34
35 #include <ardour/ardour.h>
36 #include <ardour/io.h>
37 #include <ardour/automation_event.h>
38
39 using std::map;
40 using std::set;
41 using std::string;
42 using std::vector;
43
44 class XMLNode;
45
46 namespace ARDOUR {
47
48 class Session;
49
50 class Redirect : public IO
51 {
52   public:
53         static const string state_node_name;
54
55         Redirect (Session&, const string& name, Placement,
56                   int input_min = -1, int input_max = -1, int output_min = -1, int output_max = -1);
57         Redirect (const Redirect&);
58         virtual ~Redirect ();
59
60         static boost::shared_ptr<Redirect> clone (boost::shared_ptr<const Redirect>);
61
62         bool active () const { return _active; }
63         void set_active (bool yn, void *src);
64
65         virtual uint32_t output_streams() const { return n_outputs(); }
66         virtual uint32_t input_streams () const { return n_inputs(); }
67         virtual uint32_t natural_output_streams() const { return n_outputs(); }
68         virtual uint32_t natural_input_streams () const { return n_inputs(); }
69
70         uint32_t sort_key() const { return _sort_key; }
71         void set_sort_key (uint32_t key);
72
73         Placement placement() const { return _placement; }
74         void set_placement (Placement, void *src);
75
76         virtual void run (vector<Sample *>& ibufs, uint32_t nbufs, nframes_t nframes, nframes_t offset) = 0;
77         virtual void activate () = 0;
78         virtual void deactivate () = 0;
79         virtual nframes_t latency() { return 0; }
80
81         virtual void set_block_size (nframes_t nframes) {}
82
83         sigc::signal<void,Redirect*,void*> active_changed;
84         sigc::signal<void,Redirect*,void*> placement_changed;
85         sigc::signal<void,Redirect*,bool>  AutomationPlaybackChanged;
86         sigc::signal<void,Redirect*,uint32_t> AutomationChanged;
87
88         static sigc::signal<void,Redirect*> RedirectCreated;
89         
90         XMLNode& state (bool full);
91         XMLNode& get_state (void);
92         int set_state (const XMLNode&);
93
94         void *get_gui () const { return _gui; }
95         void  set_gui (void *p) { _gui = p; }
96
97         virtual string describe_parameter (uint32_t which);
98         virtual float default_parameter_value (uint32_t which) {
99                 return 1.0f;
100         }
101
102         int load_automation (string path);
103         int save_automation (string path);
104
105         void what_has_automation (set<uint32_t>&) const;
106         void what_has_visible_automation (set<uint32_t>&) const;
107         const set<uint32_t>& what_can_be_automated () const { return can_automate_list; }
108
109         void mark_automation_visible (uint32_t, bool);
110         
111         AutomationList& automation_list (uint32_t);
112         bool find_next_event (nframes_t, nframes_t, ControlEvent&) const;
113
114         virtual void transport_stopped (nframes_t frame) {};
115         
116   protected:
117         void set_placement (const string&, void *src);
118
119         /* children may use this stuff as they see fit */
120
121         map<uint32_t,AutomationList*> parameter_automation;
122         set<uint32_t> visible_parameter_automation;
123
124         mutable Glib::Mutex _automation_lock;
125
126         void can_automate (uint32_t);
127         set<uint32_t> can_automate_list;
128
129         virtual void automation_list_creation_callback (uint32_t, AutomationList&) {}
130
131   private:
132         bool _active;
133         Placement _placement;
134         uint32_t _sort_key;
135         void* _gui;  /* generic, we don't know or care what this is */
136 };
137
138 } // namespace ARDOUR
139
140 #endif /* __ardour_redirect_h__ */