Update of /cvsroot/audacity/audacity-src/src/effects/VST
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv22018/src/effects/VST
Modified Files:
LoadVST.cpp VSTEffect.cpp VSTEffect.h aeffectx.h
Log Message:
Fixes saving/loading of programs (presets) with proper handling of program
chunks
Adds better feedback for screen readers
Fixes several GUI vs non-GUI handling issues
Fixes processing of multiple tracks (now resets properly between them)
Index: VSTEffect.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/VST/VSTEffect.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- VSTEffect.cpp 21 May 2009 04:42:05 -0000 1.34
+++ VSTEffect.cpp 24 May 2009 11:31:06 -0000 1.35
@@ -42,7 +42,7 @@
#include "../../xml/XMLWriter.h"
#include "FileDialog.h"
-#include "VSTEffect.h" // This class's header file
+#include "VSTEffect.h"
///////////////////////////////////////////////////////////////////////////////
//
@@ -54,9 +54,10 @@
{
public:
[...964 lines suppressed...]
+{
+ switch (opcode)
+ {
+ case audioMasterPinConnected:
+ return (index < mChannels ? 0 : 1);
+ default:
+#if defined(__WXDEBUG__)
+ wxPrintf(wxT("effect: %p opcode: %d index: %d value: %d ptr: %p opt:
%f user: %p\n"),
+ effect, opcode, index, value, ptr, opt, effect->user);
+#endif
+ return 0;
+ }
+
+}
+
+#endif // USE_VST
// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
Index: VSTEffect.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/VST/VSTEffect.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- VSTEffect.h 20 May 2009 06:33:45 -0000 1.16
+++ VSTEffect.h 24 May 2009 11:31:06 -0000 1.17
@@ -30,6 +30,8 @@
typedef float (*getParameterFn)(AEffect * effect, long index);
+typedef AEffect *(*vstPluginMain)(audioMasterCallback audioMaster);
+
class VSTEffect:public Effect
{
public:
@@ -53,6 +55,11 @@
virtual void End();
+ // Utility methods
+
+ wxString GetString(int opcode, int index = 0);
+ void SetString(int opcode, const wxString & str, int index = 0);
+
// VST methods
long callDispatcher(long opcode, long index, long value, void *ptr, float
opt);
@@ -61,8 +68,15 @@
void callSetParameter(long index, float parameter);
float callGetParameter(long index);
- private:
+ // VST callback
+ long int audioMaster(AEffect * effect,
+ long int opcode,
+ long int index,
+ long int value,
+ void * ptr,
+ float opt);
+ private:
bool ProcessStereo(int count,
WaveTrack *left,
WaveTrack *right,
@@ -78,12 +92,11 @@
wxString mName;
sampleCount mBlockSize;
- float *mBuffer;
float **mInBuffer;
float **mOutBuffer;
int mInputs;
int mOutputs;
- int mNumParameters;
+ int mChannels;
};
#endif // USE_VST
Index: aeffectx.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/VST/aeffectx.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- aeffectx.h 20 May 2009 06:33:45 -0000 1.3
+++ aeffectx.h 24 May 2009 11:31:06 -0000 1.4
@@ -85,6 +85,7 @@
const int effFlagsHasEditor = 1;
const int effFlagsCanReplacing = 1 << 4; // very likely
+const int effFlagsProgramChunks = 1 << 5; // from Ardour
const int effFlagsIsSynth = 1 << 8; // currently unused
const int effOpen = 0;
@@ -106,6 +107,8 @@
const int effEditClose = 15;
const int effEditIdle = 19;
const int effEditTop = 20;
+const int effGetChunk = 23; // from Ardour
+const int effSetChunk = 24; // from Ardour
const int effProcessEvents = 25;
// The next one was gleaned from
http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effGetProgramNameIndexed = 29;
Index: LoadVST.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/VST/LoadVST.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- LoadVST.cpp 21 May 2009 04:25:59 -0000 1.2
+++ LoadVST.cpp 24 May 2009 11:31:06 -0000 1.3
@@ -34,9 +34,23 @@
extern "C" {
#endif
-static long audioMaster(AEffect * effect, long opcode, long index,
- long value, void * ptr, float opt)
+typedef AEffect *(*vstPluginMain)(audioMasterCallback audioMaster);
+
+static long int audioMaster(AEffect * effect,
+ long int opcode,
+ long int index,
+ long int value,
+ void * ptr,
+ float opt)
{
+ // Forward to VSTEffect if it's active
+ if (effect && effect->user) {
+ VSTEffect *vst = (VSTEffect *) effect->user;
+ return vst->audioMaster(effect, opcode, index, value, ptr, opt);
+ }
+
+ // Handles operations during initialization...before VSTEffect has had a
+ // chance to set its instance pointer.
switch (opcode)
{
case audioMasterVersion:
@@ -52,31 +66,33 @@
default:
#if defined(__WXDEBUG__)
- wxPrintf(wxT("effect: %p opcode: %d index: %d value: %d ptr: %p opt:
%f\n"),
- effect, opcode, index, value, ptr, opt);
- wxLogDebug(wxT("effect: %p opcode: %d index: %d value: %d ptr: %p
opt: %f"),
- effect, opcode, index, value, ptr, opt);
+ wxPrintf(wxT("effect: %p opcode: %d index: %d value: %d ptr: %p opt:
%f user: %p\n"),
+ effect, opcode, index, value, ptr, opt, effect->user);
+ wxLogDebug(wxT("effect: %p opcode: %d index: %d value: %d ptr: %p
opt: %f user: %p"),
+ effect, opcode, index, value, ptr, opt, effect->user);
#endif
return 0;
}
}
-typedef AEffect *(*vstPluginMain)(audioMasterCallback audioMaster);
-
static void LoadVSTPlugin(const wxString & fname)
{
vstPluginMain pluginMain;
void *module = NULL;
#if defined(__WXDEBUG__)
- wxPrintf(wxT("%s\n"), fname.c_str());
- wxLogDebug(wxT("%s"), fname.c_str());
+// wxPrintf(wxT("%s\n"), fname.c_str());
+// wxLogDebug(wxT("%s"), fname.c_str());
#endif
#if defined(__WXMAC__)
+
+ // Remove the 'Contents/Info.plist' portion of the name and create a
+ // CFString
wxString name(wxPathOnly(wxPathOnly(fname)));
wxMacCFStringHolder path(name);
+ // Convert the path to a URL
CFURLRef urlRef =
CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
path,
@@ -86,59 +102,84 @@
return;
}
+ // Create the bundle using the URL
CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorDefault, urlRef);
+ // Done with the URL
CFRelease(urlRef);
+ // Bail if the bundle wasn't created
if (bundleRef == NULL) {
return;
}
+ // Try to locate the new plugin entry point
pluginMain = (vstPluginMain)
CFBundleGetFunctionPointerForName(bundleRef,
CFSTR("VSTPluginMain"));
+
+ // If not found, try finding the old entry point
if (pluginMain == NULL) {
pluginMain = (vstPluginMain)
CFBundleGetFunctionPointerForName(bundleRef,
CFSTR("main_macho"));
}
+ // Must not be a VST plugin
if (pluginMain == NULL) {
CFRelease(bundleRef);
return;
}
+ // Save the bundle reference
module = bundleRef;
+
#else
+
+ // Try to load the library
wxDynamicLibrary *lib = new wxDynamicLibrary(fname);
if (!lib) {
return;
}
+ // Bail if it wasn't successful
if (!lib->IsLoaded()) {
delete lib;
return;
}
- pluginMain = (vstPluginMain) lib->GetSymbol(wxT("main"));
- if (pluginMain == NULL) {
- delete lib;
- return;
+ // Try to find the entry point, while suppressing error messages
+ {
+ wxLogNull logNo;
+ pluginMain = (vstPluginMain) lib->GetSymbol(wxT("main"));
+ if (pluginMain == NULL) {
+ delete lib;
+ return;
+ }
}
+ // Save the library reference
module = lib;
+
#endif
+ // Initialize the plugin
AEffect *aeffect = pluginMain(audioMaster);
+ // Was it successful?
if (aeffect) {
+
+ // Ensure that it looks like a plugin and can deal with ProcessReplacing
+ // calls. Also exclude synths for now.
if (aeffect->magic == kEffectMagic &&
!(aeffect->flags & effFlagsIsSynth) &&
aeffect->flags & effFlagsCanReplacing) {
+ // Looks good...try to create the VSTEffect
VSTEffect *vst = new VSTEffect(fname, module, aeffect);
if (vst != NULL) {
+ // Success...register it and get out
EffectManager::Get().RegisterEffect(vst);
return;
}
@@ -153,6 +194,8 @@
#endif
}
+ // Only way we can get here is if something went wrong...clean up
+
#if defined(__WXMAC__)
CFRelease(bundleRef);
#else
@@ -165,9 +208,14 @@
wxArrayString audacityPathList = wxGetApp().audacityPathList;
wxArrayString pathList;
wxArrayString files;
-
+
+ // Check for the VST_PATH environment variable
wxString vstpath = wxGetenv(wxT("VST_PATH"));
+ if (!vstpath.IsEmpty()) {
+ wxGetApp().AddUniquePathToPathList(vstpath, pathList);
+ }
+ // Add Audacity specific paths
for (size_t i = 0; i < audacityPathList.GetCount(); i++) {
wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
wxGetApp().AddUniquePathToPathList(prefix + wxT("VST"),
@@ -180,21 +228,27 @@
#if defined(__WXMAC__)
#define VSTPATH wxT("/Library/Audio/Plug-Ins/VST")
+
+ // Look in /Library/Audio/Plug-Ins/VST and $HOME/Library/Audio/Plug-Ins/VST
wxGetApp().AddUniquePathToPathList(VSTPATH, pathList);
wxGetApp().AddUniquePathToPathList(wxString(wxGetenv(wxT("HOME"))) +
VSTPATH,
pathList);
+ // Recursively search all paths for Info.plist files. This will identify
all
+ // bundles.
wxGetApp().FindFilesInPathList(wxT("Info.plist"), pathList, files,
wxDIR_DEFAULT);
#elif defined(__WXMSW__)
TCHAR dpath[MAX_PATH];
TCHAR tpath[MAX_PATH];
DWORD len = sizeof(tpath);
+ // Setup the default VST path.
dpath[0] = '\0';
ExpandEnvironmentStrings(_T("%ProgramFiles%\\Steinberg\\VSTPlugins"),
dpath,
sizeof(dpath));
+ // Check registry for the real path
if (SHRegGetUSValue(_T("Software\\VST"),
_T("VSTPluginsPath"),
NULL,
@@ -208,11 +262,17 @@
wxGetApp().AddUniquePathToPathList(LAT1CTOWX(dpath), pathList);
}
+ // Recursively scan for all DLLs
wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files,
wxDIR_DEFAULT);
+
#else
+
+ // Recursively scan for all shared objects
wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files);
+
#endif
+ // Try loading everything found
for (size_t i = 0; i < files.GetCount(); i++) {
LoadVSTPlugin(files[i]);
}
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs