aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eg-amppp.lv2
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/eg-amppp.lv2')
-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
6 files changed, 204 insertions, 0 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