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_ladspa_plugin_h__
21 #define __ardour_ladspa_plugin_h__
29 #include <sigc++/signal.h>
31 #include <pbd/stateful.h>
33 #include <jack/types.h>
34 #include <ardour/ladspa.h>
35 #include <ardour/plugin.h>
36 #include <ardour/ladspa_plugin.h>
46 class LadspaPlugin : public ARDOUR::Plugin
49 LadspaPlugin (void *module, ARDOUR::AudioEngine&, ARDOUR::Session&, uint32_t index, nframes_t sample_rate);
50 LadspaPlugin (const LadspaPlugin &);
53 /* Plugin interface */
55 std::string unique_id() const;
56 const char * label() const { return descriptor->Label; }
57 const char * name() const { return descriptor->Name; }
58 const char * maker() const { return descriptor->Maker; }
59 uint32_t parameter_count() const { return descriptor->PortCount; }
60 float default_value (uint32_t port);
61 nframes_t latency() const;
62 void set_parameter (uint32_t port, float val);
63 float get_parameter (uint32_t port) const;
64 int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
65 std::set<uint32_t> automatable() const;
66 uint32_t nth_parameter (uint32_t port, bool& ok) const;
71 if (descriptor->activate) {
72 descriptor->activate (handle);
81 if (descriptor->deactivate) {
82 descriptor->deactivate (handle);
85 was_activated = false;
91 if (descriptor->cleanup) {
92 descriptor->cleanup (handle);
95 void set_block_size (nframes_t nframes) {}
97 int connect_and_run (vector<Sample*>& bufs, uint32_t maxbuf, int32_t& in, int32_t& out, nframes_t nframes, nframes_t offset);
98 string describe_parameter (uint32_t);
99 string state_node_name() const { return "ladspa"; }
100 void print_parameter (uint32_t, char*, uint32_t len) const;
102 bool parameter_is_audio(uint32_t) const;
103 bool parameter_is_control(uint32_t) const;
104 bool parameter_is_input(uint32_t) const;
105 bool parameter_is_output(uint32_t) const;
106 bool parameter_is_toggled(uint32_t) const;
108 XMLNode& get_state();
109 int set_state(const XMLNode& node);
110 bool save_preset(string name);
112 bool has_editor() const { return false; }
114 int require_output_streams (uint32_t);
118 LADSPA_Properties properties() const { return descriptor->Properties; }
119 uint32_t index() const { return _index; }
120 const char * copyright() const { return descriptor->Copyright; }
121 LADSPA_PortDescriptor port_descriptor(uint32_t i) const { return descriptor->PortDescriptors[i]; }
122 const LADSPA_PortRangeHint * port_range_hints() const { return descriptor->PortRangeHints; }
123 const char * const * port_names() const { return descriptor->PortNames; }
124 void set_gain (float gain) {
125 descriptor->set_run_adding_gain (handle, gain);
127 void run_adding (uint32_t nsamples) {
128 descriptor->run_adding (handle, nsamples);
130 void connect_port (uint32_t port, float *ptr) {
131 descriptor->connect_port (handle, port, ptr);
136 const LADSPA_Descriptor *descriptor;
137 LADSPA_Handle handle;
138 nframes_t sample_rate;
139 LADSPA_Data *control_data;
140 LADSPA_Data *shadow_data;
141 LADSPA_Data *latency_control_port;
145 void init (void *mod, uint32_t index, nframes_t rate);
146 void run (nframes_t nsamples);
147 void latency_compute_run ();
150 class LadspaPluginInfo : public PluginInfo {
152 LadspaPluginInfo () { };
153 ~LadspaPluginInfo () { };
155 PluginPtr load (Session& session);
158 typedef boost::shared_ptr<LadspaPluginInfo> LadspaPluginInfoPtr;
160 } // namespace ARDOUR
162 #endif /* __ardour_ladspa_plugin_h__ */