commit a3b75b17735cb2fda44da39b063cd06cece9fbab Author: dreamer Date: Sun Jan 31 21:30:48 2021 +0100 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..1db296a --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# About + +This project aims to provide basic lua bindings to [liblilv](https://github.com/lv2/lilv). + +## done + +- lv2ls + +## todo + +- lv2ls --name +- lv2info +- everything else diff --git a/lilv.lua b/lilv.lua new file mode 100644 index 0000000..cb0054e --- /dev/null +++ b/lilv.lua @@ -0,0 +1,40 @@ +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*); +]] + +return lv2 diff --git a/lv2info.lua b/lv2info.lua new file mode 100644 index 0000000..17fa756 --- /dev/null +++ b/lv2info.lua @@ -0,0 +1,7 @@ +local ffi = require "ffi" +local lv2 = require('lilv') + + +local world = lv2.lilv_world_new() +lv2.lilv_world_load_all(world) +local plugins = lv2.lilv_world_get_all_plugins(world) diff --git a/lv2ls.lua b/lv2ls.lua new file mode 100644 index 0000000..9eee3e1 --- /dev/null +++ b/lv2ls.lua @@ -0,0 +1,30 @@ +local ffi = require "ffi" +local lv2 = require('lilv') + + +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 uri = ffi.string(node_as_uri) + + print(uri) + end + + iter = lv2.lilv_plugins_next(plugin_list, iter) + end +end + +list_plugins(plugins, false)