6#include "zrythm-config.h"
11#include "plugins/plugin.h"
12#include "utils/icloneable.h"
13#include "utils/types.h"
16# include "carla_wrapper.h"
19namespace zrythm::plugins
22using CarlaPluginHandle =
void *;
30constexpr auto CARLA_STATE_FILENAME =
"state.carla"sv;
39 CARLA_PLUGIN_PATCHBAY,
40 CARLA_PLUGIN_PATCHBAY16,
41 CARLA_PLUGIN_PATCHBAY32,
42 CARLA_PLUGIN_PATCHBAY64,
45struct CarlaPatchbayPortInfo
47 CarlaPatchbayPortInfo () =
default;
48 CarlaPatchbayPortInfo (
49 unsigned int _plugin_id,
50 unsigned int _port_hints,
51 unsigned int _port_id,
52 std::string _port_name)
53 : plugin_id (_plugin_id), port_hints (_port_hints), port_id (_port_id),
54 port_name (std::move (_port_name))
57 unsigned int plugin_id = 0;
58 unsigned int port_hints = 0;
59 unsigned int port_id = 0;
60 std::string port_name;
83 static std::unique_ptr<PluginDescriptor>
84 get_descriptor_from_cached (
const CarlaCachedPluginInfo &info, PluginType type);
88 save_state (
bool is_backup, std::optional<std::filesystem::path> abs_state_dir)
96 void load_state (std::optional<std::filesystem::path> abs_path);
98 void update_buffer_size_and_sample_rate ();
115 float get_param_value (uint32_t
id);
125 void close ()
override;
143 friend void init_from (
151 to_json (j,
static_cast<const Plugin &
> (plugin));
155 from_json (j,
static_cast<Plugin &
> (plugin));
158 void populate_banks ()
override;
160 void set_selected_preset_from_index_impl (
int idx)
override;
162 void activate_impl (
bool activate)
override;
174 void instantiate_impl (
bool loading,
bool use_state_file)
override;
179 [[gnu::hot]]
void process_impl (EngineProcessTimeInfo time_nfo)
override;
181 void cleanup_impl ()
override;
188 void create_ports (
bool loading);
192 NativePluginHandle native_plugin_handle_ =
nullptr;
193 NativeHostDescriptor native_host_descriptor_ = {};
194 const NativePluginDescriptor * native_plugin_descriptor_ =
nullptr;
196 CarlaHostHandle host_handle_ =
nullptr;
198 NativeTimeInfo time_info_ = {};
248 std::vector<std::vector<float>> zero_outbufs_;
249 std::vector<const float *> inbufs_;
250 std::vector<float *> outbufs_;
252 unsigned int max_variant_audio_ins_ = 0;
253 unsigned int max_variant_audio_outs_ = 0;
254 unsigned int max_variant_cv_ins_ = 0;
255 unsigned int max_variant_cv_outs_ = 0;
256 unsigned int max_variant_midi_ins_ = 0;
257 unsigned int max_variant_midi_outs_ = 0;
Processor parameter that accepts automation and modulation sources and integrates with QML and the DS...
The PluginDescriptor class provides a set of static utility functions and member functions to work wi...
Plugin(ProcessorBaseDependencies dependencies, QObject *parent)
Creates/initializes a plugin and its internal plugin (LV2, etc.) using the given setting.
std::string save_state() const
Serializes the plugin's internal state to a base64-encoded string.
dsp::MidiPort * get_midi_out_port()
Returns the MIDI out port.
unsigned int cv_input_port_id_
Port ID of first cv input (for connecting inside patchbay).
units::sample_u32_t get_single_playback_latency() const override
Returns the latency in samples.
bool add_internal_plugin_from_descr(const PluginDescriptor &descr)
Adds the internal plugin from the given descriptor.
unsigned int midi_output_port_id_
Port ID of first midi output (for connecting inside patchbay).
unsigned int audio_output_port_id_
Port ID of first audio output (for connecting inside patchbay).
void set_param_value(uint32_t id, float val)
Called from port_set_control_value() to send the value to carla.
std::vector< std::vector< float > > zero_inbufs_
Idle callback for the plugin UI.
unsigned int midi_input_port_id_
Port ID of first midi input (for connecting inside patchbay).
dsp::ProcessorParameter * get_param_from_param_id(uint32_t id)
Returns the plugin Port corresponding to the given parameter.
unsigned int carla_plugin_id_
Plugin ID inside carla engine.
void open_custom_ui(bool show) override
Shows or hides the UI.
std::vector< CarlaPatchbayPortInfo > patchbay_port_info_
Used when connecting Carla's internal plugin to patchbay ports.
unsigned int cv_output_port_id_
Port ID of first cv output (for connecting inside patchbay).
CarlaNativePlugin(ProcessorBaseDependencies dependencies)
Creates/initializes a plugin using the given setting.
CarlaPluginType
The type of the Carla plugin.
void load_state(std::optional< std::filesystem::path > abs_path)
Loads the state from the given file or from its state file.
unsigned int audio_input_port_id_
Port ID of first audio input (for connecting inside patchbay).
~CarlaNativePlugin() override
Deactivates, cleanups and frees the instance.
bool ports_created_
Whether ports are already created or not.