Audacity  3.0.3
LoadLV2.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  LoadLV2.h
6 
7  Audacity(R) is copyright (c) 1999-2008 Audacity Team.
8  License: GPL v2. See License.txt.
9 
10 *********************************************************************/
11 
12 #ifndef LV2EFFECTSMODULE_H
13 #define LV2EFFECTSMODULE_H
14 
15 #include <memory>
16 
17 #include "lilv/lilv.h"
18 
19 #include "lv2/core/lv2.h"
20 #include "lv2/buf-size/buf-size.h"
21 #include "lv2/data-access/data-access.h"
22 #include "lv2/event/event.h"
23 #include "lv2/instance-access/instance-access.h"
24 #include "lv2/midi/midi.h"
25 #include "lv2/parameters/parameters.h"
26 #include "lv2/port-groups/port-groups.h"
27 #include "lv2/port-props/port-props.h"
28 #include "lv2/presets/presets.h"
29 #include "lv2/resize-port/resize-port.h"
30 #include "lv2/time/time.h"
31 #include "lv2/uri-map/uri-map.h"
32 #include "lv2/units/units.h"
33 
34 #include "ModuleInterface.h"
35 #include "EffectInterface.h"
36 #include "PluginInterface.h"
37 
38 #include "lv2_external_ui.h"
39 
40 #if !defined(LV2_CORE__MIDIPlugin)
41 #define LV2_CORE__MIDIPlugin LV2_CORE_PREFIX "MIDIPlugin"
42 #endif
43 
44 #if !defined(LV2_CORE__Enabled)
45 #define LV2_CORE__enabled LV2_CORE_PREFIX "enabled"
46 #endif
47 
48 #if !defined(LV2_UI__makeResident)
49 #define LV2_UI__makeResident LV2_UI_PREFIX "makeResident"
50 #endif
51 
52 #if !defined(LV2_BUF_SIZE__nominalBlockLength)
53 #define LV2_BUF_SIZE__nominalBlockLength LV2_BUF_SIZE_PREFIX "nominalBlockLength"
54 #endif
55 
56 // The "ll-plugin" package includes math functions that appear as plugins
57 // and the best way to exclude them is by their class URI.
58 #define LL_NAMESPACE "http://ll-plugins.nongnu.org/lv2/namespace#"
59 #define LL_MATH_CONSTANTS LL_NAMESPACE "MathConstantPlugin"
60 #define LL_MATH_FUNCTIONS LL_NAMESPACE "MathFunctionPlugin"
61 
62 // Define the list of URIs that need an LilvNode created
63 #undef NODE
64 #define NODE(n, u)
65 
66 #undef NODELIST
67 #define NODELIST \
68  NODE( AtomPort, LV2_ATOM__AtomPort ) \
69  NODE( MaxBlockLength, LV2_BUF_SIZE__maxBlockLength ) \
70  NODE( MinBlockLength, LV2_BUF_SIZE__minBlockLength ) \
71  NODE( AudioPort, LV2_CORE__AudioPort ) \
72  NODE( ControlPort, LV2_CORE__ControlPort ) \
73  NODE( CVPort, LV2_CORE__CVPort ) \
74  NODE( Designation, LV2_CORE__designation ) \
75  NODE( InputPort, LV2_CORE__InputPort ) \
76  NODE( InstrumentPlugin, LV2_CORE__InstrumentPlugin ) \
77  NODE( MIDIPlugin, LV2_CORE__MIDIPlugin ) \
78  NODE( OutputPort, LV2_CORE__OutputPort ) \
79  NODE( Control, LV2_CORE__control ) \
80  NODE( Enumeration, LV2_CORE__enumeration ) \
81  NODE( Integer, LV2_CORE__integer ) \
82  NODE( Name, LV2_CORE__name ) \
83  NODE( OptionalFeature, LV2_CORE__optionalFeature ) \
84  NODE( RequiredFeature, LV2_CORE__requiredFeature ) \
85  NODE( SampleRate, LV2_CORE__sampleRate ) \
86  NODE( Toggled, LV2_CORE__toggled ) \
87  NODE( ExternalUI, LV2_EXTERNAL_UI__Widget ) \
88  NODE( ExternalUIOld, LV2_EXTERNAL_UI_DEPRECATED_URI ) \
89  NODE( MidiEvent, LV2_MIDI__MidiEvent ) \
90  NODE( SupportedOption, LV2_OPTIONS__supportedOption ) \
91  NODE( RequiredOption, LV2_OPTIONS__requiredOption ) \
92  NODE( Group, LV2_PORT_GROUPS__group ) \
93  NODE( Logarithmic, LV2_PORT_PROPS__logarithmic ) \
94  NODE( Trigger, LV2_PORT_PROPS__trigger ) \
95  NODE( Preset, LV2_PRESETS__Preset ) \
96  NODE( MinimumSize, LV2_RESIZE_PORT__minimumSize ) \
97  NODE( Position, LV2_TIME__Position ) \
98  NODE( Gtk, LV2_UI__GtkUI ) \
99  NODE( Gtk3, LV2_UI__Gtk3UI ) \
100  NODE( Unit, LV2_UNITS__unit ) \
101  NODE( Comment, LILV_NS_RDFS "comment" ) \
102  NODE( Label, LILV_NS_RDFS "label" ) \
103  NODE( MathConstants, LL_MATH_CONSTANTS ) \
104  NODE( MathFunctions, LL_MATH_FUNCTIONS )
105 
106 // Define the list of URIs that need a URID registered
107 #undef URID
108 #define URID(n, u)
109 
110 #undef URIDLIST
111 #define URIDLIST \
112  URID( Blank, LV2_ATOM__Blank ) \
113  URID( Bool, LV2_ATOM__Bool ) \
114  URID( Chunk, LV2_ATOM__Chunk ) \
115  URID( Double, LV2_ATOM__Double ) \
116  URID( Float, LV2_ATOM__Float ) \
117  URID( Int, LV2_ATOM__Int ) \
118  URID( Literal, LV2_ATOM__Literal ) \
119  URID( Long, LV2_ATOM__Long ) \
120  URID( Object, LV2_ATOM__Object ) \
121  URID( Path, LV2_ATOM__Path ) \
122  URID( Property, LV2_ATOM__Property ) \
123  URID( Resource, LV2_ATOM__Resource ) \
124  URID( Sequence, LV2_ATOM__Sequence ) \
125  URID( String, LV2_ATOM__String ) \
126  URID( Tuple, LV2_ATOM__Tuple ) \
127  URID( Uri, LV2_ATOM__URI ) \
128  URID( Urid, LV2_ATOM__URID ) \
129  URID( Vector, LV2_ATOM__Vector ) \
130  URID( EventTransfer, LV2_ATOM__eventTransfer ) \
131  URID( AtomSupports, LV2_ATOM__supports ) \
132  URID( MaxBlockLength, LV2_BUF_SIZE__maxBlockLength ) \
133  URID( MinBlockLength, LV2_BUF_SIZE__minBlockLength ) \
134  URID( NominalBlockLength, LV2_BUF_SIZE__nominalBlockLength ) \
135  URID( SequenceSize, LV2_BUF_SIZE__sequenceSize ) \
136  URID( InstrumentPlugin, LV2_CORE__InstrumentPlugin ) \
137  URID( MIDIPlugin, LV2_CORE__MIDIPlugin ) \
138  URID( Toggled, LV2_CORE__toggled ) \
139  URID( ExternalUI, LV2_EXTERNAL_UI__Widget ) \
140  URID( ExternalUIOld, LV2_EXTERNAL_UI_DEPRECATED_URI ) \
141  URID( Error, LV2_LOG__Error ) \
142  URID( Note, LV2_LOG__Note ) \
143  URID( Trace, LV2_LOG__Trace ) \
144  URID( Warning, LV2_LOG__Warning ) \
145  URID( MidiEvent, LV2_MIDI__MidiEvent ) \
146  URID( RequiredOption, LV2_OPTIONS__requiredOption ) \
147  URID( SampleRate, LV2_PARAMETERS__sampleRate ) \
148  URID( RangeSteps, LV2_PORT_PROPS__rangeSteps ) \
149  URID( NotOnGUI, LV2_PORT_PROPS__notOnGUI ) \
150  URID( Expensive, LV2_PORT_PROPS__expensive ) \
151  URID( CausesArtifacts, LV2_PORT_PROPS__causesArtifacts ) \
152  URID( NotAutomatic, LV2_PORT_PROPS__notAutomatic ) \
153  URID( Position, LV2_TIME__Position ) \
154  URID( Speed, LV2_TIME__speed ) \
155  URID( Frame, LV2_TIME__frame )
156 
158 //
159 // LV2EffectsModule
160 //
162 
163 class LV2EffectsModule final : public ModuleInterface
164 {
165 public:
167  virtual ~LV2EffectsModule();
168 
169  // ComponentInterface implementation
170 
171  PluginPath GetPath() override;
173  VendorSymbol GetVendor() override;
174  wxString GetVersion() override;
176 
177  // ModuleInterface implementation
178 
179  bool Initialize() override;
180  void Terminate() override;
182 
183  const FileExtensions &GetFileExtensions() override;
184  FilePath InstallPath() override { return {}; }
185 
186  bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
188  unsigned DiscoverPluginsAtPath(
189  const PluginPath & path, TranslatableString &errMsg,
190  const RegistrationCallback &callback)
191  override;
192 
193  bool IsPluginValid(const PluginPath & path, bool bFast) override;
194 
195  std::unique_ptr<ComponentInterface>
196  CreateInstance(const PluginPath & path) override;
197 
198  // LV2EffectModule implementation
199 
200 private:
201  const LilvPlugin *GetPlugin(const PluginPath & path);
202 };
203 
204 extern LilvWorld *gWorld;
205 
206 #endif
LV2EffectsModule::InstallPath
FilePath InstallPath() override
Definition: LoadLV2.h:184
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
gWorld
LilvWorld * gWorld
Definition: LoadLV2.cpp:79
LV2EffectsModule::CreateInstance
std::unique_ptr< ComponentInterface > CreateInstance(const PluginPath &path) override
Definition: LoadLV2.cpp:306
LV2EffectsModule::~LV2EffectsModule
virtual ~LV2EffectsModule()
Definition: LoadLV2.cpp:85
LV2EffectsModule::GetDescription
TranslatableString GetDescription() override
Definition: LoadLV2.cpp:114
LV2EffectsModule::AutoRegisterPlugins
bool AutoRegisterPlugins(PluginManagerInterface &pm) override
Definition: LoadLV2.cpp:234
LV2EffectsModule::Initialize
bool Initialize() override
Definition: LoadLV2.cpp:123
EffectInterface.h
PluginPath
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
Definition: Identifier.h:214
LV2EffectsModule::GetVendor
VendorSymbol GetVendor() override
Definition: LoadLV2.cpp:103
ModuleInterface.h
LV2EffectsModule::GetVersion
wxString GetVersion() override
Definition: LoadLV2.cpp:108
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
LV2EffectsModule::LV2EffectsModule
LV2EffectsModule()
Definition: LoadLV2.cpp:81
ModuleInterface
Definition: ModuleInterface.h:70
FilePath
wxString FilePath
Definition: Project.h:20
PluginManagerInterface
Definition: PluginInterface.h:55
LV2EffectsModule::DiscoverPluginsAtPath
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
Definition: LoadLV2.cpp:277
LV2EffectsModule::GetFileExtensions
const FileExtensions & GetFileExtensions() override
Definition: LoadLV2.cpp:228
LV2EffectsModule::Terminate
void Terminate() override
Definition: LoadLV2.cpp:205
lv2_external_ui.h
PluginPaths
std::vector< PluginPath > PluginPaths
Definition: Identifier.h:215
LV2EffectsModule::GetSymbol
ComponentInterfaceSymbol GetSymbol() override
Definition: LoadLV2.cpp:98
LV2EffectsModule::FindPluginPaths
PluginPaths FindPluginPaths(PluginManagerInterface &pm) override
Definition: LoadLV2.cpp:239
LV2EffectsModule::GetOptionalFamilySymbol
EffectFamilySymbol GetOptionalFamilySymbol() override
Definition: LoadLV2.cpp:219
LV2EffectsModule::IsPluginValid
bool IsPluginValid(const PluginPath &path, bool bFast) override
Definition: LoadLV2.cpp:298
PluginInterface.h
LV2EffectsModule::GetPath
PluginPath GetPath() override
Definition: LoadLV2.cpp:93
ModuleInterface::RegistrationCallback
std::function< const PluginID &(ModuleInterface *, ComponentInterface *) > RegistrationCallback
Definition: ModuleInterface.h:123
LV2EffectsModule
Definition: LoadLV2.h:164
LV2EffectsModule::GetPlugin
const LilvPlugin * GetPlugin(const PluginPath &path)
Definition: LoadLV2.cpp:318