Skeleton LADSPA->LV2 conversion utility.
git-svn-id: http://svn.drobilla.net/lad@245 a436a847-0d15-0410-975c-d299462d15a1
This commit is contained in:
parent
3386d92011
commit
a917e28a95
|
@ -1,4 +1,4 @@
|
|||
SUBDIRS = src slv2 examples data doc
|
||||
SUBDIRS = src slv2 utils examples data doc
|
||||
|
||||
pkgconfigdir = $(libdir)/pkgconfig
|
||||
pkgconfig_DATA = libslv2.pc
|
||||
|
|
|
@ -2,6 +2,7 @@ AC_PREREQ(2.59)
|
|||
AC_INIT([libslv2],[0.0.1],[drobilla@connect.carleton.ca])
|
||||
AC_CONFIG_SRCDIR([src/plugin.c])
|
||||
AC_CONFIG_SRCDIR([slv2/plugin.h])
|
||||
AC_CONFIG_SRCDIR([utils/ladspa2lv2.c])
|
||||
AC_CONFIG_SRCDIR([examples/plugins/Amp-swh.lv2/amp.c])
|
||||
AC_CONFIG_SRCDIR([examples/hosts/test_host.c])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
|
@ -39,6 +40,13 @@ if test "$strict" = "yes"; then
|
|||
CFLAGS="$CFLAGS -std=c99 -pedantic -Wall -Wextra -Wconversion -Winit-self"
|
||||
fi
|
||||
|
||||
# Build utilities?
|
||||
build_utilities="no"
|
||||
AC_ARG_ENABLE(utilities,
|
||||
[AS_HELP_STRING(--enable-utilities, [Build utilities (no) - EXPERIMENTAL])],
|
||||
[build_utilities="$enableval"])
|
||||
AM_CONDITIONAL(BUILD_UTILITIES, [test "$build_utilities" = "yes"])
|
||||
|
||||
# Bolt on a few specific flags to CXXFLAGS that should always be used
|
||||
#CFLAGS="$CFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
|
||||
|
||||
|
@ -51,6 +59,9 @@ AC_ARG_WITH(lv2-dir,
|
|||
AC_MSG_RESULT($lv2dir)
|
||||
AC_SUBST(lv2dir)
|
||||
|
||||
# Check for RAPTOR
|
||||
PKG_CHECK_MODULES(RAPTOR, raptor >= 0.21, build_raptor="yes", build_raptor="no")
|
||||
|
||||
# Check for RASQAL
|
||||
PKG_CHECK_MODULES(RASQAL, rasqal >= 0.9.11, build_rasqal="yes", build_rasqal="no")
|
||||
|
||||
|
@ -74,6 +85,7 @@ AM_CONDITIONAL(WITH_JACK, [test "$build_jack" = "yes"])
|
|||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_FILES([src/Makefile])
|
||||
AC_CONFIG_FILES([slv2/Makefile])
|
||||
AC_CONFIG_FILES([utils/Makefile])
|
||||
AC_CONFIG_FILES([examples/Makefile])
|
||||
AC_CONFIG_FILES([examples/plugins/Makefile])
|
||||
AC_CONFIG_FILES([examples/hosts/Makefile])
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
if BUILD_UTILITIES
|
||||
|
||||
bin_PROGRAMS = ladspa2lv2
|
||||
|
||||
ladspa2lv2_LDADD = -ldl @RAPTOR_LIBS@
|
||||
ladspa2lv2_SOURCES = ladspa2lv2.c
|
||||
|
||||
endif
|
|
@ -0,0 +1,145 @@
|
|||
/* ladspa2lv2
|
||||
* Copyright (C) 2007 Dave Robillard <drobilla@connect.carleton.ca>
|
||||
*
|
||||
* 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 2 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 St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <raptor.h>
|
||||
#include <ladspa.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#define U(x) ((const unsigned char*)(x))
|
||||
|
||||
|
||||
LADSPA_Descriptor*
|
||||
load_ladspa_plugin(const char* lib_path, unsigned long index)
|
||||
{
|
||||
void* const handle = dlopen(lib_path, RTLD_LAZY);
|
||||
if (handle == NULL)
|
||||
return NULL;
|
||||
|
||||
LADSPA_Descriptor_Function df
|
||||
= (LADSPA_Descriptor_Function)dlsym(handle, "ladspa_descriptor");
|
||||
|
||||
if (df == NULL) {
|
||||
dlclose(handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
LADSPA_Descriptor* const descriptor = (LADSPA_Descriptor*)df(index);
|
||||
|
||||
return descriptor;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
write_resource(raptor_serializer* serializer,
|
||||
const char* subject_uri,
|
||||
const char* predicate_uri,
|
||||
const char* object_uri)
|
||||
{
|
||||
raptor_statement triple;
|
||||
|
||||
triple.subject = (void*)raptor_new_uri(U(subject_uri));
|
||||
triple.subject_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
|
||||
|
||||
triple.predicate = (void*)raptor_new_uri(U(predicate_uri));
|
||||
triple.predicate_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
|
||||
|
||||
//if (object.type() == RdfId::RESOURCE) {
|
||||
triple.object = (void*)raptor_new_uri(U(object_uri));
|
||||
triple.object_type = RAPTOR_IDENTIFIER_TYPE_RESOURCE;
|
||||
/*} else {
|
||||
assert(object.type() == RdfId::ANONYMOUS);
|
||||
triple.object = (unsigned char*)(strdup(object.to_string().c_str()));
|
||||
triple.object_type = RAPTOR_IDENTIFIER_TYPE_ANONYMOUS;
|
||||
}*/
|
||||
|
||||
raptor_serialize_statement(serializer, &triple);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
write_lv2_turtle(LADSPA_Descriptor* descriptor, const char* uri, const char* filename)
|
||||
{
|
||||
raptor_init();
|
||||
raptor_serializer* serializer = raptor_new_serializer("turtle");
|
||||
|
||||
// Set up namespaces
|
||||
raptor_serialize_set_namespace(serializer, raptor_new_uri(
|
||||
U("http://www.w3.org/1999/02/22-rdf-syntax-ns#")), U("rdf"));
|
||||
raptor_serialize_set_namespace(serializer, raptor_new_uri(
|
||||
U("http://www.w3.org/2000/01/rdf-schema#")), U("rdfs"));
|
||||
raptor_serialize_set_namespace(serializer, raptor_new_uri(
|
||||
U("http://www.w3.org/2001/XMLSchema")), U("xsd"));
|
||||
raptor_serialize_set_namespace(serializer, raptor_new_uri(
|
||||
U("http://usefulinc.com/ns/doap#")), U("doap"));
|
||||
raptor_serialize_set_namespace(serializer, raptor_new_uri(
|
||||
U("http://xmlns.com/foaf/0.1/")), U("foaf"));
|
||||
raptor_serialize_set_namespace(serializer, raptor_new_uri(
|
||||
U("http://lv2plug.in/ontology#")), U("lv2"));
|
||||
|
||||
raptor_serialize_start_to_filename(serializer, filename);
|
||||
|
||||
|
||||
// Write out plugin data
|
||||
|
||||
write_resource(serializer, uri,
|
||||
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type", "lv2:Plugin");
|
||||
|
||||
write_resource(serializer, uri,
|
||||
"http://usefulinc.com/ns/doap#name", descriptor->Name);
|
||||
|
||||
|
||||
|
||||
raptor_serialize_end(serializer);
|
||||
raptor_free_serializer(serializer);
|
||||
raptor_finish();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
print_usage()
|
||||
{
|
||||
printf("Usage: ladspa2slv2 /path/to/laddspalib.so index lv2_uri\n\n");
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
if (argc != 4) {
|
||||
print_usage();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char* const lib_path = argv[1];
|
||||
const unsigned long index = atol(argv[2]);
|
||||
const char* const uri = argv[3];
|
||||
|
||||
|
||||
LADSPA_Descriptor* descriptor = load_ladspa_plugin(lib_path, index);
|
||||
|
||||
if (descriptor) {
|
||||
printf("Loaded %s : %lu\n", lib_path, index);
|
||||
write_lv2_turtle(descriptor, uri, "ladspaplugin.ttl");
|
||||
} else {
|
||||
printf("Failed to load %s : %lu\n", lib_path, index);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue