Update of /cvsroot/audacity/audacity-src/src/effects/VST
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv10530/src/effects/VST

Modified Files:
        VSTEffect.cpp VSTEffect.h 
Added Files:
        LoadVST.cpp LoadVST.h aeffectx.h 
Removed Files:
        LoadVSTMac.cpp LoadVSTMac.h LoadVSTWin.cpp LoadVSTWin.h 
Log Message:
First go at GUI VST support using the VeSTige aeffects.h header.


--- LoadVSTMac.h DELETED ---

--- LoadVSTMac.cpp DELETED ---

--- LoadVSTWin.h DELETED ---

Index: VSTEffect.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/VST/VSTEffect.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- VSTEffect.h 4 Jun 2008 19:10:50 -0000       1.15
+++ VSTEffect.h 20 May 2009 06:33:45 -0000      1.16
@@ -12,15 +12,11 @@
 
 #if USE_VST
 
-#include "AudioEffect.hpp"      // VST API
-
-class wxSlider;
-class labels;
+#include "../Effect.h"
 
-#include <wx/dialog.h>
-#include <wx/stattext.h>
+#include "aeffectx.h"
 
-#include "../Effect.h"
+#define audacityVSTID CCONST('a', 'u', 'D', 'y');
 
 typedef long (*dispatcherFn)(AEffect * effect, long opCode,
                              long index, long value, void *ptr,
@@ -34,23 +30,20 @@
 
 typedef float (*getParameterFn)(AEffect * effect, long index);
 
-class VSTEffect:public Effect {
-
+class VSTEffect:public Effect
+{
  public:
 
-   VSTEffect(wxString pluginName, AEffect * aEffect);
-
+   VSTEffect(const wxString & path, void *module, AEffect * aeffect);
    virtual ~VSTEffect();
 
    virtual wxString GetEffectName();
-   
+
+   virtual wxString GetEffectIdentifier();
+
    virtual std::set<wxString> GetEffectCategories();
 
    virtual wxString GetEffectAction();
-   
-   virtual int GetEffectFlags() {
-      return PLUGIN_EFFECT | PROCESS_EFFECT;
-   }
 
    virtual bool Init();
 
@@ -62,75 +55,37 @@
 
    // VST methods
 
-   long callDispatcher(AEffect * effect, long opCode,
-                       long index, long value, void *ptr,
-                       float opt);
-   void callProcess(AEffect * effect, float **inputs,
-                    float **outputs, long sampleframes);
-   void callProcessReplacing(AEffect * effect, float **inputs,
-                             float **outputs, long sampleframes);
-   void callSetParameter(AEffect * effect, long index,
-                         float parameter);
-   float callGetParameter(AEffect * effect, long index);
+   long callDispatcher(long opcode, long index, long value, void *ptr, float 
opt);
+   void callProcess(float **inputs, float **outputs, long sampleframes);
+   void callProcessReplacing(float **inputs, float **outputs, long 
sampleframes);
+   void callSetParameter(long index, float parameter);
+   float callGetParameter(long index);
 
  private:
-   bool ProcessStereo(int count, WaveTrack * left, WaveTrack *right,
-                      longSampleCount lstart,
-                      longSampleCount rstart, sampleCount len);
 
-   void GetSamples(WaveTrack *track,
-                   longSampleCount *start,
-                   sampleCount *len);
-      
-   bool isOpened;
-   wxString pluginName;
-   AEffect *aEffect;
-
-   sampleCount mBlockSize;
-   float *buffer;
-   float **fInBuffer;
-   float **fOutBuffer;
-   int inputs;
-   int outputs;
-   int numParameters;
-};
-
-class VSTEffectDialog:public wxDialog {
- public:
-   VSTEffectDialog(wxWindow * parent,
-                   wxString effectName,
-                   int numParams,
-                   VSTEffect * vst,
-                   AEffect * aEffect,
-                   const wxPoint & pos = wxDefaultPosition);
-
-   ~VSTEffectDialog();
+   bool ProcessStereo(int count,
+                      WaveTrack *left,
+                      WaveTrack *right,
+                      sampleCount lstart,
+                      sampleCount rstart,
+                      sampleCount len);
 
-   void OnSlider(wxScrollEvent & event);
-   void OnSliderCmd(wxCommandEvent & event);
-   void OnOK(wxCommandEvent & event);
-   void OnCancel(wxCommandEvent & event);
-   void OnPreview(wxCommandEvent & event);
+   wxString mPath;
+   void *mModule;
+   AEffect *mAEffect;
 
-   DECLARE_EVENT_TABLE()
+   wxString mVendor;
+   wxString mName;
 
- private:
-   VSTEffect * vst;
-   AEffect * aEffect;
-   wxSlider **sliders;
-   wxStaticText **labels;
-   int numParams;
+   sampleCount mBlockSize;
+   float *mBuffer;
+   float **mInBuffer;
+   float **mOutBuffer;
+   int mInputs;
+   int mOutputs;
+   int mNumParameters;
 };
 
-#if defined(__WXMAC__) && defined(__UNIX__)
-
-void *NewMachOFromCFM(void *cfmfp);
-void DisposeMachOFromCFM(void *ptr);
-void *NewCFMFromMachO(void *machofp);
-void DisposeCFMFromMachO(void *ptr);
-
-#endif
-
 #endif // USE_VST
 
 

--- NEW FILE: aeffectx.h ---
/*
 * aeffectx.h - simple header to allow VeSTige compilation and eventually work
 *
 * Copyright (c) 2006 Javier Serrano Polo <jasp00/at/users.sourceforge.net>
 * 
 * This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program (see COPYING); if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 *
 */


#ifndef _AEFFECTX_H
#define _AEFFECTX_H

#define CCONST(a, b, c, d)( ( ( (int) a ) << 24 ) |             \
                                ( ( (int) b ) << 16 ) |         \
                                ( ( (int) c ) << 8 ) |          \
                                ( ( (int) d ) << 0 ) )

const int audioMasterAutomate = 0;
const int audioMasterVersion = 1;
const int audioMasterCurrentId = 2;
const int audioMasterIdle = 3;
const int audioMasterPinConnected = 4;
// unsupported? 5
const int audioMasterWantMidi = 6;
const int audioMasterGetTime = 7;
const int audioMasterProcessEvents = 8;
const int audioMasterSetTime = 9;
const int audioMasterTempoAt = 10;
const int audioMasterGetNumAutomatableParameters = 11;
const int audioMasterGetParameterQuantization = 12;
const int audioMasterIOChanged = 13;
const int audioMasterNeedIdle = 14;
const int audioMasterSizeWindow = 15;
const int audioMasterGetSampleRate = 16;
const int audioMasterGetBlockSize = 17;
const int audioMasterGetInputLatency = 18;
const int audioMasterGetOutputLatency = 19;
const int audioMasterGetPreviousPlug = 20;
const int audioMasterGetNextPlug = 21;
const int audioMasterWillReplaceOrAccumulate = 22;
const int audioMasterGetCurrentProcessLevel = 23;
const int audioMasterGetAutomationState = 24;
const int audioMasterOfflineStart = 25;
const int audioMasterOfflineRead = 26;
const int audioMasterOfflineWrite = 27;
const int audioMasterOfflineGetCurrentPass = 28;
const int audioMasterOfflineGetCurrentMetaPass = 29;
const int audioMasterSetOutputSampleRate = 30;
// unsupported? 31
const int audioMasterGetSpeakerArrangement = 31; // deprecated in 2.4?
const int audioMasterGetVendorString = 32;
const int audioMasterGetProductString = 33;
const int audioMasterGetVendorVersion = 34;
const int audioMasterVendorSpecific = 35;
const int audioMasterSetIcon = 36;
const int audioMasterCanDo = 37;
const int audioMasterGetLanguage = 38;
const int audioMasterOpenWindow = 39;
const int audioMasterCloseWindow = 40;
const int audioMasterGetDirectory = 41;
const int audioMasterUpdateDisplay = 42;
const int audioMasterBeginEdit = 43;
const int audioMasterEndEdit = 44;
const int audioMasterOpenFileSelector = 45;
const int audioMasterCloseFileSelector = 46; // currently unused
const int audioMasterEditFile = 47; // currently unused
const int audioMasterGetChunkFile = 48; // currently unused
const int audioMasterGetInputSpeakerArrangement = 49; // currently unused

const int effFlagsHasEditor = 1;
const int effFlagsCanReplacing = 1 << 4; // very likely
const int effFlagsIsSynth = 1 << 8; // currently unused

const int effOpen = 0;
const int effClose = 1; // currently unused
const int effSetProgram = 2; // currently unused
const int effGetProgram = 3; // currently unused
// The next one was gleaned from 
http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effSetProgramName = 4;
const int effGetProgramName = 5; // currently unused
// The next two were gleaned from 
http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effGetParamLabel = 6;
const int effGetParamDisplay = 7;
const int effGetParamName = 8; // currently unused
const int effSetSampleRate = 10;
const int effSetBlockSize = 11;
const int effMainsChanged = 12;
const int effEditGetRect = 13;
const int effEditOpen = 14;
const int effEditClose = 15;
const int effEditIdle = 19;
const int effEditTop = 20;
const int effProcessEvents = 25;
// The next one was gleaned from 
http://www.kvraudio.com/forum/viewtopic.php?p=1905347
const int effGetProgramNameIndexed = 29;
const int effGetEffectName = 45;
const int effGetParameterProperties = 56; // missing
const int effGetVendorString = 47;
const int effGetProductString = 48;
const int effGetVendorVersion = 49;
const int effCanDo = 51; // currently unused
const int effGetVstVersion = 58; // currently unused

const int kEffectMagic = CCONST( 'V', 's', 't', 'P' );
const int kVstLangEnglish = 1;
const int kVstMidiType = 1;
const int kVstParameterUsesFloatStep = 1 << 2;
const int kVstTempoValid = 1 << 10;
const int kVstTransportPlaying = 1 << 1;


class remoteVstPlugin;


class VstMidiEvent
{
public:
        // 00
        int type;
        // 04
        int byteSize;
        // 08
        int deltaFrames;
        // 0c?
        int flags;
        // 10?
        int noteLength;
        // 14?
        int noteOffset;
        // 18
        char midiData[4];
        // 1c?
        char detune;
        // 1d?
        char noteOffVelocity;
        // 1e?
        char reserved1;
        // 1f?
        char reserved2;

} ;




class VstEvent
{
        char dump[sizeof( VstMidiEvent )];

} ;




class VstEvents
{
public:
        // 00
        int numEvents;
        // 04
        int reserved;
        // 08
        VstEvent * events;

} ;




// Not finished, neither really used
class VstParameterProperties
{
public:
        float stepFloat;
        char label[64];
        int flags;
        int minInteger;
        int maxInteger;
        int stepInteger;
        char shortLabel[8];
        int category;
        char categoryLabel[24];
        char empty[128];

} ;


#include <stdint.h>

class AEffect
{
public:
        // Never use virtual functions!!!
        // 00-03
        int magic;
        // dispatcher 04-07
        int (* dispatcher)( AEffect * , int , int , int , void * , float );
        // process, quite sure 08-0b
        void (* process)( AEffect * , float * * , float * * , int );
        // setParameter 0c-0f
        void (* setParameter)( AEffect * , int , float );
        // getParameter 10-13
        float (* getParameter)( AEffect * , int );
        // programs 14-17
        int numPrograms;
        // Params 18-1b
        int numParams;
        // Input 1c-1f
        int numInputs;
        // Output 20-23
        int numOutputs;
        // flags 24-27
        int flags;
        // Fill somewhere 28-2b
        void * user;
        // Zeroes 2c-2f 30-33 34-37 38-3b
        char empty3[4 + 4 + 4 + 4];
        // 1.0f 3c-3f
        float unkown_float;
        // An object? pointer 40-43
        char empty4[4];
        // Zeroes 44-47
        char empty5[4];
        // Id 48-4b
        int32_t uniqueID;
        // Don't know 4c-4f
        char unknown1[4];
        // processReplacing 50-53
        void (* processReplacing)( AEffect * , float * * , float * * , int );

} ;


class VstTimeInfo
{
public:
        // 00
        double samplePos;
        // 08
        double sampleRate;
        // unconfirmed 10 18
        char empty1[8 + 8];
        // 20?
        double tempo;
        // unconfirmed 28 30 38
        char empty2[8 + 8 + 8];
        // 40?
        int timeSigNumerator;
        // 44?
        int timeSigDenominator;
        // unconfirmed 48 4c 50
        char empty3[4 + 4 + 4];
        // 54
        int flags;

} ;




typedef long int (* audioMasterCallback)( AEffect * , long int , long int ,
                                                long int , void * , float );
// we don't use it, may be noise
#define VSTCALLBACK




#endif

--- NEW FILE: LoadVST.cpp ---
/**********************************************************************

  Audacity: A Digital Audio Editor

  LoadVST.cpp

  Dominic Mazzoni

**********************************************************************/

#include "../../Audacity.h"

#if USE_VST

#if defined(__WXMAC__)
   #include <wx/mac/private.h>
#else
   #include <wx/dynlib.h>
#endif

#if defined(__WXMSW__)
   #include <windows.h>
   #include <shlwapi.h>
   #pragma comment(lib, "shlwapi")
#endif

#include "../../AudacityApp.h"
#include "../../Internat.h"
#include "../EffectManager.h"

#include "VSTEffect.h"

#ifdef __cplusplus
extern "C" {
#endif

static long audioMaster(AEffect * effect, long opcode, long index,
                        long value, void * ptr, float opt)
{
   switch (opcode)
   {
      case audioMasterVersion:
         return 2;

      case audioMasterCurrentId:
         return audacityVSTID;

      // Ignore these
      case audioMasterIdle:
      case audioMasterWantMidi:
         return 0;

      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);
#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());
#endif

#if defined(__WXMAC__)
   wxString name(wxPathOnly(wxPathOnly(fname)));
   wxMacCFStringHolder path(name);

   CFURLRef urlRef =
      CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
                                    path,
                                    kCFURLPOSIXPathStyle,
                                    true);
   if (urlRef == NULL) {
      return;
   }

   CFBundleRef bundleRef = CFBundleCreate(kCFAllocatorDefault, urlRef);

   CFRelease(urlRef);

   if (bundleRef == NULL) {
      return;
   }

   pluginMain = (vstPluginMain)
      CFBundleGetFunctionPointerForName(bundleRef,
                                        CFSTR("VSTPluginMain"));
   if (pluginMain == NULL) {
      pluginMain = (vstPluginMain)
         CFBundleGetFunctionPointerForName(bundleRef,
                                           CFSTR("main_macho"));
   }

   if (pluginMain == NULL) {
      CFRelease(bundleRef);
      return;
   }

   module = bundleRef;
#else
   wxDynamicLibrary *lib = new wxDynamicLibrary(fname);
   if (!lib) {
      return;
   }

   if (!lib->IsLoaded()) {
      delete lib;
      return;
   }

   pluginMain = (vstPluginMain) lib->GetSymbol(wxT("main"));
   if (pluginMain == NULL) {
      delete lib;
      return;
   }

   module = lib;
#endif

   AEffect *aeffect = pluginMain(audioMaster);

   if (aeffect) {
      if (aeffect->magic == kEffectMagic &&
         !(aeffect->flags & effFlagsIsSynth) &&
         aeffect->flags & effFlagsCanReplacing) {

         VSTEffect *vst = new VSTEffect(fname, module, aeffect);
         if (vst != NULL) {

            EffectManager::Get().RegisterEffect(vst);
            return;
         }
      }
#if defined(__WXDEBUG__)
      else {
         wxPrintf(wxT("bypassing %s - magic %08x flags %08x\n"),
                  fname.c_str(), aeffect->magic, aeffect->flags);
         wxLogDebug(wxT("bypassing %s - magic %08x flags %08x"),
                    fname.c_str(), aeffect->magic, aeffect->flags);
      }
#endif
   }

#if defined(__WXMAC__)
   CFRelease(bundleRef);
#else
   delete lib;
#endif
}

void LoadVSTPlugins()
{
   wxArrayString audacityPathList = wxGetApp().audacityPathList;
   wxArrayString pathList;
   wxArrayString files;
   
   wxString vstpath = wxGetenv(wxT("VST_PATH"));

   for (size_t i = 0; i < audacityPathList.GetCount(); i++) {
      wxString prefix = audacityPathList[i] + wxFILE_SEP_PATH;
      wxGetApp().AddUniquePathToPathList(prefix + wxT("VST"),
                                         pathList);
      wxGetApp().AddUniquePathToPathList(prefix + wxT("plugins"),
                                         pathList);
      wxGetApp().AddUniquePathToPathList(prefix + wxT("plug-ins"),
                                         pathList);
   }

#if defined(__WXMAC__)
#define VSTPATH wxT("/Library/Audio/Plug-Ins/VST")
   wxGetApp().AddUniquePathToPathList(VSTPATH, pathList);
   wxGetApp().AddUniquePathToPathList(wxString(wxGetenv(wxT("HOME"))) + VSTPATH,
                                      pathList);

   wxGetApp().FindFilesInPathList(wxT("Info.plist"), pathList, files, 
wxDIR_DEFAULT);
#elif defined(__WXMSW__)
   TCHAR dpath[MAX_PATH];
   TCHAR tpath[MAX_PATH];
   DWORD len = sizeof(tpath);

   dpath[0] = '\0';
   ExpandEnvironmentStrings(_T("%ProgramFiles%\\Steinberg\\VSTPlugins"),
                            dpath,
                            sizeof(dpath));

   LSTATUS s = SHRegGetUSValue(_T("Software\\VST"),
                               _T("VSTPluginsPath"),
                               NULL,
                               tpath,
                               &len,
                               FALSE,
                               dpath,
                               (DWORD) _tcslen(dpath));
   if (s == ERROR_SUCCESS) {
      tpath[len] = 0;
      ExpandEnvironmentStrings(tpath, dpath, sizeof(dpath));
      wxGetApp().AddUniquePathToPathList(LAT1CTOWX(dpath), pathList);
   }

   wxGetApp().FindFilesInPathList(wxT("*.dll"), pathList, files, wxDIR_DEFAULT);
#else
   wxGetApp().FindFilesInPathList(wxT("*.so"), pathList, files);
#endif

   for (size_t i = 0; i < files.GetCount(); i++) {
      LoadVSTPlugin(files[i]);
   }
}

#ifdef __cplusplus
}
#endif

