32#ifndef __PLUGINS_LV2_PLUGIN_H__
33#define __PLUGINS_LV2_PLUGIN_H__
35#include "zrythm-config.h"
48#include "plugins/lv2/lv2_evbuf.h"
50#include "plugins/lv2/lv2_worker.h"
54#include "zix/thread.h"
56#include <lv2/data-access/data-access.h>
57#include <lv2/log/log.h>
58#include <lv2/options/options.h>
59#include <lv2/state/state.h>
60#include <lv2/urid/urid.h>
61#include <sratom/sratom.h>
65typedef struct _GtkWidget GtkWidget;
66typedef struct _GtkCheckMenuItem GtkCheckMenuItem;
77#define LV2_PLUGIN_MAGIC 58173672
78#define IS_LV2_PLUGIN(tr) (tr && tr->magic == LV2_PLUGIN_MAGIC)
80#define LV2_ZRYTHM__defaultBank "https://lv2.zrythm.org#default-bank"
81#define LV2_ZRYTHM__initPreset "https://lv2.zrythm.org#init-preset"
82#define LV2_KX__externalUi \
83 "http://kxstudio.sf.net/ns/lv2ext/" \
87#ifndef LV2_CORE__enabled
88# define LV2_CORE__enabled LV2_CORE_PREFIX "enabled"
90#ifndef LV2_CORE__isSideChain
91# define LV2_CORE__isSideChain LV2_CORE_PREFIX "isSideChain"
94#define LV2_PARAM_MAX_STR_LEN 1200
96#define lv2_plugin_is_in_active_project(self) \
97 (plugin_is_in_active_project ((self)->plugin))
112 char symbol[LV2_PARAM_MAX_STR_LEN];
113 char label[LV2_PARAM_MAX_STR_LEN];
114 char comment[LV2_PARAM_MAX_STR_LEN];
142 LV2_Feature map_feature;
143 LV2_Feature unmap_feature;
144 LV2_Feature make_path_temp_feature;
145 LV2_Feature sched_feature;
146 LV2_Feature state_sched_feature;
147 LV2_Feature safe_restore_feature;
148 LV2_Feature log_feature;
149 LV2_Feature options_feature;
150 LV2_Feature def_state_feature;
151 LV2_Feature hard_rt_capable_feature;
152 LV2_Feature data_access_feature;
153 LV2_Feature instance_access_feature;
154 LV2_Feature bounded_block_length_feature;
334static const cyaml_schema_field_t
335 lv2_plugin_fields_schema[] =
343static const cyaml_schema_value_t
352lv2_plugin_init_loaded (
Lv2Plugin * self);
483 const LilvUI ** out_ui,
484 const LilvNode ** out_ui_type);
487lv2_plugin_get_ui_class (
const char * pl_uri,
const char * ui_uri);
514 const char * plugin_uri,
522lv2_plugin_ui_type_is_external (
const LilvNode * ui_type);
525lv2_plugin_is_ui_external (
const char * uri,
const char * ui_uri, GError ** error);
553 const char * port_sym,
559lv2_plugin_get_library_path (
Lv2Plugin * self);
562lv2_plugin_get_abs_state_file_path (
Lv2Plugin * self,
bool is_backup);
571lv2_plugin_activate (
Lv2Plugin * self,
bool activate);
Ports that transfer audio/midi/other signals to one another.
NONNULL_ARGS(1) int undo_manager_undo(UndoManager *self
Undo last action.
Lv2PluginPickUiFlag
In order of preference.
NONNULL nframes_t lv2_plugin_get_latency(Lv2Plugin *pl)
Returns the plugin's latency in samples.
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.
int lv2_plugin_instantiate(Lv2Plugin *self, bool use_state_file, char *preset_uri, LilvState *state, GError **error)
Instantiate the plugin.
NONNULL void lv2_plugin_process(Lv2Plugin *self, const EngineProcessTimeInfo *const time_nfo)
Processes the plugin for this cycle.
NONNULL void lv2_plugin_free(Lv2Plugin *self)
Frees the Lv2Plugin and all its components.
Lv2Plugin * lv2_plugin_new_from_uri(Plugin *plugin, const char *uri, GError **error)
Creates an LV2 plugin from given uri.
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 bool lv2_plugin_is_ui_supported(const char *pl_uri, const char *ui_uri)
Returns whether the given UI uri is supported.
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 Lv2Plugin * lv2_plugin_new(Plugin *plugin)
Creates a new LV2 plugin using the given Plugin instance.
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,...
NONNULL void lv2_plugin_allocate_port_buffers(Lv2Plugin *plugin)
Allocate port buffers (only necessary for MIDI).
void lv2_plugin_set_control(Port *port, uint32_t size, LV2_URID type, const void *body)
Ported from Lv2Control.
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.
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_bundle_uri(const char *pl_uri, const char *ui_uri)
Returns the bundle 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 Port * lv2_plugin_get_property_port(Lv2Plugin *self, LV2_URID property)
Returns the property port matching the given property URID.
@ LV2_PLUGIN_UI_WRAPPABLE
Plugin UI wrappable using Suil.
@ LV2_PLUGIN_UI_FOR_BRIDGING
Gtk2.
@ LV2_PLUGIN_UI_EXTERNAL
External/KxExternal UI.
uint_fast64_t unsigned_frame_t
Unsigned type for frame index.
uint32_t nframes_t
Frame count.
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
#define YAML_FIELD_DYN_PTR_ARRAY_VAR_COUNT(owner, member, schema)
Dynamic-width (reallocated) array of pointers with variable count.
LV2 extension to allow plugins to receive information about the host.
C header for the LV2 External UI extension http://kxstudio.sf.net/ns/lv2ext/external-ui.
Common struct to pass around during processing to avoid repeating the data in function arguments.
On UI instantiation, host must supply LV2_EXTERNAL_UI__Host feature.
Control change event, sent through ring buffers for UI updates.
Used temporarily to transfer data.
bool has_range
Whether the ranges below are valid.
LV2_URID value_type_urid
Value type URID (forge.Bool, forge.Int, etc.).
bool want_position
Whether the plugin has at least 1 atom port that supports position.
LV2_URID_Unmap unmap
Int => URI map.
uint32_t comm_buffer_size
Plugin <=> UI communication buffer size.
char * temp_dir
Temporary plugin state directory (absolute path).
bool has_external_ui
Whether the plugin has an external UI.
void * ui_event_buf
Buffer for readding UI port events.
LilvState * preset
Current preset.
LV2_Extension_Data_Feature ext_data_feature
Data access feature.
Sratom * ui_sratom
Atom serializer for UI thread.
SerdEnv * env
Environment for RDF printing.
Plugin * plugin
Base Plugin instance (parent).
LV2_URID_Map map
URI => Int map.
unsigned_frame_t gframes
Global (start) frames the plugin was last processed at.
LilvInstance * instance
Plugin instance (shared library).
ZixSem exit_sem
Exit semaphore.
ZixRing * ui_to_plugin_events
Port events from UI to plugin.
LV2_Atom_Forge dsp_forge
Atom forge (DSP thread).
int rolling
Transport was rolling or not last cycle.
bool safe_restore
Whether plugin restore() is thread-safe.
const LilvPlugin * lilv_plugin
Plugin class (RDF data).
LV2_State_Make_Path make_path_temp
Make path feature data.
float bpm
Last BPM known by the plugin.
const LV2_Feature * features[13]
Supported features passed when instantiating plugins.
Lv2Worker state_worker
Synchronous worker for state restore.
LV2_External_UI_Widget * external_ui_widget
Data structure used for external UIs.
int enabled_in
Index of enabled port, or -1 if no port with "enabled" designation found.
LV2_Worker_Schedule sched
Plugin worker schedule.
ZixRing * plugin_to_ui_events
Port events from plugin to UI.
LV2_Options_Option options[10]
Options to pass to plugin on instantiation.
const LV2_Feature * state_features[7]
Features that are passed to state extension calls, such as when saving the state.
uint32_t midi_event_id
MIDI event class ID in event context.
Sratom * sratom
Atom serializer.
LV2_Atom_Forge main_forge
Atom forge (main/GTK thread).
uint32_t event_delta_t
Frames since last update sent to UI.
SuilHost * suil_host
Plugin UI host support.
Lv2Worker worker
Worker thread implementation.
SuilInstance * suil_instance
Plugin UI instance (shared library).
bool request_update
Whether a plugin update is needed.
LV2_Worker_Schedule ssched
State worker schedule.
ZixSem work_lock
Lock for plugin work() method.
int control_in
Index of control input port, or -1 if no port with "control" designation found.
bool has_default_state
Whether the plugin has a default state that must be loaded before running run() for the first time.
bool exit
True iff execution is finished.
LV2_External_UI_Host extui
Used for external UIs.
const LV2_Options_Interface * options_iface
Options interface for setting plugin options dynamically.
The base plugin Inheriting plugins must have this as a child.
Must ONLY be created via port_new()
API for Suil, an LV2 UI wrapper library.