From 1b369be614511a5f21dde1700174452cb7e7fab0 Mon Sep 17 00:00:00 2001 From: Leland Lucius Date: Fri, 12 Jun 2015 23:10:23 -0500 Subject: [PATCH] Fix (hopefully final) for bug #1010. --- include/audacity/PluginInterface.h | 2 +- src/effects/ladspa/LadspaEffect.cpp | 93 +++++++++++++++++++++-------- src/effects/ladspa/LadspaEffect.h | 2 +- src/effects/nyquist/LoadNyquist.cpp | 58 +++++++++++++++++- 4 files changed, 127 insertions(+), 28 deletions(-) diff --git a/include/audacity/PluginInterface.h b/include/audacity/PluginInterface.h index 9b254108d..385454ef5 100644 --- a/include/audacity/PluginInterface.h +++ b/include/audacity/PluginInterface.h @@ -56,7 +56,7 @@ class PluginManagerInterface public: virtual ~PluginManagerInterface() {}; - virtual bool IsPluginRegistered(const PluginID & ID) = 0; + virtual bool IsPluginRegistered(const wxString & path) = 0; virtual const PluginID & RegisterPlugin(ModuleInterface *module) = 0; virtual const PluginID & RegisterPlugin(ModuleInterface *provider, EffectIdentInterface *effect) = 0; diff --git a/src/effects/ladspa/LadspaEffect.cpp b/src/effects/ladspa/LadspaEffect.cpp index 2e979595e..d1180d449 100644 --- a/src/effects/ladspa/LadspaEffect.cpp +++ b/src/effects/ladspa/LadspaEffect.cpp @@ -53,6 +53,14 @@ effects from this one class. #include "../../ShuttleGui.h" #include "../../widgets/valnum.h" +// ============================================================================ +// List of effects that ship with Audacity. These will be autoregistered. +// ============================================================================ +const static wxChar *kShippedEffects[] = +{ + wxT("sc4_1882.dll"), +}; + // ============================================================================ // Module registration entry point // @@ -144,34 +152,36 @@ void LadspaEffectsModule::Terminate() return; } -bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & WXUNUSED(pm)) +bool LadspaEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) { + // Autoregister effects that we "think" are ones that have been shipped with + // Audacity. A little simplistic, but it should suffice for now. + wxArrayString pathList = GetSearchPaths(); + wxArrayString files; + + for (int i = 0; i < WXSIZEOF(kShippedEffects); i++) + { + files.Clear(); + pm.FindFilesInPathList(kShippedEffects[i], pathList, files); + for (size_t j = 0, cnt = files.GetCount(); j < cnt; j++) + { + if (!pm.IsPluginRegistered(files[j])) + { + RegisterPlugin(pm, files[j]); + } + } + } + + // We still want to be called during the normal registration process return false; } wxArrayString LadspaEffectsModule::FindPlugins(PluginManagerInterface & pm) { - wxArrayString pathList; + wxArrayString pathList = GetSearchPaths(); wxArrayString files; - wxString pathVar; - - // Check for the LADSPA_PATH environment variable - pathVar = wxString::FromUTF8(getenv("LADSPA_PATH")); - if (!pathVar.empty()) - { - wxStringTokenizer tok(pathVar); - while (tok.HasMoreTokens()) - { - pathList.Add(tok.GetNextToken()); - } - } #if defined(__WXMAC__) -#define LADSPAPATH wxT("/Library/Audio/Plug-Ins/LADSPA") - - // Look in ~/Library/Audio/Plug-Ins/LADSPA and /Library/Audio/Plug-Ins/LADSPA - pathList.Add(wxGetHomeDir() + wxFILE_SEP_PATH + LADSPAPATH); - pathList.Add(LADSPAPATH); // Recursively scan for all shared objects pm.FindFilesInPathList(wxT("*.so"), pathList, files, true); @@ -183,11 +193,6 @@ wxArrayString LadspaEffectsModule::FindPlugins(PluginManagerInterface & pm) #else - pathList.Add(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".ladspa")); - pathList.Add(wxT("/usr/local/lib/ladspa")); - pathList.Add(wxT("/usr/lib/ladspa")); - pathList.Add(wxT(LIBDIR) wxT("/ladspa")); - // Recursively scan for all shared objects pm.FindFilesInPathList(wxT("*.so"), pathList, files, true); @@ -270,6 +275,46 @@ void LadspaEffectsModule::DeleteInstance(IdentInterface *instance) } } +wxArrayString LadspaEffectsModule::GetSearchPaths() +{ + wxArrayString pathList; + wxArrayString files; + wxString pathVar; + + // Check for the LADSPA_PATH environment variable + pathVar = wxString::FromUTF8(getenv("LADSPA_PATH")); + if (!pathVar.empty()) + { + wxStringTokenizer tok(pathVar); + while (tok.HasMoreTokens()) + { + pathList.Add(tok.GetNextToken()); + } + } + +#if defined(__WXMAC__) +#define LADSPAPATH wxT("/Library/Audio/Plug-Ins/LADSPA") + + // Look in ~/Library/Audio/Plug-Ins/LADSPA and /Library/Audio/Plug-Ins/LADSPA + pathList.Add(wxGetHomeDir() + wxFILE_SEP_PATH + LADSPAPATH); + pathList.Add(LADSPAPATH); + +#elif defined(__WXMSW__) + + // No special paths...probably should look in %CommonProgramFiles%\LADSPA + +#else + + pathList.Add(wxGetHomeDir() + wxFILE_SEP_PATH + wxT(".ladspa")); + pathList.Add(wxT("/usr/local/lib/ladspa")); + pathList.Add(wxT("/usr/lib/ladspa")); + pathList.Add(wxT(LIBDIR) wxT("/ladspa")); + +#endif + + return pathList; +} + /////////////////////////////////////////////////////////////////////////////// // // LadspaEffectOptionsDialog diff --git a/src/effects/ladspa/LadspaEffect.h b/src/effects/ladspa/LadspaEffect.h index 43551d84f..995d1a8c6 100644 --- a/src/effects/ladspa/LadspaEffect.h +++ b/src/effects/ladspa/LadspaEffect.h @@ -233,7 +233,7 @@ public: // LadspaEffectModule implementation - static void Check(const wchar_t *path); + wxArrayString GetSearchPaths(); private: ModuleManagerInterface *mModMan; diff --git a/src/effects/nyquist/LoadNyquist.cpp b/src/effects/nyquist/LoadNyquist.cpp index 54f8fcf62..06418442a 100644 --- a/src/effects/nyquist/LoadNyquist.cpp +++ b/src/effects/nyquist/LoadNyquist.cpp @@ -16,6 +16,37 @@ #include "LoadNyquist.h" +// ============================================================================ +// List of effects that ship with Audacity. These will be autoregistered. +// ============================================================================ +const static wxChar *kShippedEffects[] = +{ + wxT("adjustable-fade.ny"), + wxT("beat.ny"), + wxT("clicktrack.ny"), + wxT("clipfix.ny"), + wxT("crossfadeclips.ny"), + wxT("crossfadetracks.ny"), + wxT("delay.ny"), + wxT("equalabel.ny"), + wxT("highpass.ny"), + wxT("limiter.ny"), + wxT("lowpass.ny"), + wxT("notch.ny"), + wxT("pluck.ny"), + wxT("rissetdrum.ny"), + wxT("sample-data-export.ny"), + wxT("SilenceMarker.ny"), + wxT("SoundFinder.ny"), + wxT("SpectralEditMulti.ny"), + wxT("SpectralEditParametricEQ.ny"), + wxT("SpectralEditShelves.ny"), + wxT("StudioFadeOut.ny"), + wxT("tremolo.ny"), + wxT("vocalremover.ny"), + wxT("vocoder.ny"), +}; + // ============================================================================ // Module registration entry point // @@ -125,9 +156,32 @@ void NyquistEffectsModule::Terminate() return; } -bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & WXUNUSED(pm)) +bool NyquistEffectsModule::AutoRegisterPlugins(PluginManagerInterface & pm) { - // Nothing to do here + // Autoregister effects that we "think" are ones that have been shipped with + // Audacity. A little simplistic, but it should suffice for now. + wxArrayString pathList = NyquistEffect::GetNyquistSearchPath(); + wxArrayString files; + + if (!pm.IsPluginRegistered(NYQUIST_PROMPT_ID)) + { + RegisterPlugin(pm, NYQUIST_PROMPT_ID); + } + + for (int i = 0; i < WXSIZEOF(kShippedEffects); i++) + { + files.Clear(); + pm.FindFilesInPathList(kShippedEffects[i], pathList, files); + for (size_t j = 0, cnt = files.GetCount(); j < cnt; j++) + { + if (!pm.IsPluginRegistered(files[j])) + { + RegisterPlugin(pm, files[j]); + } + } + } + + // We still want to be called during the normal registration process return false; }