10#ifndef __PLUGINS_BASE_PLUGIN_H__
11#define __PLUGINS_BASE_PLUGIN_H__
13#include "zrythm-config.h"
28typedef struct _ModulatorWidget ModulatorWidget;
29typedef struct Lv2Plugin Lv2Plugin;
40#define PLUGIN_SCHEMA_VERSION 1
42#define PLUGIN_MAGIC 43198683
43#define IS_PLUGIN(x) (((Plugin *) x)->magic == PLUGIN_MAGIC)
44#define IS_PLUGIN_AND_NONNULL(x) (x && IS_PLUGIN (x))
46#define PLUGIN_DEFAULT_BANK_URI "https://lv2.zrythm.org#default-bank"
47#define PLUGIN_INIT_PRESET_URI "https://lv2.zrythm.org#init-preset"
52#define PLUGIN_MIN_REFRESH_RATE 30.f
53#define PLUGIN_MAX_REFRESH_RATE 121.f
58#define PLUGIN_MIN_SCALE_FACTOR 0.5f
59#define PLUGIN_MAX_SCALE_FACTOR 4.f
61#define plugin_is_in_active_project(self) \
62 (self->track && track_is_in_active_project (self->track))
66#define plugin_is_auditioner(self) \
67 (self->track && track_is_auditioner (self->track))
91 GPtrArray * ctrl_in_ports;
92 GPtrArray * audio_in_ports;
93 GPtrArray * cv_in_ports;
94 GPtrArray * midi_in_ports;
102 size_t out_ports_size;
297 unsigned int track_name_hash,
359plugin_get_full_port_group_designation (
361 const
char * port_group,
365plugin_get_port_in_group (
Plugin * self, const
char * port_group,
bool left);
398 bool confirm_overwrite,
408 unsigned int track_name_hash,
425plugin_append_ports (
Plugin * self, GPtrArray * ports);
469 const
char * abs_state_dir);
478 bool create_if_not_exists);
483NONNULL WARN_UNUSED_RESULT
bool
496plugin_get_channel (
Plugin * self);
502plugin_get_track (const
Plugin * self);
537HOT NONNULL OPTIMIZE_O3
void
558plugin_generate_window_title (
Plugin * plugin);
592plugin_set_enabled (
Plugin * self,
bool enabled,
bool fire_events);
629plugin_add_bank_if_not_exists (
Plugin * self, const
char * uri, const
char * name);
632plugin_add_preset_to_bank (
638plugin_set_selected_bank_from_index (
Plugin * self,
int idx);
641plugin_set_selected_preset_from_index (
Plugin * self,
int idx);
644plugin_set_selected_preset_by_name (
Plugin * self, const
char * name);
Ports that transfer audio/midi/other signals to one another.
NONNULL void plugin_set_ui_refresh_rate(Plugin *self)
Sets the UI refresh rate on the Plugin.
NONNULL bool plugin_is_selected(Plugin *pl)
Returns if Plugin exists in MixerSelections.
NONNULL MALLOC char * plugin_get_abs_state_dir(Plugin *self, bool is_backup, bool create_if_not_exists)
Returns the state dir as an absolute path.
NONNULL int plugin_cleanup(Plugin *self)
Cleans up an instantiated but not activated plugin.
NONNULL void plugin_connect_to_plugin(Plugin *src, Plugin *dest)
Connect the output Ports of the given source Plugin to the input Ports of the given destination Plugi...
NONNULL void plugin_open_ui(Plugin *plugin)
Process show ui.
NONNULL MALLOC char * plugin_get_escaped_name(Plugin *pl)
Returns the escaped name of the plugin.
NONNULL void plugin_set_track_name_hash(Plugin *pl, unsigned int track_name_hash)
Sets the track name hash on the plugin.
NONNULL HOT void plugin_process(Plugin *plugin, const EngineProcessTimeInfo *const time_nfo)
Process plugin.
NONNULL void plugin_connect_to_prefader(Plugin *pl, Channel *ch)
Connects the Plugin's output Port's to the input Port's of the given Channel's prefader.
NONNULL Port * plugin_get_port_by_symbol(Plugin *pl, const char *sym)
Gets a port by its symbol.
NONNULL int plugin_activate(Plugin *pl, bool activate)
Activates or deactivates the plugin.
int plugin_copy_state_dir(Plugin *self, Plugin *src, bool is_backup, const char *abs_state_dir)
Copies the state directory from the given source plugin to the given destination plugin's state direc...
NONNULL void plugin_add_in_port(Plugin *pl, Port *port)
Adds an in port to the plugin's list.
NONNULL void plugin_get_all(Project *prj, GPtrArray *arr, bool check_undo_manager)
Returns all plugins in the current project.
Plugin * plugin_new_dummy(ZPluginCategory cat, unsigned int track_name_hash, int slot)
Create a dummy plugin for tests.
NONNULL void plugin_add_automation_track(Plugin *self, AutomationTrack *at)
Adds an AutomationTrack to the Plugin.
NONNULL_ARGS(1) Plugin *plugin_clone(Plugin *src
Clones the given plugin.
NONNULL Port * plugin_get_port_in_same_group(Plugin *self, Port *port)
Find corresponding port in the same port group (eg, if this is left, find right and vice versa).
NONNULL Port * plugin_get_enabled_port(Plugin *self)
Gets the enable/disable port for this plugin.
NONNULL void plugin_expose_ports(Plugin *pl, bool expose, bool inputs, bool outputs)
Exposes or unexposes plugin ports to the backend.
NONNULL void plugin_update_automatables(Plugin *plugin)
(re)Generates automatables for the plugin.
NONNULL void plugin_set_caches(Plugin *self)
Sets caches for processing.
NONNULL void plugin_close_ui(Plugin *plugin)
Process hide ui.
HOT NONNULL OPTIMIZE_O3 void plugin_prepare_process(Plugin *self)
Prepare plugin for processing.
NONNULL void plugin_delete_state_files(Plugin *self)
Deletes any state files associated with this plugin.
NONNULL void plugin_disconnect_from_prefader(Plugin *pl, Channel *ch)
Disconnect the automatic connections from the Plugin to the Channel's prefader (if last Plugin).
NONNULL void plugin_free(Plugin *plugin)
Frees given plugin, breaks all its port connections, and frees its ports and other internal pointers.
NONNULL void plugin_update_identifier(Plugin *self)
To be called when changes to the plugin identifier were made, so we can update all children recursive...
Plugin * plugin_new_from_setting(PluginSetting *setting, unsigned int track_name_hash, ZPluginSlotType slot_type, int slot, GError **error)
Creates/initializes a plugin and its internal plugin (LV2, etc.) using the given setting.
NONNULL bool plugin_is_enabled(Plugin *self, bool check_track)
Returns whether the plugin is enabled.
NONNULL void plugin_set_track_and_slot(Plugin *pl, unsigned int track_name_hash, ZPluginSlotType slot_type, int slot)
Sets the channel and slot on the plugin and its ports.
ZPluginCategory
Plugin category.
NONNULL WARN_UNUSED_RESULT bool plugin_ensure_state_dir(Plugin *self, bool is_backup, GError **error)
Ensures the state dir exists or creates it.
HOT NONNULL void plugin_process_passthrough(Plugin *self, const EngineProcessTimeInfo *const time_nfo)
Processes the plugin by passing through the input to its output.
NONNULL int plugin_get_event_ports(Plugin *pl, Port **ports, int input)
Returns the event ports in the plugin.
NONNULL void plugin_move_automation(Plugin *pl, Track *prev_track, Track *track, ZPluginSlotType new_slot_type, int new_slot)
Moves the Plugin's automation from one Channel to another.
NONNULL void plugin_disconnect_from_plugin(Plugin *src, Plugin *dest)
Disconnect the automatic connections from the given source Plugin to the given destination Plugin.
NONNULL void plugin_move(Plugin *pl, Track *track, ZPluginSlotType slot_type, int slot, bool confirm_overwrite, bool fire_events)
Moves the plugin to the given slot in the given channel.
NONNULL void plugin_add_out_port(Plugin *pl, Port *port)
Adds an out port to the plugin's list.
void plugin_print(Plugin *self, char *buf, size_t buf_sz)
Prints the plugin to the buffer, if any, or to the log.
NONNULL void plugin_select(Plugin *self, bool select, bool exclusive)
Selects the plugin in the MixerSelections.
NONNULL void plugin_disconnect(Plugin *plugin)
To be called immediately when a channel or plugin is deleted.
NONNULL void plugin_remove_ats_from_automation_tracklist(Plugin *pl, bool free_ats, bool fire_events)
Removes the automation tracks associated with this plugin from the automation tracklist in the corres...
NONNULL bool plugin_validate(Plugin *self)
Verifies that the plugin identifiers are valid.
NONNULL void plugin_update_latency(Plugin *pl)
Updates the plugin's latency.
NONNULL void plugin_generate_automation_tracks(Plugin *plugin, Track *track)
Generates automatables for the plugin.
uint32_t nframes_t
Frame count.
A Channel is part of a Track (excluding Tracks that don't have Channels) and contains information rel...
Common struct to pass around during processing to avoid repeating the data in function arguments.
Selections to be used for the timeline's current selections, copying, undoing, etc.
A plugin bank containing presets.
A setting for a specific plugin descriptor.
The base plugin Inheriting plugins must have this as a child.
guint update_ui_source_id
ID of GSource (if > 0).
ModulatorWidget * modulator_widget
Modulator widget, if modulator.
int state_changed_event_sent
Set to true to avoid sending multiple ET_PLUGIN_STATE_CHANGED for the same plugin.
Port * enabled
Control for plugin enabled, for convenience.
Track * track
Pointer to owner track, if any.
GtkWindow * window
The Plugin's window.
bool instantiation_failed
Set to true if instantiation failed and the plugin will be treated as disabled.
bool instantiated
Whether the plugin is currently instantiated or not.
GtkBox * ev_box
The GdkWindow of this widget should be somewhere inside Plugin::window and will be used for wrapping ...
float ui_update_hz
Update frequency of the UI, in Hz (times per second).
nframes_t latency
Latency reported by the Lv2Plugin, if any, in samples.
gulong destroy_window_id
ID of the destroy signal for Plugin::window so that we can deactivate before freeing the plugin.
Port ** out_ports
Outgoing ports.
Port * own_enabled_port
Whether the plugin has a custom "enabled" port (LV2).
PluginSetting * setting
Setting this plugin was instantiated with.
Port * l_out
Instrument left stereo output, for convenience.
Port * gain
Control for plugin gain, for convenience.
bool activated
Whether the plugin is currently activated or not.
CarlaNativePlugin * carla
Pointer to Carla native plugin.
GtkBox * vbox
Vbox containing the above ev_box for wrapping, or used for packing generic UI controls.
bool deleting
Whether the plugin is currently being deleted.
bool is_function
Whether the plugin is used for functions.
MixerSelections * ms
Pointer to owner selections, if any.
char * state_dir
State directory (only basename).
Port * midi_in_port
Cache.
int ui_instantiated
Whether the UI has finished instantiating.
WrappedObjectWithChangeSignal * gobj
Used in Gtk.
bool deactivating
Temporary variable to check if plugin is currently undergoing deactivation.
gulong close_request_id
ID of the close-request signal for Plugin::window so that we can deactivate before freeing the plugin...
GtkWidget * active_preset_item
Active preset item, if wrapped or generic UI.
Port ** in_ports
Ports coming in as input.
float ui_scale_factor
Scale factor for drawing UIs in scale of the monitor.
bool visible
Whether plugin UI is opened or not.
Must ONLY be created via port_new()
Contains all of the info that will be serialized into a project file.
Track to be inserted into the Project's Tracklist.
A GObject-ified normal C object with a signal that interested parties can listen to for changes.