Browse Source

Moved libslv2 into it's own subdirectory

git-svn-id: http://svn.drobilla.net/lad/libslv2@4 a436a847-0d15-0410-975c-d299462d15a1
add_opts_to_lv2apply
David Robillard 16 years ago
parent
commit
7fd4168fe8
  1. 4
      AUTHORS
  2. 1
      COPYING
  3. 0
      ChangeLog
  4. 5
      Makefile.am
  5. 0
      NEWS
  6. 4
      README
  7. 9
      autogen.sh
  8. 100
      configure.ac
  9. 2
      doc/Makefile.am
  10. 10
      doc/mainpage.dox
  11. 1163
      doc/reference.doxygen.in
  12. 2
      examples/Makefile.am
  13. BIN
      examples/hosts/.jack_host.c.swp
  14. 24
      examples/hosts/Makefile.am
  15. 218
      examples/hosts/jack_host.c
  16. 231
      examples/hosts/test_host.c
  17. 10
      examples/plugins/Amp-swh.lv2/Makefile
  18. 96
      examples/plugins/Amp-swh.lv2/amp.c
  19. BIN
      examples/plugins/Amp-swh.lv2/amp.so
  20. 68
      examples/plugins/Amp-swh.lv2/amp.ttl
  21. 9
      examples/plugins/Amp-swh.lv2/manifest.ttl
  22. 24
      examples/plugins/Makefile.am
  23. 3
      include/Makefile.am
  24. 305
      include/lv2.h
  25. 326
      include/lv2.ttl
  26. 10
      libslv2.pc.in
  27. 11
      slv2/Makefile.am
  28. 168
      slv2/plugin.h
  29. 205
      slv2/plugininstance.h
  30. 159
      slv2/pluginlist.h
  31. 116
      slv2/port.h
  32. 65
      slv2/private_types.h
  33. 102
      slv2/query.h
  34. 36
      slv2/slv2.h
  35. 66
      slv2/types.h
  36. 14
      src/Makefile.am
  37. 190
      src/plugin.c
  38. 100
      src/plugininstance.c
  39. 243
      src/pluginlist.c
  40. 163
      src/port.c
  41. 123
      src/query.c
  42. 121
      src/util.c
  43. 53
      src/util.h

4
AUTHORS

@ -0,0 +1,4 @@
Author:
Dave Robillard <mailto:drobilla@connect.carleton.ca>

1
COPYING

@ -0,0 +1 @@
/usr/share/automake-1.9/COPYING

0
ChangeLog

5
Makefile.am

@ -0,0 +1,5 @@
SUBDIRS = include src slv2 examples doc
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libslv2.pc

0
NEWS

4
README

@ -0,0 +1,4 @@
You should not be reading this.
Tell no one!

9
autogen.sh

@ -0,0 +1,9 @@
#!/bin/sh
echo 'Generating necessary files...'
libtoolize --copy --force
aclocal
autoheader -Wall
automake --gnu --add-missing -Wall
autoconf

100
configure.ac

@ -0,0 +1,100 @@
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([include/lv2.h])
AC_CONFIG_SRCDIR([examples/plugins/Amp-swh.lv2/amp.c])
AC_CONFIG_SRCDIR([examples/hosts/test_host.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE
# Checks for compiler
AC_PROG_CC
# Check pedantic other stuff autoscan says we should :)
AC_C_CONST
AC_C_INLINE
AC_HEADER_STDBOOL
AC_TYPE_SIZE_T
# Library building stuff
AC_PROG_LIBTOOL
# Check for debugging flag
debug="no"
AC_ARG_ENABLE(debug,
[AS_HELP_STRING(--enable-debug, [Enable debugging (false)])],
[debug="$enableval"])
if test "$debug" = "yes"; then
CFLAGS="-O0 -g -DDEBUG"
CXXFLAGS="$CFLAGS"
else
CFLAGS="$CFLAGS -DNDEBUG"
CXXFLAGS="$CXXFLAGS -DNDEBUG"
fi
# Check for strict flag
strict="no"
AC_ARG_ENABLE(strict,
[AS_HELP_STRING(--enable-strict, [Enable strict compiler warnings and errors (false)])],
[strict="$enableval"])
if test "$strict" = "yes"; then
CFLAGS="$CFLAGS -std=c99 -pedantic -Wall -Wconversion -Winit-self"
CXXFLAGS="$CXXFLAGS -ansi -pedantic -Wall -Wconversion -Winit-self -Woverloaded-virtual -Wsign-promo"
fi
# Bolt on a few specific flags to CXXFLAGS that should always be used
#CXXFLAGS="$CXXFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
#CFLAGS="$CFLAGS -pipe -Wall -fmessage-length=139 -fdiagnostics-show-location=every-line"
# Check plugin install directory
AC_MSG_CHECKING([where to install LV2 plugins])
AC_ARG_WITH(lv2-dir,
AS_HELP_STRING([--with-lv2-dir=DIR],
[directory that LV2 plugins should be installed in ($libdir/lv2)]),
[lv2dir=$withval], [lv2dir=$libdir/lv2])
AC_MSG_RESULT($lv2dir)
AC_SUBST(lv2dir)
# Check for RASQAL
PKG_CHECK_MODULES(RASQAL, rasqal >= 0.20, build_rasqal="yes", build_rasqal="no")
AC_SUBST(JACK_CFLAGS)
AC_SUBST(JACK_LIBS)
# Check for JACK
build_jack="yes"
AC_ARG_ENABLE(jack,
[AS_HELP_STRING(--with-jack, [Build JACK clients (true)])],
[ if test x$with_jack = xno ; then build_jack=no ; fi ])
if test "$build_jack" = "yes"; then
PKG_CHECK_MODULES(JACK, jack >= 0.99.0, build_jack="yes", build_jack="no")
fi
if test "$build_jack" = "yes"; then
AC_DEFINE(HAVE_JACK, 1, [Has JACK])
AC_SUBST(JACK_CFLAGS)
AC_SUBST(JACK_LIBS)
else
AC_MSG_WARN([JACK not found, JACK clients will not be built.])
fi
AM_CONDITIONAL(WITH_JACK, [test "$build_jack" = "yes"])
# Write output files
AC_CONFIG_FILES([Makefile])
AC_CONFIG_FILES([src/Makefile])
AC_CONFIG_FILES([slv2/Makefile])
AC_CONFIG_FILES([include/Makefile])
AC_CONFIG_FILES([examples/Makefile])
AC_CONFIG_FILES([examples/plugins/Makefile])
AC_CONFIG_FILES([examples/hosts/Makefile])
AC_CONFIG_FILES([libslv2.pc])
AC_CONFIG_FILES([doc/Makefile])
AC_CONFIG_FILES([doc/reference.doxygen])
AC_OUTPUT
# Display summary message
AC_MSG_RESULT([])
AC_MSG_RESULT([Building JACK client: $build_jack])
AC_MSG_RESULT([])

2
doc/Makefile.am

@ -0,0 +1,2 @@
doc: $(top_srcdir)/doc/reference.doxygen $(top_srcdir)/include/lv2.h $(top_srcdir)/slv2/*.h
doxygen $(top_srcdir)/doc/reference.doxygen

10
doc/mainpage.dox

@ -0,0 +1,10 @@
/** @mainpage
@section Overview
LibSLV2 is a host library to simply the use of LV2 plugins.
It will have a lovely wordey description here once I get around to it.
For now click on the "Modules" tab above to get at the beef.
*/

1163
doc/reference.doxygen.in
File diff suppressed because it is too large
View File

2
examples/Makefile.am

@ -0,0 +1,2 @@
SUBDIRS = plugins hosts

BIN
examples/hosts/.jack_host.c.swp

24
examples/hosts/Makefile.am

@ -0,0 +1,24 @@
AM_CFLAGS = -std=c99 -I. -I$(top_srcdir)/include -I$(top_srcdir) `pkg-config --cflags rasqal`
AM_LDFLAGS = `pkg-config --libs rasqal`
bin_PROGRAMS = test_host jack_host
test_host_DEPENDENCIES = ../../src/libslv2.la
test_host_LDADD = ../../src/libslv2.la
test_host_SOURCES = \
test_host.c
if WITH_JACK
jack_host_CFLAGS = @JACK_CFLAGS@ $(AM_CFLAGS)
#jack_host_LIBS = @JACK_LIBS@
jack_host_DEPENDENCIES = ../../src/libslv2.la
jack_host_LDADD = ../../src/libslv2.la @JACK_LIBS@
jack_host_SOURCES = \
jack_host.c
endif # WITH_JACK

218
examples/hosts/jack_host.c

@ -0,0 +1,218 @@
/* LibSLV2 Jack Example Host
* Copyright (C) 2006 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 <slv2/slv2.h>
#include <jack/jack.h>
/** This program's data */
struct JackHost {
jack_client_t* jack_client; /**< Jack client */
SLV2Plugin* plugin; /**< Plugin "class" (actually just a few strings) */
SLV2Instance* instance; /**< Plugin "instance" (loaded shared lib) */
unsigned long num_ports; /**< Size of the two following arrays: */
jack_port_t** jack_ports; /**< For audio ports, otherwise NULL */
float* controls; /**< For control ports, otherwise 0.0f */
};
void die(const char* msg);
void create_port(struct JackHost* host, unsigned long port_index);
int jack_process_cb(jack_nframes_t nframes, void* data);
void list_plugins(SLV2List list);
int
main(int argc, char** argv)
{
struct JackHost host;
host.jack_client = NULL;
host.num_ports = 0;
host.jack_ports = NULL;
host.controls = NULL;
/* Find all installed plugins */
SLV2List plugins = slv2_list_new();
slv2_list_load_all(plugins);
//slv2_list_load_bundle(plugins, "http://www.scs.carleton.ca/~drobilla/files/Amp-swh.lv2");
/* Find the plugin to run */
const char* plugin_uri = (argc == 2) ? argv[1] : NULL;
if (!plugin_uri) {
fprintf(stderr, "\nYou must specify a plugin URI to load.\n");
fprintf(stderr, "\nKnown plugins:\n\n");
list_plugins(plugins);
return EXIT_FAILURE;
}
printf("URI:\t%s\n", plugin_uri);
host.plugin = slv2_list_get_plugin_by_uri(plugins, plugin_uri);
if (!host.plugin) {
fprintf(stderr, "Failed to find plugin %s.\n", plugin_uri);
slv2_list_free(plugins);
return EXIT_FAILURE;
}
/* Get the plugin's name */
char* name = slv2_plugin_get_name(host.plugin);
printf("Name:\t%s\n", name);
/* Connect to JACK (with plugin name as client name) */
host.jack_client = jack_client_open(name, JackNullOption, NULL);
free(name);
if (!host.jack_client)
die("Failed to connect to JACK.");
else
printf("Connected to JACK.\n");
/* Instantiate the plugin */
host.instance = slv2_plugin_instantiate(
host.plugin, jack_get_sample_rate(host.jack_client), NULL);
if (!host.instance)
die("Failed to instantiate plugin.\n");
else
printf("Succesfully instantiated plugin.\n");
jack_set_process_callback(host.jack_client, &jack_process_cb, (void*)(&host));
/* Create ports */
host.num_ports = slv2_plugin_get_num_ports(host.plugin);
host.jack_ports = calloc(host.num_ports, sizeof(jack_port_t*));
host.controls = calloc(host.num_ports, sizeof(float*));
for (unsigned long i=0; i < host.num_ports; ++i)
create_port(&host, i);
/* Activate plugin and JACK */
slv2_instance_activate(host.instance);
jack_activate(host.jack_client);
/* Run */
printf("Press enter to quit: ");
getc(stdin);
printf("\n");
/* Deactivate plugin and JACK */
slv2_instance_free(host.instance);
slv2_list_free(plugins);
printf("Shutting down JACK.\n");
for (unsigned long i=0; i < host.num_ports; ++i) {
if (host.jack_ports[i] != NULL) {
jack_port_unregister(host.jack_client, host.jack_ports[i]);
host.jack_ports[i] = NULL;
}
}
jack_client_close(host.jack_client);
return 0;
}
/** Abort and exit on error */
void
die(const char* msg)
{
fprintf(stderr, "%s\n", msg);
exit(EXIT_FAILURE);
}
/** Creates a port and connects the plugin instance to it's data location.
*
* For audio ports, creates a jack port and connects plugin port to buffer.
*
* For control ports, sets controls array to default value and connects plugin
* port to that element.
*/
void
create_port(struct JackHost* host,
unsigned long port_index)
{
/* Make sure this is a float port */
enum SLV2DataType type = slv2_port_get_data_type(host->plugin, port_index);
if (type != SLV2_DATA_TYPE_FLOAT)
die("Unrecognized data type, aborting.");
/* Get the port symbol (label) for console printing */
char* symbol = slv2_port_get_symbol(host->plugin, port_index);
/* Initialize the port array elements */
host->jack_ports[port_index] = NULL;
host->controls[port_index] = 0.0f;
/* Get the 'class' of the port (control input, audio output, etc) */
enum SLV2PortClass class = slv2_port_get_class(host->plugin, port_index);
/* Connect the port based on it's 'class' */
switch (class) {
case SLV2_CONTROL_RATE_INPUT:
host->controls[port_index] = slv2_port_get_default_value(host->plugin, port_index);
slv2_instance_connect_port(host->instance, port_index, &host->controls[port_index]);
printf("Set %s to %f\n", symbol, host->controls[port_index]);
break;
case SLV2_CONTROL_RATE_OUTPUT:
slv2_instance_connect_port(host->instance, port_index, &host->controls[port_index]);
break;
case SLV2_AUDIO_RATE_INPUT:
host->jack_ports[port_index] = jack_port_register(host->jack_client,
symbol, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
break;
case SLV2_AUDIO_RATE_OUTPUT:
host->jack_ports[port_index] = jack_port_register(host->jack_client,
symbol, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
break;
default:
die("ERROR: Unknown port type, aborting messily!");
}
free(symbol);
}
/** Jack process callback. */
int
jack_process_cb(jack_nframes_t nframes, void* data)
{
struct JackHost* host = (struct JackHost*)data;
/* Connect plugin ports directly to JACK buffers */
for (unsigned long i=0; i < host->num_ports; ++i)
if (host->jack_ports[i] != NULL)
slv2_instance_connect_port(host->instance, i,
jack_port_get_buffer(host->jack_ports[i], nframes));
/* Run plugin for this cycle */
slv2_instance_run(host->instance, nframes);
return 0;
}
void
list_plugins(SLV2List list)
{
for (int i=0; i < slv2_list_get_length(list); ++i) {
const SLV2Plugin* const p = slv2_list_get_plugin_by_index(list, i);
printf("%s\n", slv2_plugin_get_uri(p));
}
}

231
examples/hosts/test_host.c

@ -0,0 +1,231 @@
/* LibSLV2 Test Host
* Copyright (C) 2006 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.
*/
#define _XOPEN_SOURCE 500
#include <rasqal.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <slv2/types.h>
#include <slv2/plugin.h>
#include <slv2/plugininstance.h>
#include <slv2/pluginlist.h>
#include <slv2/port.h>
void
create_control_input()
{
printf("Control Input\n");
}
void
create_control_output()
{
printf("Control Output\n");
}
void
create_audio_input()
{
printf("Audio Input\n");
}
void
create_audio_output()
{
printf("Audio Output\n");
}
void
create_port(SLV2Plugin* plugin,
SLV2Instance* instance,
unsigned long port_index)
{
enum SLV2PortClass class = slv2_port_get_class(plugin, port_index);
switch (class) {
case SLV2_CONTROL_RATE_INPUT:
create_control_input(port_index);
break;
case SLV2_CONTROL_RATE_OUTPUT:
create_control_output(port_index);
break;
case SLV2_AUDIO_RATE_INPUT:
create_audio_input(port_index);
break;
case SLV2_AUDIO_RATE_OUTPUT:
create_audio_output(port_index);
break;
default:
printf("Unknown port type, ignored.\n");
}
//printf("Port %ld class: %d\n", i, slv2_port_get_class(p, i));
}
int
main()
{
//const char* path = "foo";
const char* path = "/home/dave/code/libslv2/examples/plugins";
SLV2List plugins = slv2_list_new();
slv2_list_load_path(plugins, path);
const char* plugin_uri = "http://plugin.org.uk/swh-plugins/amp";
printf("URI:\t%s\n", plugin_uri);
const SLV2Plugin* p = slv2_list_get_plugin_by_uri(plugins, plugin_uri);
if (p) {
/* Get the plugin's name */
unsigned char* name = slv2_plugin_get_name(p);
printf("Name:\t%s\n", name);
free(name);
unsigned long num_ports = slv2_plugin_get_num_ports(p);
//printf("Number of ports: %ld\n", num_ports);
for (unsigned long i=0; i < num_ports; ++i) {
enum SLV2PortClass class = slv2_port_get_class(p, i);
switch (class) {
case SLV2_CONTROL_RATE_INPUT:
create_control_input(i);
break;
case SLV2_CONTROL_RATE_OUTPUT:
create_control_output(i);
break;
case SLV2_AUDIO_RATE_INPUT:
create_audio_input(i);
break;
case SLV2_AUDIO_RATE_OUTPUT:
create_audio_output(i);
break;
default:
printf("Unknown port type, ignored.\n");
}
//printf("Port %ld class: %d\n", i, slv2_port_get_class(p, i));
}
SLV2Property prop;
for (unsigned long i=0; i < num_ports; ++i) {
const char* property = "a";
prop = slv2_port_get_property(p, i, property);
if (prop)
printf("Port %ld %s = %s\n", i, property, prop->values[0]);
else
printf("No port %ld %s.\n", i, property);
free(prop);
}
printf("\n");
SLV2Instance* i = slv2_plugin_instantiate(p, 48000, NULL);
if (i) {
printf("Succesfully instantiated plugin.\n");
float gain = 2.0f;
float input = 0.25f;
float output = 0.0f;
slv2_instance_connect_port(i, 0, &gain);
slv2_instance_connect_port(i, 1, &input);
slv2_instance_connect_port(i, 2, &output);
slv2_instance_activate(i);
slv2_instance_run(i, 1);
slv2_instance_deactivate(i);
printf("Gain: %f, Input: %f => Output: %f\n", gain, input, output);
slv2_instance_free(i);
}
}
slv2_list_free(plugins);
#if 0
/* Display all plugins found in path */
if (plugins)
printf("Plugins found: %ld\n", slv2_list_get_size(plugins));
else
printf("No plugins found in %s\n", path);
for (unsigned long i=0; 1; ++i) {
const SLV2Plugin* p =
slv2_list_get_plugin_by_index(plugins, i);
if (!p)
break;
else
printf("\t%s\n", slv2_plugin_get_uri(p));
}
#endif
#if 0
const uchar* bundle_url = (const uchar*)"file:/home/dave/code/ladspa2/ladspa2_sdk/examples/plugins/Amp-swh.ladspa2/";
LV2Bundle* b = slv2_bundle_load(bundle_url);
if (b != NULL) {
printf("Loaded bundle %s\n", slv2_bundle_get_url(b));
for (unsigned long i=0; i < slv2_bundle_get_num_plugins(b); ++i) {
const SLV2Plugin* p = slv2_bundle_get_plugin_by_index(b, i);
//printf("Plugin: %s\n", p->plugin_uri);
//printf("Lib: %s\n", p->lib_url);
//printf("Data: %s\n", p->data_url);
printf("\n");
const uchar* property = (uchar*)"doap:name";
printf("%s\t%s\n", slv2_plugin_get_uri(p), property);
struct SLV2Property* result = slv2_plugin_get_property(p, property);
if (result) {
for (int i=0; i < result->num_values; ++i)
printf("\t%s\n", result->values[i]);
} else {
printf("No results.\n");
}
printf("\n");
/* Instantiate plugin */
SLV2PluginInstance* instance = slv2_plugin_instantiate(
p, 48000, NULL);
if (instance != NULL) {
printf("Successfully instantiated %s\n", slv2_plugin_get_uri(p));
slv2_plugin_instance_free(instance);
}
}
} else {
printf("Failed to load bundle %s\n", bundle_url);
}
#endif
return 0;
}

10
examples/plugins/Amp-swh.lv2/Makefile

@ -0,0 +1,10 @@
CFLAGS = -Wall -I../../../include
all: amp.so
amp.so: amp.o
$(LD) amp.o -o amp.so -shared
rm amp.o
clean:
rm *.o amp.so

96
examples/plugins/Amp-swh.lv2/amp.c

@ -0,0 +1,96 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "lv2.h"
#ifdef WIN32
#define SYMBOL_EXPORT __declspec(dllexport)
#else
#define SYMBOL_EXPORT
#endif
#define AMP_URI "http://plugin.org.uk/swh-plugins/amp";
#define AMP_GAIN 0
#define AMP_INPUT 1
#define AMP_OUTPUT 2
static LV2_Descriptor *ampDescriptor = NULL;
typedef struct {
float *gain;
float *input;
float *output;
} Amp;
static void cleanupAmp(LV2_Handle instance) {
free(instance);
}
static void connectPortAmp(LV2_Handle instance, unsigned long port,
void *data) {
Amp *plugin = (Amp *)instance;
switch (port) {
case AMP_GAIN:
plugin->gain = data;
break;
case AMP_INPUT:
plugin->input = data;
break;
case AMP_OUTPUT:
plugin->output = data;
break;
}
}
static LV2_Handle instantiateAmp(const LV2_Descriptor *descriptor,
unsigned long s_rate, const char *path , const LV2_Host_Feature **features) {
Amp *plugin_data = (Amp *)malloc(sizeof(Amp));
return (LV2_Handle)plugin_data;
}
#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
static void runAmp(LV2_Handle instance, unsigned long sample_count) {
Amp *plugin_data = (Amp *)instance;
const float gain = *(plugin_data->gain);
const float * const input = plugin_data->input;
float * const output = plugin_data->output;
unsigned long pos;
float coef = DB_CO(gain);
for (pos = 0; pos < sample_count; pos++) {
output[pos] = input[pos] * coef;
}
}
static void init() {
ampDescriptor =
(LV2_Descriptor *)malloc(sizeof(LV2_Descriptor));
ampDescriptor->URI = AMP_URI;
ampDescriptor->activate = NULL;
ampDescriptor->cleanup = cleanupAmp;
ampDescriptor->connect_port = connectPortAmp;
ampDescriptor->deactivate = NULL;
ampDescriptor->instantiate = instantiateAmp;
ampDescriptor->run = runAmp;
}
SYMBOL_EXPORT
const LV2_Descriptor *lv2_descriptor(unsigned long index) {
if (!ampDescriptor) init();
switch (index) {
case 0:
return ampDescriptor;
default:
return NULL;
}
}

BIN
examples/plugins/Amp-swh.lv2/amp.so

68
examples/plugins/Amp-swh.lv2/amp.ttl

@ -0,0 +1,68 @@
@prefix lv2: <http://lv2plug.in/ontology#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
<http://plugin.org.uk/swh-plugins/amp> a lv2:Plugin ;
a lv2:AmplifierPlugin ;
doap:maintainer [
foaf:name "Steve Harris";
foaf:homepage <http://plugin.org.uk/> ;
foaf:mbox <mailto:steve@plugin.org.uk> ;
] ;
doap:name "Simple amplifier" ;
doap:name "简单放大器"@ch ;
doap:name "Einfacher Verstärker"@de ;
doap:name "Simple amp"@en-gb-gb ;
doap:name "Amplificador simple"@es ;
doap:name "Amplificateur de base"@fr ;
doap:name "Amplificatore semplice"@it ;
doap:name "簡単なアンプ"@jp ;
doap:name "Просто усилитель"@ru ;
doap:licence <http://usefulinc.com/doap/licenses/gpl> ;
lv2:property lv2:hardRtCapable ;
lv2:port [
a lv2:InputControlRatePort ;
lv2:datatype lv2:float ;
lv2:index 0 ;
lv2:symbol "gain" ;
lv2:name "gain" ;
lv2:name "收益"@ch ;
lv2:name "gewinn"@de ;
lv2:name "gain"@en-gb-gb ;
lv2:name "aumento"@es ;
lv2:name "gain"@fr ;
lv2:name "guadagno"@it ;
lv2:name "利益"@jp ;
lv2:name "увеличение"@ru ;
lv2:default 0.0 ;
lv2:minimum -90.0 ;
lv2:maximum 24.0 ;
lv2:scalePoint [
lv2:label "+5" ;
lv2:value 5.0 ;
] , [
lv2:label "0" ;
lv2:value 0.0 ;
] , [
lv2:label "-5" ;
lv2:value -5.0 ;
] , [
lv2:label "-10" ;
lv2:value -10.0 ;
]
] , [
a lv2:InputAudioRatePort ;
lv2:datatype lv2:float ;
lv2:index 1 ;
lv2:symbol "in" ;
lv2:name "in" ;
] , [
a lv2:OutputAudioRatePort ;
lv2:datatype lv2:float ;
lv2:index 2 ;
lv2:symbol "out" ;
lv2:name "out" ;
]
.

9
examples/plugins/Amp-swh.lv2/manifest.ttl

@ -0,0 +1,9 @@
# LV2 Plugin Manifest
# Lists where plugins' data files and shared objects reside.
@prefix lv2: <http://lv2plug.in/ontology#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<http://plugin.org.uk/swh-plugins/amp> lv2:binary <amp.so> ;
rdfs:seeAlso <amp.ttl> .

24
examples/plugins/Makefile.am

@ -0,0 +1,24 @@
#AM_CFLAGS = -I$(top_srcdir)/include
#AM_LDFLAGS = -module -avoidversion -Wc,-nostartfiles
#
#plugindir = @umpdir@
#
#plugin_LTLIBRARIES = \
# test_plugin.la
#
## Stolen from swh-plugins, makes stupid libtool versions go away
#install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
# mkdir -p @umpdir@
# list='$(plugin_LTLIBRARIES)'; \
# for file in $$list; do \
# sofile=`basename $$file .la`.so; \
# $(INSTALL_PROGRAM) .libs/$$sofile @umpdir@; \
# done
#
#uninstall-pluginLTLIBRARIES: $(plugin_LTLIBRARIES)
# list='$(plugin_LTLIBRARIES)'; \
# for file in $$list; do \
# sofile=`basename $$file .la`.so; \
# rm -f @umpdir@/$$sofile; \
# done
#

3
include/Makefile.am

@ -0,0 +1,3 @@
lv2includedir = $(includedir)
lv2include_HEADERS = lv2.h

305
include/lv2.h

@ -0,0 +1,305 @@
/* LV2 - LADSPA (Linux Audio Developer's Simple Plugin API) Version 2.0
* *** PROVISIONAL ***
*
* Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, Stefan
* Westerfeld
* Copyright (C) 2006 Steve Harris, Dave Robillard.
*
* This header is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; either version 2.1 of the License,
* or (at your option) any later version.
*
* This header 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
* USA.
*/
#ifndef LV2_INCLUDED
#define LV2_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif
/* ************************************************************************* */
/* Overview:
*
* There are a large number of open source and free software synthesis
* packages in use or development at this time. This API ('LV2')
* attempts to give programmers the ability to write simple 'plugin'
* audio processors in C/C++ and link them dynamically ('plug') into
* a range of these packages ('hosts'). It should be possible for any
* host and any plugin to communicate completely through this interface.
*
* This API is deliberately as short and simple as possible.
* The information required to use a plugin is in a companion data
* (RDF) file. The shared library portion of the API (defined in this
* header) does not contain enough information to make use of the plugin
* possible - the data file is mandatory.
*
* Plugins are expected to distinguish between control rate and audio
* rate data. Plugins have 'ports' that are inputs or outputs for audio
* or control data and each plugin is 'run' for a 'block' corresponding
* to a short time interval measured in samples. Audio rate data is
* communicated using arrays with one element per sample processed,
* allowing a block of audio to be processed by the plugin in a single
* pass. Control rate data is communicated using single values. Control
* rate data has a single value at the start of a call to the 'run()'
* function, and may be considered to remain this value for its duration.
* Thus the 'control rate' is determined by the block size, controlled
* by the host. The plugin may assume that all its input and output
* ports have been connected to the relevant data location (see the
* 'connect_port()' function below) before it is asked to run.
*
* Plugins will reside in shared object files suitable for dynamic linking
* by dlopen() and family. The file will provide a number of 'plugin
* types' that can be used to instantiate actual plugins (sometimes known
* as 'plugin instances') that can be connected together to perform tasks.
*
* This API contains very limited error-handling.
*/
/* ************************************************************************* */
/** Plugin Handle.
*
* This plugin handle indicates a particular instance of the plugin
* concerned. It is valid to compare this to NULL (0 for C++) but
* otherwise the host MUST not attempt to interpret it. The plugin
* may use it to reference internal instance data. */
typedef void * LV2_Handle;
/* ************************************************************************* */
/** Host feature.
*
* These are passed to a plugin's instantiate method to represent a special
* feature the host has which the plugin may depend on. This is to allow
* extensions to the LV2 specification without causing any breakage. The base
* LV2 specification does not define any host features; hosts are not required
* to use this facility.
*/
typedef struct _LV2_Host_Feature {
/** A globally unique, case-sensitive identifier for this feature.
*
* This MUST be defined in the specification of any LV2 extension which
* defines a host feature.
*/
const char * URI;
/** Pointer to arbitrary data.
*
* This is to allow hosts to pass data to a plugin (simple values, data
* structures, function pointers, etc) as part of a 'feature'. The LV2
* specification makes no restrictions on the contents of this data.
* The data here MUST be cleary defined by the LV2 extension which defines
* this feature.
* If no data is required, this may be set to NULL.
*/
void * data;
} LV2_Host_Feature;
/* ************************************************************************* */
/** Descriptor for a Type of Plugin.
*
* This structure is used to describe a plugin type. It provides a number
* of functions to instantiate it, link it to buffers and run it. */
typedef struct _LV2_Descriptor {
/** A globally unique, case-sensitive identifier for this plugin type.
*
* All plugins with the same URI MUST be compatible in terms of 'port
* signature', meaning they have the same number of ports, same port
* shortnames, and roughly the same functionality. URIs should
* probably contain a version number (or similar) for this reason.
*
* Rationale: When serializing session/patch/etc files, hosts MUST
* refer to a loaded plugin by the plugin URI only. In the future
* loading a plugin with this URI MUST yield a plugin with the
* same ports (etc) which is 100% compatible. */
const char * URI;
/** Function pointer that instantiates a plugin.
*
* A handle is returned indicating the new plugin instance. The
* instantiation function accepts a sample rate as a parameter as well
* as the plugin descriptor from which this instantiate function was
* found. This function must return NULL if instantiation fails.
*
* BundlePath is a string of the path to the plugin's .lv2 bundle
* directory, it MUST not include the trailing /.
*
* HostFeatures is a NULL terminated array of the URIs of the LV2
* features that the host supports. Plugins may refuse to instantiate
* if required features are not found here (however hosts SHOULD NOT use
* this as a discovery mechanism, instead reading the data file before
* attempting to instantiate the plugin).
*
* Note that instance initialisation should generally occur in
* activate() rather than here. If a host calls instantiate, it MUST
* call cleanup() at some point in the future. */
LV2_Handle (*instantiate)(const struct _LV2_Descriptor * Descriptor,
unsigned long SampleRate,
const char * BundlePath,
const LV2_Host_Feature** HostFeatures);
/** Function pointer that connects a port on a plugin instance to a memory
* location where the block of data for the port will be read/written.
*
* The data location is expected to be an array of void * (typically
* float *) for audio ports or a single void * value for control
* ports. Memory issues are managed by the host. The plugin must
* read/write the data at these locations every time run() is called
* and the data present at the time of this connection call MUST NOT
* be considered meaningful.
*
* connect_port() may be called more than once for a plugin instance
* to allow the host to change the buffers that the plugin is reading
* or writing. These calls may be made before or after activate()
* or deactivate() calls.
*
* connect_port() must be called at least once for each port before
* run() is called. The plugin must pay careful attention to the block
* size passed to the run function as the block allocated may only just
* be large enough to contain the block of data (typically samples), and
* is not guaranteed to be constant.
*
* Plugin writers should be aware that the host may elect to use the
* same buffer for more than one port and even use the same buffer for
* both input and output (see LV2_PROPERTY_INPLACE_BROKEN (FIXME)).
* However, overlapped buffers or use of a single buffer for both
* audio and control data may result in unexpected behaviour. */
void (*connect_port)(LV2_Handle Instance,
unsigned long Port,
void * DataLocation);
/** Function pointer that initialises a plugin instance and activates
* it for use.
*
* This is separated from instantiate() to aid real-time support and so
* that hosts can reinitialise a plugin instance by calling deactivate()
* and then activate(). In this case the plugin instance must reset all
* state information dependent on the history of the plugin instance
* except for any data locations provided by connect_port(). If there
* is nothing for activate() to do then the plugin writer may provide
* a NULL rather than an empty function.
*
* When present, hosts MUST call this function once before run()
* is called for the first time. This call SHOULD be made as close
* to the run() call as possible and indicates to real-time plugins
* that they are now live, however plugins MUST NOT rely on a prompt
* call to run() after activate(). activate() may not be called again
* unless deactivate() is called first (after which activate() may be
* called again, followed by deactivate, etc. etc.). If a host calls
* activate, it MUST call deactivate at some point in the future.
*
* Note that connect_port() may be called before or after a call to
* activate(). */
void (*activate)(LV2_Handle Instance);
/** Function pointer that runs a plugin instance for a block.
*
* Two parameters are required: the first is a handle to the particular
* instance to be run and the second indicates the block size (in
* samples) for which the plugin instance may run.
*
* Note that if an activate() function exists then it must be called
* before run(). If deactivate() is called for a plugin instance then
* the plugin instance may not be reused until activate() has been
* called again.
*
* If the plugin has the property LV2_PROPERTY_HARD_RT_CAPABLE then
* there are various things that the plugin MUST NOT do within the run()
* function (see above). */
void (*run)(LV2_Handle Instance,
unsigned long SampleCount);
/** This is the counterpart to activate() (see above). If there is
* nothing for deactivate() to do then the plugin writer may provide
* a NULL rather than an empty function.
*
* Hosts must deactivate all activated units after they have been run()
* for the last time. This call SHOULD be made as close to the last
* run() call as possible and indicates to real-time plugins that
* they are no longer live, however plugins MUST NOT rely on prompt
* deactivation. Note that connect_port() may be called before or
* after a call to deactivate().
*
* Note that deactivation is not similar to pausing as the plugin
* instance will be reinitialised when activate() is called to reuse it.
* Hosts MUST NOT call deactivate() unless activate() was previously
* called. */
void (*deactivate)(LV2_Handle Instance);
/** This is the counterpart to instantiate() (see above). Once an instance
* of a plugin has been finished with it can be deleted using this
* function. The instance handle passed ceases to be valid after
* this call.
*
* If activate() was called for a plugin instance then a corresponding
* call to deactivate() MUST be made before cleanup() is called.
* Hosts MUST NOT call cleanup() unless instantiate() was previously
* called. */
void (*cleanup)(LV2_Handle Instance);
} LV2_Descriptor;
/* ****************************************************************** */
/** Accessing a Plugin:
*
* The exact mechanism by which plugins are loaded is host-dependent,
* however all most hosts will need to know is the URI of the plugin they
* wish to load. The environment variable LV2_PATH, if present, should
* contain a colon-separated path indicating directories (containing
* plugin bundle subdirectories) that should be searched (in order)
* for plugins. It is expected that hosts will use a library to provide
* this functionality.
*
* A plugin programmer must include a function called "lv2_descriptor"
* with the following function prototype within the shared object
* file. This function will have C-style linkage (if you are using
* C++ this is taken care of by the 'extern "C"' clause at the top of
* the file).
*
* A host will find the plugin shared object file by one means or another,
* find the lv2_descriptor() function, call it, and proceed from there.
*
* Plugin types are accessed by index (not ID) using values from 0
* upwards. Out of range indexes must result in this function returning
* NULL, so the plugin count can be determined by checking for the least
* index that results in NULL being returned. Index has no meaning,
* hosts MUST NOT depend on it remaining constant (ie when serialising)
* in any way. */
const LV2_Descriptor * lv2_descriptor(unsigned long Index);
/** Datatype corresponding to the lv2_descriptor() function. */
typedef const LV2_Descriptor *
(*LV2_Descriptor_Function)(unsigned long Index);
/* ******************************************************************** */
#ifdef __cplusplus
}
#endif
#endif /* LV2_INCLUDED */

326
include/lv2.ttl

@ -0,0 +1,326 @@
# RDF Schema file for LV2 plugins
# *** PROVISIONAL ***
#
# This document describes the classes and properties that are defined by the
# core LV2 specification.
@prefix : <http://lv2plug.in/ontology#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
<> dc:creator "Steve Harris" ;
dc:date "2006-04-26" .
#
# Classes
#
:Plugin a rdfs:Class ;
rdfs:label "Plugin" ;
rdfs:comment """
This is the class that represents an LV2 plugin.
In order for it to be used by a host it must have at least one occurance of the
following properties:
rdf:type (with object :Plugin)
doap:name (one without language tag)
doap:licence
lv2:port
This can be determined by the following SPARQL query:
PREFIX : <http://lv2plug.in/ontology#>
PREFIX doap: <http://usefulinc.com/ns/doap#>
SELECT DISTINCT ?uri WHERE {
?uri a :Plugin ;
doap:name ?name ;
doap:licence ?rights ;
:port ?port .
FILTER( LANG(?name) = "" )
}
""" .
:Port a rdfs:Class ;
rdfs:label "Port" ;
rdfs:comment """
This is the class that represents an LV2 port
In order for it to be used by a host it must have at least the following
properties:
rdf:type (where object is exactly one of :InputControlRatePort,
:OutputControlRatePort, :InputAudioRatePort or :OututAudioRatePort)
:datatype
:index
:symbol
:name
""" .
:InputPort a rdfs:Class ;
rdfs:subClassOf :Port .
:OutputPort a rdfs:Class ;
rdfs:subClassOf :Port .
:ControlRatePort a rdfs:Class ;
rdfs:subClassOf :Port .
:AudioRatePort a rdfs:Class ;
rdfs:subClassOf :Port .
:InputControlRatePort a rdfs:Class ;
rdfs:label "Input control port" ;
rdfs:subClassOf :ControlRatePort ;
rdfs:subClassOf :InputPort ;
rdfs:comment """
Ports of this type will be connected to a pointer to a single value of the type
defined by the :datatype property.
Plugins will read values from this pointer during thier run method.
""" .
:OutputControlRatePort a rdfs:Class ;
rdfs:label "Output control port" ;
rdfs:subClassOf :ControlRatePort ;
rdfs:subClassOf :OutputPort ;
rdfs:comment """
Ports of this type will be connected to a pointer to a single value of the type
defined by the :datatype property.
Plugins will write values to this pointer during thier run method.
""" .
:InputAudioRatePort a rdfs:Class ;
rdfs:label "Input audio port" ;
rdfs:subClassOf :AudioRatePort ;
rdfs:subClassOf :InputPort ;
rdfs:comment """
Ports of this type will be connected to a an array of values of length
SampleCount and of the type defined by the :datatype property.
Plugins will read values from this array during their run method.
""" .
:OutputAudioRatePort a rdfs:Class ;
rdfs:label "Output audio port" ;
rdfs:subClassOf :AudioRatePort ;
rdfs:subClassOf :OutputPort ;
rdfs:comment """
Ports of this type will be connected to a an array of values of length
SampleCount and of the type defined by the :datatype property.
Plugins will write values to this array during their run method.
""" .
:ScalePoint a rdfs:Class ;
rdfs:label "Scale point" ;
rdfs:comment """
Used to describe interesting values in a Port's range.
It has two properties neccesary for use, :label and :value.
""" .
:Property a rdfs:Class ;
rdfs:label "Property" ;
rdfs:comment """
Used to inform the host of the capabilities of the Plugin.
""" .
:Hint a rdfs:Class ;
rdfs:label "Hint" ;
rdfs:comment """
Used to hint to the host various things which can make interacting with the
Port more natural.
""" .
:HostFeature a rdfs:Class ;
rdfs:label "Host feature" ;
rdfs:comment """
Used to describe a host feature which plugin may use or require.
""" .
#
# Properties
#
:property a rdf:Property ;
rdfs:domain :Plugin ;
rdfs:range :Property ;
rdfs:label "property" ;
rdfs:comment "Relates Plugins to Properties." .
:requiredHostFeature a rdf:Property ;
rdfs:domain :Plugin ;
rdfs:range :HostFeature ;
rdfs:label "Required host feature" ;
rdfs:comment """
Signifies that plugin requires a certain host feature to function.
The plugin will fail to instantiate if a required host feature is not present;
hosts SHOULD always check this before attempting to instantiate a plugin.
""" .
:hint a rdf:Property ;
rdfs:domain :Port ;
rdfs:range :Hint ;
rdfs:label "hint" ;
rdfs:comment "Relates Ports to Hints." .
:datatype a rdf:Property ;
rdfs:domain :Port ;
rdfs:range :Datatype ;
rdfs:label "datatype" ;
rdfs:comment """
Relates a Port to the datatype(s) is can accept. Currently the only specified
datatype is :float, which specfies IEEE-754 32bit floating point values.
Hosts that do not support a specfied datatype MUST NOT instantiate the plugin.
If multiple datatypes are specfied the plugin must have some way to distinguish
the values.
""" .
# FIXME: rdfs:range = xsd:nonNegativeInteger?
:index a rdf:Property ;
rdfs:domain :Port ;
rdfs:label "index" ;
rdfs:comment """
Specifies the index of the port, passed as an argument to the connect port
function. This number uniqely identifies the port within the plugin.
""" .
# FIXME: rdfs:range = xsd:NCName? Closest thing xsd: has..
:symbol a rdf:Property ;
rdfs:domain :Port ;
rdfs:label "symbol" ;
rdfs:comment """
A short name used to identify the port in an easily machine and human readable way.
The first character must be one of _, a-z or A-Z and subsequenct characters can
be from _, a-z, A-Z and 0-9.
No language tag should be used on this property.
""" .
:name a rdf:Property ;
rdfs:domain :Port ;
rdfs:label "name" ;
rdfs:comment """
A display name for labeling the Port in a user interface.
This property is required for Ports, but should not be used by the host for
port identification. The plugin author may change the values of this
property without changing the Plugin URI.
""" .
:default a rdf:Property ;
rdfs:domain :ControlRatePort ;
rdfs:label "default" ;
rdfs:comment """
The default value that the host SHOULD set this port to when there is not other
information available. Only meaningful for Ports with a :datatype of :float.
""" .
:minimum a rdf:Property ;
rdfs:domain :Port ;
rdfs:label "minimum" ;
rdfs:comment """
A hint to the host for the minimum useful value that the port will use. The
plugin is required to accept all values in the range of :float.
""" .
:minimum a rdf:Property ;
rdfs:domain :Port ;
rdfs:label "maximum" ;
rdfs:comment """
A hint to the host for the maximum useful value that the port will use. The
plugin is required to accept all values in the range of :float.
""" .
:scalePoint a rdf:Property ;
rdfs:domain :Port ;
rdfs:range :ScalePoint ;
rdfs:label "scale point" ;
rdfs:comment "Relates a Port to its ScalePoints." .
#
# Instances
#
:toggled a :Hint ;
rdfs:label "toggled" ;
rdfs:comment """
Indicates that the data item should be considered a Boolean toggle. Data less
than or equal to zero should be considered `off' or `false,' and data above
zero should be considered `on' or `true.'
""" .
:sampleRate a :Hint ;
rdfs:label "sample rate" ;
rdfs:comment """
Indicates that any bounds specified should be interpreted as multiples of the
sample rate. For instance, a frequency range from 0Hz to the Nyquist frequency
(half the sample rate) could be requested by this hint in conjunction with
:minimum 0.0 and :maximum 0.5. Hosts that support bounds at all must support
this hint