LMMS
Loading...
Searching...
No Matches
Lv2Manager.h
Go to the documentation of this file.
1/*
2 * Lv2Manager.h - Implementation of Lv2Manager class
3 *
4 * Copyright (c) 2018-2024 Johannes Lorenz <jlsf2013$users.sourceforge.net, $=@>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_LV2_MANAGER_H
26#define LMMS_LV2_MANAGER_H
27
28#include "lmmsconfig.h"
29
30#ifdef LMMS_HAVE_LV2
31
32#include <map>
33#include <set>
34#include <string_view>
35#include <lilv/lilv.h>
36
37#include "Lv2Basics.h"
38#include "Lv2UridCache.h"
39#include "Lv2UridMap.h"
40#include "Plugin.h"
41
42
43namespace lmms
44{
45
46/*
47 all Lv2 classes in relation (use our "4 spaces per tab rule" to view):
48
49 explanation:
50 "x = {y z}" means class "x" consists of classes "y" and "z"
51 (and probably other classes not mentioned)
52 "x = {y*}" means class "x" references/uses class "y"
53
54 core:
55 Lv2Proc = {LilvInstance}
56 Lv2ControlBase = {Lv2Proc, Lv2Proc... (2 for mono, 1 for stereo)}
57 Lv2Manager = {LilvPlugin*, LilvPlugin* ...}
58 (creates Lv2ControlBase, Lv2ControlBase...)
59
60 Lv2FxControls = {Lv2ControlBase}
61 Lv2Effect = {Effect + Lv2FxControls}
62 (takes Lv2SubPluginFeatures in ctor)
63 Lv2Instrument = {Instrument + Lv2ControlBase}
64 (takes Lv2SubPluginFeatures in ctor)
65
66 gui:
67 Lv2ViewProc = {Lv2Proc*}
68 Lv2ViewBase = {Lv2ViewProc, Lv2ViewProc...
69 (2 for mono, 1 for stereo)}
70 Lv2FxControlDialog = {EffectControlDialog + Lv2ViewBase}
71 Lv2InsView = {InstrumentView + Lv2ViewBase}
72
73 Lv2SubPluginFeatures:
74 Lv2SubPluginFeatures = {Lv2Manager*}
75 Lv2Effect::Descriptor = {Lv2SubPluginFeatures}
76 Lv2Instrument::Descriptor = {Lv2SubPluginFeatures}
77*/
78
79
82{
83public:
84 void initPlugins();
85
86 Lv2Manager();
88
89
90 AutoLilvNode uri(const char* uriStr);
91
93 struct Lv2Info
94 {
95 public:
99 Lv2Info(const LilvPlugin* plug, Plugin::Type type, bool valid) :
100 m_plugin(plug), m_type(type), m_valid(valid) {}
101 Lv2Info(Lv2Info&& other) = default;
102 Lv2Info& operator=(Lv2Info&& other) = default;
103
104 const LilvPlugin* plugin() const { return m_plugin; }
105 Plugin::Type type() const { return m_type; }
106 bool isValid() const { return m_valid; }
107
108 private:
111 bool m_valid = false;
112 };
113
115 const LilvPlugin *getPlugin(const std::string &uri);
117 const LilvPlugin *getPlugin(const QString& uri);
118
119 using Lv2InfoMap = std::map<std::string, Lv2Info>;
120 using Iterator = Lv2InfoMap::iterator;
121 Iterator begin() { return m_lv2InfoMap.begin(); }
122 Iterator end() { return m_lv2InfoMap.end(); }
123
124 UridMap& uridMap() { return m_uridMap; }
125 const Lv2UridCache& uridCache() const { return m_uridCache; }
126 const std::set<std::string_view>& supportedFeatureURIs() const
127 {
129 }
130 bool isFeatureSupported(const char* featName) const;
131 AutoLilvNodes findNodes(const LilvNode *subject,
132 const LilvNode *predicate, const LilvNode *object);
133
134 static bool pluginIsUnstable(const char* pluginUri)
135 {
136 return unstablePlugins.find(pluginUri) != unstablePlugins.end();
137 }
138 static bool pluginIsOnlyUsefulWithUi(const char* pluginUri)
139 {
140 return pluginsOnlyUsefulWithUi.find(pluginUri) != pluginsOnlyUsefulWithUi.end();
141 }
142 static bool pluginIsUnstableWithBuffersizeLessEqual32(const char* pluginUri)
143 {
144 return unstablePluginsBuffersizeLessEqual32.find(pluginUri) !=
146 }
147
150 static bool wantUi();
151
152private:
153 // general data
154 bool m_debug;
157 std::set<std::string_view> m_supportedFeatureURIs;
158
159 // feature data that are common for all Lv2Proc
161
162 // URID cache for fast URID access
164
165 // static
166 static const std::set<std::string_view> unstablePlugins;
167 static const std::set<std::string_view> pluginsOnlyUsefulWithUi;
168 static const std::set<std::string_view> unstablePluginsBuffersizeLessEqual32;
169
170 // functions
171 bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr);
172};
173
174
175} // namespace lmms
176
177#endif // LMMS_HAVE_LV2
178
179#endif // LMMS_LV2_MANAGER_H
#define nullptr
Definition DistrhoDefines.h:75
std::map< std::string, Lv2Info > Lv2InfoMap
Definition Lv2Manager.h:119
bool isSubclassOf(const LilvPluginClass *clvss, const char *uriStr)
Definition Lv2Manager.cpp:347
const Lv2UridCache & uridCache() const
Definition Lv2Manager.h:125
static bool wantUi()
Definition Lv2Manager.cpp:338
Lv2InfoMap m_lv2InfoMap
Definition Lv2Manager.h:156
bool isFeatureSupported(const char *featName) const
Definition Lv2Manager.cpp:321
static const std::set< std::string_view > unstablePluginsBuffersizeLessEqual32
Definition Lv2Manager.h:168
LilvWorld * m_world
Definition Lv2Manager.h:155
Iterator begin()
Definition Lv2Manager.h:121
UridMap & uridMap()
Definition Lv2Manager.h:124
std::set< std::string_view > m_supportedFeatureURIs
Definition Lv2Manager.h:157
static bool pluginIsOnlyUsefulWithUi(const char *pluginUri)
Definition Lv2Manager.h:138
Lv2InfoMap::iterator Iterator
Definition Lv2Manager.h:120
const LilvPlugin * getPlugin(const std::string &uri)
Return descriptor with URI uri or nullptr if none exists.
Definition Lv2Manager.cpp:220
static const std::set< std::string_view > pluginsOnlyUsefulWithUi
Definition Lv2Manager.h:167
const std::set< std::string_view > & supportedFeatureURIs() const
Definition Lv2Manager.h:126
Lv2Manager()
Definition Lv2Manager.cpp:168
static bool pluginIsUnstable(const char *pluginUri)
Definition Lv2Manager.h:134
UridMap m_uridMap
Definition Lv2Manager.h:160
bool m_debug
if set, debug output will be printed
Definition Lv2Manager.h:154
AutoLilvNode uri(const char *uriStr)
Definition Lv2Manager.cpp:212
Lv2UridCache m_uridCache
Definition Lv2Manager.h:163
Iterator end()
Definition Lv2Manager.h:122
static bool pluginIsUnstableWithBuffersizeLessEqual32(const char *pluginUri)
Definition Lv2Manager.h:142
void initPlugins()
Definition Lv2Manager.cpp:237
AutoLilvNodes findNodes(const LilvNode *subject, const LilvNode *predicate, const LilvNode *object)
Definition Lv2Manager.cpp:329
~Lv2Manager()
Definition Lv2Manager.cpp:204
static const std::set< std::string_view > unstablePlugins
Definition Lv2Manager.h:166
Cached URIDs for fast access (for use in real-time code).
Definition Lv2UridCache.h:41
Type
Definition Plugin.h:76
Definition Lv2UridMap.h:47
struct LilvWorldImpl LilvWorld
Definition lilv.h:88
struct LilvPluginClassImpl LilvPluginClass
Definition lilv.h:83
struct LilvPluginImpl LilvPlugin
Definition lilv.h:82
struct LilvNodeImpl LilvNode
Definition lilv.h:87
Definition AudioAlsa.cpp:35
std::unique_ptr< LilvNodes, LilvNodesDeleter > AutoLilvNodes
Definition Lv2Basics.h:64
std::unique_ptr< LilvNode, LilvNodeDeleter > AutoLilvNode
Definition Lv2Basics.h:63
bool m_valid
Definition Lv2Manager.h:111
bool isValid() const
Definition Lv2Manager.h:106
Plugin::Type type() const
Definition Lv2Manager.h:105
Lv2Info(Lv2Info &&other)=default
Plugin::Type m_type
Definition Lv2Manager.h:110
Lv2Info(const LilvPlugin *plug, Plugin::Type type, bool valid)
ctor used inside Lv2Manager
Definition Lv2Manager.h:99
Lv2Info()
use only for std::map internals
Definition Lv2Manager.h:97
Lv2Info & operator=(Lv2Info &&other)=default
const LilvPlugin * m_plugin
Definition Lv2Manager.h:109
const LilvPlugin * plugin() const
Definition Lv2Manager.h:104