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<fs::path> abs_state_dir)
override;
97 void update_buffer_size_and_sample_rate ();
114 float get_param_value (uint32_t
id);
124 void close ()
override;
142 friend void init_from (
150 to_json (j,
static_cast<const Plugin &
> (plugin));
154 from_json (j,
static_cast<Plugin &
> (plugin));
157 void populate_banks ()
override;
159 void set_selected_preset_from_index_impl (
int idx)
override;
161 void activate_impl (
bool activate)
override;
173 void instantiate_impl (
bool loading,
bool use_state_file)
override;
180 void cleanup_impl ()
override;
187 void create_ports (
bool loading);
191 NativePluginHandle native_plugin_handle_ =
nullptr;
192 NativeHostDescriptor native_host_descriptor_ = {};
193 const NativePluginDescriptor * native_plugin_descriptor_ =
nullptr;
195 CarlaHostHandle host_handle_ =
nullptr;
197 NativeTimeInfo time_info_ = {};
247 std::vector<std::vector<float>> zero_outbufs_;
248 std::vector<const float *> inbufs_;
249 std::vector<float *> outbufs_;
251 unsigned int max_variant_audio_ins_ = 0;
252 unsigned int max_variant_audio_outs_ = 0;
253 unsigned int max_variant_cv_ins_ = 0;
254 unsigned int max_variant_cv_outs_ = 0;
255 unsigned int max_variant_midi_ins_ = 0;
256 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, StateDirectoryParentPathProvider state_path_provider, QObject *parent)
Creates/initializes a plugin and its internal plugin (LV2, etc.) using the given setting.
dsp::MidiPort * get_midi_out_port()
Returns the MIDI out port.
nframes_t get_single_playback_latency() const override
Returns the latency in samples.
unsigned int cv_input_port_id_
Port ID of first cv input (for connecting inside patchbay).
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.
unsigned int audio_input_port_id_
Port ID of first audio input (for connecting inside patchbay).
~CarlaNativePlugin() override
Deactivates, cleanups and frees the instance.
void load_state(std::optional< fs::path > abs_path)
Loads the state from the given file or from its state file.
bool ports_created_
Whether ports are already created or not.
uint32_t nframes_t
Frame count.
Common struct to pass around during processing to avoid repeating the data in function arguments.