diff options
author | Thomas Grill <xovo@users.sourceforge.net> | 2004-11-14 03:34:32 +0000 |
---|---|---|
committer | Thomas Grill <xovo@users.sourceforge.net> | 2004-11-14 03:34:32 +0000 |
commit | 3dbf9adf38bf8a204d1fd4dfb4345f542b486933 (patch) | |
tree | 0c4810133b5ee0db3d312cc80ccaf1f1ece735ad /externals/grill | |
parent | 45464826849ab68693a3ed21c2d50ede00c50e67 (diff) |
a bit of code for OS X
editor-less Mac version
svn path=/trunk/; revision=2267
Diffstat (limited to 'externals/grill')
-rw-r--r-- | externals/grill/vst/src/EditorMac.cpp | 55 | ||||
-rw-r--r-- | externals/grill/vst/src/VstHost.cpp | 122 | ||||
-rw-r--r-- | externals/grill/vst/src/VstHost.h | 8 | ||||
-rw-r--r-- | externals/grill/vst/src/main.cpp | 25 | ||||
-rw-r--r-- | externals/grill/vst/src/main.h | 2 | ||||
-rw-r--r-- | externals/grill/vst/vst.xcode/project.pbxproj | 338 |
6 files changed, 531 insertions, 19 deletions
diff --git a/externals/grill/vst/src/EditorMac.cpp b/externals/grill/vst/src/EditorMac.cpp new file mode 100644 index 00000000..f5316105 --- /dev/null +++ b/externals/grill/vst/src/EditorMac.cpp @@ -0,0 +1,55 @@ +/* +vst~ - VST plugin object for PD +based on the work of Jarno Seppänen and Mark Williamson + +Copyright (c)2003-2004 Thomas Grill (xovo@gmx.net) +For information on usage and redistribution, and for a DISCLAIMER OF ALL +WARRANTIES, see the file, "license.txt," in this distribution. +*/ + +#include "Editor.h" +#include "VstHost.h" +#include <flext.h> + + +#if FLEXT_OS == FLEXT_OS_MAC +// only Mac OSX code is situated in this file + +void SetupEditor() +{ +} + +void StartEditor(VSTPlugin *p) +{ +} + +void StopEditor(VSTPlugin *p) +{ +} + +void ShowEditor(VSTPlugin *p,bool show) +{ +} + +void MoveEditor(VSTPlugin *p,int x,int y) +{ +} + +void SizeEditor(VSTPlugin *p,int x,int y) +{ +} + +void CaptionEditor(VSTPlugin *plug,bool c) +{ +} + +void TitleEditor(VSTPlugin *p,const char *t) +{ +} + +bool IsEditorShown(const VSTPlugin *p) +{ + return false; +} + +#endif // FLEXT_OS_MAC diff --git a/externals/grill/vst/src/VstHost.cpp b/externals/grill/vst/src/VstHost.cpp index beb3e8be..e5d50219 100644 --- a/externals/grill/vst/src/VstHost.cpp +++ b/externals/grill/vst/src/VstHost.cpp @@ -28,31 +28,136 @@ VSTPlugin::~VSTPlugin() Free(); // Call free } +static void FreeVST(void *handle) +{ +#if FLEXT_OS == FLEXT_OS_WIN + FreeLibrary(h_dll); +#elif FLEXT_OS == FLEXT_OS_MAC +#else +#error Platform not supported +#endif +} + +#if FLEXT_OS == FLEXT_OS_MAC +OSStatus FSPathMakeFSSpec( + const UInt8 *path, + FSSpec *spec, + Boolean *isDirectory) /* can be NULL */ +{ + OSStatus result; + FSRef ref; + + /* check parameters */ + require_action(NULL != spec, BadParameter, result = paramErr); + + /* convert the POSIX path to an FSRef */ + result = FSPathMakeRef(path, &ref, isDirectory); + require_noerr(result, FSPathMakeRef); + + /* and then convert the FSRef to an FSSpec */ + result = FSGetCatalogInfo(&ref, kFSCatInfoNone, NULL, NULL, spec, NULL); + require_noerr(result, FSGetCatalogInfo); + +FSGetCatalogInfo: +FSPathMakeRef: +BadParameter: + + return ( result ); +} +#endif + int VSTPlugin::Instance(const char *dllname) { #ifdef FLEXT_DEBUG flext::post("New Plugin 1 - %x",this); #endif + PVSTMAIN pluginmain; +#if FLEXT_OS == FLEXT_OS_WIN h_dll = LoadLibrary(dllname); if(!h_dll) return VSTINSTANCE_ERR_NO_VALID_FILE; - PVSTMAIN main = (PVSTMAIN)GetProcAddress(h_dll,"main"); - if(!main) { - FreeLibrary(h_dll); + pluginmain = (PVSTMAIN)GetProcAddress(h_dll,"main"); + void *audioMasterFPtr = Master; + +#elif FLEXT_OS == FLEXT_OS_MAC + short resFileID; + FSSpec spec; + OSErr err; + + err = FSPathMakeFSSpec(dllname,&spec,NULL); + 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; + + 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) { + #ifdef __CFM__ + pluginmain = (PVSTMAIN)NewMachOFromCFM(mainAddr); + #else + pluginmain = (PVSTMAIN)mainAddr; + #endif + } + } + + CloseResFile(resFileID); + + void *audioMasterFPtr = +#ifdef __CFM__ + NewCFMFromMachO(Master); +#else + Master; +#endif + +#else +#error Platform not supported +#endif + + if(!pluginmain) { + FreeVST(h_dll); _pEffect = NULL; return VSTINSTANCE_ERR_NO_VST_PLUGIN; } //This calls the "main" function and receives the pointer to the AEffect structure. - _pEffect = main((audioMasterCallback)Master); + _pEffect = pluginmain((audioMasterCallback)audioMasterFPtr); +#ifdef __MACOSX__ +#ifdef __CFM__ + DisposeCFMFromMachO(audioMasterFPtr); + DisposeMachOFromCFM(pluginmain); +#endif +#endif + + if(!_pEffect || _pEffect->magic != kEffectMagic) { post("VST plugin : Unable to create effect"); _pEffect = NULL; - FreeLibrary(h_dll); h_dll = NULL; + FreeVST(h_dll); + h_dll = NULL; return VSTINSTANCE_ERR_REJECTED; } @@ -158,7 +263,10 @@ void VSTPlugin::Free() // Called also in destruction // There should be a data stub accessible from the plugin object and the thread // holding the necessary data, so that both can operate independently - if(h_dll) { FreeLibrary(h_dll); h_dll = NULL; } + if(h_dll) { + FreeVST(h_dll); + h_dll = NULL; + } #ifdef FLEXT_DEBUG flext::post("Free Plugin 2 - %x",this); @@ -425,7 +533,7 @@ void VSTPlugin::process( float **inputs, float **outputs, long sampleframes ) // Host callback dispatcher long VSTPlugin::Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt) { -#if 1 +#if 0 audioMasterEnum op = (audioMasterEnum)opcode; audioMasterEnumx opx = (audioMasterEnumx)opcode; #endif diff --git a/externals/grill/vst/src/VstHost.h b/externals/grill/vst/src/VstHost.h index f49bf959..ef466a87 100644 --- a/externals/grill/vst/src/VstHost.h +++ b/externals/grill/vst/src/VstHost.h @@ -13,10 +13,14 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include <flext.h> #include "AEffectx.h" #include "AEffEditor.hpp" +#include <string> #if FLEXT_OS == FLEXT_OS_WIN #include <windows.h> typedef HWND WHandle; +#elif FLEXT_OS == FLEXT_OS_MAC +#include <CoreServices/CoreServices.h> +typedef Handle WHandle; #else #error Platform not supported! #endif @@ -54,7 +58,7 @@ public: bool Is() const { return _pEffect != NULL; } - ULONG GetVersion() const { return _pEffect?_pEffect->version:0; } + long GetVersion() const { return _pEffect?_pEffect->version:0; } bool IsSynth() const { return HasFlags(effFlagsIsSynth); } bool IsReplacing() const { return HasFlags(effFlagsCanReplacing); } @@ -139,6 +143,8 @@ protected: #if FLEXT_OS == FLEXT_OS_WIN HMODULE h_dll; +#elif FLEXT_OS == FLEXT_OS_MAC + void *h_dll; #else #error #endif diff --git a/externals/grill/vst/src/main.cpp b/externals/grill/vst/src/main.cpp index e2b6fb6e..0291ba13 100644 --- a/externals/grill/vst/src/main.cpp +++ b/externals/grill/vst/src/main.cpp @@ -13,13 +13,16 @@ WARRANTIES, see the file, "license.txt," in this distribution. #include "VstHost.h" #include <stdlib.h> +#include <string.h> +#include <string> + +#if FLEXT_OS == FLEXT_OS_WIN #include <direct.h> #include <io.h> - -#include <string> +#endif -#define VST_VERSION "0.1.0pre16" +#define VST_VERSION "0.1.0pre17" class vst: @@ -264,7 +267,7 @@ V vst::InitPlug() { FLEXT_ASSERT(plug); - vstfun = plug->IsReplacing()?VSTPlugin::processReplacing:VSTPlugin::process; + vstfun = plug->IsReplacing()?&VSTPlugin::processReplacing:&VSTPlugin::process; sigmatch = plug->GetNumInputs() == CntInSig() && plug->GetNumOutputs() == CntOutSig(); InitPlugDSP(); @@ -286,12 +289,12 @@ V vst::ClearBuf() if(!plug) return; if(vstin) { - for(I i = 0; i < plug->GetNumInputs(); ++i) delete[] vstin[i]; + for(I i = 0; i < plug->GetNumInputs(); ++i) FreeAligned(vstin[i]); delete[] vstin; vstin = NULL; delete[] tmpin; tmpin = NULL; } if(vstout) { - for(I i = 0; i < plug->GetNumOutputs(); ++i) delete[] vstout[i]; + for(I i = 0; i < plug->GetNumOutputs(); ++i) FreeAligned(vstout[i]); delete[] vstout; vstout = NULL; delete[] tmpout; tmpout = NULL; } @@ -306,17 +309,17 @@ V vst::InitBuf() vstin = new R *[inputs]; tmpin = new R *[inputs]; - for(i = 0; i < inputs; ++i) vstin[i] = new R[Blocksize()]; + for(i = 0; i < inputs; ++i) vstin[i] = (R *)NewAligned(Blocksize()*sizeof(R)); vstout = new R *[outputs]; tmpout = new R *[outputs]; - for(i = 0; i < outputs; ++i) vstout[i] = new R[Blocksize()]; + for(i = 0; i < outputs; ++i) vstout[i] = (R *)NewAligned(Blocksize()*sizeof(R)); } static std::string findFilePath(const std::string &path,const std::string &dllname) { - _chdir( path.c_str() ); #if FLEXT_OS == FLEXT_OS_WIN + _chdir( path.c_str() ); WIN32_FIND_DATA data; HANDLE fh = FindFirstFile(dllname.c_str(),&data); if(fh != INVALID_HANDLE_VALUE) { @@ -358,7 +361,9 @@ BL vst::ms_plug(I argc,const A *argv) for(I i = 0; i < argc; i++) { if(i > 0) plugname += ' '; GetAString(argv[i],buf,sizeof buf); +#if FLEXT_OS == FLEXT_OS_WIN strlwr(buf); +#endif #if FLEXT_SYS == FLEXT_SYS_PD // strip char escapes (only in newer/devel PD version) @@ -447,7 +452,7 @@ BL vst::ms_plug(I argc,const A *argv) } if(!lf) { // failed - don't make any ins or outs - post("%s - unable to load plugin '%s', load error %i",thisName(),plugname,loaderr); + post("%s - unable to load plugin '%s', load error %i",thisName(),plugname.c_str(),loaderr); ClearPlug(); } diff --git a/externals/grill/vst/src/main.h b/externals/grill/vst/src/main.h index 4e6ed877..65b03f3c 100644 --- a/externals/grill/vst/src/main.h +++ b/externals/grill/vst/src/main.h @@ -18,7 +18,7 @@ WARRANTIES, see the file, "license.txt," in this distribution. #error You need at least flext version 0.4.5 #endif -#if FLEXT_OS == FLEXT_OS_WIN +#if FLEXT_OS == FLEXT_OS_WIN || FLEXT_OS == FLEXT_OS_MAC // #else #error Platform not supported! diff --git a/externals/grill/vst/vst.xcode/project.pbxproj b/externals/grill/vst/vst.xcode/project.pbxproj new file mode 100644 index 00000000..1c90b526 --- /dev/null +++ b/externals/grill/vst/vst.xcode/project.pbxproj @@ -0,0 +1,338 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 39; + objects = { + 014CEA440018CDF011CA2923 = { + buildSettings = { + COPY_PHASE_STRIP = NO; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = "FLEXT_SYS=2 FLEXT_SHARED"; + LIBRARY_STYLE = DYNAMIC; + ZERO_LINK = YES; + }; + isa = PBXBuildStyle; + name = Development; + }; + 014CEA450018CDF011CA2923 = { + buildSettings = { + COPY_PHASE_STRIP = YES; + GCC_ALTIVEC_EXTENSIONS = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_MODEL_TUNING = ""; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = "FLEXT_SYS=2 FLEXT_SHARED"; + ZERO_LINK = NO; + }; + isa = PBXBuildStyle; + name = Deployment; + }; +//010 +//011 +//012 +//013 +//014 +//030 +//031 +//032 +//033 +//034 + 034768DFFF38A50411DB9C8B = { + children = ( + D2AAC0C705546C1D00DB518D, + ); + isa = PBXGroup; + name = Products; + refType = 4; + sourceTree = "<group>"; + }; +//030 +//031 +//032 +//033 +//034 +//080 +//081 +//082 +//083 +//084 + 0867D690FE84028FC02AAC07 = { + buildSettings = { + }; + buildStyles = ( + 014CEA440018CDF011CA2923, + 014CEA450018CDF011CA2923, + ); + hasScannedForEncodings = 1; + isa = PBXProject; + mainGroup = 0867D691FE84028FC02AAC07; + productRefGroup = 034768DFFF38A50411DB9C8B; + projectDirPath = ""; + targets = ( + D2AAC0C605546C1D00DB518D, + ); + }; + 0867D691FE84028FC02AAC07 = { + children = ( + E9E87848074674890035356B, + E9E87845074674560035356B, + E9E87713074673750035356B, + E9E87710074673590035356B, + E9C0C57707461746002B8D0A, + E9C0C57807461746002B8D0A, + E9C0C57907461746002B8D0A, + E9C0C57A07461746002B8D0A, + E9C0C57B07461746002B8D0A, + E9C0C57C07461746002B8D0A, + 034768DFFF38A50411DB9C8B, + ); + isa = PBXGroup; + name = vst; + refType = 4; + sourceTree = "<group>"; + }; +//080 +//081 +//082 +//083 +//084 +//D20 +//D21 +//D22 +//D23 +//D24 + D2AAC0C305546C1D00DB518D = { + buildActionMask = 2147483647; + files = ( + E9C0C57D07461746002B8D0A, + E9C0C58007461746002B8D0A, + E9C0C58207461746002B8D0A, + ); + isa = PBXHeadersBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + D2AAC0C405546C1D00DB518D = { + buildActionMask = 2147483647; + files = ( + E9C0C57E07461746002B8D0A, + E9C0C57F07461746002B8D0A, + E9C0C58107461746002B8D0A, + ); + isa = PBXSourcesBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + D2AAC0C505546C1D00DB518D = { + buildActionMask = 2147483647; + files = ( + E9E87711074673590035356B, + E9E87714074673750035356B, + E9E87846074674560035356B, + E9E87849074674890035356B, + ); + isa = PBXFrameworksBuildPhase; + runOnlyForDeploymentPostprocessing = 0; + }; + D2AAC0C605546C1D00DB518D = { + buildPhases = ( + D2AAC0C305546C1D00DB518D, + D2AAC0C405546C1D00DB518D, + D2AAC0C505546C1D00DB518D, + ); + buildRules = ( + ); + buildSettings = { + DYLIB_COMPATIBILITY_VERSION = 1; + DYLIB_CURRENT_VERSION = 1; + EXECUTABLE_EXTENSION = pd_darwin; + GCC_GENERATE_DEBUGGING_SYMBOLS = NO; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_PREPROCESSOR_DEFINITIONS = "FLEXT_SYS=2 FLEXT_SHARED"; + HEADER_SEARCH_PATHS = "/Volumes/Daten/Prog/pdmax/flext/source /Volumes/Daten/Prog/packs/vstsdk2.3/source/common"; + INSTALL_PATH = /usr/local/lib/flext; + LIBRARY_STYLE = BUNDLE; + OTHER_LDFLAGS = "-bundle_loader /usr/local/bin/pd"; + PRODUCT_NAME = "vst~"; + SKIP_INSTALL = YES; + }; + dependencies = ( + ); + isa = PBXNativeTarget; + name = vst; + productName = vst; + productReference = D2AAC0C705546C1D00DB518D; + productType = "com.apple.product-type.library.dynamic"; + }; + D2AAC0C705546C1D00DB518D = { + explicitFileType = "compiled.mach-o.dylib"; + includeInIndex = 0; + isa = PBXFileReference; + path = "vst~.pd_darwin"; + refType = 3; + sourceTree = BUILT_PRODUCTS_DIR; + }; +//D20 +//D21 +//D22 +//D23 +//D24 +//E90 +//E91 +//E92 +//E93 +//E94 + E9C0C57707461746002B8D0A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = Editor.h; + path = src/Editor.h; + refType = 4; + sourceTree = "<group>"; + }; + E9C0C57807461746002B8D0A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = EditorMac.cpp; + path = src/EditorMac.cpp; + refType = 4; + sourceTree = "<group>"; + }; + E9C0C57907461746002B8D0A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = main.cpp; + path = src/main.cpp; + refType = 4; + sourceTree = "<group>"; + }; + E9C0C57A07461746002B8D0A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = main.h; + path = src/main.h; + refType = 4; + sourceTree = "<group>"; + }; + E9C0C57B07461746002B8D0A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.cpp.cpp; + name = VstHost.cpp; + path = src/VstHost.cpp; + refType = 4; + sourceTree = "<group>"; + }; + E9C0C57C07461746002B8D0A = { + fileEncoding = 30; + isa = PBXFileReference; + lastKnownFileType = sourcecode.c.h; + name = VstHost.h; + path = src/VstHost.h; + refType = 4; + sourceTree = "<group>"; + }; + E9C0C57D07461746002B8D0A = { + fileRef = E9C0C57707461746002B8D0A; + isa = PBXBuildFile; + settings = { + }; + }; + E9C0C57E07461746002B8D0A = { + fileRef = E9C0C57807461746002B8D0A; + isa = PBXBuildFile; + settings = { + }; + }; + E9C0C57F07461746002B8D0A = { + fileRef = E9C0C57907461746002B8D0A; + isa = PBXBuildFile; + settings = { + }; + }; + E9C0C58007461746002B8D0A = { + fileRef = E9C0C57A07461746002B8D0A; + isa = PBXBuildFile; + settings = { + }; + }; + E9C0C58107461746002B8D0A = { + fileRef = E9C0C57B07461746002B8D0A; + isa = PBXBuildFile; + settings = { + }; + }; + E9C0C58207461746002B8D0A = { + fileRef = E9C0C57C07461746002B8D0A; + isa = PBXBuildFile; + settings = { + }; + }; + E9E87710074673590035356B = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = System.framework; + path = /System/Library/Frameworks/System.framework; + refType = 0; + sourceTree = "<absolute>"; + }; + E9E87711074673590035356B = { + fileRef = E9E87710074673590035356B; + isa = PBXBuildFile; + settings = { + }; + }; + E9E87713074673750035356B = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = ApplicationServices.framework; + path = /System/Library/Frameworks/ApplicationServices.framework; + refType = 0; + sourceTree = "<absolute>"; + }; + E9E87714074673750035356B = { + fileRef = E9E87713074673750035356B; + isa = PBXBuildFile; + settings = { + }; + }; + E9E87845074674560035356B = { + isa = PBXFileReference; + lastKnownFileType = "compiled.mach-o.dylib"; + name = libflext.dylib; + path = /usr/local/lib/libflext.dylib; + refType = 0; + sourceTree = "<absolute>"; + }; + E9E87846074674560035356B = { + fileRef = E9E87845074674560035356B; + isa = PBXBuildFile; + settings = { + }; + }; + E9E87848074674890035356B = { + isa = PBXFileReference; + lastKnownFileType = wrapper.framework; + name = vecLib.framework; + path = /System/Library/Frameworks/vecLib.framework; + refType = 0; + sourceTree = "<absolute>"; + }; + E9E87849074674890035356B = { + fileRef = E9E87848074674890035356B; + isa = PBXBuildFile; + settings = { + }; + }; + }; + rootObject = 0867D690FE84028FC02AAC07; +} |