LV2 module

LV2 plugin related code.

Contents

Classes

struct Lv2URIDs
Cached URIDs for quick access (instead of having to use symap).
struct Lv2Parameter
Used temporarily to transfer data.
struct Lv2ControlChange
Control change event, sent through ring buffers for UI updates.
struct Lv2Plugin
LV2 plugin.

Enums

enum Lv2PluginPickUiFlag { LV2_PLUGIN_UI_WRAPPABLE, LV2_PLUGIN_UI_EXTERNAL, LV2_PLUGIN_UI_FOR_BRIDGING }
In order of preference.

Typedefs

using Lv2URIDs = struct Lv2URIDs
Cached URIDs for quick access (instead of having to use symap).
using Lv2Parameter = struct Lv2Parameter
Used temporarily to transfer data.
using Lv2Plugin = struct Lv2Plugin
LV2 plugin.
using Lv2PluginPickUiFlag = enum Lv2PluginPickUiFlag
In order of preference.
using Lv2Plugin = struct Lv2Plugin
LV2 plugin.

Functions

void lv2_log_set_printf_funcs(LV2_Log_Log* log)
Needed because we can't set them directly when gi18n.h is included.
auto lv2_state_save_to_file(Lv2Plugin* pl, bool is_backup) -> LilvState*
Saves the plugin state to the filesystem and returns the state.
auto lv2_state_save_to_memory(Lv2Plugin* plugin) -> LilvState*
Saves the plugin state into a new LilvState that can be applied to any plugin with the same URI (like clones).
auto lv2_state_save_to_string(Lv2Plugin* pl, bool is_backup) -> LilvState*
Saves the plugin state to a string after writing the required files.
auto lv2_state_make_path_temp(LV2_State_Make_Path_Handle handle, const char* path) -> char*
LV2 State makePath feature for temporary files.
auto lv2_state_save_preset(Lv2Plugin* plugin, const char* dir, const char* uri, const char* label, const char* filename) -> int
Saves the preset.
auto lv2_state_delete_current_preset(Lv2Plugin* plugin) -> int
Deletes the current preset.
auto lv2_ui_is_resizable(Lv2Plugin* plugin) -> bool
Returns if the UI of the plugin is resizable.
void lv2_ui_init(Lv2Plugin* plugin)
Inits the LV2 plugin UI.
void lv2_ui_instantiate(Lv2Plugin* plugin)
Instantiates the plugin UI.
void lv2_ui_read_and_apply_events(Lv2Plugin* plugin, uint32_t nframes)
Read and apply control change events from UI, for plugins that have their own UIs.
void lv2_ui_send_event_from_ui_to_plugin(Lv2Plugin* plugin, uint32_t port_index, uint32_t buffer_size, uint32_t protocol, const void* buffer)
Write events from the plugin's UI to the plugin.
auto lv2_ui_send_event_from_plugin_to_ui(Lv2Plugin* plugin, uint32_t port_index, uint32_t type, uint32_t size, const void* body) -> int
Send event to UI, called during the real time audio thread when processing the plugin.
auto lv2_ui_send_control_val_event_from_plugin_to_ui(Lv2Plugin* lv2_plugin, Port* port) -> NONNULL void
Similar to lv2_ui_send_event_from_plugin_to_ui except that it passes a float instead of an LV2 atom.
auto lv2_urid_map_uri(LV2_URID_Map_Handle handle, const char* uri) -> LV2_URID
URID feature map implementation.
auto lv2_urid_unmap_uri(LV2_URID_Unmap_Handle handle, LV2_URID urid) -> const char*
URID feature unmap implementation.
auto lv2_plugin_create_descriptor_from_lilv(const LilvPlugin* lp) -> NONNULL PluginDescriptor*
Returns a newly allocated plugin descriptor for the given LilvPlugin if it can be hosted, otherwise NULL.
auto lv2_plugin_new_from_uri(Plugin* plugin, const char* uri) -> NONNULL Lv2Plugin*
Creates an LV2 plugin from given uri.
auto lv2_plugin_instantiate(Lv2Plugin* self, bool project, bool use_state_file, char* preset_uri, LilvState* state) -> int
Instantiate the plugin.
auto lv2_plugin_new(Plugin* plugin) -> NONNULL Lv2Plugin*
Creates a new LV2 plugin using the given Plugin instance.
auto lv2_plugin_process(Lv2Plugin* lv2_plugin, const long g_start_frames, const nframes_t local_offset, const nframes_t nframes) -> NONNULL void
Processes the plugin for this cycle.
auto lv2_plugin_get_latency(Lv2Plugin* pl) -> NONNULL nframes_t
Returns the plugin's latency in samples.
auto lv2_plugin_has_deprecated_ui(const char* uri) -> NONNULL char*
Returns whether the plugin has a custom UI that is deprecated (GtkUI, QtUI, etc.).
auto lv2_plugin_is_ui_supported(const char* pl_uri, const char* ui_uri) -> NONNULL bool
Returns whether the given UI uri is supported.
void lv2_plugin_get_uis(const char* pl_uri, char** uris, int* num_uris)
Returns the UI URIs that this plugin has.
auto lv2_plugin_pick_ui(const LilvUIs* uis, Lv2PluginPickUiFlag flag, const LilvUI** out_ui, const LilvNode** out_ui_type) -> bool
Pick the most preferable UI for the given flag.
auto lv2_plugin_get_ui_bundle_uri(const char* pl_uri, const char* ui_uri) -> NONNULL char*
Returns the bundle path of the UI as a URI.
auto lv2_plugin_get_ui_binary_uri(const char* pl_uri, const char* ui_uri) -> NONNULL char*
Returns the binary path of the UI as a URI.
auto lv2_plugin_pick_most_preferable_ui(const char* plugin_uri, char** out_ui, char** out_ui_type, bool allow_bridged) -> bool
Pick the most preferable UI.
void lv2_plugin_set_control(Port* port, uint32_t size, LV2_URID type, const void* body)
Ported from Lv2Control.
auto lv2_plugin_get_property_port(Lv2Plugin* self, LV2_URID property) -> NONNULL Port*
Returns the property port matching the given property URID.
auto lv2_plugin_get_port_value(const char* port_sym, void* user_data, uint32_t* size, uint32_t* type) -> const void*
Function to get a port value.
auto lv2_plugin_allocate_port_buffers(Lv2Plugin* plugin) -> NONNULL void
Allocate port buffers (only necessary for MIDI).
auto lv2_plugin_populate_banks(Lv2Plugin* self) -> NONNULL void
Populates the banks in the plugin instance.
auto lv2_plugin_free(Lv2Plugin* self) -> NONNULL void
Frees the Lv2Plugin and all its components.

