aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/eg-midiamp.lv2/README.txt3
-rw-r--r--plugins/eg-midiamp.lv2/manifest.ttl.in7
-rw-r--r--plugins/eg-midiamp.lv2/manifest.ttl.in~949f1baa9a283df26a7238c6bd4bb97272ae11927
-rw-r--r--plugins/eg-midiamp.lv2/manifest.ttl.in~HEAD7
-rw-r--r--plugins/eg-midiamp.lv2/midiamp.cpp128
-rw-r--r--plugins/eg-midiamp.lv2/midiamp.ttl35
l---------plugins/eg-midiamp.lv2/waf1
-rw-r--r--plugins/eg-midiamp.lv2/wscript66
-rw-r--r--plugins/wscript8
9 files changed, 262 insertions, 0 deletions
diff --git a/plugins/eg-midiamp.lv2/README.txt b/plugins/eg-midiamp.lv2/README.txt
new file mode 100644
index 0000000..8a02965
--- /dev/null
+++ b/plugins/eg-midiamp.lv2/README.txt
@@ -0,0 +1,3 @@
+== MIDI Controlled Amplifier ==
+
+A MIDI controlled amplifier implemented in C++.
diff --git a/plugins/eg-midiamp.lv2/manifest.ttl.in b/plugins/eg-midiamp.lv2/manifest.ttl.in
new file mode 100644
index 0000000..a40ca8d
--- /dev/null
+++ b/plugins/eg-midiamp.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-midiamp>
+ a lv2:Plugin ;
+ lv2:binary <midiamp@LIB_EXT@> ;
+ rdfs:seeAlso <midiamp.ttl> .
diff --git a/plugins/eg-midiamp.lv2/manifest.ttl.in~949f1baa9a283df26a7238c6bd4bb97272ae1192 b/plugins/eg-midiamp.lv2/manifest.ttl.in~949f1baa9a283df26a7238c6bd4bb97272ae1192
new file mode 100644
index 0000000..a40ca8d
--- /dev/null
+++ b/plugins/eg-midiamp.lv2/manifest.ttl.in~949f1baa9a283df26a7238c6bd4bb97272ae1192
@@ -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-midiamp>
+ a lv2:Plugin ;
+ lv2:binary <midiamp@LIB_EXT@> ;
+ rdfs:seeAlso <midiamp.ttl> .
diff --git a/plugins/eg-midiamp.lv2/manifest.ttl.in~HEAD b/plugins/eg-midiamp.lv2/manifest.ttl.in~HEAD
new file mode 100644
index 0000000..a40ca8d
--- /dev/null
+++ b/plugins/eg-midiamp.lv2/manifest.ttl.in~HEAD
@@ -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-midiamp>
+ a lv2:Plugin ;
+ lv2:binary <midiamp@LIB_EXT@> ;
+ rdfs:seeAlso <midiamp.ttl> .
diff --git a/plugins/eg-midiamp.lv2/midiamp.cpp b/plugins/eg-midiamp.lv2/midiamp.cpp
new file mode 100644
index 0000000..2fff4e7
--- /dev/null
+++ b/plugins/eg-midiamp.lv2/midiamp.cpp
@@ -0,0 +1,128 @@
+/*
+ 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/ext/atom/atom.hpp"
+#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
+#include "lv2/lv2plug.in/ns/ext/urid/urid.hpp"
+#include "lv2/lv2plug.in/ns/lv2core/Lib.hpp"
+#include "lv2/lv2plug.in/ns/lv2core/Plugin.hpp"
+
+/** MIDI-controlled amplifier. */
+class MidiAmp : public lv2::Plugin<MidiAmp> {
+public:
+ MidiAmp(double rate,
+ const char* bundle_path,
+ const LV2_Feature* const* features,
+ bool* valid)
+ : Plugin(rate, bundle_path, features, valid)
+ , m_map(features, valid)
+ , m_vol(1.0f)
+ {
+ if (!*valid) {
+ return;
+ }
+
+ midi_MidiEvent = m_map(LV2_MIDI__MidiEvent);
+ }
+
+ typedef enum {
+ AMP_CONTROL = 0,
+ AMP_INPUT = 1,
+ AMP_OUTPUT = 2
+ } PortIndex;
+
+ void connect_port(uint32_t port, void* data) {
+ switch ((PortIndex)port) {
+ case AMP_CONTROL:
+ m_ports.control = (const lv2::atom::Sequence*)data;
+ break;
+ case AMP_INPUT:
+ m_ports.input = (const float*)data;
+ break;
+ case AMP_OUTPUT:
+ m_ports.output = (float*)data;
+ break;
+ }
+ }
+
+ void run(const uint32_t n_samples) {
+ uint32_t offset = 0;
+ for (const lv2::atom::Event& ev : *m_ports.control) {
+ // Emit audio up to this event's time
+ for (uint32_t o = offset; o < ev.time.frames; ++o) {
+ m_ports.output[o] = m_ports.input[0] * m_vol;
+ }
+
+ // Process event
+ if (ev.type() == midi_MidiEvent) {
+ const uint8_t* const msg = (const uint8_t*)(&ev + 1);
+ if (lv2_midi_message_type(msg) == LV2_MIDI_MSG_CONTROLLER &&
+ msg[1] == LV2_MIDI_CTL_MSB_MAIN_VOLUME) {
+ m_vol = msg[2] / 127.0f;
+ }
+ }
+
+ offset = ev.time.frames;
+ }
+
+ // Emit remaining audio to the end of the block
+ for (uint32_t o = offset; o < n_samples; ++o) {
+ m_ports.output[o] = m_ports.input[0] * m_vol;
+ }
+ }
+
+private:
+ typedef struct {
+ const lv2::atom::Sequence* control;
+ const float* input;
+ float* output;
+ } Ports;
+
+ lv2::urid::Map<true> m_map;
+ lv2::urid::URID midi_MidiEvent;
+ Ports m_ports;
+ float m_vol;
+};
+
+/** Plugin library. */
+class MidiAmpLib : public lv2::Lib<MidiAmpLib>
+{
+public:
+ MidiAmpLib(const char* bundle_path,
+ const LV2_Feature*const* features)
+ : lv2::Lib<MidiAmpLib>(bundle_path, features)
+ , m_amp(MidiAmp::descriptor("http://lv2plug.in/plugins/eg-midiamp"))
+ {}
+
+ const LV2_Descriptor* get_plugin(uint32_t index) {
+ return index == 0 ? &m_amp : NULL;
+ }
+
+private:
+ LV2_Descriptor m_amp;
+};
+
+/** Library entry point. */
+LV2_SYMBOL_EXPORT const LV2_Lib_Descriptor*
+lv2_lib_descriptor(const char* bundle_path,
+ const LV2_Feature *const * features)
+
+{
+ return new MidiAmpLib(bundle_path, features);
+}
diff --git a/plugins/eg-midiamp.lv2/midiamp.ttl b/plugins/eg-midiamp.lv2/midiamp.ttl
new file mode 100644
index 0000000..2d985b2
--- /dev/null
+++ b/plugins/eg-midiamp.lv2/midiamp.ttl
@@ -0,0 +1,35 @@
+@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 atom: <http://lv2plug.in/ns/ext/atom#> .
+
+<http://lv2plug.in/plugins/eg-midiamp>
+ a lv2:Plugin ,
+ lv2:AmplifierPlugin ;
+ lv2:project <http://lv2plug.in/ns/lv2> ;
+ doap:name "MIDI Controlled Amplifier" ;
+ doap:license <http://opensource.org/licenses/isc> ;
+ lv2:optionalFeature lv2:hardRTCapable ;
+ lv2:port [
+ a lv2:InputPort ,
+ atom:AtomPort ;
+ atom:bufferType atom:Sequence ;
+ atom:supports <http://lv2plug.in/ns/ext/midi#MidiEvent> ;
+ lv2:designation lv2:control ;
+ lv2:index 0 ;
+ lv2:symbol "control" ;
+ lv2:name "Control"
+ ] , [
+ 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-midiamp.lv2/waf b/plugins/eg-midiamp.lv2/waf
new file mode 120000
index 0000000..59a1ac9
--- /dev/null
+++ b/plugins/eg-midiamp.lv2/waf
@@ -0,0 +1 @@
+../../waf \ No newline at end of file
diff --git a/plugins/eg-midiamp.lv2/wscript b/plugins/eg-midiamp.lv2/wscript
new file mode 100644
index 0000000..af0ec06
--- /dev/null
+++ b/plugins/eg-midiamp.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-midiamp.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('Midiamp 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-midiamp.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-midiamp.lv2)
+ for i in ['midiamp.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 = 'midiamp.cpp',
+ name = 'midiamp',
+ target = '%s/midiamp' % 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 f5f6571..94269e4 100644
--- a/plugins/wscript
+++ b/plugins/wscript
@@ -31,6 +31,14 @@ def build(bld):
files += bld.path.ant_glob('%s/*.c' % i)
files += bld.path.ant_glob('%s/*.h' % i)
+ if bld.env.BUILD_CXX:
+ for i in ['eg-midiamp.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,