PluginInfo::type added to copy constructor. But why is the copy constructor defined...
[ardour.git] / libs / ardour / ardour / plugin.h
1 /*
2     Copyright (C) 2000-2006 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_plugin_h__
21 #define __ardour_plugin_h__
22
23 #include <boost/shared_ptr.hpp>
24 #include <sigc++/signal.h>
25 #include <glibmm/ustring.h>
26
27 #include <pbd/statefuldestructible.h> 
28 #include <pbd/controllable.h>
29
30 #include <jack/types.h>
31 #include <ardour/types.h>
32 #include <ardour/cycles.h>
33
34 #include <vector>
35 #include <set>
36 #include <map>
37
38 using std::string;
39 using std::vector;
40 using std::set;
41 using std::map;
42
43 namespace ARDOUR {
44
45 class AudioEngine;
46 class Session;
47
48 class Plugin;
49
50 typedef boost::shared_ptr<Plugin> PluginPtr;
51
52 class PluginInfo {
53   public:
54         PluginInfo () { }
55         PluginInfo (const PluginInfo &o)
56                 : name(o.name),
57                 category (o.category), 
58                 creator (o.creator),
59                 path (o.path), 
60                 n_inputs(o.n_inputs), 
61                 n_outputs(o.n_outputs),
62                 type(o.type),
63                 unique_id(o.unique_id), 
64                 index(o.index) {}
65         virtual ~PluginInfo () { }
66
67         string name;
68         string category;
69         Glib::ustring creator;
70         Glib::ustring path;
71         int32_t n_inputs;
72         int32_t n_outputs;
73         ARDOUR::PluginType type;
74
75         std::string unique_id;
76
77         virtual PluginPtr load (Session& session) = 0;
78
79   protected:
80         friend class PluginManager;
81         uint32_t index;
82 };
83
84 typedef boost::shared_ptr<PluginInfo> PluginInfoPtr;
85 typedef std::list<PluginInfoPtr> PluginInfoList;
86
87 class Plugin : public PBD::StatefulDestructible
88 {
89   public:
90         Plugin (ARDOUR::AudioEngine&, ARDOUR::Session&);
91         Plugin (const Plugin&);
92         virtual ~Plugin ();
93         
94         struct ParameterDescriptor {
95
96             /* essentially a union of LADSPA and VST info */
97
98             bool integer_step;
99             bool toggled;
100             bool logarithmic;
101             bool sr_dependent;
102             string label;
103             float lower;
104             float upper;
105             float step;
106             float smallstep;
107             float largestep;
108             bool min_unbound;
109             bool max_unbound;
110         };
111
112         virtual std::string unique_id() const = 0;
113         virtual const char * label() const = 0;
114         virtual const char * name() const = 0;
115         virtual const char * maker() const = 0;
116         virtual uint32_t parameter_count () const = 0;
117         virtual float default_value (uint32_t port) = 0;
118         virtual nframes_t latency() const = 0;
119         virtual void set_parameter (uint32_t which, float val) = 0;
120         virtual float get_parameter(uint32_t which) const = 0;
121
122         virtual int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const = 0;
123         virtual uint32_t nth_parameter (uint32_t which, bool& ok) const = 0;
124         virtual void activate () = 0;
125         virtual void deactivate () = 0;
126         virtual void set_block_size (nframes_t nframes) = 0;
127
128         virtual int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, nframes_t nframes, nframes_t offset) = 0;
129         virtual std::set<uint32_t> automatable() const = 0;
130         virtual string describe_parameter (uint32_t) = 0;
131         virtual string state_node_name() const = 0;
132         virtual void print_parameter (uint32_t, char*, uint32_t len) const = 0;
133
134         virtual bool parameter_is_audio(uint32_t) const = 0;
135         virtual bool parameter_is_control(uint32_t) const = 0;
136         virtual bool parameter_is_input(uint32_t) const = 0;
137         virtual bool parameter_is_output(uint32_t) const = 0;
138
139         virtual bool save_preset(string name) = 0;
140         virtual bool load_preset (const string preset_label);
141         virtual std::vector<std::string> get_presets();
142         virtual std::string current_preset() const { return std::string(); }
143
144         static sigc::signal<bool> PresetFileExists;
145
146         virtual bool has_editor() const = 0;
147
148         sigc::signal<void,uint32_t,float> ParameterChanged;
149
150         virtual int32_t can_do (int32_t in, int32_t& out);
151         virtual uint32_t output_streams() const;
152         virtual uint32_t input_streams() const;
153         virtual int32_t configure_io (int32_t in, int32_t out);
154
155         PBD::Controllable *get_nth_control (uint32_t, bool do_not_create = false);
156         void make_nth_control (uint32_t, const XMLNode&);
157
158         PluginInfoPtr get_info() { return _info; }
159         void set_info (const PluginInfoPtr inf) { _info = inf; }
160
161         ARDOUR::AudioEngine& engine() const { return _engine; }
162         ARDOUR::Session& session() const { return _session; }
163
164         void set_cycles (uint32_t c) { _cycles = c; }
165         cycles_t cycles() const { return _cycles; }
166
167   protected:
168         ARDOUR::AudioEngine& _engine;
169         ARDOUR::Session& _session;
170         PluginInfoPtr _info;
171         uint32_t _cycles;
172         map<string,string>       presets;
173         bool save_preset(string name, string domain /* vst, ladspa etc. */);
174
175         void setup_controls ();
176
177         struct PortControllable : public PBD::Controllable {
178             PortControllable (std::string name, Plugin&, uint32_t abs_port_id,
179                               float lower, float upper, bool toggled, bool logarithmic);
180             PortControllable (const XMLNode&, Plugin&, uint32_t abs_port_id,
181                               float lower, float upper, bool toggled, bool logarithmic);
182
183             void set_value (float);
184             float get_value () const;
185
186             Plugin& plugin;
187             uint32_t absolute_port;
188             float upper;
189             float lower;
190             float range;
191             bool  toggled;
192             bool  logarithmic;
193         };
194
195         vector<PortControllable*> controls;
196 };
197
198 PluginPtr find_plugin(ARDOUR::Session&, string unique_id, ARDOUR::PluginType);
199
200 } // namespace ARDOUR
201  
202 #endif /* __ardour_plugin_h__ */