22#pragma GCC diagnostic ignored "-Wparentheses"
33#include <wx/filename.h>
40#include <unordered_map>
55 return std::make_unique<LV2EffectsModule>();
68using UriHash = std::unordered_map<wxString, LilvNode*>;
89 return XO(
"LV2 Effects");
94 return XO(
"The Audacity Team");
105 return XO(
"Provides LV2 Effects support to Audacity");
161#if defined(__WXMAC__)
162#define LV2PATH wxT("/Library/Audio/Plug-Ins/LV2")
166 libdir.AppendDir(
wxT(
"lv2"));
168 newVar +=
wxT(
":$HOME/.lv2");
174 newVar +=
wxT(
":/usr/local/lib/lv2");
175 newVar +=
wxT(
":/usr/lib/lv2");
176 newVar +=
wxT(
":") + libdir.GetPath();
178#elif defined(__WXMSW__)
180 newVar +=
wxT(
";%APPDATA%\\LV2");
181 newVar +=
wxT(
";%COMMONPROGRAMFILES%\\LV2");
182 newVar +=
wxT(
";%COMMONPROGRAMFILES(x86)%\\LV2");
187 libdir.AssignDir(
wxT(LIBDIR));
188 libdir.AppendDir(
wxT(
"lv2"));
190 newVar +=
wxT(
":$HOME/.lv2");
192 newVar +=
wxT(
":/usr/local/lib64/lv2");
193 newVar +=
wxT(
":/usr/lib64/lv2");
195 newVar +=
wxT(
":/usr/local/lib/lv2");
196 newVar +=
wxT(
":/usr/lib/lv2");
197 newVar +=
wxT(
":") + libdir.GetPath();
200 wxSetEnv(
wxT(
"SUIL_MODULE_DIR"),
wxT(PKGLIBDIR));
205 if(!customPaths.empty())
208 std::copy(customPaths.begin(), customPaths.end(), std::back_inserter(wxarr));
209 newVar += wxString::Format(
";%s", wxJoin(wxarr,
';'));
215 pathVar = newVar.Mid(1);
219 wxSetEnv(
wxT(
"LV2_PATH"), pathVar);
230 LILV_FOREACH(plugins, i, plugs)
232 const LilvPlugin *plug = lilv_plugins_get(plugs, i);
233 const LilvNode *cls = lilv_plugin_class_get_uri(lilv_plugin_get_class(plug));
238 if (lilv_node_equals(cls, node_InstrumentPlugin) ||
239 lilv_node_equals(cls, node_MIDIPlugin) ||
240 lilv_node_equals(cls, node_MathConstants) ||
241 lilv_node_equals(cls, node_MathFunctions))
243 wxLogInfo(
wxT(
"LV2 plugin '%s' has unsupported type '%s'"), lilv_node_as_string(lilv_plugin_get_uri(plug)), lilv_node_as_string(cls));
248 if (!
name || !lilv_plugin_get_port_by_index(plug, 0))
250 wxLogInfo(
wxT(
"LV2 plugin '%s' is invalid"), lilv_node_as_string(lilv_plugin_get_uri(plug)));
254 plugins.push_back(
LilvString(lilv_plugin_get_uri(plug)));
269 callback(
this, &effect );
274 errMsg =
XO(
"Could not load the library");
278std::unique_ptr<ComponentInterface>
284 result->InitializePlugin();
301 if(
auto lv2effect =
dynamic_cast<LV2EffectBase*
>(&pluginInterface))
303 LV2_Atom_Forge forge;
304 lv2_atom_forge_init(&forge, lv2effect->mFeatures.URIDMapFeature());
309 auto settings = lv2effect->MakeSettings();
319 throw std::runtime_error(
"Cannot create LV2 instance");
323 throw std::runtime_error(
"Not a LV2Effect");
330 return std::make_unique<LV2PluginValidator>();
342 return lilv_plugins_get_by_uri(
343 lilv_world_get_all_plugins(
gWorld), uri.get());
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.
static bool IsHostProcess()
Returns true if current process is considered to be a plugin host process.
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)