restore compilability amidst automation state mgmt changes
[ardour.git] / libs / ardour / ardour / insert.h
1 /*
2     Copyright (C) 2000 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_insert_h__
22 #define __ardour_insert_h__
23
24 #include <vector>
25 #include <string>
26 #include <exception>
27
28 #include <sigc++/signal.h>
29 #include <ardour/ardour.h>
30 #include <ardour/redirect.h>
31 #include <ardour/types.h>
32
33 class XMLNode;
34
35 namespace MIDI {
36         class Port;
37 }
38
39 namespace ARDOUR {
40
41 class Session;
42 class Route;
43 class Plugin;
44
45 class Insert : public Redirect
46 {
47   public:
48         Insert(Session& s, Placement p);
49         Insert(Session& s, string name, Placement p);
50
51         Insert(Session& s, Placement p, int imin, int imax, int omin, int omax);
52         
53         virtual ~Insert() { }
54
55         virtual void run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset) = 0;
56         virtual void activate () {}
57         virtual void deactivate () {}
58
59         virtual int32_t can_support_input_configuration (int32_t in) const = 0;
60         virtual int32_t configure_io (int32_t magic, int32_t in, int32_t out) = 0;
61         virtual int32_t compute_output_streams (int32_t cnt) const = 0;
62 };
63
64 class PortInsert : public Insert 
65 {
66   public:
67         PortInsert (Session&, Placement);
68         PortInsert (Session&, const XMLNode&);
69         PortInsert (const PortInsert&);
70         ~PortInsert ();
71
72         XMLNode& state(bool full);
73         XMLNode& get_state(void);
74         int set_state(const XMLNode&);
75
76         void init ();
77         void run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset);
78
79         nframes_t latency();
80         
81         uint32_t output_streams() const;
82         uint32_t input_streams() const;
83
84         int32_t can_support_input_configuration (int32_t) const;
85         int32_t configure_io (int32_t magic, int32_t in, int32_t out);
86         int32_t compute_output_streams (int32_t cnt) const;
87 };
88
89 class PluginInsert : public Insert
90 {
91   public:
92         PluginInsert (Session&, boost::shared_ptr<Plugin>, Placement);
93         PluginInsert (Session&, const XMLNode&);
94         PluginInsert (const PluginInsert&);
95         ~PluginInsert ();
96
97         static const string port_automation_node_name;
98         
99         XMLNode& state(bool);
100         XMLNode& get_state(void);
101         int set_state(const XMLNode&);
102
103         void run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset);
104         void silence (nframes_t nframes, nframes_t offset);
105         void activate ();
106         void deactivate ();
107
108         void set_block_size (nframes_t nframes);
109
110         uint32_t output_streams() const;
111         uint32_t input_streams() const;
112         uint32_t natural_output_streams() const;
113         uint32_t natural_input_streams() const;
114
115         int      set_count (uint32_t num);
116         uint32_t get_count () const { return _plugins.size(); }
117
118         int32_t can_support_input_configuration (int32_t) const;
119         int32_t configure_io (int32_t magic, int32_t in, int32_t out);
120         int32_t compute_output_streams (int32_t cnt) const;
121
122         bool is_generator() const;
123
124         void set_parameter (uint32_t port, float val);
125
126         AutoState get_port_automation_state (uint32_t port);
127         void set_port_automation_state (uint32_t port, AutoState);
128         void protect_automation ();
129
130         float default_parameter_value (uint32_t which);
131
132         boost::shared_ptr<Plugin> plugin(uint32_t num=0) const {
133                 if (num < _plugins.size()) { 
134                         return _plugins[num];
135                 } else {
136                         return _plugins[0]; // we always have one
137                 }
138         }
139
140         PluginType type ();
141
142         string describe_parameter (uint32_t);
143
144         nframes_t latency();
145
146         void transport_stopped (nframes_t now);
147
148   private:
149
150         void parameter_changed (uint32_t, float);
151         
152         vector<boost::shared_ptr<Plugin> > _plugins;
153         void automation_run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset);
154         void connect_and_run (vector<Sample *>& bufs, uint32_t nbufs, nframes_t nframes, nframes_t offset, bool with_auto, nframes_t now = 0);
155
156         void init ();
157         void set_automatable ();
158         void auto_state_changed (uint32_t which);
159         void automation_list_creation_callback (uint32_t, AutomationList&);
160
161         boost::shared_ptr<Plugin> plugin_factory (boost::shared_ptr<Plugin>);
162 };
163
164 } // namespace ARDOUR
165
166 #endif /* __ardour_insert_h__ */