initial commit

This commit is contained in:
2021-10-28 00:46:36 -03:00
commit 3274ae0d69
28 changed files with 4137 additions and 0 deletions

43
vst-template/makefile Normal file
View File

@@ -0,0 +1,43 @@
# Compile with MinGW.
# Download "vstsdk2_4.zip" from https://archive.org/download/VST2SDK
# extract the folder an place it:
#
# ├──build/
# ├──vst-scheduler/
# ├──vstsdk2.4/
# ├──vst-template/
#
FOO=../vstsdk2.4/
FOO2=../vstsdk2.4/public.sdk/source/vst2.x/
SOURCES= \
pdvst.cpp \
pdvstMain.cpp \
pdvstEditor.cpp \
$(FOO2)AudioEffect.cpp \
$(FOO2)audioeffectx.cpp \
$(empty)
WINARCH := $(shell $(CC) -dumpmachine)
ifeq (i686% , $(WINARCH))
arch = 32
else
arch = 64
endif
ALL: $(SOURCES)
g++ -Wall -I. -I$(FOO) -I$(FOO2) \
$(SOURCES) -static-libgcc -static-libstdc++ -static -lpthread -shared -o pdvst-template.dll
strip pdvst-template.dll
cp pdvst-template.dll ../build/Release$(arch)/.template/pdvst-template.dll
cp pdvst-template.dll ../build/Release$(arch)/Pd_Gain.dll
cp pdvst-template.dll ../build/Release$(arch)/Pd_Gain-gui.dll
cp pdvst-template.dll ../build/Release$(arch)/Pd_Gain-nogui.dll
cp pdvst-template.dll ../build/Release$(arch)/Pd_Midi.dll

1138
vst-template/pdvst.cpp Normal file

File diff suppressed because it is too large Load Diff

175
vst-template/pdvst.hpp Normal file
View File

@@ -0,0 +1,175 @@
/* PdVst v0.0.2 - VST - Pd bridging plugin
** Copyright (C) 2004 Joseph A. Sarlo
**
** This program is free software; you can redistribute it and/orsig
** 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; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** jsarlo@ucsd.edu
*/
#ifndef __PDVST_H
#define __PDVST_H
#include "audioeffectx.h"
#include "pdvstEditor.hpp"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#define PDBLKSIZE 64
#define MAXEXTERNS 128
#define MAXVSTBUFSIZE 4096
#define MAXPARAMS 128
#define MAXPROGRAMS 128
#define MAXCHANS 128
#define MAXFILENAMELEN 1024
#define MAXSTRLEN 4096
#define MAXEXTERNS 128
#define PDWAITMAX 1000
#define SETUPFILEEXT ".pdv"
#define DEFPDVSTBUFFERSIZE 1024
extern "C"
{
#include "pdvstTransfer.h"
}
/* program data */
typedef struct _pdvstProgram
{
char name[MAXSTRLEN];
float paramValue[MAXPARAMETERS];
} pdvstProgram;
class pdVstBuffer
{
friend class pdvst;
public:
pdVstBuffer(int nChans);
~pdVstBuffer();
void resize(int newSize);
protected:
int nChannels;
int inFrameCount;
int outFrameCount;
int size;
float **in;
float **out;
};
class pdvst : public AudioEffectX
{
friend class pdvstEditor;
public:
pdvst(audioMasterCallback audioMaster);
~pdvst();
virtual void process(float **inputs, float **outputs, VstInt32 sampleFrames);
virtual void processReplacing(float **inputs, float **outputs,
VstInt32 sampleFrames);
virtual VstInt32 processEvents (VstEvents* events);
virtual void setProgram(VstInt32 prgmNum);
virtual VstInt32 getProgram();
virtual void setProgramName(char *name);
virtual void getProgramName(char *name);
virtual void setParameter(VstInt32 index, float value);
virtual float getParameter(VstInt32 index);
virtual void getParameterLabel(VstInt32 index, char *label);
virtual void getParameterDisplay(VstInt32 index, char *text);
virtual void getParameterName(VstInt32 index, char *text);
virtual bool getEffectName(char* name);
virtual bool getOutputProperties(VstInt32 index, VstPinProperties* properties);
virtual VstInt32 canDo (char* text);
// virtual VstInt32 canMono ();
virtual void suspend();
virtual void resume();
void sendGuiAction(int action);
void sendPlugName(char * name ); // JYG : to send plug name to puredatapatch
LPTSTR displayString;//= new TCHAR[MAXSTRINGSIZE];
HWND pdGui;
protected:
static int referenceCount;
void debugLog(char *fmt, ...);
FILE *debugFile;
int pdInFrameCount;
int pdOutFrameCount;
pdVstBuffer *audioBuffer;
char pluginPath[MAXFILENAMELEN];
char vstPluginPath[MAXFILENAMELEN];
char pluginName[MAXSTRLEN];
long pluginId;
char pdFile[MAXFILENAMELEN];
char errorMessage[MAXFILENAMELEN];
char externalLib[MAXEXTERNS][MAXSTRLEN];
float vstParam[MAXPARAMS];
char **vstParamName;
int nParameters;
pdvstProgram *program;
int nPrograms;
int nChannels;
int nExternalLibs;
bool customGui;
int customGuiHeight;
int customGuiWidth;
bool isASynth;
bool dspActive;
HANDLE pdvstTransferMutex,
pdvstTransferFileMap,
vstProcEvent,
pdProcEvent;
pdvstTransferData *pdvstData;
char pdvstTransferMutexName[1024];
char pdvstTransferFileMapName[1024];
char vstProcEventName[1024];
char pdProcEventName[1024];
char guiName[1024];
bool guiNameUpdated; // used to signal to editor that the parameter guiName has changed
void startPd();
void parseSetupFile();
void updatePdvstParameters();
void setSyncToVst(int value);
// {JYG
DWORD timeFromStartup; // to measure time before vst::setProgram call
#ifdef VSTMIDIOUTENABLE
/** Stores a single midi event.
* The 'events' fields points to midiEvent.
*/
VstEvents midiOutEvents;
/** Last played note information is stored in midiEvent.
*/
VstMidiEvent midiEvent;
// version alternative (http://stackoverflow.com/questions/359125/how-to-store-data-in-variable-length-arrays-without-causing-memory-corruption)
struct VstEvents *evnts;
VstMidiEvent midiEvnts[MAXMIDIOUTQUEUESIZE];
int nbFramesWithoutMidiOutEvent;
#endif //VSTMIDIOUTENABLE
int syncDefeatNumber;
// JYG }
};
#endif

