Last active
January 31, 2021 06:39
-
-
Save dromer/3038ce5fb7b289c63327d61e06e46ee7 to your computer and use it in GitHub Desktop.
basic lv2ls implementation in luajit using liblilv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ffi = require "ffi" | |
local lv2 = ffi.load("liblilv-0.so.0") | |
ffi.cdef [[ | |
typedef struct LilvPluginImpl LilvPlugin; /**< LV2 Plugin. */ | |
typedef struct LilvPluginClassImpl LilvPluginClass; /**< Plugin Class. */ | |
typedef struct LilvPortImpl LilvPort; /**< Port. */ | |
typedef struct LilvScalePointImpl LilvScalePoint; /**< Scale Point. */ | |
typedef struct LilvUIImpl LilvUI; /**< Plugin UI. */ | |
typedef struct LilvNodeImpl LilvNode; /**< Typed Value. */ | |
typedef struct LilvWorldImpl LilvWorld; /**< Lilv World. */ | |
typedef struct LilvInstanceImpl LilvInstance; /**< Plugin instance. */ | |
typedef struct LilvStateImpl LilvState; /**< Plugin state. */ | |
typedef void LilvIter; /**< Collection iterator */ | |
typedef void LilvPluginClasses; /**< A set of #LilvPluginClass. */ | |
typedef void LilvPlugins; /**< A set of #LilvPlugin. */ | |
typedef void LilvScalePoints; /**< A set of #LilvScalePoint. */ | |
typedef void LilvUIs; /**< A set of #LilvUI. */ | |
typedef void LilvNodes; /**< A set of #LilvNode. */ | |
LilvWorld* lilv_world_new(); | |
void lilv_world_load_all(LilvWorld*); | |
LilvPlugins* lilv_world_get_all_plugins(LilvWorld*); | |
unsigned lilv_plugins_size(const LilvPlugins*); | |
LilvIter* lilv_plugins_begin(const LilvPlugins*); | |
const LilvPlugin* lilv_plugins_get(const LilvPlugins*, LilvIter*); | |
LilvIter* lilv_plugins_next(const LilvPlugins*, LilvIter*); | |
bool lilv_plugins_is_end(const LilvPlugins*, LilvIter*); | |
const LilvNode* lilv_plugin_get_uri(const LilvPlugin*); | |
const LilvNode* lilv_plugin_get_bundle_uri(const LilvPlugin*); | |
const LilvNode* lilv_plugin_get_library_uri(const LilvPlugin*); | |
const char* lilv_node_as_uri(const LilvNode*); | |
]] | |
local world = lv2.lilv_world_new() | |
lv2.lilv_world_load_all(world) | |
local plugins = lv2.lilv_world_get_all_plugins(world) | |
local function list_plugins(plugin_list, show_names) | |
local iter = lv2.lilv_plugins_begin(plugin_list) | |
while not lv2.lilv_plugins_is_end(plugin_list, iter) do | |
local plugin = lv2.lilv_plugins_get(plugin_list, iter) | |
if show_names then | |
print('thing') | |
else | |
local plugin_get_uri = lv2.lilv_plugin_get_uri(plugin) | |
local node_as_uri = lv2.lilv_node_as_uri(plugin_get_uri) | |
local str = ffi.string(node_as_uri) | |
print(str) | |
end | |
iter = lv2.lilv_plugins_next(plugin_list, iter) | |
end | |
end | |
list_plugins(plugins, false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment