Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::plugins::ClapPlugin Class Reference

CLAP-based plugin host implementation. More...

#include <src/plugins/clap_plugin.h>

Inheritance diagram for zrythm::plugins::ClapPlugin:
Collaboration diagram for zrythm::plugins::ClapPlugin:

Public Types

using AudioThreadChecker = std::function<bool ()>
 Function that returns whether the caller is an audio DSP thread.
Public Types inherited from zrythm::plugins::Plugin
enum class  InstantiationStatus : std::uint8_t { Pending , Successful , Failed }
using StateDirectoryParentPathProvider = std::function<fs::path ()>
 Returns the parent path where the plugin should save its state directory in (or load it).

Signals

void paramsChanged ()
void paramAdjusted (clap_id paramId)
void pluginLoadedChanged (bool pluginLoaded)

Public Member Functions

 ClapPlugin (dsp::ProcessorBase::ProcessorBaseDependencies dependencies, StateDirectoryParentPathProvider state_path_provider, AudioThreadChecker audio_thread_checker, PluginHostWindowFactory host_window_factory, QObject *parent=nullptr)
 Constructor for JucePlugin.
void requestRestart () noexcept override
void requestProcess () noexcept override
void requestCallback () noexcept override
bool implementsGui () const noexcept override
void guiResizeHintsChanged () noexcept override
bool guiRequestResize (uint32_t width, uint32_t height) noexcept override
bool guiRequestShow () noexcept override
bool guiRequestHide () noexcept override
void guiClosed (bool wasDestroyed) noexcept override
bool implementsTimerSupport () const noexcept override
bool timerSupportRegisterTimer (uint32_t periodMs, clap_id *timerId) noexcept override
bool timerSupportUnregisterTimer (clap_id timerId) noexcept override
bool implementsLog () const noexcept override
void logLog (clap_log_severity severity, const char *message) const noexcept override
bool implementsLatency () const noexcept override
void latencyChanged () noexcept override
bool threadCheckIsMainThread () const noexcept override
bool threadCheckIsAudioThread () const noexcept override
bool implementsParams () const noexcept override
void paramsRescan (clap_param_rescan_flags flags) noexcept override
void paramsClear (clap_id paramId, clap_param_clear_flags flags) noexcept override
void paramsRequestFlush () noexcept override
bool implementsPosixFdSupport () const noexcept override
bool posixFdSupportRegisterFd (int fd, clap_posix_fd_flags_t flags) noexcept override
bool posixFdSupportModifyFd (int fd, clap_posix_fd_flags_t flags) noexcept override
bool posixFdSupportUnregisterFd (int fd) noexcept override
bool implementsThreadPool () const noexcept override
bool threadPoolRequestExec (uint32_t numTasks) noexcept override
bool implementsState () const noexcept override
void stateMarkDirty () noexcept override
nframes_t get_single_playback_latency () const override
 Returns the latency of only the given processable, without adding the previous/next latencies.
void save_state (std::optional< fs::path > abs_state_dir) override
 Saves the state inside the standard state directory.
void load_state (std::optional< fs::path > abs_state_dir) override
 Load the state from the default directory or from abs_state_dir if given.
Public Member Functions inherited from zrythm::plugins::Plugin
int programIndex () const
 Returns the current program index, or -1 if no program exists.
void setProgramIndex (int index)
Q_SIGNAL void programIndexChanged (int index)
 Implementations should attach to this and set the program.
PluginConfigurationconfiguration () const
Q_SIGNAL void configurationChanged (PluginConfiguration *configuration)
 Emitted when the configuration is set on the plugin.
dsp::ProcessorParameterbypassParameter () const
dsp::ProcessorParametergainParameter () const
bool uiVisible () const
void setUiVisible (bool visible)
Q_SIGNAL void uiVisibleChanged (bool visible)
 Implementations should listen to this and show/hide the plugin UI accordingly.
InstantiationStatus instantiationStatus () const
Q_SIGNAL void instantiationStatusChanged (InstantiationStatus status)
Q_SIGNAL void instantiationFinished (bool successful, const QString &error)
 To be emitted by implementations when instantiation finished.
PluginDescriptorget_descriptor () const
utils::Utf8String get_name () const
Protocol::ProtocolType get_protocol () const
void set_configuration (const PluginConfiguration &setting)
 Sets the plugin setting to use.
