aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xplugins/LV2/makeplugin47
1 files changed, 34 insertions, 13 deletions
diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin
index bc28335..be152b1 100755
--- a/plugins/LV2/makeplugin
+++ b/plugins/LV2/makeplugin
@@ -10,19 +10,20 @@ def make_param_assigns(num)
.join("\n ")
end
-def make_ctrl_port(n)
+def make_ctrl_port(n, name)
%Q{ a lv2:InputPort , lv2:ControlPort ;
lv2:index #{n} ;
lv2:symbol "#{param_sym(n)}" ;
- lv2:name "Parameter #{param_sym(n)}" ;
+ lv2:name "#{name}" ;
lv2:default 0.5 ;
lv2:minimum 0.0 ;
lv2:maximum 1.0 ;}
end
-def make_lv2_port_defs(num)
+def make_lv2_port_defs(pi)
+ num = pi[:n_ctrl_ports]
ctrlports = (0 ... num)
- .map { |n| make_ctrl_port(n) }
+ .map { |n| make_ctrl_port(n, pi["ctrl_port_#{param_sym(n)}".to_sym]) }
.join("\n ] , [\n")
ctrlports + %Q{
@@ -49,7 +50,7 @@ def make_lv2_port_defs(num)
end
if ARGV.length < 1
- puts "Usage: #{__FILE__} <PluginName> [<NCtrlPorts>]"
+ puts "Usage: #{__FILE__} <PluginName>"
exit
end
@@ -58,8 +59,6 @@ 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')
@@ -72,9 +71,7 @@ def find_plugin_info(db, plugin_name)
File.open(db) do |f|
pat = /^\s*(\w+): \"([^"]+)\",/
f.each_line do |line|
- if found && line =~ /^\s*\},$/
- return pi
- end
+ break if found && line =~ /^\s*\},$/
pat.match(line) do |m|
if m[1] == 'Name' && m[2] == plugin_name
@@ -86,6 +83,29 @@ def find_plugin_info(db, plugin_name)
end
end
+ header_file = File.join('../WinVST', plugin_name, "#{plugin_name}.h")
+
+ File.open(header_file) do |f|
+ f.each_line do |line|
+ if line =~ /kNumParameters\s*=\s*(\d+)/
+ pi[:n_ctrl_ports] = $1.to_i
+ end
+ end
+ end
+
+ class_file = File.join('../WinVST', plugin_name, "#{plugin_name}.cpp")
+ fun = ""
+
+ File.open(class_file) do |f|
+ f.each_line do |line|
+ if line =~ /void #{plugin_name}::(\w+)/
+ fun = $1
+ elsif fun == 'getParameterName' and line =~ /case\s+kParam([A-Z])\:\s+vst_strncpy\s*\([^,]*,\s*\"(\w+)\",/
+ pi["ctrl_port_#{$1}".to_sym] = $2
+ end
+ end
+ end
+
return pi
end
@@ -106,6 +126,7 @@ plugin_info = find_plugin_info(File.join(root, '../../cheatsheet/src/database.js
puts "Creating plugin #{plugin_name}..."
puts "Type: #{plugin_info[:type]}"
+puts "CTRL ports: #{plugin_info[:n_ctrl_ports]}"
Templates = %w{
manifest.ttl.in
@@ -121,9 +142,9 @@ 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))
- .gsub('@TTLPortDefs@', make_lv2_port_defs(n_ctrl_ports.to_i))
+ .gsub('@NCtrlPorts@', plugin_info[:n_ctrl_ports].to_s)
+ .gsub('@AssignParams@', make_param_assigns(plugin_info[:n_ctrl_ports]))
+ .gsub('@TTLPortDefs@', make_lv2_port_defs(plugin_info))
.gsub('@TTLPluginType@', get_lv2_plugin_type(plugin_info))
fname = t.sub('Plugin', plugin_name)