aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/amp.c50
-rw-r--r--src/dahdsr.c85
-rw-r--r--src/difference.c93
-rw-r--r--src/fmod.c92
-rw-r--r--src/include/uris.h10
-rw-r--r--src/lp4pole.c60
-rw-r--r--src/product.c88
-rw-r--r--src/pulse.c62
-rw-r--r--src/random.c62
-rw-r--r--src/ratio.c88
-rw-r--r--src/sawtooth.c47
-rw-r--r--src/square.c49
-rw-r--r--src/sum.c91
-rw-r--r--src/sync_pulse.c60
-rw-r--r--src/sync_square.c51
-rw-r--r--src/tracker.c72
-rw-r--r--src/triangle.c60
17 files changed, 659 insertions, 461 deletions
diff --git a/src/amp.c b/src/amp.c
index 96ef690..4f6de84 100644
--- a/src/amp.c
+++ b/src/amp.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "math_func.h"
#include "uris.h"
@@ -61,26 +62,37 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Amp* plugin = (Amp*)instance;
- switch (port) {
- case AMP_GAIN:
- if (type == plugin->uris.lv2_ControlPort) {
- plugin->gain_is_cv = 0;
- } else if (type == plugin->uris.lv2_CVPort) {
- plugin->gain_is_cv = 1;
+ Amp* plugin = (Amp*)instance;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
} else {
- return LV2_MORPH_ERR_BAD_TYPE;
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case AMP_GAIN:
+ plugin->gain_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
}
- return LV2_MORPH_SUCCESS;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
}
+ return ret;
}
static LV2_Handle
@@ -126,9 +138,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/dahdsr.c b/src/dahdsr.c
index 00c1b3e..a4b9c65 100644
--- a/src/dahdsr.c
+++ b/src/dahdsr.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "common.h"
#include "uris.h"
@@ -114,43 +115,51 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Dahdsr* plugin = (Dahdsr*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case DAHDSR_DELAY:
- plugin->delay_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case DAHDSR_ATTACK:
- plugin->attack_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case DAHDSR_HOLD:
- plugin->hold_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case DAHDSR_DECAY:
- plugin->decay_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case DAHDSR_SUSTAIN:
- plugin->sustain_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case DAHDSR_RELEASE:
- plugin->release_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ Dahdsr* plugin = (Dahdsr*)instance;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+ switch (o->subject) {
+ case DAHDSR_DELAY:
+ plugin->delay_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case DAHDSR_ATTACK:
+ plugin->attack_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case DAHDSR_HOLD:
+ plugin->hold_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case DAHDSR_DECAY:
+ plugin->decay_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case DAHDSR_SUSTAIN:
+ plugin->sustain_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case DAHDSR_RELEASE:
+ plugin->release_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -379,9 +388,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/difference.c b/src/difference.c
index e886a09..9e76e0a 100644
--- a/src/difference.c
+++ b/src/difference.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "vector_op.h"
@@ -63,51 +64,63 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Difference* plugin = (Difference*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+ switch (o->subject) {
+ case DIFFERENCE_MINUEND:
+ plugin->minuend_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case DIFFERENCE_SUBTRAHEND:
+ plugin->subtrahend_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- switch (port) {
- case DIFFERENCE_MINUEND:
- plugin->minuend_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case DIFFERENCE_SUBTRAHEND:
- plugin->subtrahend_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
- }
-
- plugin->difference_is_cv = (plugin->minuend_is_cv ||
- plugin->subtrahend_is_cv);
-
- return LV2_MORPH_SUCCESS;
+ plugin->difference_is_cv = plugin->minuend_is_cv || plugin->subtrahend_is_cv;
+ return ret;
}
-static LV2_URID
-port_type(LV2_Handle instance,
- uint32_t port,
- LV2_Morph_Property*const* properties)
+static uint32_t
+options_get(LV2_Handle instance,
+ LV2_Options_Option* options)
{
const Difference* plugin = (const Difference*)instance;
-
- switch (port) {
- case DIFFERENCE_DIFFERENCE:
- return (plugin->difference_is_cv
- ? plugin->uris.lv2_CVPort
- : plugin->uris.lv2_ControlPort);
- default:
- return 0;
+ uint32_t ret = 0;
+ for (LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT ||
+ o->subject != DIFFERENCE_DIFFERENCE) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else {
+ o->size = sizeof(LV2_URID);
+ o->type = plugin->uris.atom_URID;
+ o->value = (plugin->difference_is_cv
+ ? &plugin->uris.lv2_CVPort
+ : &plugin->uris.lv2_ControlPort);
+ }
}
+ return ret;
}
static LV2_Handle
@@ -147,9 +160,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, port_type };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { options_get, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/fmod.c b/src/fmod.c
index 95c243e..9284d9d 100644
--- a/src/fmod.c
+++ b/src/fmod.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "math_func.h"
#include "uris.h"
@@ -63,49 +64,62 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Fmod* plugin = (Fmod*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
+ Fmod* plugin = (Fmod*)instance;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case FMOD_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case FMOD_MODULATOR:
+ plugin->modulator_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- switch (port) {
- case FMOD_FREQUENCY:
- plugin->frequency_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case FMOD_MODULATOR:
- plugin->modulator_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
- }
-
- plugin->output_is_cv = plugin->frequency_is_cv || plugin->modulator_is_cv;
- return LV2_MORPH_SUCCESS;
+ return ret;
}
-static LV2_URID
-port_type(LV2_Handle instance,
- uint32_t port,
- LV2_Morph_Property*const* properties)
+static uint32_t
+options_get(LV2_Handle instance,
+ LV2_Options_Option* options)
{
const Fmod* plugin = (const Fmod*)instance;
-
- switch (port) {
- case FMOD_OUTPUT:
- return (plugin->output_is_cv
- ? plugin->uris.lv2_CVPort
- : plugin->uris.lv2_ControlPort);
- default:
- return 0;
+ uint32_t ret = 0;
+ for (LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT || o->subject != FMOD_OUTPUT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else {
+ o->size = sizeof(LV2_URID);
+ o->type = plugin->uris.atom_URID;
+ o->value = (plugin->output_is_cv
+ ? &plugin->uris.lv2_CVPort
+ : &plugin->uris.lv2_ControlPort);
+ }
}
+ return ret;
}
static LV2_Handle
@@ -157,9 +171,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, port_type };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { options_get, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/include/uris.h b/src/include/uris.h
index 538bd05..9797e0e 100644
--- a/src/include/uris.h
+++ b/src/include/uris.h
@@ -20,12 +20,16 @@
#define blop_uris_h
#include <string.h>
+#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
+#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
typedef struct {
+ LV2_URID atom_URID;
LV2_URID lv2_CVPort;
LV2_URID lv2_ControlPort;
+ LV2_URID morph_currentType;
} URIs;
static inline void
@@ -41,8 +45,10 @@ map_uris(URIs* uris,
}
if (map) {
- uris->lv2_ControlPort = map->map(map->handle, LV2_CORE__ControlPort);
- uris->lv2_CVPort = map->map(map->handle, LV2_CORE__CVPort);
+ uris->atom_URID = map->map(map->handle, LV2_ATOM__URID);
+ uris->lv2_ControlPort = map->map(map->handle, LV2_CORE__ControlPort);
+ uris->lv2_CVPort = map->map(map->handle, LV2_CORE__CVPort);
+ uris->morph_currentType = map->map(map->handle, LV2_MORPH__currentType);
} else {
memset(uris, 0, sizeof(*uris));
}
diff --git a/src/lp4pole.c b/src/lp4pole.c
index 27b1ae0..7d2eb6b 100644
--- a/src/lp4pole.c
+++ b/src/lp4pole.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "lp4pole_filter.h"
#include "common.h"
@@ -73,31 +74,40 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Lp4pole* plugin = (Lp4pole*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case LP4POLE_CUTOFF:
- plugin->cutoff_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case LP4POLE_RESONANCE:
- plugin->resonance_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case LP4POLE_CUTOFF:
+ plugin->cutoff_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case LP4POLE_RESONANCE:
+ plugin->resonance_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -168,9 +178,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/product.c b/src/product.c
index ea07ee6..007d853 100644
--- a/src/product.c
+++ b/src/product.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "vector_op.h"
@@ -63,49 +64,62 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Product* plugin = (Product*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case PRODUCT_MULTIPLICAND:
- plugin->input1_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case PRODUCT_MULTIPLIER:
- plugin->input2_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+ switch (o->subject) {
+ case PRODUCT_MULTIPLICAND:
+ plugin->input1_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case PRODUCT_MULTIPLIER:
+ plugin->input2_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
plugin->output_is_cv = plugin->input1_is_cv || plugin->input2_is_cv;
- return LV2_MORPH_SUCCESS;
+ return ret;
}
-static LV2_URID
-port_type(LV2_Handle instance,
- uint32_t port,
- LV2_Morph_Property*const* properties)
+static uint32_t
+options_get(LV2_Handle instance,
+ LV2_Options_Option* options)
{
const Product* plugin = (const Product*)instance;
-
- switch (port) {
- case PRODUCT_PRODUCT:
- return (plugin->output_is_cv
- ? plugin->uris.lv2_CVPort
- : plugin->uris.lv2_ControlPort);
- default:
- return 0;
+ uint32_t ret = 0;
+ for (LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT || o->subject != PRODUCT_PRODUCT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else {
+ o->size = sizeof(LV2_URID);
+ o->type = plugin->uris.atom_URID;
+ o->value = (plugin->output_is_cv
+ ? &plugin->uris.lv2_CVPort
+ : &plugin->uris.lv2_ControlPort);
+ }
}
+ return ret;
}
static LV2_Handle
@@ -145,9 +159,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, port_type };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { options_get, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/pulse.c b/src/pulse.c
index b59caf8..29e1001 100644
--- a/src/pulse.c
+++ b/src/pulse.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "wavedata.h"
@@ -58,31 +59,40 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Pulse* plugin = (Pulse*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case PULSE_FREQUENCY:
- plugin->frequency_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case PULSE_PULSEWIDTH:
- plugin->pulsewidth_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ Pulse* plugin = (Pulse*)malloc(sizeof(Pulse));
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case PULSE_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case PULSE_PULSEWIDTH:
+ plugin->pulsewidth_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -187,9 +197,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/random.c b/src/random.c
index 2239d48..45d8de8 100644
--- a/src/random.c
+++ b/src/random.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include <time.h>
#include "math_func.h"
@@ -71,31 +72,40 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Random* plugin = (Random*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case RANDOM_FREQUENCY:
- plugin->frequency_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case RANDOM_SMOOTH:
- plugin->smooth_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ Random* plugin = (Random*)instance;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case RANDOM_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case RANDOM_SMOOTH:
+ plugin->smooth_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -199,9 +209,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/ratio.c b/src/ratio.c
index 57cb6a5..30873c2 100644
--- a/src/ratio.c
+++ b/src/ratio.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "math_func.h"
#include "common.h"
@@ -64,49 +65,62 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Ratio* plugin = (Ratio*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case RATIO_NUMERATOR:
- plugin->numerator_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case RATIO_DENOMINATOR:
- plugin->denominator_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+ switch (o->subject) {
+ case RATIO_NUMERATOR:
+ plugin->numerator_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case RATIO_DENOMINATOR:
+ plugin->denominator_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
plugin->output_is_cv = plugin->numerator_is_cv || plugin->denominator_is_cv;
- return LV2_MORPH_SUCCESS;
+ return ret;
}
-static LV2_URID
-port_type(LV2_Handle instance,
- uint32_t port,
- LV2_Morph_Property*const* properties)
+static uint32_t
+options_get(LV2_Handle instance,
+ LV2_Options_Option* options)
{
const Ratio* plugin = (const Ratio*)instance;
-
- switch (port) {
- case RATIO_OUTPUT:
- return (plugin->output_is_cv
- ? plugin->uris.lv2_CVPort
- : plugin->uris.lv2_ControlPort);
- default:
- return 0;
+ uint32_t ret = 0;
+ for (LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT || o->subject != RATIO_OUTPUT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else {
+ o->size = sizeof(LV2_URID);
+ o->type = plugin->uris.atom_URID;
+ o->value = (plugin->output_is_cv
+ ? &plugin->uris.lv2_CVPort
+ : &plugin->uris.lv2_ControlPort);
+ }
}
+ return ret;
}
static LV2_Handle
@@ -160,9 +174,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, port_type };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { options_get, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/sawtooth.c b/src/sawtooth.c
index 8667f73..31c9057 100644
--- a/src/sawtooth.c
+++ b/src/sawtooth.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "wavedata.h"
@@ -52,21 +53,37 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Sawtooth* plugin = (Sawtooth*)instance;
- if (type == plugin->uris.lv2_ControlPort) {
- plugin->frequency_is_cv = 0;
- } else if (type == plugin->uris.lv2_CVPort) {
- plugin->frequency_is_cv = 1;
- } else {
- return LV2_MORPH_ERR_BAD_TYPE;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case SAWTOOTH_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -149,9 +166,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/square.c b/src/square.c
index 1425114..0136124 100644
--- a/src/square.c
+++ b/src/square.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "wavedata.h"
@@ -52,21 +53,37 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Square* plugin = (Square*)instance;
- if (type == plugin->uris.lv2_ControlPort) {
- plugin->frequency_is_cv = 0;
- } else if (type == plugin->uris.lv2_CVPort) {
- plugin->frequency_is_cv = 1;
- } else {
- return LV2_MORPH_ERR_BAD_TYPE;
+ Square* plugin = (Square*)instance;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case SQUARE_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -150,9 +167,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/sum.c b/src/sum.c
index 5665447..3023733 100644
--- a/src/sum.c
+++ b/src/sum.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "vector_op.h"
@@ -62,50 +63,62 @@ connect_port(LV2_Handle instance,
break;
}
}
-
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- Sum* plugin = (Sum*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case SUM_INPUT1:
- plugin->input1_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case SUM_INPUT2:
- plugin->input2_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ Sum* plugin = (Sum*)instance;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+ switch (o->subject) {
+ case SUM_INPUT1:
+ plugin->input1_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case SUM_INPUT2:
+ plugin->input2_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
plugin->output_is_cv = plugin->input1_is_cv || plugin->input2_is_cv;
- return LV2_MORPH_SUCCESS;
+ return ret;
}
-static LV2_URID
-port_type(LV2_Handle instance,
- uint32_t port,
- LV2_Morph_Property*const* properties)
+static uint32_t
+options_get(LV2_Handle instance,
+ LV2_Options_Option* options)
{
const Sum* plugin = (const Sum*)instance;
-
- switch (port) {
- case SUM_OUTPUT:
- return (plugin->output_is_cv
- ? plugin->uris.lv2_CVPort
- : plugin->uris.lv2_ControlPort);
- default:
- return 0;
+ uint32_t ret = 0;
+ for (LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT || o->subject != SUM_OUTPUT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else {
+ o->size = sizeof(LV2_URID);
+ o->type = plugin->uris.atom_URID;
+ o->value = (plugin->output_is_cv
+ ? &plugin->uris.lv2_CVPort
+ : &plugin->uris.lv2_ControlPort);
+ }
}
+ return ret;
}
static LV2_Handle
@@ -144,9 +157,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, port_type };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { options_get, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/sync_pulse.c b/src/sync_pulse.c
index b1be0ac..0f24c80 100644
--- a/src/sync_pulse.c
+++ b/src/sync_pulse.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "common.h"
@@ -70,31 +71,40 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
- SyncPulse* plugin = (SyncPulse*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
+ SyncPulse* plugin = (SyncPulse*)malloc(sizeof(SyncPulse));
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
- switch (port) {
- case SYNCPULSE_FREQUENCY:
- plugin->frequency_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case SYNCPULSE_PULSEWIDTH:
- plugin->pulsewidth_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ switch (o->subject) {
+ case SYNCPULSE_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case SYNCPULSE_PULSEWIDTH:
+ plugin->pulsewidth_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -175,9 +185,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/sync_square.c b/src/sync_square.c
index 4ac7d1a..38fdaf5 100644
--- a/src/sync_square.c
+++ b/src/sync_square.c
@@ -20,6 +20,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
@@ -64,29 +65,37 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
SyncSquare* plugin = (SyncSquare*)instance;
-
- switch (port) {
- case SYNCSQUARE_FREQUENCY:
- if (type == plugin->uris.lv2_ControlPort) {
- plugin->frequency_is_cv = 0;
- } else if (type == plugin->uris.lv2_CVPort) {
- plugin->frequency_is_cv = 1;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
} else {
- return LV2_MORPH_ERR_BAD_TYPE;
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case SYNCSQUARE_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
}
- return LV2_MORPH_SUCCESS;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -164,9 +173,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/tracker.c b/src/tracker.c
index 3ff92c6..dd628bc 100644
--- a/src/tracker.c
+++ b/src/tracker.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "common.h"
#include "uris.h"
@@ -86,37 +87,46 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Tracker* plugin = (Tracker*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case TRACKER_HATTACK:
- plugin->hattack_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case TRACKER_HDECAY:
- plugin->hdecay_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case TRACKER_LATTACK:
- plugin->lattack_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case TRACKER_LDECAY:
- plugin->ldecay_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case TRACKER_HATTACK:
+ plugin->hattack_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case TRACKER_HDECAY:
+ plugin->hdecay_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case TRACKER_LATTACK:
+ plugin->lattack_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case TRACKER_LDECAY:
+ plugin->ldecay_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -207,9 +217,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}
diff --git a/src/triangle.c b/src/triangle.c
index fb03f7b..09c01c2 100644
--- a/src/triangle.c
+++ b/src/triangle.c
@@ -19,6 +19,7 @@
#include <stdlib.h>
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
+#include "lv2/lv2plug.in/ns/ext/options/options.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "uris.h"
#include "wavedata.h"
@@ -60,31 +61,40 @@ connect_port(LV2_Handle instance,
}
}
-static LV2_Morph_Status
-morph_port(LV2_Handle instance,
- uint32_t port,
- LV2_URID type,
- const LV2_Morph_Property*const* properties)
+static uint32_t
+options_set(LV2_Handle instance,
+ const LV2_Options_Option* options)
{
Triangle* plugin = (Triangle*)instance;
-
- if (type != plugin->uris.lv2_ControlPort &&
- type != plugin->uris.lv2_CVPort) {
- return LV2_MORPH_ERR_BAD_TYPE;
- }
-
- switch (port) {
- case TRIANGLE_FREQUENCY:
- plugin->frequency_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- case TRIANGLE_SLOPE:
- plugin->slope_is_cv = (type == plugin->uris.lv2_CVPort);
- break;
- default:
- return LV2_MORPH_ERR_BAD_PORT;
+ uint32_t ret = 0;
+ for (const LV2_Options_Option* o = options; o->key; ++o) {
+ if (o->context != LV2_OPTIONS_PORT) {
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ } else if (o->key != plugin->uris.morph_currentType) {
+ ret |= LV2_OPTIONS_ERR_BAD_KEY;
+ } else if (o->type != plugin->uris.atom_URID) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ } else {
+ LV2_URID port_type = *(const LV2_URID*)(o->value);
+ if (port_type != plugin->uris.lv2_ControlPort &&
+ port_type != plugin->uris.lv2_CVPort) {
+ ret |= LV2_OPTIONS_ERR_BAD_VALUE;
+ continue;
+ }
+
+ switch (o->subject) {
+ case TRIANGLE_FREQUENCY:
+ plugin->frequency_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ case TRIANGLE_SLOPE:
+ plugin->slope_is_cv = (port_type == plugin->uris.lv2_CVPort);
+ break;
+ default:
+ ret |= LV2_OPTIONS_ERR_BAD_SUBJECT;
+ }
+ }
}
-
- return LV2_MORPH_SUCCESS;
+ return ret;
}
static LV2_Handle
@@ -194,9 +204,9 @@ run(LV2_Handle instance,
static const void*
extension_data(const char* uri)
{
- static const LV2_Morph_Interface morph = { morph_port, NULL };
- if (!strcmp(uri, LV2_MORPH__interface)) {
- return &morph;
+ static const LV2_Options_Interface options = { NULL, options_set };
+ if (!strcmp(uri, LV2_OPTIONS__interface)) {
+ return &options;
}
return NULL;
}