aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-07-07 19:19:12 +0000
committerDavid Robillard <d@drobilla.net>2011-07-07 19:19:12 +0000
commit5a838e44308db34ac30fc71c4fde5b570110b988 (patch)
tree7499e6a5979122682b84287d29f3e45332f802a6 /plugins
parent260ef0094d77d9630edb7a04793af0ff1cbd9b2c (diff)
downloadlv2-5a838e44308db34ac30fc71c4fde5b570110b988.tar.xz
Add amp example plugin.
Upgrade to waf 1.6.6. Don't depend on a C++ compiler being present.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/eg-amp.lv2/amp.c126
-rw-r--r--plugins/eg-amp.lv2/amp.ttl83
-rw-r--r--plugins/eg-amp.lv2/manifest.ttl10
l---------plugins/eg-amp.lv2/waf1
-rw-r--r--plugins/eg-amp.lv2/wscript72
5 files changed, 292 insertions, 0 deletions
diff --git a/plugins/eg-amp.lv2/amp.c b/plugins/eg-amp.lv2/amp.c
new file mode 100644
index 0000000..1f2b824
--- /dev/null
+++ b/plugins/eg-amp.lv2/amp.c
@@ -0,0 +1,126 @@
+/*
+ LV2 Amp Example Plugin
+ Copyright 2006-2011 Steve Harris, David Robillard.
+ 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 <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+
+#define AMP_URI "http://lv2plug.in/plugins/eg-amp"
+#define AMP_GAIN 0
+#define AMP_INPUT 1
+#define AMP_OUTPUT 2
+
+typedef struct {
+ float* gain;
+ float* input;
+ float* output;
+} Amp;
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor,
+ double rate,
+ const char* bundle_path,
+ const LV2_Feature* const* features)
+{
+ Amp* amp = (Amp*)malloc(sizeof(Amp));
+
+ return (LV2_Handle)amp;
+}
+
+static void
+connect_port(LV2_Handle instance,
+ uint32_t port,
+ void* data)
+{
+ Amp* amp = (Amp*)instance;
+
+ switch (port) {
+ case AMP_GAIN:
+ amp->gain = data;
+ break;
+ case AMP_INPUT:
+ amp->input = data;
+ break;
+ case AMP_OUTPUT:
+ amp->output = data;
+ break;
+ }
+}
+
+static void
+activate(LV2_Handle instance)
+{
+}
+
+#define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
+
+static void
+run(LV2_Handle instance, uint32_t n_samples)
+{
+ Amp* amp = (Amp*)instance;
+
+ const float gain = *(amp->gain);
+ const float* const input = amp->input;
+ float* const output = amp->output;
+
+ const float coef = DB_CO(gain);
+
+ for (uint32_t pos = 0; pos < n_samples; pos++) {
+ output[pos] = input[pos] * coef;
+ }
+}
+
+static void
+deactivate(LV2_Handle instance)
+{
+}
+
+static void
+cleanup(LV2_Handle instance)
+{
+ free(instance);
+}
+
+const void*
+extension_data(const char * uri)
+{
+ return NULL;
+}
+
+static const LV2_Descriptor descriptor = {
+ AMP_URI,
+ instantiate,
+ connect_port,
+ activate,
+ run,
+ deactivate,
+ cleanup,
+ extension_data
+};
+
+LV2_SYMBOL_EXPORT
+const LV2_Descriptor*
+lv2_descriptor(uint32_t index)
+{
+ switch (index) {
+ case 0:
+ return &descriptor;
+ default:
+ return NULL;
+ }
+}
diff --git a/plugins/eg-amp.lv2/amp.ttl b/plugins/eg-amp.lv2/amp.ttl
new file mode 100644
index 0000000..24e99d4
--- /dev/null
+++ b/plugins/eg-amp.lv2/amp.ttl
@@ -0,0 +1,83 @@
+# LV2 Amp Example Plugin
+# Copyright 2006-2011 Steve Harris, David Robillard
+#
+# 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 rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://lv2plug.in/plugins/eg-amp>
+ a lv2:Plugin ,
+ lv2:AmplifierPlugin ;
+ doap:maintainer [
+ foaf:name "David Robillard" ;
+ foaf:homepage <http://drobilla.net/> ;
+ foaf:mbox <mailto:d@drobilla.net>
+ ] ;
+ doap:name "Simple Amplifier" ,
+ "简单放大器"@ch ,
+ "Einfacher Verstärker"@de ,
+ "Simple Amp"@en-gb ,
+ "Amplificador Simple"@es ,
+ "Amplificateur de Base"@fr ,
+ "Amplificatore Semplice"@it ,
+ "簡単なアンプ"@jp ,
+ "Просто Усилитель"@ru ;
+ doap:license <http://opensource.org/licenses/isc-license> ;
+ lv2:property lv2:hardRtCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "gain" ;
+ lv2:name "Gain" ,
+ "收益"@ch ,
+ "Gewinn"@de ,
+ "Gain"@en-gb ,
+ "Aumento"@es ,
+ "Gain"@fr ,
+ "Guadagno"@it ,
+ "利益"@jp ,
+ "Увеличение"@ru ;
+ lv2:default 0.0 ;
+ lv2:minimum -90.0 ;
+ lv2:maximum 24.0 ;
+ lv2:scalePoint [
+ rdfs:label "+5" ;
+ rdf:value 5.0
+ ] , [
+ rdfs:label "0" ;
+ rdf:value 0.0
+ ] , [
+ rdfs:label "-5" ;
+ rdf:value -5.0
+ ] , [
+ rdfs:label "-10" ;
+ rdf:value -10.0
+ ]
+ ] , [
+ a lv2:AudioPort ,
+ lv2:InputPort ;
+ lv2:index 1 ;
+ lv2:symbol "in" ;
+ lv2:name "In"
+ ] , [
+ a lv2:AudioPort ,
+ lv2:OutputPort ;
+ lv2:index 2 ;
+ lv2:symbol "out" ;
+ lv2:name "Out"
+ ] .
diff --git a/plugins/eg-amp.lv2/manifest.ttl b/plugins/eg-amp.lv2/manifest.ttl
new file mode 100644
index 0000000..5ca1ada
--- /dev/null
+++ b/plugins/eg-amp.lv2/manifest.ttl
@@ -0,0 +1,10 @@
+# LV2 Plugin Manifest
+# Lists where plugins' data files and shared objects reside.
+
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://lv2plug.in/plugins/eg-amp>
+ a lv2:Plugin ;
+ lv2:binary <amp.so> ;
+ rdfs:seeAlso <amp.ttl> .
diff --git a/plugins/eg-amp.lv2/waf b/plugins/eg-amp.lv2/waf
new file mode 120000
index 0000000..59a1ac9
--- /dev/null
+++ b/plugins/eg-amp.lv2/waf
@@ -0,0 +1 @@
+../../waf \ No newline at end of file
diff --git a/plugins/eg-amp.lv2/wscript b/plugins/eg-amp.lv2/wscript
new file mode 100644
index 0000000..e6a906a
--- /dev/null
+++ b/plugins/eg-amp.lv2/wscript
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+import os
+import shutil
+from waflib import Logs
+from waflib.extras import autowaf as autowaf
+
+# Variables for 'waf dist'
+APPNAME = 'eg-amp.lv2'
+VERSION = '1.0.0'
+
+# Mandatory variables
+top = '.'
+out = 'build'
+
+def options(opt):
+ autowaf.set_options(opt)
+ opt.load('compiler_c')
+
+def configure(conf):
+ autowaf.configure(conf)
+
+ conf.line_just = 51
+ autowaf.display_header('Amp Configuration')
+ conf.load('compiler_c')
+
+ autowaf.check_header(conf, 'c', 'lv2/lv2plug.in/ns/lv2core/lv2.h')
+
+ conf.env.append_value('CFLAGS', '-std=c99')
+
+ # Set env['pluginlib_PATTERN']
+ pat = conf.env['cshlib_PATTERN']
+ if pat.startswith('lib'):
+ pat = pat[3:]
+ conf.env['pluginlib_PATTERN'] = pat
+ conf.env['pluginlib_EXT'] = pat[pat.rfind('.'):]
+
+ autowaf.display_msg(conf, "LV2 bundle directory",
+ conf.env['LV2DIR'])
+ print('')
+
+def build_plugin(bld, lang, bundle, name, source, cflags=[], libs=[]):
+
+ if cflags != []:
+ obj.cflags = cflags
+ obj.cxxflags = cflags
+ if libs != []:
+ autowaf.use_lib(bld, obj, libs)
+
+def build(bld):
+ bundle = 'eg-amp.lv2'
+
+ # Copy data files to build bundle (build/eg-amp.lv2)
+ for i in [ 'amp.ttl', 'manifest.ttl' ]:
+ bld(rule = 'cp ${SRC} ${TGT}',
+ source = i,
+ target = bld.path.get_bld().make_node('%s/%s' % (bundle, i)),
+ install_path = '${LV2DIR}/%s' % bundle)
+
+ # Create a build environment that builds module-style library names
+ # e.g. eg-amp.so instead of libeg-amp.so
+ # Note for C++ you must set cxxshlib_PATTERN instead
+ penv = bld.env.derive()
+ penv['cshlib_PATTERN'] = bld.env['pluginlib_PATTERN']
+
+ # Build plugin library
+ obj = bld(features = 'c cshlib',
+ env = penv,
+ source = 'amp.c',
+ name = 'amp',
+ target = '%s/amp' % bundle,
+ install_path = '${LV2DIR}/%s' % bundle)
+