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 _has_state_interface;
133 std::vector<bool> _port_is_input;
134 std::vector<bool> _port_is_output;
135 std::vector<bool> _port_is_midi;
136 std::vector<bool> _port_is_audio;
137 std::vector<bool> _port_is_control;
139 std::map<std::string,uint32_t> _port_indices;
144 const void* (*extension_data) (const char* uri);
147 LV2_DataAccess _data_access_extension_data;
148 LV2_Feature _data_access_feature;
149 LV2_Feature _instance_access_feature;
150 LV2_Feature _map_path_feature;
151 LV2_Feature _make_path_feature;
153 static URIMap _uri_map;
154 static uint32_t _midi_event_type;
155 static uint32_t _state_path_type;
157 const std::string state_dir () const;
160 lv2_state_store_callback (void* handle,
168 lv2_state_retrieve_callback (void* handle,
174 static char* lv2_state_abstract_path (void* host_data,
175 const char* absolute_path);
176 static char* lv2_state_absolute_path (void* host_data,
177 const char* abstract_path);
178 static char* lv2_state_make_path (void* host_data,
181 void init (void* c_plugin, framecnt_t rate);
182 void run (pframes_t nsamples);
184 void latency_compute_run ();
185 std::string do_save_preset (std::string);
186 void do_remove_preset (std::string);
187 void find_presets ();
188 void add_state (XMLNode *) const;
192 class LV2PluginInfo : public PluginInfo {
194 LV2PluginInfo (void* c_plugin);
197 static PluginInfoList* discover ();
199 PluginPtr load (Session& session);
204 typedef boost::shared_ptr<LV2PluginInfo> LV2PluginInfoPtr;
206 } // namespace ARDOUR
208 #endif /* __ardour_lv2_plugin_h__ */