View File

@@ -0,0 +1,217 @@
/* PdVst v0.0.2 - VST - Pd bridging plugin
** Copyright (C) 2004 Joseph A. Sarlo
**
** This program is free software; you can redistribute it and/orsig
** 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; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** jsarlo@ucsd.edu
*/
#ifndef __pdvstEditor
#include "pdvstEditor.hpp"
#endif
#ifndef __PDVST_H
#include "pdvst.hpp"
#endif
#include <stdio.h>
#include <windows.h>
extern HINSTANCE hInstance;
//extern int pdGuiWindowHeight, pdGuiWindowWidth;
int useCount = 0;
pdvstEditor::pdvstEditor(AudioEffect *effect)
: AEffEditor(effect)
{
systemWindowHidden=false;
effect->setEditor(this);
editWindow = NULL;
//((pdvst *)(effect))->debugLog("begin editor");
}
pdvstEditor::~pdvstEditor()
{
}
bool pdvstEditor::getRect(ERect **erect)
{
static ERect r = {0,0,((pdvst *)this->effect)->customGuiHeight,((pdvst *)this->effect)->customGuiWidth};
*erect = &r;
return (true);
}
bool pdvstEditor::open(void *ptr)
{
systemWindow = ptr;
WNDCLASS myWindowClass;
useCount++;
if (useCount == 1)
{
myWindowClass.style = 0;
myWindowClass.lpfnWndProc = (WNDPROC)windowProc;
myWindowClass.cbClsExtra = 0;
myWindowClass.cbWndExtra = 0;
myWindowClass.hInstance = hInstance;
myWindowClass.hIcon = 0;
myWindowClass.hCursor = 0;
myWindowClass.hbrBackground = GetSysColorBrush(COLOR_APPWORKSPACE);
// myWindowClass.hbrBackground = CreateSolidBrush(RGB(180, 180, 180));
myWindowClass.lpszMenuName = 0;
myWindowClass.lpszClassName = "pdvstWindowClass";
RegisterClass(&myWindowClass);
}
LPTSTR plugName= new TCHAR[MAXSTRINGSIZE];
GetWindowText((HWND)systemWindow,plugName,MAXSTRINGSIZE);
((pdvst *)this->effect)->sendPlugName((char *) plugName );
// sprintf( ((pdvst *)this->effect)->displayString,"valeurSetParameter=%f",((pdvst *)this->effect)->vstParam[0]);
//((pdvst *)this->effect)->sendPlugName((char *) ((pdvst *)this->effect)->displayString );
//////
editWindow = CreateWindowEx(0, "pdvstWindowClass", "Window",
WS_CHILD | WS_VISIBLE, 0,0,((pdvst *)this->effect)->customGuiWidth,((pdvst *)this->effect)->customGuiHeight,
(HWND)systemWindow, NULL, hInstance, NULL);
SetWindowLongPtr(editWindow, GWLP_USERDATA, (LONG_PTR)this);
/* openButton = CreateWindowEx(0, "Button", "open", WS_CHILD | WS_VISIBLE,
70, 24, 120, 25, editWindow, NULL, hInstance,
NULL);
*/
((pdvst *)this->effect)->sendGuiAction(1);
return (true);
}
void pdvstEditor::close()
{
if (pdGuiWindow)
{
// detach pdGuiWindow from editWindow
SetParent(pdGuiWindow,NULL);
//Remove WS_CHILD style and add WS_POPUP style
DWORD style = GetWindowLong(pdGuiWindow,GWL_STYLE);
// style = style & ~(WS_POPUPWINDOW);
style = style | WS_POPUP;
style = style & ~(WS_CHILD);
style = style |(WS_SYSMENU);
style = style | (WS_BORDER);
SetWindowLong(pdGuiWindow,GWL_STYLE,style);
systemWindowHidden=false;
pdGuiWindow=NULL;
}
if (editWindow)
{
((pdvst *)this->effect)->sendGuiAction(0);
DestroyWindow(editWindow);
}
editWindow = NULL;
useCount = 0;
UnregisterClass("pdvstWindowClass", hInstance);
}
void pdvstEditor::idle()
{
// JYG :: masquer la fenêtre GUI créée par hôte VST pour laisser puredata le faire
// SetWindowPos((HWND)systemWindow,HWND_TOPMOST,-300,-300,0,0,SWP_NOSIZE); // déplacer la fenetre
// SetWindowPos((HWND)systemWindow,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOMOVE|SWP_NOSIZE|SWP_HIDEWINDOW); //masquer la fenêtre
// systemWindowHidden=true;
// JYG
if (((pdvst *)this->effect)->guiNameUpdated)
if (editWindow)//&&!pdGuiWindow)
{
HWND tref=NULL;
parms.ref = &tref;
strcpy(parms.s,(char*)((pdvst *)this->effect)->guiName);
parms.exact = false;
EnumWindows(enumwnd,(LPARAM)&parms);
pdGuiWindow = tref;
// pdGuiWindow=FindWindow(NULL,"Pd_Gain(gui).pd - C:/Program Files (x86)/Ableton/Live 8.0.4/Program/pdvst");
// pdGuiWindow=FindWindow(NULL,(char*)((pdvst *)this->effect)->guiName);
if (pdGuiWindow)
{
if(SetParent(pdGuiWindow,(HWND)editWindow))//systemWindow))
{
((pdvst *)this->effect)->guiNameUpdated=0;
//Remove WS_POPUP style and add WS_CHILD style
DWORD style = GetWindowLong(pdGuiWindow,GWL_STYLE);
// style = style & ~(WS_POPUPWINDOW);
style = style & ~(WS_POPUP);
style = style & ~(WS_CHILD); // WS_CHILD Crashes tcltk with reaper
style = style & ~(WS_SYSMENU);
style = style & ~(WS_BORDER);
style = style & ~(WS_HSCROLL);
style = style & ~(WS_VSCROLL);
style = style & ~(WS_SIZEBOX);
style = style & ~(WS_CAPTION);
SetWindowLong(pdGuiWindow,GWL_STYLE,style);
MoveWindow(pdGuiWindow, 0,0,((pdvst *)this->effect)->customGuiWidth,((pdvst *)this->effect)->customGuiHeight,TRUE);
systemWindowHidden=true;
}
}
}
AEffEditor::idle();
}
LONG WINAPI pdvstEditor::windowProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam)
{
pdvstEditor *self = (pdvstEditor *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (message == WM_COMMAND)
{
if (HIWORD(wParam) == BN_CLICKED &&
(HWND)lParam == self->openButton)
{
// ((pdvst *)self->effect)->sendGuiAction(1);
}
}
return (DefWindowProc(hwnd, message, wParam, lParam));
}
BOOL CALLBACK enumwnd(HWND hwnd,LPARAM lParam)
{
enumparms *parms = (enumparms *)lParam;
char buf[256];
GetWindowText(hwnd,buf,sizeof buf);
if(parms->exact? strcmp(buf,parms->s) == 0 : strstr(buf,parms->s) != NULL) {
*parms->ref = hwnd;
return FALSE;
}
else {
// also search for child windows
EnumChildWindows(hwnd,enumwnd,lParam);
return TRUE;
}
}
// ***********

View File

@@ -0,0 +1,61 @@
/* PdVst v0.0.2 - VST - Pd bridging plugin
** Copyright (C) 2004 Joseph A. Sarlo
**
** This program is free software; you can redistribute it and/orsig
** 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; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** jsarlo@ucsd.edu
*/
#ifndef __pdvstEditor
#define __pdvstEditor
#include <stdio.h>
#include <windows.h>
#include "aeffeditor.h"
typedef struct _enumparms
{
HWND *ref;
char s[1024];
bool exact;
}enumparms;
class pdvstEditor : public AEffEditor
{
friend class pdvst;
public:
pdvstEditor(AudioEffect *effect);
virtual ~pdvstEditor ();
HWND openButton;;
HWND editWindow;
HWND pdGuiWindow;
static LONG WINAPI windowProc(HWND mhwnd, UINT message,
WPARAM wParam, LPARAM lParam);
protected:
virtual bool getRect(ERect **erect);
virtual bool open(void *ptr);
virtual void close();
virtual void idle();
private:
void *systemWindow;
bool systemWindowHidden;
enumparms parms;
};
#endif
static BOOL CALLBACK enumwnd(HWND hwnd,LPARAM lParam);

383
vst-template/pdvstMain.cpp Normal file
View File

@@ -0,0 +1,383 @@
/* PdVst v0.0.2 - VST - Pd bridging plugin
** Copyright (C) 2004 Joseph A. Sarlo
**
** This program is free software; you can redistribute it and/orsig
** 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; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** jsarlo@ucsd.edu
*/
#include <windows.h>
#include <math.h>
#include "pdvst.hpp"
#include <unistd.h>
static AudioEffect *effect = 0;
bool oome = false;
//HINSTANCE hInstance;
bool globalIsASynth = false;
bool globalDebug = false;
int globalNChannels = 0;
int globalNPrograms = 0;
int globalNParams = 0;
int globalNExternalLibs = 0;
long globalPluginId = 'pdvp';
char globalExternalLib[MAXEXTERNS][MAXSTRLEN];
char globalVstParamName[MAXPARAMS][MAXSTRLEN];
char globalPluginPath[MAXFILENAMELEN];
char globalVstPluginPath[MAXFILENAMELEN];
char globalPluginName[MAXSTRLEN];
char globalPdFile[MAXFILENAMELEN];
char globalPureDataPath[MAXFILENAMELEN];
char globalHostPdvstPath[MAXFILENAMELEN];
bool globalCustomGui = false;
int globalCustomGuiWidth= 320;
int globalCustomGuiHeight= 150;
pdvstProgram globalProgram[MAXPROGRAMS];
char *trimWhitespace(char *str);
void parseSetupFile();
#include "audioeffect.h"
//------------------------------------------------------------------------
/** Must be implemented externally. */
extern AudioEffect* createEffectInstance (audioMasterCallback audioMaster);
extern "C" {
#if defined (__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#define VST_EXPORT __attribute__ ((visibility ("default")))
#else
#define VST_EXPORT
#endif
VST_EXPORT AEffect *VSTPluginMain(audioMasterCallback audioMaster)
{
// get vst version
if (!audioMaster(0, audioMasterVersion, 0, 0, 0, 0))
return 0; // old version
// Create the AudioEffect
AudioEffect* effect = createEffectInstance (audioMaster);
if (!effect)
return 0;
return effect->getAeffect();
}
// support for old hosts not looking for VSTPluginMain
#if (TARGET_API_MAC_CARBON && __ppc__)
VST_EXPORT AEffect* main_macho (audioMasterCallback audioMaster) { return VSTPluginMain (audioMaster); }
#elif WIN32
VST_EXPORT AEffect* MAIN (audioMasterCallback audioMaster) { return VSTPluginMain (audioMaster); }
#elif BEOS
VST_EXPORT AEffect* main_plugin (audioMasterCallback audioMaster) { return VSTPluginMain (audioMaster); }
#endif
} // extern "C"
#if WIN32
#include <windows.h>
void* hInstance;
extern "C" {
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpvReserved)
{
hInstance = hInst;
parseSetupFile();
return 1;
}
} // extern "C"
#endif
char *trimWhitespace(char *str)
{
char *buf;
if (strlen(str) > 0)
{
buf = str;
while (isspace(*buf) && (buf - str) <= (int)strlen(str))
buf++;
memmove(str, buf, (strlen(buf) + 1) * sizeof(char));
if (strlen(str) > 0)
{
buf = str + strlen(str) - 1;
while (isspace(*buf) && (buf >= str))
{
*buf = 0;
buf--;
}
}
}
return (str);
}
void parseSetupFile()
{
FILE *setupFile;
char setupFileName[MAXFILENAMELEN];
char tFileName[MAXFILENAMELEN];
char line[MAXSTRLEN];
char param[MAXSTRLEN];
char value[MAXSTRLEN];
char vstDataPath[MAXSTRLEN];
char vstSetupFileName[MAXSTRLEN]; // path to setup file if it is located in vst subdir
int i, equalPos, progNum = -1;
// find filepaths
GetModuleFileName((HMODULE)hInstance,
(LPTSTR)tFileName,
(DWORD)MAXFILENAMELEN);
if (strrchr(tFileName, '\\'))
{
strcpy(globalPluginName, strrchr(tFileName, '\\') + 1);
}
else
{
strcpy(globalPluginName, tFileName);
}
// alternate setup file path in vst plugins folder
if (strrchr(tFileName, '\\'))
{
strcpy(vstDataPath, tFileName);
*(strrchr(vstDataPath, '\\') + 1) = 0;
sprintf(vstDataPath, "%s%s\\", vstDataPath,globalPluginName);
// remove .dll extension (from globalPluginName)
if (strstr(vstDataPath, ".dll"))
*(strstr(vstDataPath, ".dll")) = 0;
if (strstr(vstDataPath, ".DLL"))
*(strstr(vstDataPath, ".DLL")) = 0;
sprintf(vstDataPath, "%s\\", vstDataPath); //
// path to alternate setup file
sprintf(vstSetupFileName,"%s%s",vstDataPath,globalPluginName);
// remove .dll extension
if (strstr(vstSetupFileName, ".dll"))
*(strstr(vstSetupFileName, ".dll")) = 0;
if (strstr(vstSetupFileName, ".DLL"))
*(strstr(vstSetupFileName, ".DLL")) = 0;
// add SETUPFILEEXT extension
sprintf(vstSetupFileName,"%s%s",vstSetupFileName,SETUPFILEEXT);
//MessageBox(NULL, vstDataPath,"vstDataPath",MB_OK) ;
//MessageBox(NULL, vstSetupFileName,"vstSetupFileName",MB_OK) ;
}
GetModuleFileName(NULL,
(LPTSTR)tFileName,
(DWORD)MAXFILENAMELEN);
if (strrchr(tFileName, '\\'))
{
strcpy(globalPluginPath, tFileName);
*(strrchr(globalPluginPath, '\\') + 1) = 0;
sprintf(globalPluginPath, "%spdvst\\", globalPluginPath);
}
else
{
strcpy(globalPluginPath, tFileName);
}
strcpy(globalHostPdvstPath,globalPluginPath);
// remove .dll extension
if (strstr(strlwr(globalPluginName), ".dll"))
*(strstr(strlwr(globalPluginName), ".dll")) = 0;
sprintf(setupFileName,
"%s%s%s",
globalPluginPath,
globalPluginName,
SETUPFILEEXT);
// initialize program info
strcpy(globalProgram[0].name, "Default");
memset(globalProgram[0].paramValue, 0, MAXPARAMS * sizeof(float));
// initialize parameter info
globalNParams = 0;
for (i = 0; i < MAXPARAMS; i++)
strcpy(globalVstParamName[i], "<unnamed>");
globalNPrograms = 1;
// check existence of setup file in vst-subfolder
if( access(vstSetupFileName, F_OK ) != -1 )
// if exists choose this alternate file
{
setupFile = fopen(vstSetupFileName, "r");
//strcpy(setupFileName,vstSetupFileName);
strcpy(globalPluginPath,vstDataPath);
}
else
setupFile = fopen(setupFileName, "r");
// parse the setup file
if (setupFile) {
while (fgets(line, sizeof(line), setupFile))
{
equalPos = strchr(line, '=') - line;
if (equalPos > 0 && line[0] != '#')
{
strcpy(param, line);
param[equalPos] = 0;
strcpy(value, line + equalPos + 1);
strcpy(param, trimWhitespace(strlwr(param)));
strcpy(value, trimWhitespace(value));
// number of channels
if (strcmp(param, "channels") == 0)
globalNChannels = atoi(value);
// main PD patch
if (strcmp(param, "main") == 0)
{
// strcpy(globalPdFile, strlwr(value));
strcpy(globalPdFile, value);
}
if (strcmp(param, "pdpath") == 0)
{
// strcpy(globalPureDataPath, strlwr(value));
strcpy(globalPureDataPath, value);
}
// vst plugin ID
if (strcmp(param, "id") == 0)
{
globalPluginId = 0;
for (i = 0; i < 4; i++)
globalPluginId += (long)pow((double)16,(int) (i * 2)) * value[3 - i];
}
// is vst instrument
if (strcmp(param, "synth") == 0)
{
if (strcmp(strlwr(value), "true") == 0)
{
globalIsASynth = true;
}
else if (strcmp(strlwr(value), "false") == 0)
{
globalIsASynth = false;
}
}
// external libraries
if (strcmp(param, "lib") == 0)
{
while (strlen(value) > 0)
{
if (strchr(value, ',') == NULL)
{
strcpy(globalExternalLib[globalNExternalLibs], value);
value[0] = 0;
}
else
{
int commaIndex = strchr(value, ',') - value;
strncpy(globalExternalLib[globalNExternalLibs],
value,
commaIndex);
memmove(value,
value + commaIndex + 1,
(strlen(value) - commaIndex) * sizeof(char));
strcpy(value, trimWhitespace(value));
}
globalNExternalLibs++;
}
}
// has custom gui
if (strcmp(param, "customgui") == 0)
{
if (strcmp(strlwr(value), "true") == 0)
{
globalCustomGui = true;
}
else if (strcmp(strlwr(value), "false") == 0)
{
globalCustomGui = false;
}
}
// custom gui height
if (strcmp(param, "guiheight") == 0)
globalCustomGuiHeight = atoi(value);
// custom gui width
if (strcmp(param, "guiwidth") == 0)
{
globalCustomGuiWidth = atoi(value);
}
// debug (show Pd GUI)
if (strcmp(param, "debug") == 0)
{
if (strcmp(strlwr(value), "true") == 0)
{
globalDebug = true;
}
else if (strcmp(strlwr(value), "false") == 0)
{
globalDebug = false;
}
}
// number of parameters
if (strcmp(param, "parameters") == 0)
{
int numParams = atoi(value);
if (numParams >= 0 && numParams < MAXPARAMS)
globalNParams = numParams;
}
// parameters names
if (strstr(param, "nameparameter") == \
param && globalNPrograms < MAXPARAMS)
{
int paramNum = atoi(param + strlen("nameparameter"));
if (paramNum < MAXPARAMS && paramNum >= 0)
strcpy(globalVstParamName[paramNum], value);
}
// program name
if (strcmp(param, "program") == 0 && \
globalNPrograms < MAXPROGRAMS)
{
progNum++;
strcpy(globalProgram[progNum].name, value);
globalNPrograms = progNum + 1;
}
// program parameters
if (strstr(param, "parameter") == \
param && globalNPrograms < MAXPROGRAMS &&
!isalpha(param[strlen("parameter")]))
{
int paramNum = atoi(param + strlen("parameter"));
if (paramNum < MAXPARAMS && paramNum >= 0)
globalProgram[progNum].paramValue[paramNum] = \
(float)atof(value);
}
}
}
}
fclose(setupFile);
}

