23#pragma GCC diagnostic ignored "-Wparentheses"
34#include <wx/filename.h>
42#include <unordered_map>
57 return std::make_unique<LV2EffectsModule>();
70using UriHash = std::unordered_map<wxString, LilvNode*>;
91 return XO(
"LV2 Effects");
96 return XO(
"The Audacity Team");
107 return XO(
"Provides LV2 Effects support to Audacity");
121#if defined(__WXMAC__)
122#define LV2PATH wxT("/Library/Audio/Plug-Ins/LV2")
126 libdir.AppendDir(
wxT(
"lv2"));
128 newVar +=
wxT(
":$HOME/.lv2");
134 newVar +=
wxT(
":/usr/local/lib/lv2");
135 newVar +=
wxT(
":/usr/lib/lv2");
136 newVar +=
wxT(
":") + libdir.GetPath();
138#elif defined(__WXMSW__)
140 newVar +=
wxT(
";%APPDATA%\\LV2");
141 newVar +=
wxT(
";%COMMONPROGRAMFILES%\\LV2");
142 newVar +=
wxT(
";%COMMONPROGRAMFILES(x86)%\\LV2");
147 libdir.AssignDir(
wxT(LIBDIR));
148 libdir.AppendDir(
wxT(
"lv2"));
150 newVar +=
wxT(
":$HOME/.lv2");
152 newVar +=
wxT(
":/usr/local/lib64/lv2");
153 newVar +=
wxT(
":/usr/lib64/lv2");
155 newVar +=
wxT(
":/usr/local/lib/lv2");
156 newVar +=
wxT(
":/usr/lib/lv2");
157 newVar +=
wxT(
":") + libdir.GetPath();
160 wxSetEnv(
wxT(
"SUIL_MODULE_DIR"),
wxT(PKGLIBDIR));
165 wxGetEnv(
wxT(
"LV2_PATH"), &pathVar);
169 pathVar = newVar.Mid(1);
176 wxSetEnv(
wxT(
"LV2_PATH"), pathVar);
213 LILV_FOREACH(plugins, i, plugs)
215 const LilvPlugin *plug = lilv_plugins_get(plugs, i);
216 const LilvNode *cls = lilv_plugin_class_get_uri(lilv_plugin_get_class(plug));
221 if (lilv_node_equals(cls, node_InstrumentPlugin) ||
222 lilv_node_equals(cls, node_MIDIPlugin) ||
223 lilv_node_equals(cls, node_MathConstants) ||
224 lilv_node_equals(cls, node_MathFunctions))
226 wxLogInfo(
wxT(
"LV2 plugin '%s' has unsupported type '%s'"), lilv_node_as_string(lilv_plugin_get_uri(plug)), lilv_node_as_string(cls));
231 if (!
name || !lilv_plugin_get_port_by_index(plug, 0))
233 wxLogInfo(
wxT(
"LV2 plugin '%s' is invalid"), lilv_node_as_string(lilv_plugin_get_uri(plug)));
237 plugins.push_back(
LilvString(lilv_plugin_get_uri(plug)));
252 callback(
this, &effect );
257 errMsg =
XO(
"Could not load the library");
261std::unique_ptr<ComponentInterface>
266 auto result = std::make_unique<LV2Effect>(*plug);
267 result->InitializePlugin();
283 if(
auto lv2effect =
dynamic_cast<LV2Effect*
>(&pluginInterface))
285 LV2_Atom_Forge forge;
286 lv2_atom_forge_init(&forge, lv2effect->mFeatures.URIDMapFeature());
291 auto settings = lv2effect->MakeSettings();
301 throw std::runtime_error(
"Cannot create LV2 instance");
305 throw std::runtime_error(
"Not a LV2Effect");
311 return std::make_unique<LV2PluginValidator>();
324 return lilv_plugins_get_by_uri(
325 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
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)
void Validate(ComponentInterface &pluginInterface) override
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.
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.