#else

#ifdef __cplusplus
extern "C" {
#endif

void LoadVSTPlugins()
{
   return;
}

#ifdef __cplusplus
}
#endif

#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.
//
// Local Variables:
// c-basic-offset: 3
// indent-tabs-mode: nil
// End:
//
// vim: et sts=3 sw=3
// arch-tag: d75c9c59-4f9b-4398-b4e8-11ffddc283cf


--- NEW FILE: LoadVST.h ---
/**********************************************************************

  Audacity: A Digital Audio Editor

  LoadVST.h

  Mark Tomlinson

**********************************************************************/

extern "C"
{
   void LoadVSTPlugins();
};


// Indentation settings for Vim and Emacs and unique identifier for Arch, a
// version control system. Please do not modify past this point.
//
// Local Variables:
// c-basic-offset: 3
// indent-tabs-mode: nil
// End:
//
// vim: et sts=3 sw=3
// arch-tag: 3a891fd3-bbb4-430f-8486-f2e31bc8da78

Index: VSTEffect.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/VST/VSTEffect.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- VSTEffect.cpp       4 Jun 2008 19:10:50 -0000       1.32
+++ VSTEffect.cpp       20 May 2009 06:33:45 -0000      1.33
@@ -18,237 +18,746 @@
 
 #if USE_VST
 
-#include "AEffect.h"            // VST API
-#include "AEffEditor.hpp"
-
 #include <wx/defs.h>
 #include <wx/button.h>
+#include <wx/combobox.h>
 #include <wx/dialog.h>
+#include <wx/filename.h>
[...1308 lines suppressed...]
 {
-   effect->setParameter(effect, index, parameter);
+   mAEffect->setParameter(mAEffect, index, parameter);
 }
 
-float VSTEffect::callGetParameter(AEffect * effect, long index)
+float VSTEffect::callGetParameter(long index)
 {
-   return effect->getParameter(effect, index);
+   return mAEffect->getParameter(mAEffect, index);
 }
 
-#endif // MACOSX
-
 #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.
 //

--- LoadVSTWin.cpp DELETED ---


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to