#!/usr/bin/perl # # dx7lv2sounds2preset - create a presets.ttl and add this to manifest.ttl for # Dexed.lv2 - LV2 plugin # # This generator builds the presets-ttl and a suitable manifest.ttl # # (c) by H. Wirtz # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software Foundation, # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # open(MANIFEST,">manifest.ttl")||die("Cannot open manifest.ttl for writing: $!\n"); print MANIFEST "\@prefix lv2: .\n"; print MANIFEST "\@prefix pset: .\n"; print MANIFEST "\@prefix rdfs: .\n"; print MANIFEST "\@prefix ui: .\n"; print MANIFEST "\@prefix mdap: .\n"; print MANIFEST "\@prefix pset: .\n"; print MANIFEST "\@prefix doap: .\n"; print MANIFEST "\@prefix foaf: .\n"; print MANIFEST "\n"; print MANIFEST "\n"; print MANIFEST " a lv2:Plugin, doap:Project, lv2:SynthPlugin ;\n"; print MANIFEST " rdfs:seeAlso ;\n"; print MANIFEST " rdfs:seeAlso .\n"; print MANIFEST "\n"; open(PRESETS,">presets.ttl")||die("Cannot open presets.ttl for writing: $!\n"); print PRESETS "\@prefix lv2: .\n"; print PRESETS "\@prefix pset: .\n"; print PRESETS "\@prefix rdfs: .\n"; print PRESETS "\n"; while($voice=shift(@ARGV)) { insert_data($voice); } close(PRESETS); close(MANIFEST); sub insert_data { my($voice)=@_; open(M_VOICE,"<".$voice."/manifest.ttl")||die("Cannot open ".$voice."/manifest.ttl: $!\n"); while($l=) { if($l=~/^\s*rdfs:label \"(.+)\"/) { $voice_name=$1 } elsif($l=~/\s*rdfs:seeAlso <(.+)>/) { $file=$1; } } close(M_VOICE); if($voice_name eq "" || $file eq "") { print "Voice data for ".$voice."/manifest.ttl is not consistent\n"; print "voice: [$voice_name] file: [$file]\n"; return; } print MANIFEST "\n"; print MANIFEST " a pset:Preset ;\n"; print MANIFEST " rdfs:label \"".$voice_name."\"\n"; print MANIFEST " lv2:appliesTo ;\n"; print MANIFEST " rdfs:seeAlso .\n"; print MANIFEST "\n"; print PRESETS "\n"; open(VOICE,"<".$voice."/".$file)||die("Cannot open ".$voice."/".$file.": $!"); while($l=) { next if($l=~/^\s*$/); next if($l=~/^[^ ]/); print PRESETS $l; } close(VOICE); print PRESETS "\n"; }