mirror of
https://github.com/cookiengineer/audacity
synced 2025-10-11 17:13:37 +02:00
Update lilv, lv2, serd, sord, sratom, and add suil.
This commit is contained in:
@@ -1,9 +1,25 @@
|
||||
%module lilv
|
||||
%typedef unsigned uint32_t;
|
||||
%{
|
||||
#define SWIG_FILE_WITH_INIT
|
||||
#include "lilv/lilv.h"
|
||||
#include "lilv/lilvmm.hpp"
|
||||
%}
|
||||
|
||||
%include "numpy.i"
|
||||
%init %{
|
||||
import_array();
|
||||
%}
|
||||
%apply (float* INPLACE_ARRAY1) {(void* data_location)}
|
||||
|
||||
%feature("compactdefaultargs") %{
|
||||
lilv_plugin_get_num_ports_of_class;
|
||||
get_num_ports_of_class;
|
||||
%}
|
||||
%varargs(3, LilvNode* node = NULL) lilv_plugin_get_num_ports_of_class;
|
||||
%varargs(3, LilvNode* node = NULL) get_num_ports_of_class;
|
||||
%typemap(in, numinputs=0) LilvNode *node3 ""; // Make sure it's NULL terminated
|
||||
|
||||
%include "lilv/lilv.h"
|
||||
%include "lilv/lilvmm.hpp"
|
||||
|
||||
@@ -25,6 +41,14 @@ namespace Lilv {
|
||||
raise StopIteration
|
||||
|
||||
return Iterator(self)
|
||||
|
||||
def get_by_uri(self, *args):
|
||||
"""get_by_uri(self, LilvNode uri) -> PluginClass"""
|
||||
ret = _lilv.Plugins_get_by_uri(self, *args)
|
||||
if ret.me is None:
|
||||
return None
|
||||
else:
|
||||
return ret
|
||||
%}
|
||||
};
|
||||
|
||||
|
1744
lib-src/lv2/lilv/bindings/numpy.i
Normal file
1744
lib-src/lv2/lilv/bindings/numpy.i
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,90 +7,158 @@ import sys
|
||||
import wave
|
||||
import numpy
|
||||
|
||||
# Read command line arguments
|
||||
if len(sys.argv) != 4:
|
||||
print 'USAGE: lv2_apply.py PLUGIN_URI INPUT_WAV OUTPUT_WAV'
|
||||
sys.exit(1)
|
||||
class WavFile(object):
|
||||
"""Helper class for accessing wav file data. Should work on the most common
|
||||
formats (8 bit unsigned, 16 bit signed, 32 bit signed). Audio data is
|
||||
converted to float32."""
|
||||
|
||||
# Initialise Lilv
|
||||
world = lilv.World()
|
||||
world.load_all()
|
||||
# (struct format code, is_signedtype) for each sample width:
|
||||
WAV_SPECS = {
|
||||
1: ("B", False),
|
||||
2: ("h", True),
|
||||
4: ("l", True),
|
||||
}
|
||||
|
||||
plugin_uri = world.new_uri(sys.argv[1])
|
||||
wav_in_path = sys.argv[2]
|
||||
wav_out_path = sys.argv[3]
|
||||
def __init__(self, wav_in_path):
|
||||
self.wav_in = wave.open(wav_in_path, 'r')
|
||||
self.framerate = self.wav_in.getframerate()
|
||||
self.nframes = self.wav_in.getnframes()
|
||||
self.nchannels = self.wav_in.getnchannels()
|
||||
self.sampwidth = self.wav_in.getsampwidth()
|
||||
wav_spec = self.WAV_SPECS[self.sampwidth]
|
||||
self.struct_fmt_code, self.signed = wav_spec
|
||||
self.range = 2 ** (8*self.sampwidth)
|
||||
|
||||
def read(self):
|
||||
"""Read data from an open wav file. Return a list of channels, where each
|
||||
channel is a list of floats."""
|
||||
raw_bytes = self.wav_in.readframes(self.nframes)
|
||||
struct_fmt = "%u%s" % (len(raw_bytes) / self.sampwidth, self.struct_fmt_code)
|
||||
data = wave.struct.unpack(struct_fmt, raw_bytes)
|
||||
if self.signed:
|
||||
data = [i / float(self.range/2) for i in data]
|
||||
else:
|
||||
data = [(i - float(range/2)) / float(range/2) for i in data]
|
||||
|
||||
# Find plugin
|
||||
plugin = world.get_all_plugins().get_by_uri(plugin_uri)
|
||||
if not plugin:
|
||||
print "Unknown plugin `%s'\n" % plugin_uri
|
||||
sys.exit(1)
|
||||
channels = []
|
||||
for i in xrange(self.nchannels):
|
||||
channels.append([data[j] for j in xrange(0, len(data), self.nchannels) ])
|
||||
|
||||
lv2_InputPort = world.new_uri(lilv.LILV_URI_INPUT_PORT)
|
||||
lv2_OutputPort = world.new_uri(lilv.LILV_URI_OUTPUT_PORT)
|
||||
lv2_AudioPort = world.new_uri(lilv.LILV_URI_AUDIO_PORT)
|
||||
return channels
|
||||
|
||||
n_audio_in = plugin.get_num_ports_of_class(lv2_InputPort, lv2_AudioPort)
|
||||
n_audio_out = plugin.get_num_ports_of_class(lv2_OutputPort, lv2_AudioPort)
|
||||
if n_audio_out == 0:
|
||||
print "Plugin has no audio outputs\n"
|
||||
sys.exit(1)
|
||||
def close(self):
|
||||
self.wav_in.close()
|
||||
|
||||
# Open input file
|
||||
wav_in = wave.open(wav_in_path, 'r')
|
||||
if not wav_in:
|
||||
print "Failed to open input `%s'\n" % wav_in_path
|
||||
sys.exit(1)
|
||||
if wav_in.getnchannels() != n_audio_in:
|
||||
print "Input has %d channels, but plugin has %d audio inputs\n" % (
|
||||
wav_in.getnchannels(), n_audio_in)
|
||||
sys.exit(1)
|
||||
def main():
|
||||
# Read command line arguments
|
||||
if len(sys.argv) != 4:
|
||||
print('USAGE: lv2_apply.py PLUGIN_URI INPUT_WAV OUTPUT_WAV')
|
||||
sys.exit(1)
|
||||
|
||||
# Open output file
|
||||
wav_out = wave.open(wav_out_path, 'w')
|
||||
if not wav_out:
|
||||
print "Failed to open output `%s'\n" % wav_out_path
|
||||
sys.exit(1)
|
||||
# Initialise Lilv
|
||||
world = lilv.World()
|
||||
world.load_all()
|
||||
|
||||
# Set output file to same format as input (except possibly nchannels)
|
||||
wav_out.setparams(wav_in.getparams())
|
||||
wav_out.setnchannels(n_audio_out)
|
||||
plugin_uri = sys.argv[1]
|
||||
wav_in_path = sys.argv[2]
|
||||
wav_out_path = sys.argv[3]
|
||||
|
||||
rate = wav_in.getframerate()
|
||||
nframes = wav_in.getnframes()
|
||||
# Find plugin
|
||||
plugin_uri_node = world.new_uri(plugin_uri)
|
||||
plugin = world.get_all_plugins().get_by_uri(plugin_uri_node)
|
||||
if not plugin:
|
||||
print("Unknown plugin `%s'\n" % plugin_uri)
|
||||
sys.exit(1)
|
||||
|
||||
# Instantiate plugin
|
||||
instance = lilv.Instance(plugin, rate)
|
||||
lv2_InputPort = world.new_uri(lilv.LILV_URI_INPUT_PORT)
|
||||
lv2_OutputPort = world.new_uri(lilv.LILV_URI_OUTPUT_PORT)
|
||||
lv2_AudioPort = world.new_uri(lilv.LILV_URI_AUDIO_PORT)
|
||||
lv2_ControlPort = world.new_uri(lilv.LILV_URI_CONTROL_PORT)
|
||||
lv2_default = world.new_uri("http://lv2plug.in/ns/lv2core#default")
|
||||
|
||||
def read_float(wf, nframes):
|
||||
wav = wf.readframes(nframes)
|
||||
if wf.getsampwidth() == 4:
|
||||
wav = wave.struct.unpack("<%ul" % (len(wav) / 4), wav)
|
||||
wav = [ i / float(math.pow(2, 32)) for i in wav ]
|
||||
elif wf.getsampwidth() == 2:
|
||||
wav = wave.struct.unpack("<%uh" % (len(wav) / 2), wav)
|
||||
wav = [ i / float(math.pow(2, 16)) for i in wav ]
|
||||
n_audio_in = plugin.get_num_ports_of_class(lv2_InputPort, lv2_AudioPort)
|
||||
n_audio_out = plugin.get_num_ports_of_class(lv2_OutputPort, lv2_AudioPort)
|
||||
if n_audio_out == 0:
|
||||
print("Plugin has no audio outputs\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Open input file
|
||||
try:
|
||||
wav_in = WavFile(wav_in_path)
|
||||
except:
|
||||
print("Failed to open input `%s'\n" % wav_in_path)
|
||||
sys.exit(1)
|
||||
|
||||
if wav_in.nchannels != n_audio_in:
|
||||
print("Input has %d channels, but plugin has %d audio inputs\n" % (
|
||||
wav_in.nchannels, n_audio_in))
|
||||
sys.exit(1)
|
||||
|
||||
# Open output file
|
||||
wav_out = wave.open(wav_out_path, 'w')
|
||||
if not wav_out:
|
||||
print("Failed to open output `%s'\n" % wav_out_path)
|
||||
sys.exit(1)
|
||||
|
||||
# Set output file to same format as input (except possibly nchannels)
|
||||
wav_out.setparams(wav_in.wav_in.getparams())
|
||||
wav_out.setnchannels(n_audio_out)
|
||||
|
||||
print('%s => %s => %s @ %d Hz'
|
||||
% (wav_in_path, plugin.get_name(), wav_out_path, wav_in.framerate))
|
||||
|
||||
instance = lilv.Instance(plugin, wav_in.framerate)
|
||||
|
||||
channels = wav_in.read()
|
||||
wav_in.close()
|
||||
|
||||
# Connect all ports to buffers. NB if we fail to connect any buffer, lilv
|
||||
# will segfault.
|
||||
audio_input_buffers = []
|
||||
audio_output_buffers = []
|
||||
control_input_buffers = []
|
||||
control_output_buffers = []
|
||||
for index in range(plugin.get_num_ports()):
|
||||
port = plugin.get_port_by_index(index)
|
||||
if port.is_a(lv2_InputPort):
|
||||
if port.is_a(lv2_AudioPort):
|
||||
audio_input_buffers.append(numpy.array(channels[len(audio_input_buffers)], numpy.float32))
|
||||
instance.connect_port(index, audio_input_buffers[-1])
|
||||
elif port.is_a(lv2_ControlPort):
|
||||
#if port.has_property(lv2_default): # Doesn't seem to work
|
||||
default = lilv.lilv_node_as_float(lilv.lilv_nodes_get_first(port.get_value(lv2_default)))
|
||||
control_input_buffers.append(numpy.array([default], numpy.float32))
|
||||
instance.connect_port(index, control_input_buffers[-1])
|
||||
else:
|
||||
raise ValueError("Unhandled port type")
|
||||
elif port.is_a(lv2_OutputPort):
|
||||
if port.is_a(lv2_AudioPort):
|
||||
audio_output_buffers.append(numpy.array([0] * wav_in.nframes, numpy.float32))
|
||||
instance.connect_port(index, audio_output_buffers[-1])
|
||||
elif port.is_a(lv2_ControlPort):
|
||||
control_output_buffers.append(numpy.array([0], numpy.float32))
|
||||
instance.connect_port(index, control_output_buffers[-1])
|
||||
else:
|
||||
raise ValueError("Unhandled port type")
|
||||
|
||||
# Run the plugin:
|
||||
instance.run(wav_in.nframes)
|
||||
|
||||
# Interleave output buffers:
|
||||
data = numpy.dstack(audio_output_buffers).flatten()
|
||||
|
||||
# Return to original int range:
|
||||
if wav_in.signed:
|
||||
data = data * float(wav_in.range / 2)
|
||||
else:
|
||||
wav = wave.struct.unpack("%uB" % (len(wav)), wav)
|
||||
wav = [ s - 128 for s in wav ]
|
||||
wav = [ i / float(math.pow(2, 8)) for i in wav ]
|
||||
data = (data + 1) * float(wav_in.range/2)
|
||||
|
||||
n_channels = wf.getnchannels()
|
||||
wavs = []
|
||||
if n_channels > 1:
|
||||
for i in xrange(n_channels):
|
||||
wavs.append([ wav[j] for j in xrange(0, len(wav), n_channels) ])
|
||||
else:
|
||||
wavs = [ wav ]
|
||||
# Write output file in chunks to stop memory usage getting out of hand:
|
||||
CHUNK_SIZE = 8192
|
||||
for chunk in numpy.array_split(data, CHUNK_SIZE):
|
||||
wav_out.writeframes(wave.struct.pack("%u%s" % (len(chunk), wav_in.struct_fmt_code), *chunk))
|
||||
wav_out.close()
|
||||
|
||||
return wavs
|
||||
|
||||
in_buf = read_float(wav_in, nframes)
|
||||
|
||||
# TODO: buffer marshaling
|
||||
#instance.connect_port(3, in_buf)
|
||||
|
||||
print '%s => %s => %s @ %d Hz' % (wav_in_path, plugin.get_name(), wav_out_path, rate)
|
||||
|
||||
instance.connect_port(3, in_buf)
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
196
lib-src/lv2/lilv/bindings/test/bindings_test_plugin.c
Normal file
196
lib-src/lv2/lilv/bindings/test/bindings_test_plugin.c
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
Copyright 2006-2011 David Robillard <d@drobilla.net>
|
||||
Copyright 2006 Steve Harris <steve@plugin.org.uk>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/** Include standard C headers */
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
LV2 headers are based on the URI of the specification they come from, so a
|
||||
consistent convention can be used even for unofficial extensions. The URI
|
||||
of the core LV2 specification is <http://lv2plug.in/ns/lv2core>, by
|
||||
replacing `http:/` with `lv2` any header in the specification bundle can be
|
||||
included, in this case `lv2.h`.
|
||||
*/
|
||||
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
|
||||
|
||||
/**
|
||||
The URI is the identifier for a plugin, and how the host associates this
|
||||
implementation in code with its description in data. In this plugin it is
|
||||
only used once in the code, but defining the plugin URI at the top of the
|
||||
file is a good convention to follow. If this URI does not match that used
|
||||
in the data files, the host will fail to load the plugin.
|
||||
*/
|
||||
#define TEST_URI "http://example.org/lilv-bindings-test-plugin"
|
||||
|
||||
/**
|
||||
In code, ports are referred to by index. An enumeration of port indices
|
||||
should be defined for readability.
|
||||
*/
|
||||
typedef enum {
|
||||
TEST_CONTROL_IN = 0,
|
||||
TEST_CONTROL_OUT = 1,
|
||||
TEST_AUDIO_IN = 2,
|
||||
TEST_AUDIO_OUT = 3
|
||||
} PortIndex;
|
||||
|
||||
/**
|
||||
Every plugin defines a private structure for the plugin instance. All data
|
||||
associated with a plugin instance is stored here, and is available to
|
||||
every instance method. In this simple plugin, only port buffers need to be
|
||||
stored, since there is no additional instance data. */
|
||||
typedef struct {
|
||||
// Port buffers
|
||||
} Test;
|
||||
|
||||
/**
|
||||
The instantiate() function is called by the host to create a new plugin
|
||||
instance. The host passes the plugin descriptor, sample rate, and bundle
|
||||
path for plugins that need to load additional resources (e.g. waveforms).
|
||||
The features parameter contains host-provided features defined in LV2
|
||||
extensions, but this simple plugin does not use any.
|
||||
|
||||
This function is in the ``instantiation'' threading class, so no other
|
||||
methods on this instance will be called concurrently with it.
|
||||
*/
|
||||
static LV2_Handle
|
||||
instantiate(const LV2_Descriptor* descriptor,
|
||||
double rate,
|
||||
const char* bundle_path,
|
||||
const LV2_Feature* const* features)
|
||||
{
|
||||
Test* test = (Test*)malloc(sizeof(Test));
|
||||
|
||||
return (LV2_Handle)test;
|
||||
}
|
||||
|
||||
/**
|
||||
The connect_port() method is called by the host to connect a particular port
|
||||
to a buffer. The plugin must store the data location, but data may not be
|
||||
accessed except in run().
|
||||
|
||||
This method is in the ``audio'' threading class, and is called in the same
|
||||
context as run().
|
||||
*/
|
||||
static void
|
||||
connect_port(LV2_Handle instance,
|
||||
uint32_t port,
|
||||
void* data)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
The activate() method is called by the host to initialise and prepare the
|
||||
plugin instance for running. The plugin must reset all internal state
|
||||
except for buffer locations set by connect_port(). Since this plugin has
|
||||
no other internal state, this method does nothing.
|
||||
|
||||
This method is in the ``instantiation'' threading class, so no other
|
||||
methods on this instance will be called concurrently with it.
|
||||
*/
|
||||
static void
|
||||
activate(LV2_Handle instance)
|
||||
{
|
||||
}
|
||||
|
||||
/** Process a block of audio (audio thread, must be RT safe). */
|
||||
static void
|
||||
run(LV2_Handle instance, uint32_t n_samples)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
The deactivate() method is the counterpart to activate() called by the host
|
||||
after running the plugin. It indicates that the host will not call run()
|
||||
again until another call to activate() and is mainly useful for more
|
||||
advanced plugins with ``live'' characteristics such as those with auxiliary
|
||||
processing threads. As with activate(), this plugin has no use for this
|
||||
information so this method does nothing.
|
||||
|
||||
This method is in the ``instantiation'' threading class, so no other
|
||||
methods on this instance will be called concurrently with it.
|
||||
*/
|
||||
static void
|
||||
deactivate(LV2_Handle instance)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
Destroy a plugin instance (counterpart to instantiate()).
|
||||
|
||||
This method is in the ``instantiation'' threading class, so no other
|
||||
methods on this instance will be called concurrently with it.
|
||||
*/
|
||||
static void
|
||||
cleanup(LV2_Handle instance)
|
||||
{
|
||||
free(instance);
|
||||
}
|
||||
|
||||
/**
|
||||
The extension_data function returns any extension data supported by the
|
||||
plugin. Note that this is not an instance method, but a function on the
|
||||
plugin descriptor. It is usually used by plugins to implement additional
|
||||
interfaces. This plugin does not have any extension data, so this function
|
||||
returns NULL.
|
||||
|
||||
This method is in the ``discovery'' threading class, so no other functions
|
||||
or methods in this plugin library will be called concurrently with it.
|
||||
*/
|
||||
static const void*
|
||||
extension_data(const char* uri)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
Define the LV2_Descriptor for this plugin. It is best to define descriptors
|
||||
statically to avoid leaking memory and non-portable shared library
|
||||
constructors and destructors to clean up properly.
|
||||
*/
|
||||
static const LV2_Descriptor descriptor = {
|
||||
TEST_URI,
|
||||
instantiate,
|
||||
connect_port,
|
||||
activate,
|
||||
run,
|
||||
deactivate,
|
||||
cleanup,
|
||||
extension_data
|
||||
};
|
||||
|
||||
/**
|
||||
The lv2_descriptor() function is the entry point to the plugin library. The
|
||||
host will load the library and call this function repeatedly with increasing
|
||||
indices to find all the plugins defined in the library. The index is not an
|
||||
indentifier, the URI of the returned descriptor is used to determine the
|
||||
identify of the plugin.
|
||||
|
||||
This method is in the ``discovery'' threading class, so no other functions
|
||||
or methods in this plugin library will be called concurrently with it.
|
||||
*/
|
||||
LV2_SYMBOL_EXPORT
|
||||
const LV2_Descriptor*
|
||||
lv2_descriptor(uint32_t index)
|
||||
{
|
||||
switch (index) {
|
||||
case 0:
|
||||
return &descriptor;
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
49
lib-src/lv2/lilv/bindings/test/bindings_test_plugin.ttl.in
Normal file
49
lib-src/lv2/lilv/bindings/test/bindings_test_plugin.ttl.in
Normal file
@@ -0,0 +1,49 @@
|
||||
# Lilv Bindings Test Plugin
|
||||
# Copyright 2011 David Robillard <d@drobilla.net>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
@prefix doap: <http://usefulinc.com/ns/doap#> .
|
||||
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
|
||||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
|
||||
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> .
|
||||
|
||||
<http://example.org/lilv-bindings-test-plugin>
|
||||
a lv2:Plugin ;
|
||||
doap:name "Lilv Bindings Test" ;
|
||||
doap:license <http://opensource.org/licenses/isc> ;
|
||||
lv2:port [
|
||||
a lv2:InputPort ,
|
||||
lv2:ControlPort ;
|
||||
lv2:index 0 ;
|
||||
lv2:symbol "input" ;
|
||||
lv2:name "Input"
|
||||
] , [
|
||||
a lv2:OutputPort ,
|
||||
lv2:ControlPort ;
|
||||
lv2:index 1 ;
|
||||
lv2:symbol "output" ;
|
||||
lv2:name "Output"
|
||||
] , [
|
||||
a lv2:AudioPort ,
|
||||
lv2:InputPort ;
|
||||
lv2:index 2 ;
|
||||
lv2:symbol "audio_input" ;
|
||||
lv2:name "Audio Input" ;
|
||||
] , [
|
||||
a lv2:AudioPort ,
|
||||
lv2:OutputPort ;
|
||||
lv2:index 3 ;
|
||||
lv2:symbol "audio_output" ;
|
||||
lv2:name "Audio Output" ;
|
||||
] .
|
7
lib-src/lv2/lilv/bindings/test/manifest.ttl.in
Normal file
7
lib-src/lv2/lilv/bindings/test/manifest.ttl.in
Normal file
@@ -0,0 +1,7 @@
|
||||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
|
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
|
||||
|
||||
<http://example.org/lilv-bindings-test-plugin>
|
||||
a lv2:Plugin ;
|
||||
lv2:binary <bindings_test_plugin@SHLIB_EXT@> ;
|
||||
rdfs:seeAlso <bindings_test_plugin.ttl> .
|
84
lib-src/lv2/lilv/bindings/test/python/test_api.py
Normal file
84
lib-src/lv2/lilv/bindings/test/python/test_api.py
Normal file
@@ -0,0 +1,84 @@
|
||||
# Copyright 2013 Kaspar Emanuel <kaspar.emanuel@gmail.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
from lilv import *
|
||||
import unittest
|
||||
import os
|
||||
|
||||
class UriTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = lilv_world_new()
|
||||
lilv_world_load_all(self.world)
|
||||
def testInvalidURI(self):
|
||||
self.uri = lilv_new_uri(self.world, "invalid_uri")
|
||||
self.assertIsNone(self.uri)
|
||||
def testInvalidURI2(self):
|
||||
self.uri = lilv_new_uri(self.world, "invalid_uri")
|
||||
self.assertFalse( lilv_node_is_uri(self.uri) )
|
||||
def testNonExistentURI(self):
|
||||
self.uri = lilv_new_uri(self.world, "exist:does_not")
|
||||
plugins = lilv_world_get_all_plugins(self.world)
|
||||
self.plugin = lilv_plugins_get_by_uri(plugins, self.uri)
|
||||
self.assertIsNone(self.plugin)
|
||||
def testPortTypes(self):
|
||||
self.uri = lilv_new_uri(self.world, LILV_URI_INPUT_PORT)
|
||||
self.assertIsNotNone(self.uri)
|
||||
def testPortTypes2(self):
|
||||
self.uri = lilv_new_uri(self.world, LILV_URI_OUTPUT_PORT)
|
||||
self.assertIsNotNone(self.uri)
|
||||
def testPortTypes3(self):
|
||||
self.uri = lilv_new_uri(self.world, LILV_URI_AUDIO_PORT)
|
||||
self.assertIsNotNone(self.uri)
|
||||
def testPortTypes4(self):
|
||||
self.uri = lilv_new_uri(self.world, LILV_URI_CONTROL_PORT)
|
||||
self.assertIsNotNone(self.uri)
|
||||
def tearDown(self):
|
||||
lilv_node_free(self.uri)
|
||||
lilv_world_free(self.world)
|
||||
|
||||
class PluginTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = lilv_world_new()
|
||||
location = "file://" + os.getcwd() + "/bindings/bindings_test_plugin.lv2/"
|
||||
self.plugin_uri = lilv_new_uri(self.world, location)
|
||||
self.assertIsNotNone(self.plugin_uri, "Invalid URI: '" + location + "'")
|
||||
lilv_world_load_bundle(self.world, self.plugin_uri)
|
||||
self.plugins = lilv_world_get_all_plugins(self.world)
|
||||
self.plugin = lilv_plugins_get(self.plugins, lilv_plugins_begin(self.plugins))
|
||||
self.assertIsNotNone(self.plugin, msg="Test plugin not found at location: '" + location + "'")
|
||||
self.assertEqual(location, lilv_node_as_string(lilv_plugin_get_bundle_uri(self.plugin)))
|
||||
self.instance = lilv_plugin_instantiate(self.plugin, 48000, None)
|
||||
self.assertIsNotNone(self.instance)
|
||||
self.lv2_InputPort = lilv_new_uri(self.world, LILV_URI_INPUT_PORT)
|
||||
self.lv2_OutputPort = lilv_new_uri(self.world, LILV_URI_OUTPUT_PORT)
|
||||
self.lv2_AudioPort = lilv_new_uri(self.world, LILV_URI_AUDIO_PORT)
|
||||
self.lv2_ControlPort = lilv_new_uri(self.world, LILV_URI_CONTROL_PORT)
|
||||
def testPorts(self):
|
||||
n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_InputPort, self.lv2_AudioPort)
|
||||
self.assertEqual(n, 1)
|
||||
def testPorts2(self):
|
||||
n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_OutputPort, self.lv2_AudioPort)
|
||||
self.assertEqual(n, 1)
|
||||
def testPorts3(self):
|
||||
n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_OutputPort, self.lv2_ControlPort)
|
||||
self.assertEqual(n, 1)
|
||||
def testPorts4(self):
|
||||
n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_InputPort, self.lv2_ControlPort)
|
||||
self.assertEqual(n, 1)
|
||||
def tearDown(self):
|
||||
lilv_node_free(self.lv2_InputPort)
|
||||
lilv_node_free(self.lv2_OutputPort)
|
||||
lilv_node_free(self.lv2_AudioPort)
|
||||
lilv_node_free(self.plugin_uri)
|
||||
lilv_world_free(self.world)
|
70
lib-src/lv2/lilv/bindings/test/python/test_api_mm.py
Normal file
70
lib-src/lv2/lilv/bindings/test/python/test_api_mm.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# Copyright 2013 Kaspar Emanuel <kaspar.emanuel@gmail.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for any
|
||||
# purpose with or without fee is hereby granted, provided that the above
|
||||
# copyright notice and this permission notice appear in all copies.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
import lilv
|
||||
import unittest
|
||||
import os
|
||||
|
||||
class UriTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = lilv.World()
|
||||
self.world.load_all();
|
||||
def testInvalidURI(self):
|
||||
self.plugin_uri = self.world.new_uri("invalid_uri")
|
||||
self.assertEqual(self.plugin_uri, None)
|
||||
def testInvalidURI2(self):
|
||||
self.plugin_uri = self.world.new_uri("invalid_uri")
|
||||
self.assertFalse( lilv.lilv_node_is_uri(self.plugin_uri) )
|
||||
def testNonExistentURI(self):
|
||||
self.plugin_uri = self.world.new_uri("exist:does_not")
|
||||
self.plugin = self.world.get_all_plugins().get_by_uri(self.plugin_uri)
|
||||
self.assertEqual(self.plugin, None)
|
||||
def testPortTypes(self):
|
||||
self.assertIsNotNone( self.world.new_uri(lilv.LILV_URI_INPUT_PORT) )
|
||||
def testPortTypes2(self):
|
||||
self.assertIsNotNone( self.world.new_uri(lilv.LILV_URI_OUTPUT_PORT) )
|
||||
def testPortTypes3(self):
|
||||
self.assertIsNotNone( self.world.new_uri(lilv.LILV_URI_AUDIO_PORT) )
|
||||
def testPortTypes4(self):
|
||||
self.assertIsNotNone( self.world.new_uri(lilv.LILV_URI_CONTROL_PORT) )
|
||||
|
||||
class PluginTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.world = lilv.World()
|
||||
location = "file://" + os.getcwd() + "/bindings/bindings_test_plugin.lv2/"
|
||||
self.plugin_uri = self.world.new_uri(location)
|
||||
self.assertIsNotNone(self.plugin_uri, "Invalid URI: '" + location + "'")
|
||||
self.world.load_bundle(self.plugin_uri)
|
||||
self.plugins = self.world.get_all_plugins()
|
||||
self.plugin = self.plugins.get(self.plugins.begin())
|
||||
self.assertIsNotNone(self.plugin, msg="Test plugin not found at location: '" + location + "'")
|
||||
self.assertEqual(location, self.plugin.get_bundle_uri().as_string())
|
||||
self.instance = lilv.Instance(self.plugin, 48000, None)
|
||||
self.assertIsNotNone(self.instance)
|
||||
self.lv2_InputPort = self.world.new_uri(lilv.LILV_URI_INPUT_PORT)
|
||||
self.lv2_OutputPort = self.world.new_uri(lilv.LILV_URI_OUTPUT_PORT)
|
||||
self.lv2_AudioPort = self.world.new_uri(lilv.LILV_URI_AUDIO_PORT)
|
||||
self.lv2_ControlPort = self.world.new_uri(lilv.LILV_URI_CONTROL_PORT)
|
||||
def testPorts(self):
|
||||
n = self.plugin.get_num_ports_of_class(self.lv2_InputPort, self.lv2_AudioPort)
|
||||
self.assertEqual(n, 1)
|
||||
def testPorts2(self):
|
||||
n = self.plugin.get_num_ports_of_class(self.lv2_OutputPort, self.lv2_AudioPort)
|
||||
self.assertEqual(n, 1)
|
||||
def testPorts3(self):
|
||||
n = self.plugin.get_num_ports_of_class(self.lv2_OutputPort, self.lv2_ControlPort)
|
||||
self.assertEqual(n, 1)
|
||||
def testPorts4(self):
|
||||
n = self.plugin.get_num_ports_of_class(self.lv2_InputPort, self.lv2_ControlPort)
|
||||
self.assertEqual(n, 1)
|
Reference in New Issue
Block a user