From 7fd4168fe8581e46f4ee35cc182db6220b6eed04 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 6 Jun 2006 20:20:33 +0000 Subject: Moved libslv2 into it's own subdirectory git-svn-id: http://svn.drobilla.net/lad/libslv2@4 a436a847-0d15-0410-975c-d299462d15a1 --- examples/plugins/Amp-swh.lv2/Makefile | 10 ++++ examples/plugins/Amp-swh.lv2/amp.c | 96 ++++++++++++++++++++++++++++++ examples/plugins/Amp-swh.lv2/amp.so | Bin 0 -> 2629 bytes examples/plugins/Amp-swh.lv2/amp.ttl | 68 +++++++++++++++++++++ examples/plugins/Amp-swh.lv2/manifest.ttl | 9 +++ 5 files changed, 183 insertions(+) create mode 100644 examples/plugins/Amp-swh.lv2/Makefile create mode 100644 examples/plugins/Amp-swh.lv2/amp.c create mode 100755 examples/plugins/Amp-swh.lv2/amp.so create mode 100644 examples/plugins/Amp-swh.lv2/amp.ttl create mode 100644 examples/plugins/Amp-swh.lv2/manifest.ttl (limited to 'examples/plugins/Amp-swh.lv2') diff --git a/examples/plugins/Amp-swh.lv2/Makefile b/examples/plugins/Amp-swh.lv2/Makefile new file mode 100644 index 0000000..4fb858a --- /dev/null +++ b/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 diff --git a/examples/plugins/Amp-swh.lv2/amp.c b/examples/plugins/Amp-swh.lv2/amp.c new file mode 100644 index 0000000..a30c4bd --- /dev/null +++ b/examples/plugins/Amp-swh.lv2/amp.c @@ -0,0 +1,96 @@ +#include +#include + +#include + +#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; + } +} + diff --git a/examples/plugins/Amp-swh.lv2/amp.so b/examples/plugins/Amp-swh.lv2/amp.so new file mode 100755 index 0000000..281b709 Binary files /dev/null and b/examples/plugins/Amp-swh.lv2/amp.so differ diff --git a/examples/plugins/Amp-swh.lv2/amp.ttl b/examples/plugins/Amp-swh.lv2/amp.ttl new file mode 100644 index 0000000..d44c0b9 --- /dev/null +++ b/examples/plugins/Amp-swh.lv2/amp.ttl @@ -0,0 +1,68 @@ +@prefix lv2: . +@prefix foaf: . +@prefix doap: . + + a lv2:Plugin ; + a lv2:AmplifierPlugin ; + doap:maintainer [ + foaf:name "Steve Harris"; + foaf:homepage ; + foaf:mbox ; + ] ; + doap:name "Simple amplifier" ; + doap:name "简单放大器"@ch ; + doap:name "Einfacher Verstärker"@de ; + doap:name "Simple amp"@en-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 ; + 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 ; + 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" ; + ] +. + diff --git a/examples/plugins/Amp-swh.lv2/manifest.ttl b/examples/plugins/Amp-swh.lv2/manifest.ttl new file mode 100644 index 0000000..a26f506 --- /dev/null +++ b/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: . +@prefix rdfs: . + + lv2:binary ; + rdfs:seeAlso . + -- cgit v1.2.1