Enum documentation

enum Lv2PluginPickUiFlag

In order of preference.

Enumerators
LV2_PLUGIN_UI_WRAPPABLE

Plugin UI wrappable using Suil.

LV2_PLUGIN_UI_EXTERNAL

External/KxExternal UI.

LV2_PLUGIN_UI_FOR_BRIDGING

Gtk2.

Typedef documentation

typedef struct Lv2Parameter Lv2Parameter

Used temporarily to transfer data.

typedef struct Lv2Plugin Lv2Plugin

LV2 plugin.

typedef enum Lv2PluginPickUiFlag Lv2PluginPickUiFlag

In order of preference.

typedef struct Lv2Plugin Lv2Plugin

LV2 plugin.

Function documentation

void lv2_log_set_printf_funcs(LV2_Log_Log* log)

Needed because we can't set them directly when gi18n.h is included.

LilvState* lv2_state_save_to_file(Lv2Plugin* pl, bool is_backup)

Saves the plugin state to the filesystem and returns the state.

LilvState* lv2_state_save_to_memory(Lv2Plugin* plugin)

Saves the plugin state into a new LilvState that can be applied to any plugin with the same URI (like clones).

Must be free'd with lilv_state_free().

LilvState* lv2_state_save_to_string(Lv2Plugin* pl, bool is_backup)

Saves the plugin state to a string after writing the required files.

char* lv2_state_make_path_temp(LV2_State_Make_Path_Handle handle, const char* path)

LV2 State makePath feature for temporary files.

Should be passed to LV2_Descriptor::instantiate() and this function must return an absolute path.

int lv2_state_save_preset(Lv2Plugin* plugin, const char* dir, const char* uri, const char* label, const char* filename)

Saves the preset.

int lv2_state_delete_current_preset(Lv2Plugin* plugin)

Deletes the current preset.

bool lv2_ui_is_resizable(Lv2Plugin* plugin)

Returns if the UI of the plugin is resizable.

void lv2_ui_init(Lv2Plugin* plugin)

Inits the LV2 plugin UI.

To be called for generic, suil-wrapped and external UIs.

void lv2_ui_instantiate(Lv2Plugin* plugin)

Instantiates the plugin UI.

void lv2_ui_read_and_apply_events(Lv2Plugin* plugin, uint32_t nframes)

Read and apply control change events from UI, for plugins that have their own UIs.

Parameters
plugin
nframes Used for event ports.

Called in the real-time audio thread during plugin processing.

void lv2_ui_send_event_from_ui_to_plugin(Lv2Plugin* plugin, uint32_t port_index, uint32_t buffer_size, uint32_t protocol, const void* buffer)

Write events from the plugin's UI to the plugin.

