aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-18 16:45:27 -0500
committerDavid Robillard <d@drobilla.net>2015-02-18 16:45:27 -0500
commit9b4b2b68f50db95da7d63a62a8ebee90be58da58 (patch)
tree553a61146a9f66f39c68e74950565e531bd3862d /plugins
parent3520e1fba6c5ab47b5f01c6f0755abe45d622a6d (diff)
downloadlv2-9b4b2b68f50db95da7d63a62a8ebee90be58da58.tar.xz
Add preliminary C++ work.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/eg-amppp.lv2/README.txt3
-rw-r--r--plugins/eg-amppp.lv2/amppp.cpp78
-rw-r--r--plugins/eg-amppp.lv2/amppp.ttl49
-rw-r--r--plugins/eg-amppp.lv2/manifest.ttl.in7
l---------plugins/eg-amppp.lv2/waf1
-rw-r--r--plugins/eg-amppp.lv2/wscript66
-rw-r--r--plugins/wscript11
7 files changed, 213 insertions, 2 deletions
diff --git a/plugins/eg-amppp.lv2/README.txt b/plugins/eg-amppp.lv2/README.txt
new file mode 100644
index 0000000..a5cb36c
--- /dev/null
+++ b/plugins/eg-amppp.lv2/README.txt
@@ -0,0 +1,3 @@
+== Simple C++ Amplifier ==
+
+This is a version of the simple amplifier example, but written in C++.
diff --git a/plugins/eg-amppp.lv2/amppp.cpp b/plugins/eg-amppp.lv2/amppp.cpp
new file mode 100644
index 0000000..ac939c0
--- /dev/null
+++ b/plugins/eg-amppp.lv2/amppp.cpp
@@ -0,0 +1,78 @@
+/*
+ Copyright 2015 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.
+*/
+
+#include <math.h>
+#include <stdlib.h>
+
+#include "lv2/lv2plug.in/ns/lv2core/Plugin.hpp"
+
+class Amppp : public lv2::Plugin {
+public:
+ Amppp(double rate,
+ const char* bundle_path,
+ const LV2_Feature* const* features)
+ : Plugin(rate, bundle_path, features)
+ {}
+
+ typedef enum {
+ AMP_GAIN = 0,
+ AMP_INPUT = 1,
+ AMP_OUTPUT = 2
+ } PortIndex;
+
+ void connect_port(uint32_t port, void* data) {
+ switch ((PortIndex)port) {
+ case AMP_GAIN:
+ m_ports.gain = (const float*)data;
+ break;
+ case AMP_INPUT:
+ m_ports.input = (const float*)data;
+ break;
+ case AMP_OUTPUT:
+ m_ports.output = (float*)data;
+ break;
+ }
+ }
+
+ #define DB_CO(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
+
+ void run(uint32_t n_samples) {
+ const float coef = DB_CO(*m_ports.gain);
+ for (uint32_t pos = 0; pos < n_samples; pos++) {
+ m_ports.output[pos] = m_ports.input[pos] * coef;
+ }
+ }
+
+private:
+ typedef struct {
+ const float* gain;
+ const float* input;
+ float* output;
+ } Ports;
+
+ Ports m_ports;
+};
+
+static const LV2_Descriptor descriptor = lv2::descriptor<Amppp>("http://lv2plug.in/plugins/eg-amppp");
+
+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-amppp.lv2/amppp.ttl b/plugins/eg-amppp.lv2/amppp.ttl
new file mode 100644
index 0000000..1d90459
--- /dev/null
+++ b/plugins/eg-amppp.lv2/amppp.ttl
@@ -0,0 +1,49 @@
+@prefix doap: <http://usefulinc.com/ns/doap#> .
+@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#> .
+@prefix units: <http://lv2plug.in/ns/extensions/units#> .
+
+<http://lv2plug.in/plugins/eg-amppp>
+ a lv2:Plugin ,
+ lv2:AmplifierPlugin ;
+ lv2:project <http://lv2plug.in/ns/lv2> ;
+ doap:name "Simple C++ Amplifier" ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "gain" ;
+ lv2:name "Gain" ;
+ lv2:default 0.0 ;
+ lv2:minimum -90.0 ;
+ lv2:maximum 24.0 ;
+ units:unit units:db ;
+ 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-amppp.lv2/manifest.ttl.in b/plugins/eg-amppp.lv2/manifest.ttl.in
new file mode 100644
index 0000000..4985490
--- /dev/null
+++ b/plugins/eg-amppp.lv2/manifest.ttl.in
@@ -0,0 +1,7 @@
+@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+
+<http://lv2plug.in/plugins/eg-amppp>
+ a lv2:Plugin ;
+ lv2:binary <amppp@LIB_EXT@> ;
+ rdfs:seeAlso <amppp.ttl> .
diff --git a/plugins/eg-amppp.lv2/waf b/plugins/eg-amppp.lv2/waf
new file mode 120000
index 0000000..59a1ac9
--- /dev/null
+++ b/plugins/eg-amppp.lv2/waf
@@ -0,0 +1 @@
+../../waf \ No newline at end of file
diff --git a/plugins/eg-amppp.lv2/wscript b/plugins/eg-amppp.lv2/wscript
new file mode 100644
index 0000000..27b1039
--- /dev/null
+++ b/plugins/eg-amppp.lv2/wscript
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+from waflib.extras import autowaf as autowaf
+import re
+
+# Variables for 'waf dist'
+APPNAME = 'eg-amppp.lv2'
+VERSION = '1.0.0'
+
+# Mandatory variables
+top = '.'
+out = 'build'
+
+def options(opt):
+ opt.load('compiler_cxx')
+ autowaf.set_options(opt)
+
+def configure(conf):
+ conf.load('compiler_cxx')
+ autowaf.configure(conf)
+ autowaf.set_c99_mode(conf)
+ autowaf.display_header('Amppp Configuration')
+
+ if not autowaf.is_child():
+ autowaf.check_pkg(conf, 'lv2', uselib_store='LV2')
+
+ conf.check(features='cxx cxxshlib', lib='m', uselib_store='M', mandatory=False)
+
+ autowaf.display_msg(conf, 'LV2 bundle directory', conf.env.LV2DIR)
+ print('')
+
+def build(bld):
+ bundle = 'eg-amppp.lv2'
+
+ # Make a pattern for shared objects without the 'lib' prefix
+ module_pat = re.sub('^lib', '', bld.env.cshlib_PATTERN)
+ module_ext = module_pat[module_pat.rfind('.'):]
+
+ # Build manifest.ttl by substitution (for portable lib extension)
+ bld(features = 'subst',
+ source = 'manifest.ttl.in',
+ target = '%s/%s' % (bundle, 'manifest.ttl'),
+ install_path = '${LV2DIR}/%s' % bundle,
+ LIB_EXT = module_ext)
+
+ # Copy other data files to build bundle (build/eg-amppp.lv2)
+ for i in ['amppp.ttl']:
+ bld(features = 'subst',
+ is_copy = True,
+ source = i,
+ target = '%s/%s' % (bundle, i),
+ install_path = '${LV2DIR}/%s' % bundle)
+
+ # Use LV2 headers from parent directory if building as a sub-project
+ includes = None
+ if autowaf.is_child:
+ includes = '../..'
+
+ # Build plugin library
+ obj = bld(features = 'cxx cxxshlib',
+ source = 'amppp.cpp',
+ name = 'amppp',
+ target = '%s/amppp' % bundle,
+ install_path = '${LV2DIR}/%s' % bundle,
+ uselib = 'M LV2',
+ includes = includes)
+ obj.env.cxxshlib_PATTERN = module_pat
diff --git a/plugins/wscript b/plugins/wscript
index f099183..28e5e02 100644
--- a/plugins/wscript
+++ b/plugins/wscript
@@ -15,7 +15,7 @@ def bld_book_src(task):
filenames += [i.abspath()]
literasc.gen(open(task.outputs[0].abspath(), 'w'), filenames)
-
+
def build(bld):
files = [bld.path.find_node('README.txt')]
for i in ['eg-amp.lv2',
@@ -29,6 +29,14 @@ def build(bld):
files += bld.path.ant_glob('%s/*.ttl' % i)
files += bld.path.ant_glob('%s/*.c' % i)
+ if bld.env.BUILD_CXX:
+ for i in ['eg-amppp.lv2']:
+ print i
+ files += bld.path.ant_glob('%s/*.txt' % i)
+ files += bld.path.ant_glob('%s/manifest.ttl*' % i)
+ files += bld.path.ant_glob('%s/*.ttl' % i)
+ files += bld.path.ant_glob('%s/*.cpp' % i)
+
# Compile book sources into book.txt asciidoc source
bld(rule = bld_book_src,
source = files,
@@ -41,4 +49,3 @@ def build(bld):
stylesdir, pygments_style),
source = 'book.txt',
target = 'book.html')
-