View File

@@ -0,0 +1,135 @@
/* PdVst v0.0.2 - VST - Pd bridging plugin
** Copyright (C) 2004 Joseph A. Sarlo
**
** This program is free software; you can redistribute it and/orsig
** 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; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** jsarlo@ucsd.edu
*/
#ifndef __pdvstTransfer_H
#define __pdvstTransfer_H
#include <stdio.h>
#define VSTMIDIOUTENABLE
#define MAXCHANNELS 16
#define MAXPARAMETERS 128
#define MAXBLOCKSIZE 256
#define MAXSTRINGSIZE 4096
#define MAXMIDIQUEUESIZE 1024
//#ifdef VSTMIDIOUTENABLE
#define MAXMIDIOUTQUEUESIZE 1024
//#endif // VSTMIDIOUTENABLE
typedef enum _pdvstParameterDataType
{
FLOAT_TYPE,
STRING_TYPE
} pdvstParameterDataType;
typedef enum _pdvstParameterState
{
PD_SEND,
PD_RECEIVE
} pdvstParameterState;
typedef enum _pdvstMidiMessageType
{
NOTE_OFF,
NOTE_ON,
KEY_PRESSURE,
CONTROLLER_CHANGE,
PROGRAM_CHANGE,
CHANNEL_PRESSURE,
PITCH_BEND,
OTHER
} pdvstMidiMessageType;
typedef union _pdvstParameterData
{
float floatData;
char stringData[MAXSTRINGSIZE];
} pdvstParameterData;
typedef struct _pdvstParameter
{
int updated;
pdvstParameterDataType type;
pdvstParameterData value;
pdvstParameterState direction;
} pdvstParameter;
typedef struct _pdvstMidiMessage
{
pdvstMidiMessageType messageType;
int channelNumber;
char statusByte;
char dataByte1;
char dataByte2;
} pdvstMidiMessage;
typedef struct _vstTimeInfo
{
int updated;
//-------------------------------------------------------------------------------------------------------
double samplePos; ///< current Position in audio samples (always valid)
double sampleRate; ///< current Sample Rate in Herz (always valid)
double nanoSeconds; ///< System Time in nanoseconds (10^-9 second)
double ppqPos; ///< Musical Position, in Quarter Note (1.0 equals 1 Quarter Note)
double tempo; ///< current Tempo in BPM (Beats Per Minute)
double barStartPos; ///< last Bar Start Position, in Quarter Note
double cycleStartPos; ///< Cycle Start (left locator), in Quarter Note
double cycleEndPos; ///< Cycle End (right locator), in Quarter Note
int timeSigNumerator; ///< Time Signature Numerator (e.g. 3 for 3/4)
int timeSigDenominator; ///< Time Signature Denominator (e.g. 4 for 3/4)
int smpteOffset; ///< SMPTE offset (in SMPTE subframes (bits; 1/80 of a frame)). The current SMPTE position can be calculated using #samplePos, #sampleRate, and #smpteFrameRate.
int smpteFrameRate; ///< @see VstSmpteFrameRate
int samplesToNextClock; ///< MIDI Clock Resolution (24 Per Quarter Note), can be negative (nearest clock)
int flags; ///< @see VstTimeInfoFlags
//-------------------------------------------------------------------------------------------------------
}pdvstTimeInfo;
typedef struct _pdvstTransferData
{
int active;
int syncToVst;
int nChannels;
int sampleRate;
int blockSize;
int nParameters;
int midiQueueSize;
int midiQueueUpdated;
float samples[MAXCHANNELS][MAXBLOCKSIZE];
pdvstParameter vstParameters[MAXPARAMETERS];
pdvstMidiMessage midiQueue[MAXMIDIQUEUESIZE];
pdvstParameter guiState;
pdvstParameter plugName; // transmitted by host
pdvstParameter guiName; // transmitted by pd : name of gui window to be embedded
// #ifdef VSTMIDIOUTENABLE
int midiOutQueueSize;
int midiOutQueueUpdated;
pdvstMidiMessage midiOutQueue[MAXMIDIOUTQUEUESIZE];
// #endif // VSTMIDIOUTENABLE
pdvstTimeInfo hostTimeInfo;
} pdvstTransferData;
#endif