int lv2_ui_send_event_from_plugin_to_ui(Lv2Plugin* plugin, uint32_t port_index, uint32_t type, uint32_t size, const void* body)

Send event to UI, called during the real time audio thread when processing the plugin.

Parameters
plugin
port_index
type Atom type.
size
body

NONNULL void lv2_ui_send_control_val_event_from_plugin_to_ui(Lv2Plugin* lv2_plugin, Port* port)

Similar to lv2_ui_send_event_from_plugin_to_ui except that it passes a float instead of an LV2 atom.

LV2_URID lv2_urid_map_uri(LV2_URID_Map_Handle handle, const char* uri)

URID feature map implementation.

LV2_URID is just an int (uint32_t) for the given uri.

NONNULL PluginDescriptor* lv2_plugin_create_descriptor_from_lilv(const LilvPlugin* lp)

Returns a newly allocated plugin descriptor for the given LilvPlugin if it can be hosted, otherwise NULL.

NONNULL Lv2Plugin* lv2_plugin_new_from_uri(Plugin* plugin, const char* uri)

Creates an LV2 plugin from given uri.

Parameters
plugin A newly created Plugin with its descriptor filled in.
uri The URI.

Used when populating the plugin browser.

int lv2_plugin_instantiate(Lv2Plugin* self, bool project, bool use_state_file, char* preset_uri, LilvState* state)

Instantiate the plugin.

Parameters
self Plugin to instantiate.
project
use_state_file Whether to use the plugin's state file to instantiate the plugin.
preset_uri URI of preset to load.
state State to load, if loading from a state. This is used when cloning plugins for example. The state of the original plugin is passed here.
Returns 0 if OK, non-zero if error.

All of the actual initialization is done here. If this is a new plugin, preset_uri should be empty. If the project is being loaded, preset uri should be the state file path.

NONNULL Lv2Plugin* lv2_plugin_new(Plugin* plugin)

Creates a new LV2 plugin using the given Plugin instance.

Parameters
plugin A newly allocated Plugin instance.

The given plugin instance must be a newly allocated one.

NONNULL void lv2_plugin_process(Lv2Plugin* lv2_plugin, const long g_start_frames, const nframes_t local_offset, const nframes_t nframes)

Processes the plugin for this cycle.

Parameters
lv2_plugin
g_start_frames The global start frames.
local_offset
nframes The number of frames to process.

NONNULL nframes_t lv2_plugin_get_latency(Lv2Plugin* pl)

Returns the plugin's latency in samples.

This will be 0 if the plugin does not report latency.

NONNULL char* lv2_plugin_has_deprecated_ui(const char* uri)

Returns whether the plugin has a custom UI that is deprecated (GtkUI, QtUI, etc.).

Returns If the plugin has a deprecated UI, returns the UI URI, otherwise NULL.

NONNULL bool lv2_plugin_is_ui_supported(const char* pl_uri, const char* ui_uri)

Returns whether the given UI uri is supported.

void lv2_plugin_get_uis(const char* pl_uri, char** uris, int* num_uris)

Returns the UI URIs that this plugin has.

bool lv2_plugin_pick_ui(const LilvUIs* uis, Lv2PluginPickUiFlag flag, const LilvUI** out_ui, const LilvNode** out_ui_type)

Pick the most preferable UI for the given flag.

Returns Whether a UI was picked.

NONNULL char* lv2_plugin_get_ui_bundle_uri(const char* pl_uri, const char* ui_uri)

Returns the bundle path of the UI as a URI.

NONNULL char* lv2_plugin_get_ui_binary_uri(const char* pl_uri, const char* ui_uri)

Returns the binary path of the UI as a URI.

bool lv2_plugin_pick_most_preferable_ui(const char* plugin_uri, char** out_ui, char** out_ui_type, bool allow_bridged)

Pick the most preferable UI.

Returns Whether a UI was picked.

Calls lv2_plugin_pick_ui().

void lv2_plugin_set_control(Port* port, uint32_t size, LV2_URID type, const void* body)

Ported from Lv2Control.

NONNULL Port* lv2_plugin_get_property_port(Lv2Plugin* self, LV2_URID property)

Returns the property port matching the given property URID.

const void* lv2_plugin_get_port_value(const char* port_sym, void* user_data, uint32_t* size, uint32_t* type)

Function to get a port value.

Used when saving the state. This function MUST set size and type appropriately.

NONNULL void lv2_plugin_allocate_port_buffers(Lv2Plugin* plugin)

Allocate port buffers (only necessary for MIDI).

NONNULL void lv2_plugin_populate_banks(Lv2Plugin* self)

Populates the banks in the plugin instance.

NONNULL void lv2_plugin_free(Lv2Plugin* self)

Frees the Lv2Plugin and all its components.