diff options
author | David Robillard <d@drobilla.net> | 2014-08-06 01:26:06 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-08-06 01:26:06 +0000 |
commit | 74d7751c37d2c991d244c1c23e1a4cd24451ac41 (patch) | |
tree | af301c27cbf585ae71f95e9e14e2380f062e6739 /plugins/eg06-fifths.lv2 | |
parent | f181b31c11d6a9317695c68c6cce30319e7e2faa (diff) | |
download | lv2-74d7751c37d2c991d244c1c23e1a4cd24451ac41.tar.xz |
Order book chapters in build script rather than by bundle name.
Diffstat (limited to 'plugins/eg06-fifths.lv2')
-rw-r--r-- | plugins/eg06-fifths.lv2/README.txt | 3 | ||||
-rw-r--r-- | plugins/eg06-fifths.lv2/fifths.c | 196 | ||||
-rw-r--r-- | plugins/eg06-fifths.lv2/fifths.ttl | 30 | ||||
-rw-r--r-- | plugins/eg06-fifths.lv2/manifest.ttl.in | 8 | ||||
-rw-r--r-- | plugins/eg06-fifths.lv2/uris.h | 64 | ||||
l--------- | plugins/eg06-fifths.lv2/waf | 1 | ||||
-rw-r--r-- | plugins/eg06-fifths.lv2/wscript | 64 |
7 files changed, 0 insertions, 366 deletions
diff --git a/plugins/eg06-fifths.lv2/README.txt b/plugins/eg06-fifths.lv2/README.txt deleted file mode 100644 index 2154321..0000000 --- a/plugins/eg06-fifths.lv2/README.txt +++ /dev/null @@ -1,3 +0,0 @@ -== Fifths == - -This plugin demonstrates simple MIDI event reading and writing. diff --git a/plugins/eg06-fifths.lv2/fifths.c b/plugins/eg06-fifths.lv2/fifths.c deleted file mode 100644 index c7d12e1..0000000 --- a/plugins/eg06-fifths.lv2/fifths.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - LV2 Fifths Example Plugin - Copyright 2014 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 <string.h> -#ifndef __cplusplus -# include <stdbool.h> -#endif - -#include <sndfile.h> - -#include "lv2/lv2plug.in/ns/ext/atom/util.h" -#include "lv2/lv2plug.in/ns/ext/midi/midi.h" -#include "lv2/lv2plug.in/ns/ext/patch/patch.h" -#include "lv2/lv2plug.in/ns/ext/state/state.h" -#include "lv2/lv2plug.in/ns/ext/urid/urid.h" -#include "lv2/lv2plug.in/ns/lv2core/lv2.h" - -#include "./uris.h" - -enum { - FIFTHS_IN = 0, - FIFTHS_OUT = 1 -}; - -typedef struct { - // Features - LV2_URID_Map* map; - - // Ports - const LV2_Atom_Sequence* in_port; - LV2_Atom_Sequence* out_port; - - // URIs - FifthsURIs uris; -} Fifths; - -static void -connect_port(LV2_Handle instance, - uint32_t port, - void* data) -{ - Fifths* self = (Fifths*)instance; - switch (port) { - case FIFTHS_IN: - self->in_port = (const LV2_Atom_Sequence*)data; - break; - case FIFTHS_OUT: - self->out_port = (LV2_Atom_Sequence*)data; - break; - default: - break; - } -} - -static LV2_Handle -instantiate(const LV2_Descriptor* descriptor, - double rate, - const char* path, - const LV2_Feature* const* features) -{ - // Allocate and initialise instance structure. - Fifths* self = (Fifths*)malloc(sizeof(Fifths)); - if (!self) { - return NULL; - } - memset(self, 0, sizeof(Fifths)); - - // Get host features - for (int i = 0; features[i]; ++i) { - if (!strcmp(features[i]->URI, LV2_URID__map)) { - self->map = (LV2_URID_Map*)features[i]->data; - } - } - if (!self->map) { - fprintf(stderr, "Missing feature urid:map\n"); - free(self); - return NULL; - } - - // Map URIs and initialise forge/logger - map_fifths_uris(self->map, &self->uris); - - return (LV2_Handle)self; -} - -static void -cleanup(LV2_Handle instance) -{ - free(instance); -} - -static void -run(LV2_Handle instance, - uint32_t sample_count) -{ - Fifths* self = (Fifths*)instance; - FifthsURIs* uris = &self->uris; - - // Struct for a 3 byte MIDI event, used for writing notes - typedef struct { - LV2_Atom_Event event; - uint8_t msg[3]; - } MIDINoteEvent; - - // Initially self->out_port contains a Chunk with size set to capacity - - // Get the capacity - const uint32_t out_capacity = self->out_port->atom.size; - - // Write an empty Sequence header to the output - lv2_atom_sequence_clear(self->out_port); - self->out_port->atom.type = self->in_port->atom.type; - - // Read incoming events - LV2_ATOM_SEQUENCE_FOREACH(self->in_port, ev) { - if (ev->body.type == uris->midi_Event) { - const uint8_t* const msg = (const uint8_t*)(ev + 1); - switch (lv2_midi_message_type(msg)) { - case LV2_MIDI_MSG_NOTE_ON: - case LV2_MIDI_MSG_NOTE_OFF: - // Forward note to output - lv2_atom_sequence_append_event( - self->out_port, out_capacity, ev); - - const uint8_t note = msg[1]; - if (note <= 127 - 7) { - // Make a note one 5th (7 semitones) higher than input - MIDINoteEvent fifth; - - // Could simply do fifth.event = *ev here instead... - fifth.event.time.frames = ev->time.frames; // Same time - fifth.event.body.type = ev->body.type; // Same type - fifth.event.body.size = ev->body.size; // Same size - - fifth.msg[0] = msg[0]; // Same status - fifth.msg[1] = msg[1] + 7; // Pitch up 7 semitones - fifth.msg[2] = msg[2]; // Same velocity - - // Write 5th event - lv2_atom_sequence_append_event( - self->out_port, out_capacity, &fifth.event); - } - break; - default: - // Forward all other MIDI events directly - lv2_atom_sequence_append_event( - self->out_port, out_capacity, ev); - break; - } - } - } -} - -static const void* -extension_data(const char* uri) -{ - return NULL; -} - -static const LV2_Descriptor descriptor = { - EG_FIFTHS_URI, - instantiate, - connect_port, - NULL, // activate, - run, - NULL, // 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/eg06-fifths.lv2/fifths.ttl b/plugins/eg06-fifths.lv2/fifths.ttl deleted file mode 100644 index 7f58a33..0000000 --- a/plugins/eg06-fifths.lv2/fifths.ttl +++ /dev/null @@ -1,30 +0,0 @@ -@prefix atom: <http://lv2plug.in/ns/ext/atom#> . -@prefix doap: <http://usefulinc.com/ns/doap#> . -@prefix lv2: <http://lv2plug.in/ns/lv2core#> . -@prefix urid: <http://lv2plug.in/ns/ext/urid#> . -@prefix midi: <http://lv2plug.in/ns/ext/midi#> . - -<http://lv2plug.in/plugins/eg-fifths> - a lv2:Plugin ; - doap:name "Example Fifths" ; - doap:license <http://opensource.org/licenses/isc> ; - lv2:project <http://lv2plug.in/ns/lv2> ; - lv2:requiredFeature urid:map ; - lv2:optionalFeature lv2:hardRTCapable ; - lv2:port [ - a lv2:InputPort , - atom:AtomPort ; - atom:bufferType atom:Sequence ; - atom:supports midi:MidiEvent ; - lv2:index 0 ; - lv2:symbol "in" ; - lv2:name "In" - ] , [ - a lv2:OutputPort , - atom:AtomPort ; - atom:bufferType atom:Sequence ; - atom:supports midi:MidiEvent ; - lv2:index 1 ; - lv2:symbol "out" ; - lv2:name "Out" - ] . diff --git a/plugins/eg06-fifths.lv2/manifest.ttl.in b/plugins/eg06-fifths.lv2/manifest.ttl.in deleted file mode 100644 index f87f2c1..0000000 --- a/plugins/eg06-fifths.lv2/manifest.ttl.in +++ /dev/null @@ -1,8 +0,0 @@ -@prefix lv2: <http://lv2plug.in/ns/lv2core#> . -@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . -@prefix ui: <http://lv2plug.in/ns/extensions/ui#> . - -<http://lv2plug.in/plugins/eg-fifths> - a lv2:Plugin ; - lv2:binary <fifths@LIB_EXT@> ; - rdfs:seeAlso <fifths.ttl> . diff --git a/plugins/eg06-fifths.lv2/uris.h b/plugins/eg06-fifths.lv2/uris.h deleted file mode 100644 index e174fb4..0000000 --- a/plugins/eg06-fifths.lv2/uris.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - LV2 Fifths Example Plugin - Copyright 2014 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. -*/ - -#ifndef FIFTHS_URIS_H -#define FIFTHS_URIS_H - -#include "lv2/lv2plug.in/ns/ext/log/log.h" -#include "lv2/lv2plug.in/ns/ext/midi/midi.h" -#include "lv2/lv2plug.in/ns/ext/state/state.h" - -#define EG_FIFTHS_URI "http://lv2plug.in/plugins/eg-fifths" -#define EG_FIFTHS__sample EG_FIFTHS_URI "#sample" -#define EG_FIFTHS__applySample EG_FIFTHS_URI "#applySample" -#define EG_FIFTHS__freeSample EG_FIFTHS_URI "#freeSample" - -typedef struct { - LV2_URID atom_Blank; - LV2_URID atom_Path; - LV2_URID atom_Resource; - LV2_URID atom_Sequence; - LV2_URID atom_URID; - LV2_URID atom_eventTransfer; - LV2_URID eg_applySample; - LV2_URID eg_sample; - LV2_URID eg_freeSample; - LV2_URID midi_Event; - LV2_URID patch_Set; - LV2_URID patch_property; - LV2_URID patch_value; -} FifthsURIs; - -static inline void -map_fifths_uris(LV2_URID_Map* map, FifthsURIs* uris) -{ - uris->atom_Blank = map->map(map->handle, LV2_ATOM__Blank); - uris->atom_Path = map->map(map->handle, LV2_ATOM__Path); - uris->atom_Resource = map->map(map->handle, LV2_ATOM__Resource); - uris->atom_Sequence = map->map(map->handle, LV2_ATOM__Sequence); - uris->atom_URID = map->map(map->handle, LV2_ATOM__URID); - uris->atom_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer); - uris->eg_applySample = map->map(map->handle, EG_FIFTHS__applySample); - uris->eg_freeSample = map->map(map->handle, EG_FIFTHS__freeSample); - uris->eg_sample = map->map(map->handle, EG_FIFTHS__sample); - uris->midi_Event = map->map(map->handle, LV2_MIDI__MidiEvent); - uris->patch_Set = map->map(map->handle, LV2_PATCH__Set); - uris->patch_property = map->map(map->handle, LV2_PATCH__property); - uris->patch_value = map->map(map->handle, LV2_PATCH__value); -} - -#endif /* FIFTHS_URIS_H */ diff --git a/plugins/eg06-fifths.lv2/waf b/plugins/eg06-fifths.lv2/waf deleted file mode 120000 index 59a1ac9..0000000 --- a/plugins/eg06-fifths.lv2/waf +++ /dev/null @@ -1 +0,0 @@ -../../waf
\ No newline at end of file diff --git a/plugins/eg06-fifths.lv2/wscript b/plugins/eg06-fifths.lv2/wscript deleted file mode 100644 index 46e2345..0000000 --- a/plugins/eg06-fifths.lv2/wscript +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env python -from waflib.extras import autowaf as autowaf -import re - -# Variables for 'waf dist' -APPNAME = 'eg-fifths.lv2' -VERSION = '1.0.0' - -# Mandatory variables -top = '.' -out = 'build' - -def options(opt): - opt.load('compiler_c') - autowaf.set_options(opt) - -def configure(conf): - conf.load('compiler_c') - autowaf.configure(conf) - autowaf.set_c99_mode(conf) - autowaf.display_header('Fifths Configuration') - - if not autowaf.is_child(): - autowaf.check_pkg(conf, 'lv2', atleast_version='1.2.1', uselib_store='LV2') - - autowaf.display_msg(conf, 'LV2 bundle directory', conf.env.LV2DIR) - print('') - -def build(bld): - bundle = 'eg-fifths.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-fifths.lv2) - for i in ['fifths.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 = ['.'] - if autowaf.is_child: - includes += ['../..'] - - # Build plugin library - obj = bld(features = 'c cshlib', - source = 'fifths.c', - name = 'fifths', - target = '%s/fifths' % bundle, - install_path = '${LV2DIR}/%s' % bundle, - use = 'SNDFILE LV2', - includes = includes) - obj.env.cshlib_PATTERN = module_pat |