Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Implementation of LV2 module #983

Merged
merged 6 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For hosts (ie. Video Editors) that want to support LV2 Custom GUIs they should set the mlt environment variable "lv2context_can_ui" to "1" and the the lv2 plugin instance will be instantiated with LV2 UI features and extensions and then they can get "global_lv2_world" handle of LilvWorld* and and retrieve the UI URI and handles and create ui support with suil library (http://drobilla.net/software/suil.html).

This is the plan for supporting Custom GUIs.


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
Loading