aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/LV2/include/lv2wrapper.h
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/LV2/include/lv2wrapper.h')
-rw-r--r--plugins/LV2/include/lv2wrapper.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/plugins/LV2/include/lv2wrapper.h b/plugins/LV2/include/lv2wrapper.h
new file mode 100644
index 0000000..26531cb
--- /dev/null
+++ b/plugins/LV2/include/lv2wrapper.h
@@ -0,0 +1,75 @@
+#include "lv2/core/lv2.h"
+
+LV2_Descriptor descriptor;
+
+template<typename Plugin>
+class LV2Wrapper
+{
+public:
+ LV2Wrapper()
+ {
+ LV2_Descriptor d = {
+ Plugin::URI,
+ LV2Wrapper::instantiate,
+ LV2Wrapper::connect_port,
+ LV2Wrapper::activate,
+ LV2Wrapper::run,
+ LV2Wrapper::deactivate,
+ LV2Wrapper::destroy,
+ LV2Wrapper::extension_data
+ };
+ descriptor = d;
+ }
+
+private:
+ static LV2_Handle instantiate(
+ const LV2_Descriptor * d,
+ double rate,
+ const char * path,
+ const LV2_Feature * const * features)
+ {
+ return new Plugin{rate};
+ }
+
+ static void connect_port(
+ LV2_Handle instance,
+ uint32_t port,
+ void * data)
+ {
+ auto accel = static_cast<Plugin *>(instance);
+ accel->connect_port(port, data);
+ }
+
+ static void activate(LV2_Handle instance)
+ {
+ }
+
+ static void run(LV2_Handle instance, uint32_t num_samples)
+ {
+ auto accel = static_cast<Plugin *>(instance);
+ accel->run(num_samples);
+ }
+
+ static void deactivate(LV2_Handle)
+ {
+ }
+
+ static void destroy(LV2_Handle instance)
+ {
+ delete static_cast<Plugin *>(instance);
+ }
+
+ static const void * extension_data(const char * uri)
+ {
+ return nullptr;
+ }
+};
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor * lv2_descriptor(uint32_t idx)
+{
+ if (idx == 0)
+ return &descriptor;
+
+ return nullptr;
+}