2 Copyright (C) 2000-2006 Paul Davis
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.
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.
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.
20 #ifndef __ardour_plugin_h__
21 #define __ardour_plugin_h__
23 #include <boost/shared_ptr.hpp>
24 #include <sigc++/signal.h>
25 #include <glibmm/ustring.h>
27 #include "pbd/statefuldestructible.h"
28 #include "pbd/controllable.h"
30 #include <jack/types.h>
31 #include "ardour/chan_count.h"
32 #include "ardour/chan_mapping.h"
33 #include "ardour/cycles.h"
34 #include "ardour/latent.h"
35 #include "ardour/plugin_insert.h"
36 #include "ardour/types.h"
50 typedef boost::shared_ptr<Plugin> PluginPtr;
55 virtual ~PluginInfo () { }
59 Glib::ustring creator;
63 ARDOUR::PluginType type;
65 std::string unique_id;
67 virtual PluginPtr load (Session& session) = 0;
70 friend class PluginManager;
74 typedef boost::shared_ptr<PluginInfo> PluginInfoPtr;
75 typedef std::list<PluginInfoPtr> PluginInfoList;
77 class Plugin : public PBD::StatefulDestructible, public Latent
80 Plugin (ARDOUR::AudioEngine&, ARDOUR::Session&);
81 Plugin (const Plugin&);
84 struct ParameterDescriptor {
86 /* essentially a union of LADSPA and VST info */
102 virtual std::string unique_id() const = 0;
103 virtual const char * label() const = 0;
104 virtual const char * name() const = 0;
105 virtual const char * maker() const = 0;
106 virtual uint32_t parameter_count () const = 0;
107 virtual float default_value (uint32_t port) = 0;
108 virtual float get_parameter(uint32_t which) const = 0;
110 virtual int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const = 0;
111 virtual uint32_t nth_parameter (uint32_t which, bool& ok) const = 0;
112 virtual void activate () = 0;
113 virtual void deactivate () = 0;
114 virtual void set_block_size (nframes_t nframes) = 0;
116 virtual int connect_and_run (BufferSet& bufs,
117 ChanMapping in, ChanMapping out,
118 nframes_t nframes, nframes_t offset) = 0;
120 virtual std::set<Evoral::Parameter> automatable() const = 0;
121 virtual std::string describe_parameter (Evoral::Parameter) = 0;
122 virtual std::string state_node_name() const = 0;
123 virtual void print_parameter (uint32_t, char*, uint32_t len) const = 0;
125 virtual bool parameter_is_audio(uint32_t) const = 0;
126 virtual bool parameter_is_control(uint32_t) const = 0;
127 virtual bool parameter_is_input(uint32_t) const = 0;
128 virtual bool parameter_is_output(uint32_t) const = 0;
130 virtual bool save_preset (std::string) = 0;
131 virtual bool load_preset (const std::string uri);
133 struct PresetRecord {
134 PresetRecord(const std::string& u, const std::string& l) : uri(u), label(l) {}
139 virtual std::vector<PresetRecord> get_presets();
140 virtual std::string current_preset() const { return std::string(); }
142 const PresetRecord* preset_by_label(const std::string& label);
143 const PresetRecord* preset_by_uri(const std::string& uri);
145 virtual bool has_editor() const = 0;
147 sigc::signal<void,uint32_t,float> ParameterChanged;
149 /* NOTE: this block of virtual methods looks like the interface
150 to a Processor, but Plugin does not inherit from Processor.
151 It is therefore not required that these precisely match
152 the interface, but it is likely that they will evolve together.
155 /* this returns true if the plugin can change its inputs or outputs on demand.
156 LADSPA, LV2 and VST plugins cannot do this. AudioUnits can.
159 virtual bool reconfigurable_io() const { return false; }
161 /* this is only called if reconfigurable_io() returns true */
162 virtual bool configure_io (ChanCount /*in*/, ChanCount /*out*/) { return true; }
164 /* specific types of plugins can overload this. As of September 2008, only
167 virtual bool can_support_io_configuration (const ChanCount& /*in*/, ChanCount& /*out*/) const { return false; }
168 virtual ChanCount output_streams() const;
169 virtual ChanCount input_streams() const;
171 PluginInfoPtr get_info() { return _info; }
172 void set_info (const PluginInfoPtr inf) { _info = inf; }
174 ARDOUR::AudioEngine& engine() const { return _engine; }
175 ARDOUR::Session& session() const { return _session; }
177 void set_cycles (uint32_t c) { _cycles = c; }
178 cycles_t cycles() const { return _cycles; }
181 friend class PluginInsert;
182 friend struct PluginInsert::PluginControl;
184 virtual void set_parameter (uint32_t which, float val) = 0;
186 bool save_preset (std::string, std::string /* vst, ladspa etc. */);
188 ARDOUR::AudioEngine& _engine;
189 ARDOUR::Session& _session;
192 std::map<std::string,PresetRecord> presets;
195 PluginPtr find_plugin(ARDOUR::Session&, std::string unique_id, ARDOUR::PluginType);
197 } // namespace ARDOUR
199 #endif /* __ardour_plugin_h__ */