Skip to content

Commit

Permalink
Adding support to enumeration parameter type in lv2 module
Browse files Browse the repository at this point in the history
  • Loading branch information
mr.fantastic committed Jun 28, 2024
1 parent 38ef4df commit afbd9c0
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 2 deletions.
61 changes: 60 additions & 1 deletion src/modules/jackrack/factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,62 @@ static void lv2_add_port_to_metadata(mlt_properties p, lv2_plugin_desc_t *desc,
}

if (LADSPA_IS_HINT_ENUMERATION(hint_descriptor)) {
/* WIP */
mlt_properties_set(p, "type", "string");

char *str_ptr = strchr(desc->uri, '<');
while (str_ptr != NULL) {
*str_ptr++ = ':';
str_ptr = strchr(str_ptr, '<');
}

LilvNode* puri_temp = lilv_new_uri(g_lv2_plugin_mgr->lv2_world, desc->uri);

str_ptr = strchr(desc->uri, ':');
while (str_ptr != NULL) {
*str_ptr++ = '<';
str_ptr = strchr(str_ptr, ':');
}

const LilvPlugin* p_temp = lilv_plugins_get_by_uri(g_lv2_plugin_mgr->plugin_list, puri_temp);
const LilvPort *port_temp = lilv_plugin_get_port_by_index(p_temp, j);

lilv_node_free(puri_temp);

mlt_properties values_temp = mlt_properties_new();
mlt_properties_set_data(p,
"values",
values_temp,
0,
(mlt_destructor) mlt_properties_close,
NULL);

// Fill scalePoints Map
LilvScalePoints* sp = lilv_port_get_scale_points(p_temp, port_temp);
if (sp) {
LILV_FOREACH (scale_points, s, sp) {
const LilvScalePoint* p = lilv_scale_points_get(sp, s);
const LilvNode* val = lilv_scale_point_get_value(p);
if (!lilv_node_is_float(val) && !lilv_node_is_int(val)) {
continue;
}

const float f = lilv_node_as_float(val);


char key_temp[20];

if (lilv_node_is_float(val)) {
snprintf(key_temp, 20, "%f", f);
} else if (lilv_node_is_int(val)) {
snprintf(key_temp, 20, "%d", (int) f);
}

mlt_properties_set(values_temp, key_temp, lilv_node_as_string(lilv_scale_point_get_label(p)));

}

lilv_scale_points_free(sp);
}
}

if (LADSPA_IS_HINT_LOGARITHMIC(hint_descriptor))
Expand Down Expand Up @@ -412,6 +467,10 @@ MLT_REPOSITORY
#ifdef WITH_LV2
g_lv2_plugin_mgr = lv2_mgr_new();

char global_lv2_world[20];
snprintf (global_lv2_world, 20, "%p", g_lv2_plugin_mgr->lv2_world);
mlt_environment_set ("global_lv2_world", global_lv2_world);

for (list = g_lv2_plugin_mgr->all_plugins; list; list = g_slist_next(list)) {
lv2_plugin_desc_t *desc = (lv2_plugin_desc_t *) list->data;
char *s = NULL;
Expand Down
15 changes: 14 additions & 1 deletion src/modules/jackrack/lv2_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

#define CONTROL_FIFO_SIZE 128

extern char *mlt_environment(const char *name);

extern const LV2_Feature *features[];

#ifdef WITH_JACK
Expand Down Expand Up @@ -272,8 +274,19 @@ static int lv2_plugin_instantiate(const LilvPlugin *plugin,
gint copies,
LilvInstance **instances)
{
gint i;
char *lv2context_can_ui = mlt_environment ("lv2context_can_ui");
if (lv2context_can_ui != NULL)
{
/* Video editors and other hosts that support custom GUI should use mlt_environment_set ("lv2context_can_ui", "1")
to inform mlt lv2 plugin manager and set UI features and extensions if not set.
*/
if (lv2context_can_ui[0] == '1')
{
//WIP: if support UI
}
}

gint i;
for (i = 0; i < copies; i++) {
instances[i] = lilv_plugin_instantiate(plugin, lv2_sample_rate, features);

Expand Down
1 change: 1 addition & 0 deletions src/modules/jackrack/plugin_mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#include <lv2/resize-port/resize-port.h>
#include <lv2/ui/ui.h>
#include <lv2/worker/worker.h>
#include <lv2/state/state.h>

#include "lv2_urid_helper.h"

Expand Down

0 comments on commit afbd9c0

Please sign in to comment.