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
21typedef struct _WrappedObjectWithChangeSignal WrappedObjectWithChangeSignal;
22
29#define PLUGIN_DESCRIPTOR_SCHEMA_VERSION 1
30
34typedef enum ZPluginCategory
35{
38 PC_DELAY,
39 PC_REVERB,
40 PC_DISTORTION,
41 PC_WAVESHAPER,
42 PC_DYNAMICS,
43 PC_AMPLIFIER,
44 PC_COMPRESSOR,
45 PC_ENVELOPE,
46 PC_EXPANDER,
47 PC_GATE,
48 PC_LIMITER,
49 PC_FILTER,
50 PC_ALLPASS_FILTER,
51 PC_BANDPASS_FILTER,
52 PC_COMB_FILTER,
53 PC_EQ,
54 PC_MULTI_EQ,
55 PC_PARA_EQ,
56 PC_HIGHPASS_FILTER,
57 PC_LOWPASS_FILTER,
58 PC_GENERATOR,
59 PC_CONSTANT,
60 PC_INSTRUMENT,
61 PC_OSCILLATOR,
62 PC_MIDI,
63 PC_MODULATOR,
64 PC_CHORUS,
65 PC_FLANGER,
66 PC_PHASER,
67 PC_SIMULATOR,
68 PC_SIMULATOR_REVERB,
69 PC_SPATIAL,
70 PC_SPECTRAL,
71 PC_PITCH,
72 PC_UTILITY,
73 PC_ANALYZER,
74 PC_CONVERTER,
75 PC_FUNCTION,
76 PC_MIXER,
78
79static const cyaml_strval_t plugin_descriptor_category_strings[] = {
80 {"None", ZPLUGIN_CATEGORY_NONE},
81 { "Delay", PC_DELAY },
82 { "Reverb", PC_REVERB },
83 { "Distortion", PC_DISTORTION },
84 { "Waveshaper", PC_WAVESHAPER },
85 { "Dynamics", PC_DYNAMICS },
86 { "Amplifier", PC_AMPLIFIER },
87 { "Compressor", PC_COMPRESSOR },
88 { "Envelope", PC_ENVELOPE },
89 { "Expander", PC_EXPANDER },
90 { "Gate", PC_GATE },
91 { "Limiter", PC_LIMITER },
92 { "Filter", PC_FILTER },
93 { "Allpass Filter", PC_ALLPASS_FILTER },
94 { "Bandpass Filter", PC_BANDPASS_FILTER },
95 { "Comb Filter", PC_COMB_FILTER },
96 { "EQ", PC_EQ },
97 { "Multi-EQ", PC_MULTI_EQ },
98 { "Parametric EQ", PC_PARA_EQ },
99 { "Highpass Filter", PC_HIGHPASS_FILTER },
100 { "Lowpass Filter", PC_LOWPASS_FILTER },
101 { "Generator", PC_GENERATOR },
102 { "Constant", PC_CONSTANT },
103 { "Instrument", PC_INSTRUMENT },
104 { "Oscillator", PC_OSCILLATOR },
105 { "MIDI", PC_MIDI },
106 { "Modulator", PC_MODULATOR },
107 { "Chorus", PC_CHORUS },
108 { "Flanger", PC_FLANGER },
109 { "Phaser", PC_PHASER },
110 { "Simulator", PC_SIMULATOR },
111 { "Simulator Reverb", PC_SIMULATOR_REVERB },
112 { "Spatial", PC_SPATIAL },
113 { "Spectral", PC_SPECTRAL },
114 { "Pitch", PC_PITCH },
115 { "Utility", PC_UTILITY },
116 { "Analyzer", PC_ANALYZER },
117 { "Converter", PC_CONVERTER },
118 { "Function", PC_FUNCTION },
119 { "Mixer", PC_MIXER },
120};
121
125typedef enum ZPluginProtocol
126{
129 Z_PLUGIN_PROTOCOL_LV2,
130 Z_PLUGIN_PROTOCOL_DSSI,
131 Z_PLUGIN_PROTOCOL_LADSPA,
132 Z_PLUGIN_PROTOCOL_VST,
133 Z_PLUGIN_PROTOCOL_VST3,
134 Z_PLUGIN_PROTOCOL_AU,
135 Z_PLUGIN_PROTOCOL_SFZ,
136 Z_PLUGIN_PROTOCOL_SF2,
137 Z_PLUGIN_PROTOCOL_CLAP,
138 Z_PLUGIN_PROTOCOL_JSFX,
140
141static const cyaml_strval_t plugin_protocol_strings[] = {
142 {N_ ("Dummy"), Z_PLUGIN_PROTOCOL_DUMMY },
143 { "LV2", Z_PLUGIN_PROTOCOL_LV2 },
144 { "DSSI", Z_PLUGIN_PROTOCOL_DSSI },
145 { "LADSPA", Z_PLUGIN_PROTOCOL_LADSPA},
146 { "VST", Z_PLUGIN_PROTOCOL_VST },
147 { "VST3", Z_PLUGIN_PROTOCOL_VST3 },
148 { "AU", Z_PLUGIN_PROTOCOL_AU },
149 { "SFZ", Z_PLUGIN_PROTOCOL_SFZ },
150 { "SF2", Z_PLUGIN_PROTOCOL_SF2 },
151 { "CLAP", Z_PLUGIN_PROTOCOL_CLAP },
152 { "JSFX", Z_PLUGIN_PROTOCOL_JSFX },
153};
154
159{
160 ARCH_32,
161 ARCH_64
163
164static const cyaml_strval_t plugin_architecture_strings[] = {
165 {"32-bit", ARCH_32},
166 { "64-bit", ARCH_64},
167};
168
172typedef enum CarlaBridgeMode
173{
174 CARLA_BRIDGE_NONE,
175 CARLA_BRIDGE_UI,
176 CARLA_BRIDGE_FULL,
178
179static const cyaml_strval_t carla_bridge_mode_strings[] = {
180 {"None", CARLA_BRIDGE_NONE},
181 { "UI", CARLA_BRIDGE_UI },
182 { "Full", CARLA_BRIDGE_FULL},
183};
184
185/***
186 * A descriptor to be implemented by all plugins
187 * This will be used throughout the UI
188 */
189typedef struct PluginDescriptor
190{
191 int schema_version;
192 char * author;
193 char * name;
194 char * website;
195 ZPluginCategory category;
221 char * path;
223 char * uri;
224
226 int64_t unique_id;
227
230
231 bool has_custom_ui;
232
236 unsigned int ghash;
237
241
242static const cyaml_schema_field_t plugin_descriptor_fields_schema[] = {
243 YAML_FIELD_INT (PluginDescriptor, schema_version),
244 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, author),
245 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, name),
246 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, website),
247 YAML_FIELD_ENUM (PluginDescriptor, category, plugin_descriptor_category_strings),
248 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, category_str),
249 YAML_FIELD_INT (PluginDescriptor, num_audio_ins),
250 YAML_FIELD_INT (PluginDescriptor, num_audio_outs),
251 YAML_FIELD_INT (PluginDescriptor, num_midi_ins),
252 YAML_FIELD_INT (PluginDescriptor, num_midi_outs),
253 YAML_FIELD_INT (PluginDescriptor, num_ctrl_ins),
254 YAML_FIELD_INT (PluginDescriptor, num_ctrl_outs),
255 YAML_FIELD_INT (PluginDescriptor, num_cv_ins),
256 YAML_FIELD_UINT (PluginDescriptor, unique_id),
257 YAML_FIELD_INT (PluginDescriptor, num_cv_outs),
258 YAML_FIELD_ENUM (PluginDescriptor, arch, plugin_architecture_strings),
259 YAML_FIELD_ENUM (PluginDescriptor, protocol, plugin_protocol_strings),
260 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, path),
261 YAML_FIELD_STRING_PTR_OPTIONAL (PluginDescriptor, uri),
262 YAML_FIELD_ENUM (PluginDescriptor, min_bridge_mode, carla_bridge_mode_strings),
263 YAML_FIELD_INT (PluginDescriptor, has_custom_ui),
264 YAML_FIELD_UINT (PluginDescriptor, ghash),
265
266 CYAML_FIELD_END
267};
268
269static const cyaml_schema_value_t plugin_descriptor_schema = {
270 YAML_VALUE_PTR (PluginDescriptor, plugin_descriptor_fields_schema),
271};
272
274plugin_descriptor_new (void);
275
276const char *
277plugin_protocol_to_str (ZPluginProtocol prot);
278
280plugin_protocol_from_str (const char * str);
281
282static inline const char *
283plugin_protocol_get_icon_name (ZPluginProtocol prot)
284{
285 const char * icon = NULL;
286 switch (prot)
287 {
288 case Z_PLUGIN_PROTOCOL_LV2:
289 icon = "logo-lv2";
290 break;
291 case Z_PLUGIN_PROTOCOL_LADSPA:
292 icon = "logo-ladspa";
293 break;
294 case Z_PLUGIN_PROTOCOL_AU:
295 icon = "logo-au";
296 break;
297 case Z_PLUGIN_PROTOCOL_VST:
298 case Z_PLUGIN_PROTOCOL_VST3:
299 icon = "logo-vst";
300 break;
301 case Z_PLUGIN_PROTOCOL_SFZ:
302 case Z_PLUGIN_PROTOCOL_SF2:
303 icon = "file-music-line";
304 break;
305 default:
306 icon = "plug";
307 break;
308 }
309 return icon;
310}
311
312const char *
313plugin_category_to_string (ZPluginCategory category);
314
318NONNULL void
320
324NONNULL PluginDescriptor *
326
330NONNULL bool
332
336NONNULL bool
338
342NONNULL int
344
348NONNULL int
350
355NONNULL ZPluginCategory
357
358char *
359plugin_descriptor_category_to_string (ZPluginCategory category);
360
365const char *
367
372bool
374 const PluginDescriptor * self,
375 int slot_type,
376 int track_type);
377
382NONNULL bool
384 const PluginDescriptor * a,
385 const PluginDescriptor * b);
386
391NONNULL bool
393
398NONNULL CarlaBridgeMode
400
411NONNULL bool
413
414NONNULL GMenuModel *
415plugin_descriptor_generate_context_menu (const PluginDescriptor * self);
416
417NONNULL void
418plugin_descriptor_free (PluginDescriptor * self);
419
420NONNULL void
421plugin_descriptor_free_closure (void * data, GClosure * closure);
422
427#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 * 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.