3 Copyright (C) 2008-2011 Paul Davis
4 Author: David Robillard
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 #ifndef __ardour_lv2_plugin_h__
23 #define __ardour_lv2_plugin_h__
31 #include "pbd/stateful.h"
33 #include <jack/types.h>
35 #include "ardour/plugin.h"
36 #include "ardour/uri_map.h"
43 class LV2Plugin : public ARDOUR::Plugin
46 LV2Plugin (ARDOUR::AudioEngine& engine,
47 ARDOUR::Session& session,
49 framecnt_t sample_rate);
50 LV2Plugin (const LV2Plugin &);
53 std::string unique_id () const;
54 const char* uri () const;
55 const char* label () const;
56 const char* name () const;
57 const char* maker () const;
59 uint32_t num_ports () const;
60 uint32_t parameter_count () const;
61 float default_value (uint32_t port);
62 framecnt_t signal_latency () const;
63 void set_parameter (uint32_t port, float val);
64 float get_parameter (uint32_t port) const;
65 int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const;
66 uint32_t nth_parameter (uint32_t port, bool& ok) const;
68 const void* extension_data (const char* uri) const;
74 bool is_external_ui () const;
76 const char* port_symbol (uint32_t port) const;
78 const LV2_Feature* const* features () { return _features; }
80 std::set<Evoral::Parameter> automatable () const;
86 int set_block_size (pframes_t /*nframes*/) { return 0; }
88 int connect_and_run (BufferSet& bufs,
89 ChanMapping in, ChanMapping out,
90 pframes_t nframes, framecnt_t offset);
92 std::string describe_parameter (Evoral::Parameter);
93 std::string state_node_name () const { return "lv2"; }
95 void print_parameter (uint32_t param,
99 bool parameter_is_audio (uint32_t) const;
100 bool parameter_is_control (uint32_t) const;
101 bool parameter_is_midi (uint32_t) const;
102 bool parameter_is_input (uint32_t) const;
103 bool parameter_is_output (uint32_t) const;
104 bool parameter_is_toggled (uint32_t) const;
106 boost::shared_ptr<Plugin::ScalePoints>
107 get_scale_points(uint32_t port_index) const;
109 static uint32_t midi_event_type () { return _midi_event_type; }
111 void set_insert_info(const PluginInsert* insert);
113 int set_state (const XMLNode& node, int version);
114 bool save_preset (std::string uri);
115 void remove_preset (std::string uri);
116 bool load_preset (PresetRecord);
117 std::string current_preset () const;
119 bool has_editor () const;
125 LV2_Feature** _features;
126 framecnt_t _sample_rate;
127 float* _control_data;
130 float* _latency_control_port;
132 bool _supports_persist;
133 std::vector<bool> _port_is_input;
135 std::map<std::string,uint32_t> _port_indices;
140 const void* (*extension_data) (const char* uri);
143 LV2_DataAccess _data_access_extension_data;
144 LV2_Feature _data_access_feature;
145 LV2_Feature _instance_access_feature;
146 LV2_Feature _path_support_feature;
147 LV2_Feature _new_file_support_feature;
148 LV2_Feature _persist_feature;
150 static URIMap _uri_map;
151 static uint32_t _midi_event_type;
153 static int lv2_persist_store_callback (void* host_data,
159 static const void* lv2_persist_retrieve_callback (void* host_data,
164 static char* lv2_files_abstract_path (void* host_data,
165 const char* absolute_path);
166 static char* lv2_files_absolute_path (void* host_data,
167 const char* abstract_path);
168 static char* lv2_files_new_file_path (void* host_data,
169 const char* relative_path);
171 void init (void* c_plugin, framecnt_t rate);
172 void run (pframes_t nsamples);
174 void latency_compute_run ();
175 std::string do_save_preset (std::string);
176 void do_remove_preset (std::string);
177 void find_presets ();
178 void add_state (XMLNode *) const;
182 class LV2PluginInfo : public PluginInfo {
184 LV2PluginInfo (void* c_plugin);
187 static PluginInfoList* discover ();
189 PluginPtr load (Session& session);
194 typedef boost::shared_ptr<LV2PluginInfo> LV2PluginInfoPtr;
196 } // namespace ARDOUR
198 #endif /* __ardour_lv2_plugin_h__ */