void VSTPlugin::FreePlugin() { #if FLEXT_OS == FLEXT_OS_WIN if(hdll) { FreeLibrary(hdll); hdll = NULL; } #elif FLEXT_OS == FLEXT_OS_MAC #ifdef __CFM__ if(audiomaster) DisposeCFMFromMachO(audiomaster); if(pluginmain) DisposeMachOFromCFM(pluginmain); #endif if(hdll) { CFBundleUnloadExecutable(hdll); CFRelease(hdll); hdll = NULL; } #else #error Platform not supported #endif effect = NULL; audiomaster = NULL; pluginmain = NULL; }
void LoadVSTPlugins() { #ifdef __MACOSX__ audioMasterCallback audioMasterFPtr = (audioMasterCallback)NewCFMFromMachO(audioMaster); #else // What is the corrct way of creating an audioMasterCallback // in OS 9/Carbon??? // audioMasterCallback audioMasterFPtr = NULL; audioMasterCallback audioMasterFPtr = audioMaster; #endif wxArrayString audacityPathList = wxGetApp().audacityPathList; wxArrayString pathList; wxArrayString files; unsigned int i; for(i=0; i<audacityPathList.GetCount(); i++) { wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH; wxGetApp().AddUniquePathToPathList(prefix + "VST", pathList); wxGetApp().AddUniquePathToPathList(prefix + "Plugins", pathList); wxGetApp().AddUniquePathToPathList(prefix + "Plug-Ins", pathList); } #ifdef __MACOSX__ wxGetApp().AddUniquePathToPathList("/Library/Audio/Plug-Ins/VST", pathList); wxString vstPath; vstPath.Printf("/Users/%s/Library/Audio/Plug-Ins/VST", wxGetenv("USER")); wxGetApp().AddUniquePathToPathList(vstPath, pathList); #endif wxGetApp().FindFilesInPathList("*", pathList, wxFILE, files); for(i=0; i<files.GetCount(); i++) { short resFileID; FSSpec spec; wxMacFilename2FSSpec(FILENAME(files[i]), &spec); resFileID = FSpOpenResFile(&spec, fsRdPerm); short cResCB = Count1Resources('aEff'); for (int i = 0; i < cResCB; i++) { Handle codeH; CFragConnectionID connID; Ptr mainAddr; Str255 errName; Str255 fragName; char fragNameCStr[256]; short resID; OSType resType; OSErr err; codeH = Get1IndResource('aEff', short(i+1)); if (!codeH) continue; GetResInfo(codeH, &resID, &resType, fragName); DetachResource(codeH); HLock(codeH); err = GetMemFragment(*codeH, GetHandleSize(codeH), fragName, kPrivateCFragCopy, &connID, (Ptr *) & mainAddr, errName); if (!err) { vstPluginMain pluginMain; AEffect *theEffect; #ifdef __MACOSX__ pluginMain = (vstPluginMain)NewMachOFromCFM(mainAddr); #else pluginMain = (vstPluginMain)mainAddr; #endif theEffect = pluginMain(audioMasterFPtr); if (theEffect->magic == kEffectMagic) { memcpy(fragNameCStr, &fragName[1], fragName[0]); fragNameCStr[fragName[0]] = 0; VSTEffect *vst = new VSTEffect(wxString(fragNameCStr), theEffect); Effect::RegisterEffect(vst); } #ifdef __MACOSX__ DisposeMachOFromCFM(pluginMain); #endif audacityVSTID++; } } CloseResFile(resFileID); } #ifdef __MACOSX__ DisposeCFMFromMachO(audioMasterFPtr); #endif // __MACOSX__ }