void custom_prepare_for_processing (const dsp::graph::GraphNode *node, units::sample_rate_t sample_rate, nframes_t max_block_length) final
void custom_process_block (EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport) noexcept final
 Custom processor logic after processing all owned parameters.
void custom_release_resources () final
fs::path get_state_directory () const
bool currently_enabled () const
 Returns whether the plugin is enabled (not bypassed).
bool currently_enabled_rt () const noexcept
Public Member Functions inherited from zrythm::dsp::ProcessorBase
 ProcessorBase (ProcessorBaseDependencies dependencies, utils::Utf8String name={ u8"ProcessorBase" })
void set_name (const utils::Utf8String &name)
 Set a custom name to be used in the DSP graph.
void add_input_port (const dsp::PortUuidReference &uuid)
void add_output_port (const dsp::PortUuidReference &uuid)
void add_parameter (const dsp::ProcessorParameterUuidReference &uuid)
auto & get_input_ports () const
auto & get_output_ports () const
auto & get_parameters () const
utils::Utf8String get_node_name () const final
 Returns a human friendly name of the node.
void process_block (EngineProcessTimeInfo time_nfo, const dsp::ITransport &transport) noexcept final
 Calls custom_process_block() internally after processing all the parameters.
void prepare_for_processing (const graph::GraphNode *node, units::sample_rate_t sample_rate, nframes_t max_block_length) final
 Called to allocate resources required for processing.
void release_resources () final
 Called to release resources allocated by prepare_for_processing().
Public Member Functions inherited from zrythm::utils::UuidIdentifiableObject< Plugin >
UuidIdentifiableObject & operator= (const UuidIdentifiableObject &other)=default
auto get_uuid () const

Protected Member Functions

void prepare_for_processing_impl (units::sample_rate_t sample_rate, nframes_t max_block_length) override
void process_impl (EngineProcessTimeInfo time_info) noexcept override
void release_resources_impl () override
Protected Member Functions inherited from zrythm::plugins::Plugin
 Plugin (ProcessorBaseDependencies dependencies, StateDirectoryParentPathProvider state_path_provider, QObject *parent)
 Creates/initializes a plugin and its internal plugin (LV2, etc.) using the given setting.
dsp::ProcessorParameterUuidReference generate_default_bypass_param () const
 To be called by implementations to generate the default bypass parameter if the plugin does not provide its own.
dsp::ProcessorParameterUuidReference generate_default_gain_param () const
 To be called by implementations to generate the default gain parameter if the plugin does not provide its own.
Protected Member Functions inherited from zrythm::dsp::ProcessorBase
auto dependencies () const

Friends

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

Additional Inherited Members

Protected Attributes inherited from zrythm::plugins::Plugin
bool instantiation_failed_ = false
 Set to true if instantiation failed and the plugin will be treated as disabled.
StateDirectoryParentPathProvider state_dir_parent_path_provider_
 Plugins should create a state directory with their UUID as the directory name under the path provided by this.
std::optional< dsp::ProcessorParameter::Uuid > bypass_id_
 Bypass toggle parameter,.
std::optional< dsp::ProcessorParameter::Uuid > gain_id_
 Zrythm-provided plugin gain parameter.
std::vector< dsp::AudioPort * > audio_in_ports_
std::vector< dsp::AudioPort * > audio_out_ports_
std::vector< dsp::CVPort * > cv_in_ports_
dsp::MidiPortmidi_in_port_ {}
dsp::MidiPortmidi_out_port_ {}
dsp::ProcessorParameterbypass_param_rt_ {}
Properties inherited from zrythm::plugins::Plugin
int programIndex
zrythm::plugins::PluginConfigurationconfiguration
zrythm::dsp::ProcessorParameterbypassParameter
zrythm::dsp::ProcessorParametergainParameter
bool uiVisible
InstantiationStatus instantiationStatus

Detailed Description

CLAP-based plugin host implementation.

This class provides hosting capabilities for CLAP plugins.

Definition at line 23 of file clap_plugin.h.

Member Typedef Documentation

◆ AudioThreadChecker

using zrythm::plugins::ClapPlugin::AudioThreadChecker = std::function<bool ()>

