diff options
-rw-r--r-- | plugins/LV2/lib/makeplugin/plugin_description_template.rb | 5 | ||||
-rw-r--r-- | plugins/LV2/lib/makeplugin/plugin_info.rb | 25 | ||||
-rwxr-xr-x | plugins/LV2/makeplugin | 2 |
3 files changed, 23 insertions, 9 deletions
diff --git a/plugins/LV2/lib/makeplugin/plugin_description_template.rb b/plugins/LV2/lib/makeplugin/plugin_description_template.rb index 3b990b2..13857b8 100644 --- a/plugins/LV2/lib/makeplugin/plugin_description_template.rb +++ b/plugins/LV2/lib/makeplugin/plugin_description_template.rb @@ -41,10 +41,11 @@ module MakePlugin private def make_ctrl_port(n, ctrl_port) + puts "Adding ctrl port #{n}, #{ctrl_port.inspect}." %Q{ a lv2:InputPort , lv2:ControlPort ; lv2:index #{n} ; - lv2:symbol "#{ctrl_port[:sym]}" ; - lv2:name "#{ctrl_port[:name]}" ; + lv2:symbol "#{ctrl_port[1][:sym]}" ; + lv2:name "#{ctrl_port[1][:name]}" ; lv2:default 0.5 ; lv2:minimum 0.0 ; lv2:maximum 1.0 ;} diff --git a/plugins/LV2/lib/makeplugin/plugin_info.rb b/plugins/LV2/lib/makeplugin/plugin_info.rb index 686a8e8..0cb945c 100644 --- a/plugins/LV2/lib/makeplugin/plugin_info.rb +++ b/plugins/LV2/lib/makeplugin/plugin_info.rb @@ -32,12 +32,13 @@ module MakePlugin def initialize(root, name) @name = name - @ctrl_ports = [] + @ctrl_ports = {} @var_decls = [] @var_inits = [] self.find_plugin_info(root) if @n_ctrl_ports != @ctrl_ports.length - raise "Expected #{@n_ctrl_ports} but found #{@ctrl_ports.length}" + pp @ctrl_ports + raise "Expected #{@n_ctrl_ports} control ports, but found #{@ctrl_ports.length}" end end @@ -121,12 +122,10 @@ module MakePlugin File.open(class_file) do |f| f.each_line do |line| - if line =~ /void #{@name}::(\w+)/ - fun = $1 + if line =~ /^(void|float) #{@name}::(\w+)/ + fun = $2 elsif line =~ /^#{@name}::#{@name}/ fun = 'constructor_' - elsif fun == 'getParameterName' and line =~ /case\s+kParam([A-Z])\:\s+vst_strncpy\s*\([^,]*,\s*\"([^"]+)\",/ - @ctrl_ports << { sym: $1, name: $2 } elsif fun == 'constructor_' and line =~ /\{\s*$/ fun = 'constructor' elsif fun == 'constructor' @@ -135,6 +134,20 @@ module MakePlugin else @var_inits << line.chomp end + elsif fun == 'getParameterName' and line =~ /case\s+kParam([A-Z])\:\s+vst_strncpy\s*\([^,]*,\s*\"([^"]+)\",/ + puts "getParameterName(#{$1}, #{$2})" + if @ctrl_ports.has_key?($1) + @ctrl_ports[$1][:name] = $2 + else + @ctrl_ports[$1] = { name: $2 } + end + elsif fun == 'getParameter' and line =~ /case\s+kParam([A-Z])\: return (\w+);/ + puts "getParameter(#{$1}, #{$2})" + if @ctrl_ports.has_key?($1) + @ctrl_ports[$1][:sym] = $2 + else + @ctrl_ports[$1] = { sym: $2 } + end end end end diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin index de6aaeb..fc49385 100755 --- a/plugins/LV2/makeplugin +++ b/plugins/LV2/makeplugin @@ -7,7 +7,7 @@ require_relative 'lib/makeplugin/plugin_info' def make_param_assigns(ctrl_ports) ctrl_ports - .map.with_index { |p, n| "#{p[:sym]} = *params[#{n}];" } + .map.with_index { |p, n| "#{p[1][:sym]} = *params[#{n}];" } .join("\n ") end |