Update of /cvsroot/pure-data/externals/grill/vst/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25336/src
Modified Files:
editorwin.hpp main.cpp main.h vst.rc vsthost.cpp vsthost.h
Added Files:
vstedit.cpp vstmaster.cpp vstmidi.cpp vstparam.cpp
Log Message:
restructured VSThost code
better shell support
fix for build system
update for flext build systemcleanups
VSTTime info
added event processing (like Midi in)
Index: vsthost.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/vsthost.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** vsthost.h 10 Mar 2005 05:01:30 -0000 1.3
--- vsthost.h 11 Mar 2005 04:58:01 -0000 1.4
***************
*** 3,7 ****
based on the work of Jarno Seppänen and Mark Williamson
! Copyright (c)2003-2004 Thomas Grill (xovo(a)gmx.net)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
--- 3,7 ----
based on the work of Jarno Seppänen and Mark Williamson
! Copyright (c)2003-2005 Thomas Grill (gr(a)grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
***************
*** 12,18 ****
#include <flext.h>
#include "AEffectx.h"
#include "AEffEditor.hpp"
! #include <string>
#if FLEXT_OS == FLEXT_OS_WIN
--- 12,22 ----
#include <flext.h>
+ #include <string>
+ #include <map>
+ #include <math.h>
+
#include "AEffectx.h"
#include "AEffEditor.hpp"
!
#if FLEXT_OS == FLEXT_OS_WIN
***************
*** 29,48 ****
! #define MAX_EVENTS 64
! #define MAX_INOUTS 8
!
! #define VSTINSTANCE_ERR_NO_VALID_FILE -1
! #define VSTINSTANCE_ERR_NO_VST_PLUGIN -2
! #define VSTINSTANCE_ERR_REJECTED -3
! #define VSTINSTANCE_NO_ERROR 0
!
! #define MIDI_NOTEON 144
! #define MIDI_NOTEOFF 128
! #define MIDI_POLYAFTERTOUCH 160
! #define MIDI_CONTROLCHANGE 176
! #define MIDI_PROGRAMCHANGE 192
! #define MIDI_AFTERTOUCH 208
! #define MIDI_PITCHBEND 224
class VSTPlugin:
--- 33,43 ----
! #define MIDI_MAX_EVENTS 64
+ class Responder
+ {
+ public:
+ virtual void Respond(const t_symbol *sym,int argc = 0,const t_atom *argv = NULL) = 0;
+ };
class VSTPlugin:
***************
*** 51,64 ****
public:
! VSTPlugin();
~VSTPlugin();
! int Instance(const char *dllname,const char *subplug = NULL);
void Free();
void DspInit(float samplerate,int blocksize);
! bool Is() const { return _pEffect != NULL; }
! long GetVersion() const { return _pEffect?_pEffect->version:0; }
bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
--- 46,64 ----
public:
! static void Setup();
!
! VSTPlugin(Responder *resp);
~VSTPlugin();
! bool Instance(const char *plug,const char *subplug = NULL);
void Free();
void DspInit(float samplerate,int blocksize);
! //////////////////////////////////////////////////////////////////////////////
! public:
! bool Is() const { return effect != NULL; }
!
! long GetVersion() const { return effect?effect->version:0; }
bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
***************
*** 66,77 ****
bool HasEditor() const { return HasFlags(effFlagsHasEditor); }
! const char *GetName() const { return _sProductName; }
! const char *GetVendorName() const { return _sVendorName; }
! const char *GetDllName() const { return _sDllName.c_str(); }
! int GetNumInputs() const { return _pEffect?_pEffect->numInputs:0; }
! int GetNumOutputs() const { return _pEffect?_pEffect->numOutputs:0; }
! int GetNumParams() const { return _pEffect?_pEffect->numParams:0; }
void GetParamName(int numparam,char *name) const;
void GetParamValue(int numparam,char *parval) const;
--- 66,87 ----
bool HasEditor() const { return HasFlags(effFlagsHasEditor); }
! const char *GetName() const { return productname; }
! const char *GetVendorName() const { return vendorname; }
! const char *GetDllName() const { return dllname.c_str(); }
! int GetNumInputs() const { return effect?effect->numInputs:0; }
! int GetNumOutputs() const { return effect?effect->numOutputs:0; }
! void ListPlugs(const t_symbol *sym) const;
!
! private:
! char productname[300];
! char vendorname[300];
! std::string dllname; // Contains dll name
!
! //////////////////////////////////////////////////////////////////////////////
!
! public:
! int GetNumParams() const { return effect?effect->numParams:0; }
void GetParamName(int numparam,char *name) const;
void GetParamValue(int numparam,char *parval) const;
***************
*** 90,108 ****
void SetCurrentProgram(int prg) { Dispatch(effSetProgram,0,prg); }
int GetCurrentProgram() const { return Dispatch(effGetProgram); }
! int GetNumPrograms() const { return _pEffect->numPrograms; }
int GetNumCategories() const { return Dispatch(effGetNumProgramCategories); }
! bool GetProgramName( int cat, int p , char* buf) const;
! bool AddMIDI(unsigned char data0,unsigned char data1=0,unsigned char data2=0);
- bool AddNoteOn( unsigned char note,unsigned char speed,unsigned char midichannel=0);
- bool AddNoteOff( unsigned char note,unsigned char midichannel=0);
-
- void AddControlChange( int control , int value );
- void AddProgramChange( int value );
- void AddPitchBend( int value );
- void AddAftertouch( int value );
void Edit(bool open);
--- 100,132 ----
void SetCurrentProgram(int prg) { Dispatch(effSetProgram,0,prg); }
int GetCurrentProgram() const { return Dispatch(effGetProgram); }
! int GetNumPrograms() const { return effect->numPrograms; }
int GetNumCategories() const { return Dispatch(effGetNumProgramCategories); }
! bool GetProgramName(int cat,int p,char* buf) const;
+ private:
+ struct NameCmp:
+ std::less<std::string>
+ {
+ bool operator()(const std::string &a,const std::string &b) const { return a.compare(b) < 0; }
+ };
! typedef std::map<std::string,int,NameCmp> NameMap;
! int paramnamecnt;
! NameMap paramnames;
!
! //////////////////////////////////////////////////////////////////////////////
!
! public:
! void SetPos(int x,int y,bool upd = true);
! void SetX(int x,bool upd = true) { SetPos(x,posy,upd); }
! void SetY(int y,bool upd = true) { SetPos(posx,y,upd); }
! int GetX() const { return posx; }
! int GetY() const { return posy; }
! void SetCaption(bool b);
! bool GetCaption() const { return caption; }
! void SetTitle(const char *t);
! const char *GetTitle() const { return title.c_str(); }
void Edit(bool open);
***************
*** 121,182 ****
void Paint(ERect &r) const { Dispatch(effEditDraw,0,0,&r); }
! void processReplacing( float **inputs, float **outputs, long sampleframes );
! void process( float **inputs, float **outputs, long sampleframes );
! long Dispatch(long opCode, long index = 0, long value = 0, void *ptr = NULL, float opt = 0) const
! {
! return Is()?_pEffect->dispatcher(_pEffect, opCode, index, value, ptr, opt):0;
! }
! static long VSTCALLBACK Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
! void SetPos(int x,int y,bool upd = true);
! void SetX(int x,bool upd = true) { SetPos(x,posy,upd); }
! void SetY(int y,bool upd = true) { SetPos(posx,y,upd); }
! int GetX() const { return posx; }
! int GetY() const { return posy; }
! void SetCaption(bool b);
! bool GetCaption() const { return caption; }
! void SetTitle(const char *t);
! const char *GetTitle() const { return title.c_str(); }
! protected:
! MHandle h_dll;
! WHandle hwnd;
! AEffect *_pEffect;
! static void FreeVST(MHandle handle);
! inline long GetFlags() const { return _pEffect?_pEffect->flags:0; }
! inline bool HasFlags(long msk) const { return _pEffect && (_pEffect->flags&msk); }
! char _sProductName[300];
! char _sVendorName[300];
! std::string _sDllName; // Contains dll name
! struct NameCmp:
! std::less<std::string>
{
! bool operator()(const std::string &a,const std::string &b) const { return a.compare(b) < 0; }
! };
! typedef std::map<std::string,int,NameCmp> NameMap;
! int paramnamecnt;
! NameMap paramnames;
!
! // static VstTimeInfo _timeInfo;
! VstMidiEvent midievent[MAX_EVENTS];
! VstEvents events;
! int queue_size;
! void SendMidi();
! char _midichannel;
! int posx,posy; // Window position
! bool caption; // Window border
! std::string title; // Window title
};
--- 145,315 ----
void Paint(ERect &r) const { Dispatch(effEditDraw,0,0,&r); }
! private:
! int posx,posy; // Window position
! bool caption; // Window border
! std::string title; // Window title
! //////////////////////////////////////////////////////////////////////////////
! public:
! enum {
! MIDI_NOTEON = 144,
! MIDI_NOTEOFF = 128,
! MIDI_POLYAFTERTOUCH = 160,
! MIDI_CONTROLCHANGE = 176,
! MIDI_PROGRAMCHANGE = 192,
! MIDI_AFTERTOUCH = 208,
! MIDI_PITCHBEND = 224
! };
!
! bool AddMIDI(unsigned char data0,unsigned char data1 = 0,unsigned char data2 = 0);
! static int range(int value,int mn = 0,int mx = 127) { return value < mn?mn:(value > mx?mx:value); }
! bool AddNoteOn(unsigned char note,unsigned char speed,unsigned char midichannel = 0)
! {
! return AddMIDI((char)MIDI_NOTEON|midichannel,note,speed);
! }
! bool AddNoteOff(unsigned char note,unsigned char midichannel = 0)
! {
! return AddMIDI((char)MIDI_NOTEOFF|midichannel,note,0);
! }
!
! void AddControlChange(int control,int value)
! {
! AddMIDI(MIDI_CONTROLCHANGE+(midichannel&0xf),range(control),range(value));
! }
! void AddProgramChange(int value)
! {
! AddMIDI(MIDI_PROGRAMCHANGE+(midichannel&0xf),range(value),0);
! }
! void AddPitchBend(int value)
! {
! AddMIDI(MIDI_PITCHBEND+(midichannel&0xf),((value>>7)&127),(value&127));
! }
! void AddAftertouch(int value)
! {
! AddMIDI((char)MIDI_AFTERTOUCH|midichannel,range(value));
! }
! private:
! void SendMidi();
! // static VstTimeInfo _timeInfo;
! VstMidiEvent midievent[MIDI_MAX_EVENTS];
! VstEvents events;
! int eventqusz;
!
! char midichannel;
!
! //////////////////////////////////////////////////////////////////////////////
!
! public:
!
! void SetPlaying(bool p) { if(playing != p) transchg = true,playing = p; }
! bool GetPlaying() const { return playing; }
! void SetLooping(bool p) { if(looping != p) transchg = true,looping = p; }
! bool GetLooping() const { return looping; }
!
! void SetSamplePos(double p) { if(samplepos != p) transchg = true,samplepos = p; }
! double GetSamplePos() const { return samplepos; }
! void SetTempo(double p) { if(tempo != p) transchg = true,tempo = p; }
! double GetTempo() const { return tempo; }
! void SetPPQPos(double p) { if(ppqpos != p) transchg = true,ppqpos = p; }
! double GetPPQPos() const { return ppqpos; }
!
! void SetTimesigNom(int p) { if(timesignom != p) transchg = true,timesignom = p; }
! int GetTimesigNom() const { return timesignom; }
! void SetTimesigDen(int p) { if(timesigden != p) transchg = true,timesigden = p; }
! int GetTimesigDen() const { return timesigden; }
! void SetBarStart(double p) { if(barstartpos != p) transchg = true,barstartpos = p; }
! double GetBarStart() const { return barstartpos; }
! void SetCycleStart(double p) { if(cyclestartpos != p) transchg = true,cyclestartpos = p; }
! double GetCycleStart() const { return cyclestartpos; }
! void SetCycleEnd(double p) { if(cycleendpos != p) transchg = true,cycleendpos = p; }
! double GetCycleEnd() const { return cycleendpos; }
!
! void SetSmpteOffset(int p) { if(smpteoffset != p) transchg = true,smpteoffset = p; }
! int GetSmpteOffset() const { return smpteoffset; }
! void SetSmpteRate(int p) { if(smpterate != p) transchg = true,smpterate = p; }
! int GetSmpteRate() const { return smpterate; }
!
! private:
!
! bool playing,looping;
! float samplerate;
! bool transchg;
!
! double samplepos,tempo;
! double ppqpos;
!
! int timesignom,timesigden;
! double barstartpos;
! double cyclestartpos,cycleendpos;
! int smpteoffset,smpterate;
!
! //////////////////////////////////////////////////////////////////////////////
!
! public:
! void processReplacing(float **inputs,float **outputs,long sampleframes )
{
! FLEXT_ASSERT(effect);
! effect->processReplacing(effect,inputs,outputs,sampleframes);
! if(playing) updatepos(sampleframes);
! }
! void process(float **inputs,float **outputs,long sampleframes )
! {
! FLEXT_ASSERT(effect);
! effect->process(effect,inputs,outputs,sampleframes);
! if(playing) updatepos(sampleframes);
! }
! private:
! void updatepos(long frames);
! //////////////////////////////////////////////////////////////////////////////
! private:
! Responder *responder;
!
! bool NewPlugin(const char *plugname);
! void FreePlugin();
! bool InstPlugin(long plugid = 0);
!
! static long uniqueid;
! static std::string dllloading;
!
! inline long GetFlags() const { return effect?effect->flags:0; }
! inline bool HasFlags(long msk) const { return effect && (effect->flags&msk); }
!
!
! // the handle to the shared library
! MHandle hdll;
! // the handle to the plugin editor window
! WHandle hwnd;
! // the VST plugin instance
! AEffect *effect;
!
! typedef AEffect *(VSTCALLBACK *PVSTMAIN)(audioMasterCallback audioMaster);
! PVSTMAIN pluginmain;
! audioMasterCallback audiomaster;
!
! long Dispatch(long opCode,long index = 0,long value = 0,void *ptr = NULL,float opt = 0) const
! {
! FLEXT_ASSERT(effect);
! return effect->dispatcher(effect,opCode,index,value,ptr,opt);
! }
!
! static long VSTCALLBACK Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
!
! static const t_symbol *sym_event,*sym_evmidi,*sym_evaudio,*sym_evvideo,*sym_evparam,*sym_evtrigger,*sym_evsysex,*sym_ev_;
! static const t_symbol *sym_midi[8];
!
! void ProcessEvent(const VstEvent &ev);
};
--- NEW FILE: vstparam.cpp ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: vstedit.cpp ---
(This appears to be a binary file; contents omitted.)
Index: main.h
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** main.h 10 Mar 2005 05:01:30 -0000 1.7
--- main.h 11 Mar 2005 04:58:01 -0000 1.8
***************
*** 25,40 ****
#endif
- typedef void V;
- typedef int I;
- typedef long L;
- typedef unsigned long UL;
- typedef float F;
- typedef t_sample R;
- typedef char C;
- typedef bool BL;
- typedef t_atom A;
- typedef t_symbol S;
-
-
#endif
--- 25,28 ----
--- NEW FILE: vstmaster.cpp ---
(This appears to be a binary file; contents omitted.)
Index: vsthost.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/vsthost.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** vsthost.cpp 10 Mar 2005 05:01:30 -0000 1.3
--- vsthost.cpp 11 Mar 2005 04:58:01 -0000 1.4
***************
*** 3,88 ****
based on the work of Jarno Seppänen and Mark Williamson
! Copyright (c)2003-2004 Thomas Grill (xovo(a)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 "AEffectx.h"
[...1112 lines suppressed...]
}
! void VSTPlugin::ListPlugs(const t_symbol *sym) const
{
! if(responder) {
! if(Is() && Dispatch(effGetPlugCategory) == kPlugCategShell) {
! t_atom at;
! // sub plugin-name given -> scan plugs
! char tmp[64];
! // scan shell for subplugins
! while(Dispatch(effShellGetNextPlugin,0,0,tmp)) {
! SetString(at,tmp);
! responder->Respond(sym,1,&at);
! }
}
! // bang
! responder->Respond(sym);
}
}
Index: vst.rc
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/vst.rc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** vst.rc 23 Jan 2004 04:20:44 -0000 1.3
--- vst.rc 11 Mar 2005 04:58:01 -0000 1.4
***************
*** 47,51 ****
VALUE "FileVersion", "0,1, 0, 8"
VALUE "InternalName", "vst~"
! VALUE "LegalCopyright", "Copyright (C) 2003-2004 Thomas Grill"
VALUE "OriginalFilename", "vst~.DLL"
VALUE "ProductName", "VST plugin object"
--- 47,51 ----
VALUE "FileVersion", "0,1, 0, 8"
VALUE "InternalName", "vst~"
! VALUE "LegalCopyright", "Copyright (C) 2003-2005 Thomas Grill"
VALUE "OriginalFilename", "vst~.DLL"
VALUE "ProductName", "VST plugin object"
Index: main.cpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/main.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** main.cpp 10 Mar 2005 05:01:29 -0000 1.21
--- main.cpp 11 Mar 2005 04:58:01 -0000 1.22
***************
*** 27,109 ****
! #define VST_VERSION "0.1.0pre18"
! class vst:
! public flext_dsp
{
FLEXT_HEADER_S(vst,flext_dsp,Setup)
[...1053 lines suppressed...]
! V vst::m_note(I note,I velocity)
{
if(!plug) return;
--- 947,951 ----
}
! void vst::m_note(int note,int velocity)
{
if(!plug) return;
***************
*** 919,920 ****
--- 956,963 ----
plug->AddNoteOff(note);
}
+
+ void vst::Respond(const t_symbol *sym,int argc,const t_atom *argv)
+ {
+ FLEXT_ASSERT(sym);
+ ToOutAnything(GetOutAttr(),sym,argc,argv);
+ }
--- NEW FILE: vstmidi.cpp ---
(This appears to be a binary file; contents omitted.)
Index: editorwin.hpp
===================================================================
RCS file: /cvsroot/pure-data/externals/grill/vst/src/editorwin.hpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** editorwin.hpp 18 Dec 2004 05:06:58 -0000 1.1
--- editorwin.hpp 11 Mar 2005 04:58:01 -0000 1.2
***************
*** 39,43 ****
break;
case WM_CLOSE:
! #ifdef FLEXT_DEBUG
flext::post("WM_CLOSE");
#endif
--- 39,43 ----
break;
case WM_CLOSE:
! #ifdef FLEXT_LOGGING
flext::post("WM_CLOSE");
#endif
***************
*** 47,51 ****
break;
case WM_DESTROY:
! #ifdef FLEXT_DEBUG
flext::post("WM_DESTROY");
#endif
--- 47,51 ----
break;
case WM_DESTROY:
! #ifdef FLEXT_LOGGING
flext::post("WM_DESTROY");
#endif
***************
*** 67,71 ****
// x and y are the coordinates of the client rect (= actual VST interface)
plug->SetPos(x,y,false);
! #ifdef FLEXT_DEBUG
flext::post("WM_MOVE x/y=%i/%i",x,y);
#endif
--- 67,71 ----
// x and y are the coordinates of the client rect (= actual VST interface)
plug->SetPos(x,y,false);
! #ifdef FLEXT_LOGGING
flext::post("WM_MOVE x/y=%i/%i",x,y);
#endif
***************
*** 88,92 ****
#endif
! #if 0 //def FLEXT_DEBUG
case WM_SIZE: {
WORD wx = LOWORD(lp),wy = HIWORD(lp);
--- 88,92 ----
#endif
! #if 0 //def FLEXT_LOGGING
case WM_SIZE: {
WORD wx = LOWORD(lp),wy = HIWORD(lp);
***************
*** 99,103 ****
default:
! #ifdef FLEXT_DEBUG
flext::post("WND MSG %i, WP=%i, lp=%i",msg,wp,lp);
#endif
--- 99,103 ----
default:
! #ifdef FLEXT_LOGGING
flext::post("WND MSG %i, WP=%i, lp=%i",msg,wp,lp);
#endif
***************
*** 170,174 ****
plug->GetEditorRect(r);
windowsize(wnd,plug->GetX(),plug->GetY(),r.right-r.left,r.bottom-r.top,plug->GetCaption(),SWP_SHOWWINDOW);
! #ifdef FLEXT_DEBUG
flext::post("Editor rect left/top=%i/%i, right/bottom=%i/%i",r.left,r.top,r.right,r.bottom);
#endif
--- 170,174 ----
plug->GetEditorRect(r);
windowsize(wnd,plug->GetX(),plug->GetY(),r.right-r.left,r.bottom-r.top,plug->GetCaption(),SWP_SHOWWINDOW);
! #ifdef FLEXT_LOGGING
flext::post("Editor rect left/top=%i/%i, right/bottom=%i/%i",r.left,r.top,r.right,r.bottom);
#endif
***************
*** 221,229 ****
void StartEditor(VSTPlugin *p)
{
! #ifdef FLEXT_DEBUG
flext::post("Start editor 1");
#endif
flext::LaunchThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
! #ifdef FLEXT_DEBUG
flext::post("Start editor 2");
#endif
--- 221,229 ----
void StartEditor(VSTPlugin *p)
{
! #ifdef FLEXT_LOGGING
flext::post("Start editor 1");
#endif
flext::LaunchThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
! #ifdef FLEXT_LOGGING
flext::post("Start editor 2");
#endif
***************
*** 232,241 ****
void StopEditor(VSTPlugin *p)
{
! #ifdef FLEXT_DEBUG
flext::post("Stop editor 1");
#endif
PostMessage(p->EditorHandle(),WM_CLOSE,0,0);
flext::StopThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
! #ifdef FLEXT_DEBUG
flext::post("Stop editor 2");
#endif
--- 232,241 ----
void StopEditor(VSTPlugin *p)
{
! #ifdef FLEXT_LOGGING
flext::post("Stop editor 1");
#endif
PostMessage(p->EditorHandle(),WM_CLOSE,0,0);
flext::StopThread(threadfun,reinterpret_cast<flext::thr_params *>(p));
! #ifdef FLEXT_LOGGING
flext::post("Stop editor 2");
#endif