aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2015-06-19 00:11:05 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2015-06-19 00:11:05 +0200
commitf97ba9906ba3f09f594c35f6dd24f3bd1bbf9ba4 (patch)
treea3d7e86585f1dd58d62158f0fecbee02d89671f2
parent457a8be07ba67b6d7e268105dd8c65ea91ab63a7 (diff)
downloadsynthpod-f97ba9906ba3f09f594c35f6dd24f3bd1bbf9ba4.tar.xz
add cv2control and control2cv converter plugs.
-rw-r--r--plugins/CMakeLists.txt4
-rw-r--r--plugins/manifest.ttl.in12
-rw-r--r--plugins/synthpod.ttl78
-rw-r--r--plugins/synthpod_control2cv.c114
-rw-r--r--plugins/synthpod_cv2control.c165
-rw-r--r--plugins/synthpod_lv2.c4
-rw-r--r--plugins/synthpod_lv2.h4
7 files changed, 380 insertions, 1 deletions
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 54c5d78a..3df7a541 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -34,7 +34,9 @@ endif()
add_library(synthpod.lv2 MODULE
synthpod_lv2.c
synthpod_stereo.c
- synthpod_keyboard.c)
+ synthpod_keyboard.c
+ synthpod_cv2control.c
+ synthpod_control2cv.c)
target_link_libraries(synthpod.lv2 synthpod.lib)
set_target_properties(synthpod.lv2 PROPERTIES PREFIX "" OUTPUT_NAME "synthpod")
install(TARGETS synthpod.lv2 DESTINATION ${SYNTHPOD_PLUGIN_DIR})
diff --git a/plugins/manifest.ttl.in b/plugins/manifest.ttl.in
index 2b2dac69..50583a6a 100644
--- a/plugins/manifest.ttl.in
+++ b/plugins/manifest.ttl.in
@@ -96,3 +96,15 @@ synthpod:keyboard_x11
a ui:X11UI ;
ui:binary <synthpod_ui@LIB_EXT@> ;
rdfs:seeAlso <synthpod.ttl> .
+
+# CV2Control Keyboard
+synthpod:cv2control
+ a lv2:Plugin ;
+ lv2:binary <synthpod@LIB_EXT@> ;
+ rdfs:seeAlso <synthpod.ttl> .
+
+# Control2CV Keyboard
+synthpod:control2cv
+ a lv2:Plugin ;
+ lv2:binary <synthpod@LIB_EXT@> ;
+ rdfs:seeAlso <synthpod.ttl> .
diff --git a/plugins/synthpod.ttl b/plugins/synthpod.ttl
index 18d7e5ba..9a281799 100644
--- a/plugins/synthpod.ttl
+++ b/plugins/synthpod.ttl
@@ -15,6 +15,7 @@
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix doap: <http://usefulinc.com/ns/doap#> .
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@@ -341,3 +342,80 @@ synthpod:keyboard
lv2:portProperty lv2:integer ;
units:unit units:oct ;
] .
+
+# CV2Control Plugin
+synthpod:cv2control
+ a lv2:Plugin ,
+ lv2:ConverterPlugin ;
+ doap:name "Synthpod CV2Control" ;
+ doap:license lic:Artistic-2.0 ;
+ lv2:project proj:synthpod ;
+ lv2:requiredFeature bufsz:boundedBlockLength ;
+ lv2:optionalFeature lv2:isLive , lv2:hardRTCapable ;
+
+ lv2:port [
+ # cv_in
+ a lv2:InputPort ,
+ lv2:CVPort ;
+ lv2:index 0 ;
+ lv2:symbol "cv_in" ;
+ lv2:name "CV In" ;
+ pg:group synthpod:group_in ;
+ ] , [
+ # mode
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 1 ;
+ lv2:symbol "mode" ;
+ lv2:name "Mode" ;
+ pg:group synthpod:group_in ;
+ lv2:default 1 ;
+ lv2:minimum 0 ;
+ lv2:maximum 2 ;
+ lv2:portProperty lv2:integer, lv2:enumeration ;
+ lv2:scalePoint [ rdfs:label "Minimum" ; rdf:value 0 ] ;
+ lv2:scalePoint [ rdfs:label "Average" ; rdf:value 1 ] ;
+ lv2:scalePoint [ rdfs:label "Maximum" ; rdf:value 2 ] ;
+ ] , [
+ # control_out
+ a lv2:OutputPort ,
+ lv2:ControlPort ;
+ lv2:index 2 ;
+ lv2:symbol "control_out" ;
+ lv2:name "Output" ;
+ lv2:default 0 ;
+ lv2:minimum 0 ;
+ lv2:maximum 1 ;
+ pg:group synthpod:group_out ;
+ ] .
+
+# Control2CV Plugin
+synthpod:control2cv
+ a lv2:Plugin ,
+ lv2:ConverterPlugin ;
+ doap:name "Synthpod Control2CV" ;
+ doap:license lic:Artistic-2.0 ;
+ lv2:project proj:synthpod ;
+ lv2:requiredFeature bufsz:boundedBlockLength ;
+ lv2:optionalFeature lv2:isLive , lv2:hardRTCapable ;
+
+ lv2:port [
+ # control_out
+ a lv2:InputPort ,
+ lv2:ControlPort ;
+ lv2:index 0 ;
+ lv2:symbol "control_in" ;
+ lv2:name "Input" ;
+ lv2:default 0 ;
+ lv2:minimum 0 ;
+ lv2:maximum 1 ;
+ pg:group synthpod:group_in ;
+ ] , [
+ # cv_out
+ a lv2:OutputPort ,
+ lv2:CVPort ;
+ lv2:index 1 ;
+ lv2:symbol "cv_out" ;
+ lv2:name "CV Out" ;
+ pg:group synthpod:group_out ;
+ ] .
diff --git a/plugins/synthpod_control2cv.c b/plugins/synthpod_control2cv.c
new file mode 100644
index 00000000..8a75730b
--- /dev/null
+++ b/plugins/synthpod_control2cv.c
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the Artistic License 2.0 as published by
+ * The Perl Foundation.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Artistic License 2.0 for more details.
+ *
+ * You should have received a copy of the Artistic License 2.0
+ * along the source as a COPYING file. If not, obtain it from
+ * http://www.perlfoundation.org/artistic_license_2_0.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <synthpod_lv2.h>
+
+#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
+#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
+#include <lv2/lv2plug.in/ns/ext/atom/util.h>
+#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
+
+typedef struct _plughandle_t plughandle_t;
+
+struct _plughandle_t {
+ const float *input;
+ float *cv_out;
+};
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor, double rate,
+ const char *bundle_path, const LV2_Feature *const *features)
+{
+ plughandle_t *handle = calloc(1, sizeof(plughandle_t));
+ if(!handle)
+ return NULL;
+
+ return handle;
+}
+
+static void
+connect_port(LV2_Handle instance, uint32_t port, void *data)
+{
+ plughandle_t *handle = instance;
+
+ switch(port)
+ {
+ case 0:
+ handle->input = (const float *)data;
+ break;
+ case 1:
+ handle->cv_out = (float *)data;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+activate(LV2_Handle instance)
+{
+ //plughandle_t *handle = instance;
+
+ // nothing
+}
+
+static void
+run(LV2_Handle instance, uint32_t nsamples)
+{
+ plughandle_t *handle = instance;
+
+ for(int i=0; i<nsamples; i++)
+ handle->cv_out[i] = *handle->input;
+}
+
+static void
+deactivate(LV2_Handle instance)
+{
+ //plughandle_t *handle = instance;
+
+ // nothing
+}
+
+static void
+cleanup(LV2_Handle instance)
+{
+ plughandle_t *handle = instance;
+
+ free(handle);
+}
+
+static const void*
+extension_data(const char* uri)
+{
+ return NULL;
+}
+
+const LV2_Descriptor synthpod_control2cv = {
+ .URI = SYNTHPOD_CONTROL2CV_URI,
+ .instantiate = instantiate,
+ .connect_port = connect_port,
+ .activate = activate,
+ .run = run,
+ .deactivate = deactivate,
+ .cleanup = cleanup,
+ .extension_data = extension_data
+};
diff --git a/plugins/synthpod_cv2control.c b/plugins/synthpod_cv2control.c
new file mode 100644
index 00000000..fae6e74c
--- /dev/null
+++ b/plugins/synthpod_cv2control.c
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 2015 Hanspeter Portner (dev@open-music-kontrollers.ch)
+ *
+ * This is free software: you can redistribute it and/or modify
+ * it under the terms of the Artistic License 2.0 as published by
+ * The Perl Foundation.
+ *
+ * This source is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * Artistic License 2.0 for more details.
+ *
+ * You should have received a copy of the Artistic License 2.0
+ * along the source as a COPYING file. If not, obtain it from
+ * http://www.perlfoundation.org/artistic_license_2_0.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include <synthpod_lv2.h>
+
+#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
+#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
+#include <lv2/lv2plug.in/ns/ext/atom/util.h>
+#include <lv2/lv2plug.in/ns/ext/midi/midi.h>
+
+typedef struct _plughandle_t plughandle_t;
+
+struct _plughandle_t {
+ const float *cv_in;
+ const float *mode;
+ float *output;
+};
+
+static LV2_Handle
+instantiate(const LV2_Descriptor* descriptor, double rate,
+ const char *bundle_path, const LV2_Feature *const *features)
+{
+ plughandle_t *handle = calloc(1, sizeof(plughandle_t));
+ if(!handle)
+ return NULL;
+
+ return handle;
+}
+
+static void
+connect_port(LV2_Handle instance, uint32_t port, void *data)
+{
+ plughandle_t *handle = instance;
+
+ switch(port)
+ {
+ case 0:
+ handle->cv_in = (const float *)data;
+ break;
+ case 1:
+ handle->mode = (const float *)data;
+ break;
+ case 2:
+ handle->output = (float *)data;
+ break;
+ default:
+ break;
+ }
+}
+
+static void
+activate(LV2_Handle instance)
+{
+ //plughandle_t *handle = instance;
+
+ // nothing
+}
+
+static void
+run(LV2_Handle instance, uint32_t nsamples)
+{
+ plughandle_t *handle = instance;
+
+ int mode = floor(*handle->mode);
+
+ switch(mode)
+ {
+ case 0:
+ {
+ float min = 1.f;
+
+ for(int i=0; i<nsamples; i++)
+ {
+ const float *val = &handle->cv_in[i];
+ if(*val < min)
+ min = *val;
+ }
+
+ *handle->output = min;
+
+ break;
+ }
+ case 1:
+ {
+ float sum = 0.f;
+
+ for(int i=0; i<nsamples; i++)
+ {
+ const float *val = &handle->cv_in[i];
+ sum += *val;
+ }
+
+ *handle->output = sum / nsamples;
+
+ break;
+ }
+ case 2:
+ {
+ float max = 0.f;
+
+ for(int i=0; i<nsamples; i++)
+ {
+ const float *val = &handle->cv_in[i];
+ if(*val > max)
+ max = *val;
+ }
+
+ *handle->output = max;
+
+ break;
+ }
+ }
+}
+
+static void
+deactivate(LV2_Handle instance)
+{
+ //plughandle_t *handle = instance;
+
+ // nothing
+}
+
+static void
+cleanup(LV2_Handle instance)
+{
+ plughandle_t *handle = instance;
+
+ free(handle);
+}
+
+static const void*
+extension_data(const char* uri)
+{
+ return NULL;
+}
+
+const LV2_Descriptor synthpod_cv2control = {
+ .URI = SYNTHPOD_CV2CONTROL_URI,
+ .instantiate = instantiate,
+ .connect_port = connect_port,
+ .activate = activate,
+ .run = run,
+ .deactivate = deactivate,
+ .cleanup = cleanup,
+ .extension_data = extension_data
+};
diff --git a/plugins/synthpod_lv2.c b/plugins/synthpod_lv2.c
index acee9ca6..0f976237 100644
--- a/plugins/synthpod_lv2.c
+++ b/plugins/synthpod_lv2.c
@@ -28,6 +28,10 @@ lv2_descriptor(uint32_t index)
return &synthpod_stereo;
case 1:
return &synthpod_keyboard;
+ case 2:
+ return &synthpod_cv2control;
+ case 3:
+ return &synthpod_control2cv;
default:
return NULL;
}
diff --git a/plugins/synthpod_lv2.h b/plugins/synthpod_lv2.h
index 3b5754ab..f59f924b 100644
--- a/plugins/synthpod_lv2.h
+++ b/plugins/synthpod_lv2.h
@@ -32,9 +32,13 @@
// plugin uris
#define SYNTHPOD_STEREO_URI SYNTHPOD_URI"#stereo"
#define SYNTHPOD_KEYBOARD_URI SYNTHPOD_URI"#keyboard"
+#define SYNTHPOD_CV2CONTROL_URI SYNTHPOD_URI"#cv2control"
+#define SYNTHPOD_CONTROL2CV_URI SYNTHPOD_URI"#control2cv"
extern const LV2_Descriptor synthpod_stereo;
extern const LV2_Descriptor synthpod_keyboard;
+extern const LV2_Descriptor synthpod_cv2control;
+extern const LV2_Descriptor synthpod_control2cv;
// common UI uris
#define SYNTHPOD_COMMON_EO_URI SYNTHPOD_URI"#common_eo"