Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
LV2

Data Structures

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

Macros

#define LV2_PLUGIN_MAGIC   58173672
 
#define IS_LV2_PLUGIN(tr)   (tr && tr->magic == LV2_PLUGIN_MAGIC)
 
#define LV2_ZRYTHM__defaultBank   "https://lv2.zrythm.org#default-bank"
 
#define LV2_ZRYTHM__initPreset   "https://lv2.zrythm.org#init-preset"
 
#define LV2_KX__externalUi
 
#define LV2_CORE__enabled   LV2_CORE_PREFIX "enabled"
 
#define LV2_CORE__isSideChain   LV2_CORE_PREFIX "isSideChain"
 
#define LV2_PARAM_MAX_STR_LEN   1200
 
#define lv2_plugin_is_in_active_project(self)    (plugin_is_in_active_project ((self)->plugin))
 

Typedefs

typedef int(* PresetSink) (Lv2Plugin *plugin, const LilvNode *node, const LilvNode *title, void *data)
 

Enumerations

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

Functions

void lv2_log_set_printf_funcs (LV2_Log_Log *log)
 Needed because we can't set them directly when gi18n.h is included.
 
int lv2_log_vprintf (LV2_Log_Handle handle, LV2_URID type, const char *fmt, va_list ap)
 
int lv2_log_printf (LV2_Log_Handle handle, LV2_URID type, const char *fmt,...)
 
NONNULL void lv2_state_apply_state (Lv2Plugin *plugin, LilvState *state)
 
WARN_UNUSED_RESULT NONNULL 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).
 
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.
 
int lv2_state_save_preset (Lv2Plugin *plugin, const char *dir, const char *uri, const char *label, const char *filename)
 Saves the preset.
 
bool lv2_state_apply_preset (Lv2Plugin *plugin, const LilvNode *preset, const char *path, GError **error)
 Applies the given preset, or the preset in the path if preset is NULL.
 
int lv2_state_delete_current_preset (Lv2Plugin *plugin)
 Deletes the current preset.
 
int lv2_state_load_presets (Lv2Plugin *plugin, PresetSink sink, void *data)
 
int lv2_state_unload_presets (Lv2Plugin *plugin)
 
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.
 
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.
 
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.
 
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.
 
const char * lv2_urid_unmap_uri (LV2_URID_Unmap_Handle handle, LV2_URID urid)
 URID feature unmap implementation.
 
NONNULL void lv2_plugin_init_loaded (Lv2Plugin *self)
 
NONNULL PluginDescriptorlv2_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.
 
Lv2Pluginlv2_plugin_new_from_uri (Plugin *plugin, const char *uri, GError **error)
 Creates an LV2 plugin from given uri.
 
int lv2_plugin_instantiate (Lv2Plugin *self, bool use_state_file, char *preset_uri, LilvState *state, GError **error)
 Instantiate the plugin.
 
NONNULL Lv2Pluginlv2_plugin_new (Plugin *plugin)
 Creates a new LV2 plugin using the given Plugin instance.
 
NONNULL void lv2_plugin_process (Lv2Plugin *self, const EngineProcessTimeInfo *const time_nfo)
 Processes the plugin for this cycle.
 
NONNULL nframes_t lv2_plugin_get_latency (Lv2Plugin *pl)
 Returns the plugin's latency in samples.
 
NONNULL char * lv2_plugin_has_deprecated_ui (const char *uri)
 Returns whether the plugin has a custom UI that is deprecated (GtkUI, QtUI, etc.).
 
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.
 
NONNULL char * lv2_plugin_get_ui_class (const char *pl_uri, const char *ui_uri)
 
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, bool print_result)
 Pick the most preferable UI.
 
NONNULL bool lv2_plugin_ui_type_is_external (const LilvNode *ui_type)
 
NONNULL bool lv2_plugin_is_ui_external (const char *uri, const char *ui_uri, GError **error)
 
void lv2_plugin_set_control (Port *port, uint32_t size, LV2_URID type, const void *body)
 Ported from Lv2Control.
 
NONNULL Portlv2_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.
 
NONNULL char * lv2_plugin_get_library_path (Lv2Plugin *self)
 
NONNULL char * lv2_plugin_get_abs_state_file_path (Lv2Plugin *self, bool is_backup)
 
NONNULL void lv2_plugin_allocate_port_buffers (Lv2Plugin *plugin)
 Allocate port buffers (only necessary for MIDI).
 
NONNULL int lv2_plugin_activate (Lv2Plugin *self, bool activate)
 
NONNULL bool lv2_plugin_can_cleanup (const char *uri)
 Returns whether the plugin can be cleaned up (some plugins crash on cleanup).
 
NONNULL void lv2_plugin_populate_banks (Lv2Plugin *self)
 Populates the banks in the plugin instance.
 
NONNULL int lv2_plugin_cleanup (Lv2Plugin *self)
 
NONNULL void lv2_plugin_free (Lv2Plugin *self)
 Frees the Lv2Plugin and all its components.
 

