21#pragma GCC diagnostic ignored "-Wparentheses"
32#include <wx/filename.h>
39#include <unordered_map>
54 return std::make_unique<LV2EffectsModule>();
67using UriHash = std::unordered_map<wxString, LilvNode*>;
88 return XO(
"LV2 Effects");
93 return XO(
"The Audacity Team");
104 return XO(
"Provides LV2 Effects support to Audacity");
150#if defined(__WXMAC__)
151#define LV2PATH wxT("/Library/Audio/Plug-Ins/LV2")
155 libdir.AppendDir(
wxT(
"lv2"));
157 newVar +=
wxT(
":$HOME/.lv2");
163 newVar +=
wxT(
":/usr/local/lib/lv2");
164 newVar +=
wxT(
":/usr/lib/lv2");
165 newVar +=
wxT(
":") + libdir.GetPath();
167#elif defined(__WXMSW__)
169 newVar +=
wxT(
";%APPDATA%\\LV2");
170 newVar +=
wxT(
";%COMMONPROGRAMFILES%\\LV2");
171 newVar +=
wxT(
";%COMMONPROGRAMFILES(x86)%\\LV2");
176 libdir.AssignDir(
wxT(LIBDIR));
177 libdir.AppendDir(
wxT(
"lv2"));
179 newVar +=
wxT(
":$HOME/.lv2");
181 newVar +=
wxT(
":/usr/local/lib64/lv2");
182 newVar +=
wxT(
":/usr/lib64/lv2");
184 newVar +=
wxT(
":/usr/local/lib/lv2");
185 newVar +=
wxT(
":/usr/lib/lv2");
186 newVar +=
wxT(
":") + libdir.GetPath();
189 wxSetEnv(
wxT(
"SUIL_MODULE_DIR"),
wxT(PKGLIBDIR));
194 if(!customPaths.empty())
197 std::copy(customPaths.begin(), customPaths.end(), std::back_inserter(wxarr));
198 newVar += wxString::Format(
";%s", wxJoin(wxarr,
';'));
204 pathVar = newVar.Mid(1);
208 wxSetEnv(
wxT(
"LV2_PATH"), pathVar);
219 LILV_FOREACH(plugins, i, plugs)
221 const LilvPlugin *plug = lilv_plugins_get(plugs, i);
222 const LilvNode *cls = lilv_plugin_class_get_uri(lilv_plugin_get_class(plug));
227 if (lilv_node_equals(cls, node_InstrumentPlugin) ||
228 lilv_node_equals(cls, node_MIDIPlugin) ||
229 lilv_node_equals(cls, node_MathConstants) ||
230 lilv_node_equals(cls, node_MathFunctions))
232 wxLogInfo(
wxT(
"LV2 plugin '%s' has unsupported type '%s'"), lilv_node_as_string(lilv_plugin_get_uri(plug)), lilv_node_as_string(cls));
237 if (!
name || !lilv_plugin_get_port_by_index(plug, 0))
239 wxLogInfo(
wxT(
"LV2 plugin '%s' is invalid"), lilv_node_as_string(lilv_plugin_get_uri(plug)));
243 plugins.push_back(
LilvString(lilv_plugin_get_uri(plug)));
258 callback(
this, &effect );
263 errMsg =
XO(
"Could not load the library");
267std::unique_ptr<ComponentInterface>
273 result->InitializePlugin();
290 if(
auto lv2effect =
dynamic_cast<LV2EffectBase*
>(&pluginInterface))
292 LV2_Atom_Forge forge;
293 lv2_atom_forge_init(&forge, lv2effect->mFeatures.URIDMapFeature());
298 auto settings = lv2effect->MakeSettings();
308 throw std::runtime_error(
"Cannot create LV2 instance");
312 throw std::runtime_error(
"Not a LV2Effect");
319 return std::make_unique<LV2PluginValidator>();
331 return lilv_plugins_get_by_uri(
332 lilv_world_get_all_plugins(
gWorld), uri.get());
const TranslatableString name
std::vector< PluginPath > PluginPaths
wxString PluginPath
type alias for identifying a Plugin supplied by a module, each module defining its own interpretation...
#define LV2EFFECTS_FAMILY
#define LV2EFFECTS_VERSION
wxString LilvString(const LilvNode *node)
Lilv_ptr< LilvNode, lilv_node_free > LilvNodePtr
DECLARE_BUILTIN_PROVIDER(LV2sEffectBuiltin)
DECLARE_PROVIDER_ENTRY(AudacityModule)
std::unordered_map< wxString, LilvNode * > UriHash
Defines the module to handle the LV2 effect protocol.
static Settings & settings()
ComponentInterface provides name / vendor / version functions to identify plugins....
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
std::vector< LV2_Feature > mFeatures
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
TranslatableString GetDescription() const override
bool CheckPluginExist(const PluginPath &path) const override
Performs plugin/module existence check, still plugin may fail to load. Implementation should avoid lo...
unsigned DiscoverPluginsAtPath(const PluginPath &path, TranslatableString &errMsg, const RegistrationCallback &callback) override
virtual ~LV2EffectsModule()
void Terminate() override
Called just prior to deletion to allow releasing any resources.
void AutoRegisterPlugins(PluginManagerInterface &pm) override
Called so that a provider of a static set of plug-ins can register them.
EffectFamilySymbol GetOptionalFamilySymbol() override
A symbol identifying the family of plug-ins provided by this.
PluginPaths FindModulePaths(PluginManagerInterface &pm) override
bool Initialize() override
Called immediately after creation. Let provider initialize.
wxString GetVersion() const override
bool SupportsCustomModulePaths() const override
PluginPath GetPath() const override
std::unique_ptr< Validator > MakeValidator() const override
std::unique_ptr< ComponentInterface > LoadPlugin(const PluginPath &path) override
Load the plug-in at a path reported by DiscoverPluginsAtPath.
const FileExtensions & GetFileExtensions() override
File types associated with this protocol.
VendorSymbol GetVendor() const override
ComponentInterfaceSymbol GetSymbol() const override
static const LilvPlugin * GetPlugin(const PluginPath &path)
static std::unique_ptr< LV2Wrapper > Create(LV2InstanceFeaturesList &baseFeatures, const LV2Ports &ports, LV2PortStates &portStates, const LV2EffectSettings &settings, float sampleRate, EffectOutputs *pOutputs)
Factory.
virtual PluginPaths ReadCustomPaths(const PluginProvider &provider)=0
std::function< const PluginID &(PluginProvider *, ComponentInterface *) > RegistrationCallback
Further expand a path reported by FindModulePaths.
Holds a msgid for the translation catalog; may also bind format arguments.
void Validate(ComponentInterface &pluginInterface) override
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
void FinalizeGWorld()
Call at end of session.
URIDLIST bool InitializeGWorld()
Call before any use of the constants defined in this file.
DynamicRangeProcessorSettings GetSettings(EffectSettingsAccess &access)
void copy(const T *src, T *dst, int32_t n)