Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::gui::old_dsp::plugins::Plugin Class Referenceabstract

This class provides the core functionality for managing a plugin, including creating/initializing the plugin, connecting and disconnecting its ports, activating and deactivating it, and managing its state and UI. More...

#include <src/gui/dsp/plugin.h>

Inheritance diagram for zrythm::gui::old_dsp::plugins::Plugin:
Collaboration diagram for zrythm::gui::old_dsp::plugins::Plugin:

Data Structures

struct  Bank
 A plugin bank containing presets. More...
struct  Preset
 Plugin preset. More...
struct  PresetIdentifier
 Preset identifier. More...

Public Types

using PluginSlot = zrythm::plugins::PluginSlot
using PluginSlotType = zrythm::plugins::PluginSlotType
using PluginSlotNo = PluginSlot::SlotNo
using PluginDescriptor = zrythm::plugins::PluginDescriptor
using Protocol = zrythm::plugins::Protocol
using PluginCategory = zrythm::plugins::PluginCategory
using PluginConfiguration = zrythm::plugins::PluginConfiguration
using TrackUuid = zrythm::structure::tracks::TrackUuid
using TrackPtrVariant = zrythm::structure::tracks::TrackPtrVariant
using TrackResolver = zrythm::structure::tracks::TrackResolver

Public Member Functions

PluginDescriptorget_descriptor ()
utils::Utf8String get_name () const
Protocol::ProtocolType get_protocol () const
auto get_input_port_span () const
auto get_output_port_span () const
void set_setting (const PluginConfiguration &setting)
 Sets the plugin setting to use.
void init_loaded ()
 Initializes a plugin after deserialization.
utils::Utf8String get_full_designation_for_port (const dsp::Port &port) const
bool is_auditioner () const
 Whether the plugin is used for MIDI auditioning in SampleProcessor.
void set_ui_refresh_rate ()
 Sets the UI refresh rate on the Plugin.
dsp::ProcessorParameterget_enabled_param () const
 Gets the enable/disable port for this plugin.
void remove_ats_from_automation_tracklist (bool free_ats, bool fire_events)
 Removes the automation tracks associated with this plugin from the automation tracklist in the corresponding track.
utils::Utf8String get_full_port_group_designation (const utils::Utf8String &port_group) const
dsp::Portget_port_in_same_group (const dsp::Port &port)
 Finds the corresponding port in the same port group (eg, if this is left, find right and vice versa).
void activate (bool activate=true)
 Activates or deactivates the plugin.
auto get_slot_type () const
void append_ports (std::vector< dsp::Port * > &ports)
 Appends this plugin's ports to the given vector.
std::optional< dsp::PortPtrVariant > get_port_by_symbol (const utils::Utf8String &sym)
 Gets a port by its symbol.
void copy_state_dir (const Plugin &src, bool is_backup, std::optional< fs::path > abs_state_dir)
 Copies the state directory from the given source plugin to this plugin's state directory.
fs::path get_abs_state_dir (bool is_backup, bool create_if_not_exists)
 Returns the state dir as an absolute path.
fs::path get_abs_state_dir (bool is_backup) const
 Simply gets the absolute state directory path, without attempting to create it.
void ensure_state_dir (bool is_backup)
 Ensures the state dir exists or creates it.
std::optional< TrackPtrVariant > get_track () const
void set_track (const TrackUuid &track_id)
TrackUuid get_track_id () const
bool has_track () const
void prepare_process (std::size_t block_length)
 Updates the plugin's latency.
void copy_members_from (Plugin &other)
void instantiate ()
 Instantiates the plugin (e.g.
auto get_slot () const -> std::optional< PluginSlot >
 Returns the slot this number is inserted at in the owner.
void process_block (EngineProcessTimeInfo time_nfo) override
 Process plugin.
utils::Utf8String get_node_name () const override
 Returns a human friendly name of the node.
utils::Utf8String generate_window_title () const
void open_ui ()
 Process show ui.
bool is_selected () const
void set_selected (bool selected)
bool is_enabled (bool check_track) const
 Returns whether the plugin is enabled.
void set_enabled (bool enabled, bool fire_events)
void process_passthrough (EngineProcessTimeInfo time_nfo)
 Processes the plugin by passing through the input to its output.
void close_ui ()
 Process hide ui.
void update_automatables ()
 (re)Generates automatables for the plugin.
void set_selected_bank_from_index (int idx)
void set_selected_preset_from_index (int idx)
void set_selected_preset_by_name (const utils::Utf8String &name)
void set_caches ()
 Sets caches for processing.
void connect_to_plugin (Plugin &dest)
 Connect the output Ports of the given source Plugin to the input Ports of the given destination Plugin.
void disconnect_from_plugin (Plugin &dest)
 Disconnect the automatic connections from the given source Plugin to the given destination Plugin.
void delete_state_files ()
 Deletes any state files associated with this plugin.
void cleanup ()
 Cleans up resources of an instantiated but not activated plugin.
Public Member Functions inherited from zrythm::dsp::graph::IProcessable
virtual nframes_t get_single_playback_latency () const
 Returns the latency of only the given processable, without adding the previous/next latencies.
virtual void prepare_for_processing (sample_rate_t sample_rate, nframes_t max_block_length)
 Called to allocate resources required for processing.
virtual void release_resources ()
 Called to release resources allocated by prepare_for_processing().
Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< Plugin >
UuidIdentifiableObjectoperator= (const UuidIdentifiableObject &other)=default
auto get_uuid () const

Static Public Member Functions

static Pluginfrom_variant (const auto &variant)
static auto name_projection (const auto &var)
static fs::path get_abs_state_dir (const fs::path &plugin_state_dir, bool is_backup)
 Constructs the absolute path to the plugin state dir based on the given relative path given.

Data Fields

OptionalRef< dsp::PortRegistryport_registry_
OptionalRef< dsp::ProcessorParameterRegistryparam_registry_
std::optional< structure::tracks::TrackResolver > track_resolver_
std::optional< TrackUuidtrack_id_
std::unique_ptr< PluginConfigurationsetting_
 Setting this plugin was instantiated with.
std::vector< dsp::PortUuidReferencein_ports_
 Ports coming in as input.
std::vector< dsp::ProcessorParameterUuidReferenceparams_
dsp::ProcessorParameterUuidReference enabled_
 Zrythm-provided param for plugin enabled,.
dsp::ProcessorParameterUuidReference gain_
 Zrythm-provided param for plugin gain.
std::vector< dsp::AudioPort * > audio_in_ports_
std::vector< dsp::CVPort * > cv_in_ports_
std::vector< dsp::MidiPort * > midi_in_ports_
dsp::MidiPortmidi_in_port_ = nullptr
 Cache.
std::vector< dsp::PortUuidReferenceout_ports_
 Outgoing ports.
dsp::AudioPortl_out_ = nullptr
 Instrument left stereo output, for convenience.
dsp::AudioPortr_out_ = nullptr
std::vector< Bankbanks_
PresetIdentifier selected_bank_
PresetIdentifier selected_preset_
bool visible_ = false
 Whether plugin UI is opened or not.
bool instantiated_ {}
 Latency reported by the Lv2Plugin, if any, in samples.
bool instantiation_failed_ = false
 Set to true if instantiation failed and the plugin will be treated as disabled.
bool activated_ = false
 Whether the plugin is currently activated or not.
float ui_update_hz_ = 0.f
 Update frequency of the UI, in Hz (times per second).
float ui_scale_factor_ = 0.f
 Scale factor for drawing UIs in scale of the monitor.
fs::path state_dir_
 State directory (only basename).
bool deleting_ = false
 Whether the plugin is currently being deleted.
ulong destroy_window_id_ = 0
 ID of the destroy signal for Plugin.window so that we can deactivate before freeing the plugin.
ulong close_request_id_ = 0
 ID of the close-request signal for Plugin.window so that we can deactivate before freeing the plugin.
bool selected_ {}
 Whether selected in the slot owner (mixer for example).
uint update_ui_source_id_ = 0
 ID of GSource (if > 0).
bool deactivating_ = false
 Temporary variable to check if plugin is currently undergoing deactivation.
bool is_function_ = false
 Whether the plugin is used for functions.

Static Public Attributes

static constexpr auto DEFAULT_BANK_URI = "https://lv2.zrythm.org#default-bank"
static constexpr auto INIT_PRESET_URI = "https://lv2.zrythm.org#init-preset"
static constexpr float MIN_REFRESH_RATE = 30.f
 UI refresh rate limits.
static constexpr float MAX_REFRESH_RATE = 121.f
static constexpr float MIN_SCALE_FACTOR = 0.5f
 UI scale factor limits.
static constexpr float MAX_SCALE_FACTOR = 4.f

Protected Member Functions

Bankadd_bank_if_not_exists (std::optional< utils::Utf8String > uri, const utils::Utf8String &name)
 Adds a bank to the plugin's list and returns a reference to it.
 Plugin (dsp::PortRegistry &port_registry, dsp::ProcessorParameterRegistry &param_registry, QObject &derived)
 Creates/initializes a plugin and its internal plugin (LV2, etc.) using the given setting.

Friends

void to_json (nlohmann::json &j, const Plugin &p)
void from_json (const nlohmann::json &j, Plugin &p)

Detailed Description

This class provides the core functionality for managing a plugin, including creating/initializing the plugin, connecting and disconnecting its ports, activating and deactivating it, and managing its state and UI.

The plugin can be of various types, such as LV2, Carla native, etc., and this class provides a common interface for working with them.

Definition at line 42 of file plugin.h.


The documentation for this class was generated from the following file: