/********************************************************************** Audacity: A Digital Audio Editor LoadLadspa.cpp Dominic Mazzoni From the ladspa docs: "To allow multiple hosts to share plugin types, hosts may wish to check for environment variable LADSPA_PATH. If present, this should contain a colon-separated path indicating directories that should be searched (in order) when loading plugin types." **********************************************************************/ #define descriptorFnName "ladspa_descriptor" #include #include #include #include #include #include "ladspa.h" #include "../../Audacity.h" #include "../../AudacityApp.h" #include "../../Internat.h" #include "LadspaEffect.h" void LoadLadspaEffect(wxSortedArrayString &uniq, wxString fname) { wxLogNull logNo; LADSPA_Descriptor_Function mainFn = NULL; // As a courtesy to some plug-ins that might be bridges to // open other plug-ins, we set the current working // directory to be the plug-in's directory. wxString saveOldCWD = ::wxGetCwd(); wxString prefix = ::wxPathOnly(fname); ::wxSetWorkingDirectory(prefix); wxDynamicLibrary* pDLL = new wxDynamicLibrary(); if (pDLL && pDLL->Load(fname, wxDL_LAZY)) { mainFn = (LADSPA_Descriptor_Function)(pDLL->GetSymbol(wxT(descriptorFnName))); } if (mainFn) { int index = 0; const LADSPA_Descriptor *data; data = mainFn(index); while(data) { wxString uniqid = wxString::Format(wxT("%08x-%s"), data->UniqueID, LAT1CTOWX(data->Label).c_str()); if (uniq.Index(uniqid) == wxNOT_FOUND) { uniq.Add(uniqid); LadspaEffect *effect = new LadspaEffect(data); Effect::RegisterEffect(effect); } // Get next plugin index++; data = mainFn(index); } } ::wxSetWorkingDirectory(saveOldCWD); } void LoadLadspaPlugins() { wxArrayString audacityPathList = wxGetApp().audacityPathList; wxArrayString pathList; wxArrayString files; wxSortedArrayString uniq; wxString pathVar; unsigned int i; pathVar = wxGetenv(wxT("LADSPA_PATH")); if (pathVar != wxT("")) wxGetApp().AddMultiPathsToPathList(pathVar, pathList); #ifdef __WXGTK__ wxGetApp().AddUniquePathToPathList(wxT(INSTALL_PREFIX) wxT("/ladspa"), pathList); wxGetApp().AddUniquePathToPathList(wxT("/usr/local/lib/ladspa"), pathList); wxGetApp().AddUniquePathToPathList(wxT("/usr/lib/ladspa"), pathList); #endif #ifdef __WXMAC__ wxGetApp().AddUniquePathToPathList(wxT("~/Library/Audio/Plug-Ins/LADSPA"), pathList); wxGetApp().AddUniquePathToPathList(wxT("/Library/Audio/Plug-Ins/LADSPA"), pathList); #endif for(i=0; i