Zrythm
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
plugin_descriptor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: © 2018-2021 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
10#ifndef __PLUGINS_PLUGIN_DESCRIPTOR_H__
11#define __PLUGINS_PLUGIN_DESCRIPTOR_H__
12
13#include "zrythm-config.h"
14
15#include <stdbool.h>
16
17#include "utils/yaml.h"
18
19#include <glib/gi18n.h>
20
21#include <CarlaBackend.h>
22
23typedef struct _WrappedObjectWithChangeSignal WrappedObjectWithChangeSignal;
24
31#define PLUGIN_DESCRIPTOR_SCHEMA_VERSION 1
32
36typedef enum ZPluginCategory
37{
40 PC_DELAY,
41 PC_REVERB,
42 PC_DISTORTION,
43 PC_WAVESHAPER,
44 PC_DYNAMICS,
45 PC_AMPLIFIER,
46 PC_COMPRESSOR,
47 PC_ENVELOPE,
48 PC_EXPANDER,
49 PC_GATE,
50 PC_LIMITER,
51 PC_FILTER,
52 PC_ALLPASS_FILTER,
53 PC_BANDPASS_FILTER,
54 PC_COMB_FILTER,
55 PC_EQ,
56 PC_MULTI_EQ,
57 PC_PARA_EQ,
58 PC_HIGHPASS_FILTER,
59 PC_LOWPASS_FILTER,
60 PC_GENERATOR,
61 PC_CONSTANT,
62 PC_INSTRUMENT,
63 PC_OSCILLATOR,
64 PC_MIDI,
65 PC_MODULATOR,
66 PC_CHORUS,
67 PC_FLANGER,
68 PC_PHASER,
69 PC_SIMULATOR,
70 PC_SIMULATOR_REVERB,
71 PC_SPATIAL,
72 PC_SPECTRAL,
73 PC_PITCH,
74 PC_UTILITY,
75 PC_ANALYZER,
76 PC_CONVERTER,
77 PC_FUNCTION,
78 PC_MIXER,
80
81static const cyaml_strval_t plugin_descriptor_category_strings[] = {
82 {"None", ZPLUGIN_CATEGORY_NONE},
83 { "Delay", PC_DELAY },
84 { "Reverb", PC_REVERB },
85 { "Distortion", PC_DISTORTION },
86 { "Waveshaper", PC_WAVESHAPER },
87 { "Dynamics", PC_DYNAMICS },
88 { "Amplifier", PC_AMPLIFIER },
89 { "Compressor", PC_COMPRESSOR },
90 { "Envelope", PC_ENVELOPE },
91 { "Expander", PC_EXPANDER },
92 { "Gate", PC_GATE },
93 { "Limiter", PC_LIMITER },
94 { "Filter", PC_FILTER },
95 { "Allpass Filter", PC_ALLPASS_FILTER },
96 { "Bandpass Filter", PC_BANDPASS_FILTER },
97 { "Comb Filter", PC_COMB_FILTER },
98 { "EQ", PC_EQ },
99 { "Multi-EQ", PC_MULTI_EQ },
100 { "Parametric EQ", PC_PARA_EQ },
101 { "Highpass Filter", PC_HIGHPASS_FILTER },
102 { "Lowpass Filter", PC_LOWPASS_FILTER },
103 { "Generator", PC_GENERATOR },
104 { "Constant", PC_CONSTANT },
105 { "Instrument", PC_INSTRUMENT },
106 { "Oscillator", PC_OSCILLATOR },
107 { "MIDI", PC_MIDI },
108 { "Modulator", PC_MODULATOR },
109 { "Chorus", PC_CHORUS },
110 { "Flanger", PC_FLANGER },
111 { "Phaser", PC_PHASER },
112 { "Simulator", PC_SIMULATOR },
113 { "Simulator Reverb", PC_SIMULATOR_REVERB },
114 { "Spatial", PC_SPATIAL },
115 { "Spectral", PC_SPECTRAL },
116 { "Pitch", PC_PITCH },
117 { "Utility", PC_UTILITY },
118 { "Analyzer", PC_ANALYZER },
119 { "Converter", PC_CONVERTER },
120 { "Function", PC_FUNCTION },
121 { "Mixer", PC_MIXER },
122};
123
127typedef enum ZPluginProtocol
128{
131 Z_PLUGIN_PROTOCOL_LV2,
132 Z_PLUGIN_PROTOCOL_DSSI,
133 Z_PLUGIN_PROTOCOL_LADSPA,
134 Z_PLUGIN_PROTOCOL_VST,
135 Z_PLUGIN_PROTOCOL_VST3,
136 Z_PLUGIN_PROTOCOL_AU,
137 Z_PLUGIN_PROTOCOL_SFZ,
138 Z_PLUGIN_PROTOCOL_SF2,
139 Z_PLUGIN_PROTOCOL_CLAP,
140 Z_PLUGIN_PROTOCOL_JSFX,
142
143static const cyaml_strval_t plugin_protocol_strings[] = {
144 {N_ ("Dummy"), Z_PLUGIN_PROTOCOL_DUMMY },
145 { "LV2", Z_PLUGIN_PROTOCOL_LV2 },
146 { "DSSI", Z_PLUGIN_PROTOCOL_DSSI },
147 { "LADSPA", Z_PLUGIN_PROTOCOL_LADSPA},
148 { "VST", Z_PLUGIN_PROTOCOL_VST },
149 { "VST3", Z_PLUGIN_PROTOCOL_VST3 },
150 { "AU", Z_PLUGIN_PROTOCOL_AU },
151 { "SFZ", Z_PLUGIN_PROTOCOL_SFZ },
152 { "SF2", Z_PLUGIN_PROTOCOL_SF2 },
153 { "CLAP", Z_PLUGIN_PROTOCOL_CLAP },
154 { "JSFX", Z_PLUGIN_PROTOCOL_JSFX },
155};
156
161{
162 ARCH_32,
163 ARCH_64
165
166static const cyaml_strval_t plugin_architecture_strings[] = {
167 {"32-bit", ARCH_32},
168 { "64-bit", ARCH_64},
169};
170
174typedef enum CarlaBridgeMode
175{
176 CARLA_BRIDGE_NONE,
177 CARLA_BRIDGE_UI,
178 CARLA_BRIDGE_FULL,
180
181static const cyaml_strval_t carla_bridge_mode_strings[] = {
182 {"None", CARLA_BRIDGE_NONE},
183 { "UI", CARLA_BRIDGE_UI },
184 { "Full", CARLA_BRIDGE_FULL},
185};
186
187/***
188 * A descriptor to be implemented by all plugins
189 * This will be used throughout the UI
190 */
191typedef struct PluginDescriptor
192{
193 int schema_version;
194 char * author;
195 char * name;
196 char * website;
197 ZPluginCategory category;
221 char * path;
223 char * uri;
224
226 int64_t unique_id;
227
230
231 bool has_custom_ui;
232
239 unsigned int ghash;
240
242 char * sha1;
243
247
248static const cyaml_schema_field_t plugin_descriptor_fields_schema[] = {
249 YAML_FIELD_INT (PluginDescriptor, schema_version),
250 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, author),
251 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, name),
252 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, website),
253 YAML_FIELD_ENUM (PluginDescriptor, category, plugin_descriptor_category_strings),
254 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, category_str),
255 YAML_FIELD_INT (PluginDescriptor, num_audio_ins),
256 YAML_FIELD_INT (PluginDescriptor, num_audio_outs),
257 YAML_FIELD_INT (PluginDescriptor, num_midi_ins),
258 YAML_FIELD_INT (PluginDescriptor, num_midi_outs),
259 YAML_FIELD_INT (PluginDescriptor, num_ctrl_ins),
260 YAML_FIELD_INT (PluginDescriptor, num_ctrl_outs),
261 YAML_FIELD_INT (PluginDescriptor, num_cv_ins),
262 YAML_FIELD_UINT (PluginDescriptor, unique_id),
263 YAML_FIELD_INT (PluginDescriptor, num_cv_outs),
264 YAML_FIELD_ENUM (PluginDescriptor, arch, plugin_architecture_strings),
265 YAML_FIELD_ENUM (PluginDescriptor, protocol, plugin_protocol_strings),
266 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, path),
267 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, uri),
268 YAML_FIELD_ENUM (PluginDescriptor, min_bridge_mode, carla_bridge_mode_strings),
269 YAML_FIELD_INT (PluginDescriptor, has_custom_ui),
270 YAML_FIELD_UINT (PluginDescriptor, ghash),
271 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, sha1),
272
273 CYAML_FIELD_END
274};
275
276static const cyaml_schema_value_t plugin_descriptor_schema = {
277 YAML_VALUE_PTR (PluginDescriptor, plugin_descriptor_fields_schema),
278};
279
281plugin_descriptor_new (void);
282
283const char *
284plugin_protocol_to_str (ZPluginProtocol prot);
285
287plugin_protocol_from_str (const char * str);
288
289static inline const char *
290plugin_protocol_get_icon_name (ZPluginProtocol prot)
291{
292 const char * icon = NULL;
293 switch (prot)
294 {
295 case Z_PLUGIN_PROTOCOL_LV2:
296 icon = "logo-lv2";
297 break;
298 case Z_PLUGIN_PROTOCOL_LADSPA:
299 icon = "logo-ladspa";
300 break;
301 case Z_PLUGIN_PROTOCOL_AU:
302 icon = "logo-au";
303 break;
304 case Z_PLUGIN_PROTOCOL_VST:
305 case Z_PLUGIN_PROTOCOL_VST3:
306 icon = "logo-vst";
307 break;
308 case Z_PLUGIN_PROTOCOL_SFZ:
309 case Z_PLUGIN_PROTOCOL_SF2:
310 icon = "file-music-line";
311 break;
312 default:
313 icon = "plug";
314 break;
315 }
316 return icon;
317}
318
319bool
320plugin_protocol_is_supported (ZPluginProtocol protocol);
321
322const char *
323plugin_category_to_string (ZPluginCategory category);
324
325PluginType
326plugin_descriptor_get_carla_plugin_type_from_protocol (ZPluginProtocol protocol);
327
329plugin_descriptor_get_protocol_from_carla_plugin_type (PluginType ptype);
330
332plugin_descriptor_get_category_from_carla_category_str (const char * category);
333
335plugin_descriptor_get_category_from_carla_category (PluginCategory carla_cat);
336
340NONNULL void
342
346NONNULL PluginDescriptor *
348
352NONNULL bool
354
358NONNULL bool
360
364NONNULL int
366
370NONNULL int
372
377NONNULL ZPluginCategory
379
380char *
381plugin_descriptor_category_to_string (ZPluginCategory category);
382
387const char *
389
394bool
396 const PluginDescriptor * self,
397 int slot_type,
398 int track_type);
399
404NONNULL bool
406 const PluginDescriptor * a,
407 const PluginDescriptor * b);
408
413NONNULL bool
415
420NONNULL CarlaBridgeMode
422
433NONNULL bool
435
436NONNULL GMenuModel *
437plugin_descriptor_generate_context_menu (const PluginDescriptor * self);
438
439NONNULL void
440plugin_descriptor_free (PluginDescriptor * self);
441
442NONNULL void
443plugin_descriptor_free_closure (void * data, GClosure * closure);
444
449#endif
NONNULL bool plugin_descriptor_is_same_plugin(const PluginDescriptor *a, const PluginDescriptor *b)
Returns whether the two descriptors describe the same plugin, ignoring irrelevant fields.
bool plugin_descriptor_is_valid_for_slot_type(const PluginDescriptor *self, int slot_type, int track_type)
Returns if the given plugin identifier can be dropped in a slot of the given type.
NONNULL CarlaBridgeMode plugin_descriptor_get_min_bridge_mode(const PluginDescriptor *self)
Returns the minimum bridge mode required for this plugin.
NONNULL int plugin_descriptor_is_midi_modifier(const PluginDescriptor *const descr)
Returns if the Plugin is a midi modifier or not.
NONNULL bool plugin_descriptor_is_instrument(const PluginDescriptor *const descr)
Returns if the Plugin is an instrument or not.
NONNULL bool plugin_descriptor_is_whitelisted(const PluginDescriptor *self)
Returns whether the plugin is known to work, so it should be whitelisted.
PluginArchitecture
32 or 64 bit.
CarlaBridgeMode
Carla bridge mode.
NONNULL bool plugin_descriptor_is_effect(const PluginDescriptor *const descr)
Returns if the Plugin is an effect or not.
const char * plugin_descriptor_get_icon_name(const PluginDescriptor *const self)
Gets an appropriate icon name for the given descriptor.
ZPluginProtocol
Plugin protocol.
ZPluginCategory
Plugin category.
NONNULL void plugin_descriptor_copy(PluginDescriptor *dest, const PluginDescriptor *src)
Clones the plugin descriptor.
NONNULL PluginDescriptor * plugin_descriptor_clone(const PluginDescriptor *src)
Clones the plugin descriptor.
NONNULL ZPluginCategory plugin_descriptor_string_to_category(const char *str)
Returns the ZPluginCategory matching the given string.
NONNULL bool plugin_descriptor_has_custom_ui(const PluginDescriptor *self)
Returns if the Plugin has a supported custom UI.
NONNULL int plugin_descriptor_is_modulator(const PluginDescriptor *const descr)
Returns if the Plugin is a modulator or not.
@ Z_PLUGIN_PROTOCOL_DUMMY
Dummy protocol for tests.
@ ZPLUGIN_CATEGORY_NONE
None specified.
#define YAML_VALUE_PTR(cc, fields_schema)
Schema to be used as a pointer.
Definition yaml.h:202
CarlaBridgeMode min_bridge_mode
Minimum required bridge mode.
int num_midi_ins
Number of MIDI input ports.
int num_midi_outs
Number of MIDI output ports.
ZPluginProtocol protocol
Plugin protocol (Lv2/DSSI/LADSPA/VST/etc.).
int num_audio_outs
Number of audio output ports.
int num_cv_outs
Number of output CV ports.
char * category_str
Lv2 plugin subcategory.
WrappedObjectWithChangeSignal * gobj
Used in Gtk.
int num_ctrl_ins
Number of input control (plugin param) ports.
char * sha1
SHA1 of the file (replaces ghash).
char * path
Path, if not an Lv2Plugin which uses URIs.
unsigned int ghash
Hash of the plugin's bundle (.so/.ddl for VST) used when caching PluginDescriptor's,...
int num_ctrl_outs
Number of output control (plugin param) ports.
PluginArchitecture arch
Architecture (32/64bit).
int num_cv_ins
Number of input CV ports.
int64_t unique_id
Used for VST.
char * uri
Lv2Plugin URI.
int num_audio_ins
Number of audio input ports.
A GObject-ified normal C object with a signal that interested parties can listen to for changes.
YAML utils.