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.
21 #ifndef __ardour_lv2_plugin_h__
22 #define __ardour_lv2_plugin_h__
30 #include "pbd/stateful.h"
32 #include <jack/types.h>
34 #include "ardour/plugin.h"
35 #include "ardour/uri_map.h"
42 class LV2Plugin : public ARDOUR::Plugin
45 LV2Plugin (ARDOUR::AudioEngine& engine,
46 ARDOUR::Session& session,
48 framecnt_t sample_rate);
49 LV2Plugin (const LV2Plugin &);
52 std::string unique_id () const;
53 const char* uri () const;
54 const char* label () const;
55 const char* name () const;
56 const char* maker () const;
58 uint32_t num_ports () const;
59 uint32_t parameter_count () const;
60 float default_value (uint32_t port);
61 framecnt_t signal_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 uint32_t nth_parameter (uint32_t port, bool& ok) const;
67 const void* extension_data (const char* uri);
72 bool is_external_ui () const;
74 const char* port_symbol (uint32_t port) const;
76 const LV2_Feature* const* features () { return _features; }
78 std::set<Evoral::Parameter> automatable () const;
84 int set_block_size (pframes_t /*nframes*/) { return 0; }
86 int connect_and_run (BufferSet& bufs,
87 ChanMapping in, ChanMapping out,
88 pframes_t nframes, framecnt_t offset);
90 std::string describe_parameter (Evoral::Parameter);
91 std::string state_node_name () const { return "lv2"; }
93 void print_parameter (uint32_t param,
97 bool parameter_is_audio (uint32_t) const;
98 bool parameter_is_control (uint32_t) const;
99 bool parameter_is_midi (uint32_t) const;
100 bool parameter_is_input (uint32_t) const;
101 bool parameter_is_output (uint32_t) const;
102 bool parameter_is_toggled (uint32_t) const;
104 boost::shared_ptr<Plugin::ScalePoints>
105 get_scale_points(uint32_t port_index) const;
107 static uint32_t midi_event_type () { return _midi_event_type; }
109 void set_insert_info(const PluginInsert* insert);
111 int set_state (const XMLNode& node, int version);
112 bool save_preset (std::string uri);
113 void remove_preset (std::string uri);
114 bool load_preset (PresetRecord);
115 std::string current_preset () const;
117 bool has_editor () const;
123 LV2_Feature** _features;
124 framecnt_t _sample_rate;
125 float* _control_data;
128 float* _latency_control_port;
130 bool _supports_persist;
131 std::vector<bool> _port_is_input;
133 std::map<std::string,uint32_t> _port_indices;
138 const void* (*extension_data) (const char* uri);
141 LV2_DataAccess _data_access_extension_data;
142 LV2_Feature _data_access_feature;
143 LV2_Feature _instance_access_feature;
144 LV2_Feature _path_support_feature;
145 LV2_Feature _new_file_support_feature;
146 LV2_Feature _persist_feature;
148 static URIMap _uri_map;
149 static uint32_t _midi_event_type;
151 static int lv2_persist_store_callback (void* host_data,
157 static const void* lv2_persist_retrieve_callback (void* host_data,
162 static char* lv2_files_abstract_path (void* host_data,
163 const char* absolute_path);
164 static char* lv2_files_absolute_path (void* host_data,
165 const char* abstract_path);
166 static char* lv2_files_new_file_path (void* host_data,
167 const char* relative_path);
169 void init (void* c_plugin, framecnt_t rate);
170 void run (pframes_t nsamples);
172 void latency_compute_run ();
173 std::string do_save_preset (std::string);
174 void do_remove_preset (std::string);
175 void find_presets ();
176 void add_state (XMLNode *) const;
180 class LV2PluginInfo : public PluginInfo {
182 LV2PluginInfo (void* c_plugin);
185 static PluginInfoList* discover ();
187 PluginPtr load (Session& session);
192 typedef boost::shared_ptr<LV2PluginInfo> LV2PluginInfoPtr;
194 } // namespace ARDOUR
196 #endif /* __ardour_lv2_plugin_h__ */