aboutsummaryrefslogtreecommitdiffstats
path: root/src/dahdsr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dahdsr.c')
-rw-r--r--src/dahdsr.c85
1 files changed, 47 insertions, 38 deletions
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;
}