aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vst/src
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2004-11-14 03:34:32 +0000
committerThomas Grill <xovo@users.sourceforge.net>2004-11-14 03:34:32 +0000
commit3dbf9adf38bf8a204d1fd4dfb4345f542b486933 (patch)
tree0c4810133b5ee0db3d312cc80ccaf1f1ece735ad /externals/grill/vst/src
parent45464826849ab68693a3ed21c2d50ede00c50e67 (diff)
a bit of code for OS X
editor-less Mac version svn path=/trunk/; revision=2267
Diffstat (limited to 'externals/grill/vst/src')
-rw-r--r--externals/grill/vst/src/EditorMac.cpp55
-rw-r--r--externals/grill/vst/src/VstHost.cpp122
-rw-r--r--externals/grill/vst/src/VstHost.h8
-rw-r--r--externals/grill/vst/src/main.cpp25
-rw-r--r--externals/grill/vst/src/main.h2
5 files changed, 193 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!