Detailed Description

LV2 plugin related code.

Macro Definition Documentation

◆ IS_LV2_PLUGIN

#define IS_LV2_PLUGIN ( tr)    (tr && tr->magic == LV2_PLUGIN_MAGIC)

Definition at line 78 of file lv2_plugin.h.

◆ LV2_CORE__enabled

#define LV2_CORE__enabled   LV2_CORE_PREFIX "enabled"

Definition at line 88 of file lv2_plugin.h.

◆ LV2_CORE__isSideChain

#define LV2_CORE__isSideChain   LV2_CORE_PREFIX "isSideChain"

Definition at line 91 of file lv2_plugin.h.

◆ LV2_KX__externalUi

#define LV2_KX__externalUi
Value:
"http://kxstudio.sf.net/ns/lv2ext/" \
"external-ui#Widget"

Definition at line 82 of file lv2_plugin.h.

◆ LV2_PARAM_MAX_STR_LEN

#define LV2_PARAM_MAX_STR_LEN   1200

Definition at line 94 of file lv2_plugin.h.

◆ lv2_plugin_is_in_active_project

#define lv2_plugin_is_in_active_project ( self)     (plugin_is_in_active_project ((self)->plugin))

Definition at line 96 of file lv2_plugin.h.

◆ LV2_PLUGIN_MAGIC

#define LV2_PLUGIN_MAGIC   58173672

Definition at line 77 of file lv2_plugin.h.

◆ LV2_ZRYTHM__defaultBank

#define LV2_ZRYTHM__defaultBank   "https://lv2.zrythm.org#default-bank"

Definition at line 80 of file lv2_plugin.h.

◆ LV2_ZRYTHM__initPreset

#define LV2_ZRYTHM__initPreset   "https://lv2.zrythm.org#init-preset"

Definition at line 81 of file lv2_plugin.h.

Typedef Documentation

◆ PresetSink

typedef int(* PresetSink) (Lv2Plugin *plugin, const LilvNode *node, const LilvNode *title, void *data)

Definition at line 31 of file lv2_state.h.

Enumeration Type Documentation

◆ Lv2PluginPickUiFlag

In order of preference.

Enumerator
LV2_PLUGIN_UI_WRAPPABLE 

Plugin UI wrappable using Suil.

LV2_PLUGIN_UI_EXTERNAL 

External/KxExternal UI.

LV2_PLUGIN_UI_FOR_BRIDGING 

Gtk2.

Definition at line 436 of file lv2_plugin.h.

Function Documentation

◆ lv2_plugin_get_latency()

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.

◆ lv2_plugin_get_port_value()

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.

◆ lv2_plugin_has_deprecated_ui()

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.

◆ lv2_plugin_instantiate()

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

Instantiate the plugin.

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.

Parameters
selfPlugin to instantiate.
use_state_fileWhether to use the plugin's state file to instantiate the plugin.
preset_uriURI of preset to load.
stateState 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.

◆ lv2_plugin_new()

NONNULL Lv2Plugin * lv2_plugin_new ( Plugin * plugin)

Creates a new LV2 plugin using the given Plugin instance.

The given plugin instance must be a newly allocated one.

Parameters
pluginA newly allocated Plugin instance.

◆ lv2_plugin_new_from_uri()

Lv2Plugin * lv2_plugin_new_from_uri ( Plugin * plugin,
const char * uri,
GError ** error )

Creates an LV2 plugin from given uri.

Used when populating the plugin browser.

Parameters
pluginA newly created Plugin with its descriptor filled in.
uriThe URI.

◆ lv2_plugin_pick_most_preferable_ui()

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

Pick the most preferable UI.

Calls lv2_plugin_pick_ui().

Parameters
[out]ui(Output) UI of the specific plugin.
[out]ui_typeUI type (eg, X11).
Returns
Whether a UI was picked.

◆ lv2_plugin_pick_ui()

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.

Parameters
[out]ui(Output) UI of the specific plugin.
[out]ui_typeUI type (eg, X11).
Returns
Whether a UI was picked.

◆ lv2_state_apply_preset()

bool lv2_state_apply_preset ( Lv2Plugin * plugin,
const LilvNode * preset,
const char * path,
GError ** error )

Applies the given preset, or the preset in the path if preset is NULL.

Returns
Whether the preset was applied.

◆ lv2_state_make_path_temp()

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.

◆ lv2_state_save_to_memory()

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().

◆ lv2_ui_init()

void lv2_ui_init ( Lv2Plugin * plugin)

Inits the LV2 plugin UI.

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

◆ lv2_ui_read_and_apply_events()

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.

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

Parameters
nframesUsed for event ports.

◆ lv2_ui_send_control_val_event_from_plugin_to_ui()

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.

Parameters
lv2_portThe port to pass the value of.

◆ lv2_ui_send_event_from_plugin_to_ui()

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
typeAtom type.

◆ lv2_ui_send_event_from_ui_to_plugin()

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.

Parameters
protocolformat

◆ lv2_urid_map_uri()

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.