20#pragma GCC diagnostic ignored "-Wparentheses"
31#include <wx/filename.h>
38#include <unordered_map>
53 return std::make_unique<LV2EffectsModule>();
66using UriHash = std::unordered_map<wxString, LilvNode*>;
87 return XO(
"LV2 Effects");
92 return XO(
"The Audacity Team");
103 return XO(
"Provides LV2 Effects support to Audacity");
117#if defined(__WXMAC__)
118#define LV2PATH wxT("/Library/Audio/Plug-Ins/LV2")
122 libdir.AppendDir(
wxT(
"lv2"));
124 newVar +=
wxT(
":$HOME/.lv2");
130 newVar +=
wxT(
":/usr/local/lib/lv2");
131 newVar +=
wxT(
":/usr/lib/lv2");
132 newVar +=
wxT(
":") + libdir.GetPath();
134#elif defined(__WXMSW__)
136 newVar +=
wxT(
";%APPDATA%\\LV2");
137 newVar +=
wxT(
";%COMMONPROGRAMFILES%\\LV2");
138 newVar +=
wxT(
";%COMMONPROGRAMFILES(x86)%\\LV2");
143 libdir.AssignDir(
wxT(LIBDIR));
144 libdir.AppendDir(
wxT(
"lv2"));
146 newVar +=
wxT(
":$HOME/.lv2");
148 newVar +=
wxT(
":/usr/local/lib64/lv2");
149 newVar +=
wxT(
":/usr/lib64/lv2");
151 newVar +=
wxT(
":/usr/local/lib/lv2");
152 newVar +=
wxT(
":/usr/lib/lv2");
153 newVar +=
wxT(
":") + libdir.GetPath();
156 wxSetEnv(
wxT(
"SUIL_MODULE_DIR"),
wxT(PKGLIBDIR));
161 wxGetEnv(
wxT(
"LV2_PATH"), &pathVar);
165 pathVar = newVar.Mid(1);
172 wxSetEnv(
wxT(
"LV2_PATH"), pathVar);
209 LILV_FOREACH(plugins, i, plugs)
211 const LilvPlugin *plug = lilv_plugins_get(plugs, i);
212 const LilvNode *cls = lilv_plugin_class_get_uri(lilv_plugin_get_class(plug));
217 if (lilv_node_equals(cls, node_InstrumentPlugin) ||
218 lilv_node_equals(cls, node_MIDIPlugin) ||
219 lilv_node_equals(cls, node_MathConstants) ||
220 lilv_node_equals(cls, node_MathFunctions))
222 wxLogInfo(
wxT(
"LV2 plugin '%s' has unsupported type '%s'"), lilv_node_as_string(lilv_plugin_get_uri(plug)), lilv_node_as_string(cls));
227 if (!
name || !lilv_plugin_get_port_by_index(plug, 0))
229 wxLogInfo(
wxT(
"LV2 plugin '%s' is invalid"), lilv_node_as_string(lilv_plugin_get_uri(plug)));
233 plugins.push_back(
LilvString(lilv_plugin_get_uri(plug)));
248 callback(
this, &effect );
253 errMsg =
XO(
"Could not load the library");
257std::unique_ptr<ComponentInterface>
263 result->InitializePlugin();
280 if(
auto lv2effect =
dynamic_cast<LV2EffectBase*
>(&pluginInterface))
282 LV2_Atom_Forge forge;
283 lv2_atom_forge_init(&forge, lv2effect->mFeatures.URIDMapFeature());
288 auto settings = lv2effect->MakeSettings();
298 throw std::runtime_error(
"Cannot create LV2 instance");
302 throw std::runtime_error(
"Not a LV2Effect");
309 return std::make_unique<LV2PluginValidator>();
322 return lilv_plugins_get_by_uri(
323 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
LV2EffectSettings & GetSettings(EffectSettings &settings)
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
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.
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.