Function that returns whether the caller is an audio DSP thread.

Definition at line 33 of file clap_plugin.h.

Constructor & Destructor Documentation

◆ ClapPlugin()

zrythm::plugins::ClapPlugin::ClapPlugin ( dsp::ProcessorBase::ProcessorBaseDependencies dependencies,
StateDirectoryParentPathProvider state_path_provider,
AudioThreadChecker audio_thread_checker,
PluginHostWindowFactory host_window_factory,
QObject * parent = nullptr )

Constructor for JucePlugin.

Parameters
dependenciesProcessor dependencies
state_path_providerFunction to provide state directory path
format_managerJUCE format manager for plugin creation
sample_rate_providerFunction to provide current sample rate
buffer_size_providerFunction to provide current buffer size
parentParent QObject

Member Function Documentation

◆ get_single_playback_latency()

nframes_t zrythm::plugins::ClapPlugin::get_single_playback_latency ( ) const
overridevirtual

Returns the latency of only the given processable, without adding the previous/next latencies.

Reimplemented from zrythm::dsp::graph::IProcessable.

◆ implementsGui()

bool zrythm::plugins::ClapPlugin::implementsGui ( ) const
inlineoverridenoexcept

Definition at line 60 of file clap_plugin.h.

◆ implementsLatency()

bool zrythm::plugins::ClapPlugin::implementsLatency ( ) const
inlineoverridenoexcept

Definition at line 79 of file clap_plugin.h.

◆ implementsLog()

bool zrythm::plugins::ClapPlugin::implementsLog ( ) const
inlineoverridenoexcept

Definition at line 74 of file clap_plugin.h.

◆ implementsParams()

bool zrythm::plugins::ClapPlugin::implementsParams ( ) const
inlineoverridenoexcept

Definition at line 87 of file clap_plugin.h.

◆ implementsPosixFdSupport()

bool zrythm::plugins::ClapPlugin::implementsPosixFdSupport ( ) const
inlineoverridenoexcept

Definition at line 94 of file clap_plugin.h.

◆ implementsState()

bool zrythm::plugins::ClapPlugin::implementsState ( ) const
inlineoverridenoexcept

Definition at line 106 of file clap_plugin.h.

◆ implementsThreadPool()

bool zrythm::plugins::ClapPlugin::implementsThreadPool ( ) const
inlineoverridenoexcept

Definition at line 102 of file clap_plugin.h.

◆ implementsTimerSupport()

bool zrythm::plugins::ClapPlugin::implementsTimerSupport ( ) const
inlineoverridenoexcept

Definition at line 68 of file clap_plugin.h.

◆ load_state()

void zrythm::plugins::ClapPlugin::load_state ( std::optional< fs::path > abs_state_dir)
overridevirtual

Load the state from the default directory or from abs_state_dir if given.

Exceptions
ZrythmExceptionIf the state could not be saved.

Implements zrythm::plugins::Plugin.

◆ prepare_for_processing_impl()

void zrythm::plugins::ClapPlugin::prepare_for_processing_impl ( units::sample_rate_t sample_rate,
nframes_t max_block_length )
overrideprotectedvirtual

Reimplemented from zrythm::plugins::Plugin.

◆ process_impl()

void zrythm::plugins::ClapPlugin::process_impl ( EngineProcessTimeInfo time_info)
overrideprotectedvirtualnoexcept

◆ release_resources_impl()

void zrythm::plugins::ClapPlugin::release_resources_impl ( )
overrideprotectedvirtual

Reimplemented from zrythm::plugins::Plugin.

◆ save_state()

void zrythm::plugins::ClapPlugin::save_state ( std::optional< fs::path > abs_state_dir)
overridevirtual

Saves the state inside the standard state directory.

Parameters
abs_state_dirIf passed, the state will be savedinside this directory instead of the plugin's state directory. Used when saving presets.
Exceptions
ZrythmExceptionIf the state could not be saved.

Implements zrythm::plugins::Plugin.

◆ from_json

void from_json ( const nlohmann::json & j,
ClapPlugin & p )
friend

Definition at line 167 of file clap_plugin.h.

◆ to_json

void to_json ( nlohmann::json & j,
const ClapPlugin & p )
friend

Definition at line 163 of file clap_plugin.h.


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