Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
plugin_descriptor.h
1// SPDX-FileCopyrightText: © 2018-2021, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "zrythm-config.h"
7
8#include "dsp/plugin_slot.h"
9#include "gui/dsp/plugin_protocol.h"
10#include "utils/icloneable.h"
11#include "utils/serialization.h"
12
13#include <QObject>
14
20
21namespace zrythm::gui::old_dsp::plugins
22{
23
24using PluginSlotType = zrythm::dsp::PluginSlotType;
25
29enum class ZPluginCategory
30{
32 NONE,
33 DELAY,
34 REVERB,
35 DISTORTION,
36 WAVESHAPER,
37 DYNAMICS,
38 AMPLIFIER,
39 COMPRESSOR,
40 ENVELOPE,
41 EXPANDER,
42 GATE,
43 LIMITER,
44 FILTER,
45 ALLPASS_FILTER,
46 BANDPASS_FILTER,
47 COMB_FILTER,
48 EQ,
49 MULTI_EQ,
50 PARA_EQ,
51 HIGHPASS_FILTER,
52 LOWPASS_FILTER,
53 GENERATOR,
54 CONSTANT,
55 INSTRUMENT,
56 OSCILLATOR,
57 MIDI,
58 MODULATOR,
59 CHORUS,
60 FLANGER,
61 PHASER,
62 SIMULATOR,
63 SIMULATOR_REVERB,
64 SPATIAL,
65 SPECTRAL,
66 PITCH,
67 UTILITY,
68 ANALYZER,
69 CONVERTER,
70 FUNCTION,
71 MIXER,
72};
73
77enum class PluginArchitecture
78{
79 ARCH_32_BIT,
80 ARCH_64_BIT
81};
82
86enum class CarlaBridgeMode
87{
88 None,
89 UI,
90 Full,
91};
92
112class PluginDescriptor final : public QObject, public ICloneable<PluginDescriptor>
113{
114 Q_OBJECT
115 QML_ELEMENT
116 Q_PROPERTY (QString name READ getName CONSTANT FINAL)
117
118public:
119 static ZPluginCategory string_to_category (const utils::Utf8String &str);
120 static utils::Utf8String category_to_string (ZPluginCategory category);
121
122 bool is_instrument () const;
123 bool is_effect () const;
124 bool is_modulator () const;
125 bool is_midi_modifier () const;
126
130 bool is_valid_for_slot_type (PluginSlotType slot_type, int track_type) const;
131
136 bool is_same_plugin (const PluginDescriptor &other) const;
137
141 bool has_custom_ui () const;
142
146 CarlaBridgeMode get_min_bridge_mode () const;
147
157 bool is_whitelisted () const;
158
163
164 // GMenuModel * generate_context_menu () const;
165
166 [[nodiscard]] QString getName () const { return name_.to_qstring (); }
167
168 void
169 init_after_cloning (const PluginDescriptor &other, ObjectCloneType clone_type)
170 override;
171
172private:
173 static constexpr auto kAuthorKey = "author"sv;
174 static constexpr auto kNameKey = "name"sv;
175 static constexpr auto kWebsiteKey = "website"sv;
176 static constexpr auto kCategoryKey = "category"sv;
177 static constexpr auto kCategoryStringKey = "categoryString"sv;
178 static constexpr auto kNumAudioInsKey = "numAudioIns"sv;
179 static constexpr auto kNumAudioOutsKey = "numAudioOuts"sv;
180 static constexpr auto kNumMidiInsKey = "numMidiIns"sv;
181 static constexpr auto kNumMidiOutsKey = "numMidiOuts"sv;
182 static constexpr auto kNumCtrlInsKey = "numCtrlIns"sv;
183 static constexpr auto kNumCtrlOutsKey = "numCtrlOuts"sv;
184 static constexpr auto kNumCvInsKey = "numCvIns"sv;
185 static constexpr auto kNumCvOutsKey = "numCvOuts"sv;
186 static constexpr auto kUniqueIdKey = "uniqueId"sv;
187 static constexpr auto kArchitectureKey = "architecture"sv;
188 static constexpr auto kProtocolKey = "protocol"sv;
189 static constexpr auto kPathKey = "path"sv;
190 static constexpr auto kUriKey = "uri"sv;
191 static constexpr auto kMinBridgeModeKey = "minBridgeMode"sv;
192 static constexpr auto kHasCustomUIKey = "hasCustomUI"sv;
193 static constexpr auto kGHashKey = "ghash"sv;
194 static constexpr auto kSha1Key = "sha1"sv;
195 friend void to_json (nlohmann::json &j, const PluginDescriptor &p)
196 {
197 j = nlohmann::json{
198 { kAuthorKey, p.author_ },
199 { kNameKey, p.name_ },
200 { kWebsiteKey, p.website_ },
201 { kCategoryKey, p.category_ },
202 { kCategoryStringKey, p.category_str_ },
203 { kNumAudioInsKey, p.num_audio_ins_ },
204 { kNumAudioOutsKey, p.num_audio_outs_ },
205 { kNumMidiInsKey, p.num_midi_ins_ },
206 { kNumMidiOutsKey, p.num_midi_outs_ },
207 { kNumCtrlInsKey, p.num_ctrl_ins_ },
208 { kNumCtrlOutsKey, p.num_ctrl_outs_ },
209 { kNumCvInsKey, p.num_cv_ins_ },
210 { kNumCvOutsKey, p.num_cv_outs_ },
211 { kUniqueIdKey, p.unique_id_ },
212 { kArchitectureKey, p.arch_ },
213 { kProtocolKey, p.protocol_ },
214 { kPathKey, p.path_ },
215 { kUriKey, p.uri_ },
216 { kMinBridgeModeKey, p.min_bridge_mode_ },
217 { kHasCustomUIKey, p.has_custom_ui_ },
218 { kGHashKey, p.ghash_ },
219 { kSha1Key, p.sha1_ },
220 };
221 }
222 friend void from_json (const nlohmann::json &j, PluginDescriptor &p)
223 {
224 j.at (kAuthorKey).get_to (p.author_);
225 j.at (kNameKey).get_to (p.name_);
226 j.at (kWebsiteKey).get_to (p.website_);
227 j.at (kCategoryKey).get_to (p.category_);
228 j.at (kCategoryStringKey).get_to (p.category_str_);
229 j.at (kNumAudioInsKey).get_to (p.num_audio_ins_);
230 j.at (kNumAudioOutsKey).get_to (p.num_audio_outs_);
231 j.at (kNumMidiInsKey).get_to (p.num_midi_ins_);
232 j.at (kNumMidiOutsKey).get_to (p.num_midi_outs_);
233 j.at (kNumCtrlInsKey).get_to (p.num_ctrl_ins_);
234 j.at (kNumCtrlOutsKey).get_to (p.num_ctrl_outs_);
235 j.at (kNumCvInsKey).get_to (p.num_cv_ins_);
236 j.at (kNumCvOutsKey).get_to (p.num_cv_outs_);
237 j.at (kUniqueIdKey).get_to (p.unique_id_);
238 j.at (kArchitectureKey).get_to (p.arch_);
239 j.at (kProtocolKey).get_to (p.protocol_);
240 j.at (kPathKey).get_to (p.path_);
241 j.at (kUriKey).get_to (p.uri_);
242 j.at (kMinBridgeModeKey).get_to (p.min_bridge_mode_);
243 j.at (kHasCustomUIKey).get_to (p.has_custom_ui_);
244 j.at (kGHashKey).get_to (p.ghash_);
245 j.at (kSha1Key).get_to (p.sha1_);
246 }
247
248public:
249 utils::Utf8String author_;
250 utils::Utf8String name_;
251 utils::Utf8String website_;
252 ZPluginCategory category_ = ZPluginCategory::NONE;
268 int num_cv_ins_ = 0;
272 PluginArchitecture arch_ = PluginArchitecture::ARCH_32_BIT;
276 fs::path path_;
279
281 int64_t unique_id_ = 0;
282
284 CarlaBridgeMode min_bridge_mode_ = CarlaBridgeMode::None;
285
286 bool has_custom_ui_ = false;
287
294 unsigned int ghash_ = 0;
295
297 std::string sha1_;
298};
299
300inline bool
301operator== (const PluginDescriptor &a, const PluginDescriptor &b)
302{
303 return a.arch_ == b.arch_ && a.protocol_ == b.protocol_
304 && a.unique_id_ == b.unique_id_ && a.ghash_ == b.ghash_
305 && a.sha1_ == b.sha1_ && a.uri_ == b.uri_;
306}
307
308} // namespace zrythm::gui::old_dsp::plugins
309
The PluginDescriptor class provides a set of static utility functions and member functions to work wi...
CarlaBridgeMode get_min_bridge_mode() const
Returns the minimum bridge mode required for this plugin.
fs::path path_
Path, if not an Lv2Plugin which uses URIs.
bool has_custom_ui() const
Returns if the Plugin has a supported custom UI.
utils::Utf8String category_str_
Lv2 plugin subcategory.
utils::Utf8String get_icon_name() const
Gets an appropriate icon name.
bool is_same_plugin(const PluginDescriptor &other) const
Returns whether the two descriptors describe the same plugin, ignoring irrelevant fields.
bool is_whitelisted() const
Returns whether the plugin is known to work, so it should be whitelisted.
std::string sha1_
SHA1 of the file (replaces ghash).
bool is_valid_for_slot_type(PluginSlotType slot_type, int track_type) const
Returns if this can be dropped in a slot of the given type.
int num_ctrl_outs_
Number of output control (plugin param) ports.
Protocol::ProtocolType protocol_
Plugin protocol (Lv2/DSSI/LADSPA/VST/etc.).
int num_audio_outs_
Number of audio output ports.
PluginArchitecture arch_
Architecture (32/64bit).
int num_ctrl_ins_
Number of input control (plugin param) ports.
CarlaBridgeMode min_bridge_mode_
Minimum required bridge mode.
unsigned int ghash_
Hash of the plugin's bundle (.so/.ddl for VST) used when caching PluginDescriptor's,...
Lightweight UTF-8 string wrapper with safe conversions.
Definition string.h:39
ObjectCloneType
Definition icloneable.h:25