From 8e1de3ce53f1e61d24578379bd38a42401fa37e8 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Wed, 22 Jul 2020 16:47:13 +0200 Subject: LV2: makeplugin script not handles number of control ports. If specified, the correct number will be put in the class declaration, and the correct number of params will be assigned to their respecive param instance variables. The ttl file is not updated with this info yet. --- plugins/LV2/Template/Plugin.cpp | 2 +- plugins/LV2/Template/Plugin.h | 2 +- plugins/LV2/makeplugin | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/plugins/LV2/Template/Plugin.cpp b/plugins/LV2/Template/Plugin.cpp index c70f6ab..49d4420 100644 --- a/plugins/LV2/Template/Plugin.cpp +++ b/plugins/LV2/Template/Plugin.cpp @@ -9,7 +9,7 @@ void @Plugin@::run(uint32_t num_samples) { - A = *params[0]; + @AssignParams@ processReplacing(const_cast(in), out, num_samples); } diff --git a/plugins/LV2/Template/Plugin.h b/plugins/LV2/Template/Plugin.h index aee342d..7569955 100644 --- a/plugins/LV2/Template/Plugin.h +++ b/plugins/LV2/Template/Plugin.h @@ -3,7 +3,7 @@ #include -class @Plugin@ : public LV2Plugin<1> { +class @Plugin@ : public LV2Plugin<@NCtrlPorts@> { public: @Plugin@(double rate); diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin index 8fc98eb..5b11a87 100755 --- a/plugins/LV2/makeplugin +++ b/plugins/LV2/makeplugin @@ -1,7 +1,13 @@ #!/usr/bin/env ruby -unless ARGV[0] - puts "Give me the name of a plugin to make." +def make_param_assigns(num) + (0 ... num) + .map { |n| "#{('A'.ord + n).chr} = *param[#{n}];" } + .join("\n ") +end + +if ARGV.length < 1 + puts "Usage: #{__FILE__} []" exit end @@ -10,6 +16,8 @@ root = File.dirname(__FILE__) plugin_name = ARGV[0] plugin_slug = plugin_name.downcase +n_ctrl_ports = ARGV[1] || '1' + target_dir = File.join(root, 'src', plugin_name) template_dir = File.join(root, 'Template') @@ -29,6 +37,8 @@ begin tpl = IO.read(File.join(template_dir, t)) .gsub('@Plugin@', plugin_name) .gsub('@plugin@', plugin_slug) + .gsub('@NCtrlPorts@', n_ctrl_ports) + .gsub('@AssignParams@', make_param_assigns(n_ctrl_ports.to_i)) fname = t.sub('Plugin', plugin_name) -- cgit v1.2.3