From 592e01cd1a572d03a3c79c99a6af7d2e3828c171 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sun, 2 Aug 2020 18:57:35 +0200 Subject: LV2: makeplugin use cheatsheet db for plugin type mapping. Only the 'Saturation' type is mapped to lv2::DistortionPlugin for now, but this is easy to expand as we go. I'll update this for each new plugin type that's ported for now. --- plugins/LV2/Template/Plugin.ttl | 2 +- plugins/LV2/makeplugin | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/plugins/LV2/Template/Plugin.ttl b/plugins/LV2/Template/Plugin.ttl index 1402c9e..1ede09d 100644 --- a/plugins/LV2/Template/Plugin.ttl +++ b/plugins/LV2/Template/Plugin.ttl @@ -7,7 +7,7 @@ a lv2:Plugin , - lv2:EffectPlugin ; + lv2:@TTLPluginType@ ; lv2:project ; lv2:optionalFeature lv2:hardRTCapable ; diff --git a/plugins/LV2/makeplugin b/plugins/LV2/makeplugin index 5fae69f..3dd2782 100755 --- a/plugins/LV2/makeplugin +++ b/plugins/LV2/makeplugin @@ -63,7 +63,47 @@ n_ctrl_ports = ARGV[1] || '1' target_dir = File.join(root, 'src', plugin_name) template_dir = File.join(root, 'Template') +PLUGIN_FIELDS = %w{Type Use Description Comment} + +def find_plugin_info(db, plugin_name) + pi = { name: plugin_name } + found = false + + File.open(db) do |f| + pat = /^\s*(\w+): \"([^"]+)\",/ + f.each_line do |line| + if found && line =~ /^\s*\},$/ + return pi + end + + pat.match(line) do |m| + if m[1] == 'Name' && m[2] == plugin_name + found = true + elsif found && PLUGIN_FIELDS.include?(m[1]) + pi[m[1].downcase.to_sym] = m[2] + end + end + end + end + + return pi +end + +def get_lv2_plugin_type(plugin_info) + case plugin_info[:type] + when 'Saturation' + 'DistortionPlugin' + else + 'EffectsPlugin' + end +end + +puts "Reading plugin info from cheatsheet..." +plugin_info = find_plugin_info(File.join(root, '../../cheatsheet/src/database.js'), plugin_name) + + puts "Creating plugin #{plugin_name}..." +puts "Type: #{plugin_info[:type]}" Templates = %w{ manifest.ttl.in @@ -82,6 +122,7 @@ begin .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('@TTLPluginType@', get_lv2_plugin_type(plugin_info)) fname = t.sub('Plugin', plugin_name) -- cgit v1.2.3