From 87e60a7db4d81c8548a753e7c9c7c0d6eec2065b Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Tue, 21 Jul 2020 22:43:18 +0200 Subject: LV2: Add template plugin and script. To ease booting up a new plugin. The script just reads the template files, replaces the placeholders with the new plugin name, and writes them out as the proper plugin files in the right directory. Primitive, but does the job. The script should work with any version of ruby. --- plugins/LV2/Template/Plugin.cpp | 24 ++++++++++++++++++++ plugins/LV2/Template/Plugin.h | 27 ++++++++++++++++++++++ plugins/LV2/Template/Plugin.ttl | 44 ++++++++++++++++++++++++++++++++++++ plugins/LV2/Template/manifest.ttl.in | 12 ++++++++++ plugins/LV2/makeplugin | 44 ++++++++++++++++++++++++++++++++++++ 5 files changed, 151 insertions(+) create mode 100644 plugins/LV2/Template/Plugin.cpp create mode 100644 plugins/LV2/Template/Plugin.h create mode 100644 plugins/LV2/Template/Plugin.ttl create mode 100644 plugins/LV2/Template/manifest.ttl.in create mode 100755 plugins/LV2/makeplugin diff --git a/plugins/LV2/Template/Plugin.cpp b/plugins/LV2/Template/Plugin.cpp new file mode 100644 index 0000000..c70f6ab --- /dev/null +++ b/plugins/LV2/Template/Plugin.cpp @@ -0,0 +1,24 @@ +#include "@Plugin@.h" +#include +#include + +@Plugin@::@Plugin@(double rate) + : LV2Plugin(rate) +{ +} + +void @Plugin@::run(uint32_t num_samples) +{ + A = *params[0]; + + processReplacing(const_cast(in), out, num_samples); +} + +// +// Include the processing code from the VST version. +// +#include +#include "../../../LinuxVST/src/@Plugin@/@Plugin@Proc.cpp" + +// Create the LV2Wrapper and register the plugin +LV2Wrapper<@Plugin@> plugin; diff --git a/plugins/LV2/Template/Plugin.h b/plugins/LV2/Template/Plugin.h new file mode 100644 index 0000000..aee342d --- /dev/null +++ b/plugins/LV2/Template/Plugin.h @@ -0,0 +1,27 @@ +#ifndef __@Plugin@_H +#define __@Plugin@_H + +#include + +class @Plugin@ : public LV2Plugin<1> { +public: + @Plugin@(double rate); + + void run(uint32_t num_samples); + + static constexpr const char * URI = "https://www.airwindows.com/@plugin@"; + +private: + /* + * These are the original DSP functions from the VST plugin. + * They need to be called from the LV2 plugins `run` function. + */ + void processReplacing(float **in, float **out, VstInt32 samples); + void processDoubleReplacing(double **in, double **out, VstInt32 samples); + + /* + * Members needed by the processing functions. + */ +}; + +#endif diff --git a/plugins/LV2/Template/Plugin.ttl b/plugins/LV2/Template/Plugin.ttl new file mode 100644 index 0000000..b149e85 --- /dev/null +++ b/plugins/LV2/Template/Plugin.ttl @@ -0,0 +1,44 @@ +# Airwindows @Plugin@ plugin description + +@prefix lv2: . +@prefix rdf: . +@prefix rdfs: . +@prefix units: . + + + a lv2:Plugin , + lv2:EffectPlugin ; + lv2:project ; + + lv2:optionalFeature lv2:hardRTCapable ; + + # Define the ports for this plugin. + lv2:port [ + a lv2:InputPort , lv2:ControlPort ; + lv2:index 0 ; + lv2:symbol "A" ; + lv2:name "Parameter A" ; + lv2:default 0.5 ; + lv2:minimum 0.0 ; + lv2:maximum 1.0 ; + ] , [ + a lv2:InputPort , lv2:AudioPort ; + lv2:index 1 ; + lv2:symbol "in_l" ; + lv2:name "In left" ; + ] , [ + a lv2:InputPort , lv2:AudioPort ; + lv2:index 2 ; + lv2:symbol "in_r" ; + lv2:name "In right" ; + ] , [ + a lv2:OutputPort , lv2:AudioPort ; + lv2:index 3 ; + lv2:symbol "out_l" ; + lv2:name "Out left" ; + ] , [ + a lv2:OutputPort , lv2:AudioPort ; + lv2:index 4 ; + lv2:symbol "out_r" ; + lv2:name "Out right" ; + ] . diff --git a/plugins/LV2/Template/manifest.ttl.in b/plugins/LV2/Template/manifest.ttl.in new file mode 100644 index 0000000..50bff4d --- /dev/null +++ b/plugins/LV2/Template/manifest.ttl.in @@ -0,0 +1,12 @@ +# LV2 Plugin manifest for Airwindows @Plugin@ plugin + +@prefix doap: . +@prefix lv2: . +@prefix rdfs: . + + + a lv2:Plugin ; + doap:name "Airwindows @Plugin@" ; + doap:license ; + lv2:binary <@Plugin@@CMAKE_SHARED_LIBRARY_SUFFIX@> ; + rdfs:seeAlso <@Plugin@.ttl> . diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin new file mode 100755 index 0000000..8fc98eb --- /dev/null +++ b/plugins/LV2/makeplugin @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby + +unless ARGV[0] + puts "Give me the name of a plugin to make." + exit +end + +root = File.dirname(__FILE__) + +plugin_name = ARGV[0] +plugin_slug = plugin_name.downcase + +target_dir = File.join(root, 'src', plugin_name) +template_dir = File.join(root, 'Template') + +puts "Creating plugin #{plugin_name}..." + +Templates = %w{ + manifest.ttl.in + Plugin.ttl + Plugin.h + Plugin.cpp +} + +begin + Dir.mkdir(target_dir) + + Templates.each do |t| + tpl = IO.read(File.join(template_dir, t)) + .gsub('@Plugin@', plugin_name) + .gsub('@plugin@', plugin_slug) + + fname = t.sub('Plugin', plugin_name) + + puts " - #{fname}..." + File.open(File.join(target_dir, fname), "w") do |f| + f.write(tpl) + end + end + +rescue SystemCallError => e + puts "Could not create plugin: #{e}" + puts "Aborting!" +end -- cgit v1.2.3