2 Copyright (C) 2008-2011 Paul Davis
3 Author: David Robillard
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_lv2_plugin_h__
21 #define __ardour_lv2_plugin_h__
27 #include "ardour/plugin.h"
28 #include "ardour/uri_map.h"
35 class LV2Plugin : public ARDOUR::Plugin
38 LV2Plugin (ARDOUR::AudioEngine& engine,
39 ARDOUR::Session& session,
41 framecnt_t sample_rate);
42 LV2Plugin (const LV2Plugin &);
45 std::string unique_id () const;
46 const char* uri () const;
47 const char* label () const;
48 const char* name () const;
49 const char* maker () const;
51 uint32_t num_ports () const;
52 uint32_t parameter_count () const;
53 float default_value (uint32_t port);
54 framecnt_t signal_latency () const;
55 void set_parameter (uint32_t port, float val);
56 float get_parameter (uint32_t port) const;
57 int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
58 uint32_t nth_parameter (uint32_t port, bool& ok) const;
60 const void* extension_data (const char* uri) const;
66 bool is_external_ui () const;
68 const char* port_symbol (uint32_t port) const;
70 const LV2_Feature* const* features () { return _features; }
72 std::set<Evoral::Parameter> automatable () const;
78 int set_block_size (pframes_t /*nframes*/) { return 0; }
80 int connect_and_run (BufferSet& bufs,
81 ChanMapping in, ChanMapping out,
82 pframes_t nframes, framecnt_t offset);
84 std::string describe_parameter (Evoral::Parameter);
85 std::string state_node_name () const { return "lv2"; }
87 void print_parameter (uint32_t param,
91 bool parameter_is_audio (uint32_t) const;
92 bool parameter_is_control (uint32_t) const;
93 bool parameter_is_event (uint32_t) const;
94 bool parameter_is_input (uint32_t) const;
95 bool parameter_is_output (uint32_t) const;
96 bool parameter_is_toggled (uint32_t) const;
98 boost::shared_ptr<Plugin::ScalePoints>
99 get_scale_points(uint32_t port_index) const;
101 static uint32_t midi_event_type () { return _midi_event_type; }
103 void set_insert_info(const PluginInsert* insert);
105 int set_state (const XMLNode& node, int version);
106 bool save_preset (std::string uri);
107 void remove_preset (std::string uri);
108 bool load_preset (PresetRecord);
109 std::string current_preset () const;
111 bool has_editor () const;
117 LV2_Feature** _features;
118 framecnt_t _sample_rate;
119 float* _control_data;
122 float* _latency_control_port;
127 PORT_OUTPUT = 1 << 1,
130 PORT_CONTROL = 1 << 4
133 typedef unsigned PortFlags;
135 std::vector<PortFlags> _port_flags;
136 std::map<std::string,uint32_t> _port_indices;
139 const void* (*extension_data) (const char* uri);
142 LV2_DataAccess _data_access_extension_data;
143 LV2_Feature _data_access_feature;
144 LV2_Feature _instance_access_feature;
145 LV2_Feature _make_path_feature;
147 mutable unsigned _state_version;
150 bool _has_state_interface;
152 static URIMap _uri_map;
153 static uint32_t _midi_event_type;
154 static uint32_t _state_path_type;
156 const std::string plugin_dir () const;
157 const std::string scratch_dir () const;
158 const std::string file_dir () const;
159 const std::string state_dir (unsigned num) const;
161 static char* lv2_state_make_path (void* host_data,
164 void init (void* c_plugin, framecnt_t rate);
165 void run (pframes_t nsamples);
167 void latency_compute_run ();
168 std::string do_save_preset (std::string);
169 void do_remove_preset (std::string);
170 void find_presets ();
171 void add_state (XMLNode *) const;
175 class LV2PluginInfo : public PluginInfo {
177 LV2PluginInfo (void* c_plugin);
180 static PluginInfoList* discover ();
182 PluginPtr load (Session& session);
187 typedef boost::shared_ptr<LV2PluginInfo> LV2PluginInfoPtr;
189 } // namespace ARDOUR
191 #endif /* __ardour_lv2_plugin_h__ */