Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
plugin_configuration.h
1// SPDX-FileCopyrightText: © 2021-2022, 2024-2025 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include "plugins/plugin_descriptor.h"
7
8namespace zrythm::plugins
9{
10
16class PluginConfiguration : public QObject
17{
18 Q_OBJECT
19 Q_PROPERTY (
20 zrythm::plugins::PluginDescriptor * descriptor READ descriptor CONSTANT)
21 QML_ELEMENT
22 QML_UNCREATABLE ("")
23
24public:
25 PluginConfiguration (QObject * parent = nullptr) : QObject (parent) { };
26
27 // ============================================================================
28 // QML Interface
29 // ============================================================================
30
31 PluginDescriptor * descriptor () const { return descr_.get (); }
32
33 // ============================================================================
34
39 static std::unique_ptr<PluginConfiguration>
42 enum class HostingType : std::uint8_t
43 {
47 JUCE,
48
54 Custom
55 };
56
57public:
62 void validate ();
63
64 void print () const;
65
66 friend void init_from (
67 PluginConfiguration &obj,
68 const PluginConfiguration &other,
69 utils::ObjectCloneType clone_type);
70
71 zrythm::plugins::PluginDescriptor * get_descriptor () const
72 {
73 return descr_.get ();
74 }
75
76 auto get_name () const { return get_descriptor ()->name_; }
77
78 void copy_fields_from (const PluginConfiguration &other);
79
80private:
81 static constexpr auto kDescriptorKey = "descriptor"sv;
82 static constexpr auto kForceGenericUIKey = "forceGenericUI"sv;
83 static constexpr auto kBridgeModeKey = "bridgeMode"sv;
84 friend void to_json (nlohmann::json &j, const PluginConfiguration &p)
85 {
86 j = nlohmann::json{
87 { kDescriptorKey, p.descr_ },
88 { kForceGenericUIKey, p.force_generic_ui_ },
89 { kBridgeModeKey, p.bridge_mode_ },
90 };
91 }
92 friend void from_json (const nlohmann::json &j, PluginConfiguration &p);
93
94public:
96 std::unique_ptr<zrythm::plugins::PluginDescriptor> descr_;
97
98 HostingType hosting_type_{ HostingType::JUCE };
99
101 bool force_generic_ui_{};
102
104 zrythm::plugins::BridgeMode bridge_mode_{};
105
106 BOOST_DESCRIBE_CLASS (
108 (),
109 (descr_, hosting_type_, force_generic_ui_, bridge_mode_),
110 (),
111 ())
112};
113
114}
Configuration for instantiating a plugin descriptor.
zrythm::plugins::BridgeMode bridge_mode_
Requested carla bridge mode.
static std::unique_ptr< PluginConfiguration > create_new_for_descriptor(const zrythm::plugins::PluginDescriptor &descr)
Creates a plugin setting with the recommended settings for the given plugin descriptor based on the c...
std::unique_ptr< zrythm::plugins::PluginDescriptor > descr_
The descriptor of the plugin this setting is for.
@ Custom
Plugin hosted via custom plugin format implementation.
bool force_generic_ui_
Whether to force a generic UI.
void validate()
Makes sure the setting is valid in the current run and changes any fields to make it conform.
The PluginDescriptor class provides a set of static utility functions and member functions to work wi...