diff options
-rw-r--r-- | plugins/LV2/Template/Plugin.ttl | 28 | ||||
-rwxr-xr-x | plugins/LV2/makeplugin | 45 |
2 files changed, 45 insertions, 28 deletions
diff --git a/plugins/LV2/Template/Plugin.ttl b/plugins/LV2/Template/Plugin.ttl index b149e85..1402c9e 100644 --- a/plugins/LV2/Template/Plugin.ttl +++ b/plugins/LV2/Template/Plugin.ttl @@ -14,31 +14,5 @@ # 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" ; +@TTLPortDefs@ ] . diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin index 5b11a87..5fae69f 100755 --- a/plugins/LV2/makeplugin +++ b/plugins/LV2/makeplugin @@ -1,11 +1,53 @@ #!/usr/bin/env ruby +def param_sym(n) + ('A'.ord + n).chr +end + def make_param_assigns(num) (0 ... num) - .map { |n| "#{('A'.ord + n).chr} = *param[#{n}];" } + .map { |n| "#{param_sym(n)} = *param[#{n}];" } .join("\n ") end +def make_ctrl_port(n) + %Q{ a lv2:InputPort , lv2:ControlPort ; + lv2:index #{n} ; + lv2:symbol "#{param_sym(n)}" ; + lv2:name "Parameter #{param_sym(n)}" ; + lv2:default 0.5 ; + lv2:minimum 0.0 ; + lv2:maximum 1.0 ;} +end + +def make_lv2_port_defs(num) + ctrlports = (0 ... num) + .map { |n| make_ctrl_port(n) } + .join("\n ] , [\n") + + ctrlports + %Q{ + ] , [ + a lv2:InputPort , lv2:AudioPort ; + lv2:index #{num} ; + lv2:symbol "in_l" ; + lv2:name "In left" ; + ] , [ + a lv2:InputPort , lv2:AudioPort ; + lv2:index #{num + 1} ; + lv2:symbol "in_r" ; + lv2:name "In right" ; + ] , [ + a lv2:OutputPort , lv2:AudioPort ; + lv2:index #{num + 2} ; + lv2:symbol "out_l" ; + lv2:name "Out left" ; + ] , [ + a lv2:OutputPort , lv2:AudioPort ; + lv2:index #{num + 3} ; + lv2:symbol "out_r" ; + lv2:name "Out right" ;} +end + if ARGV.length < 1 puts "Usage: #{__FILE__} <PluginName> [<NCtrlPorts>]" exit @@ -39,6 +81,7 @@ begin .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)) fname = t.sub('Plugin', plugin_name) |