aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/vst/src/VstHost.h
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/vst/src/VstHost.h')
-rw-r--r--externals/grill/vst/src/VstHost.h184
1 files changed, 88 insertions, 96 deletions
diff --git a/externals/grill/vst/src/VstHost.h b/externals/grill/vst/src/VstHost.h
index b6246e7d..6b856956 100644
--- a/externals/grill/vst/src/VstHost.h
+++ b/externals/grill/vst/src/VstHost.h
@@ -7,18 +7,21 @@ For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution.
*/
-#ifndef _VSTPLUGIN_HOST
-#define _VSTPLUGIN_HOST
+#ifndef __VSTHOST_H
+#define __VSTHOST_H
-#include "Vst\AEffectx.h"
#include <flext.h>
+#include "Vst\AEffectx.h"
+#include "vst\aeffeditor.h"
#if FLEXT_OS == FLEXT_OS_WIN
#include <windows.h>
+typedef HWND WHandle;
#else
#error Platform not supported!
#endif
+
#define MAX_EVENTS 64
#define MAX_INOUTS 8
@@ -35,138 +38,127 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define MIDI_AFTERTOUCH 208
#define MIDI_PITCHBEND 224
-typedef AEffect* (*PVSTMAIN)(audioMasterCallback audioMaster);
-typedef HWND (*POPWIN)(void);
-typedef HWND (*GETWIN)(void);
class VSTPlugin:
public flext
{
public:
- int GetNumCategories();
- bool GetProgramName( int cat, int p , char* buf);
- void AddControlChange( int control , int value );
- void AddProgramChange( int value );
- void AddPitchBend( int value );
- void AddAftertouch( int value );
- bool ShowParams();
- void SetShowParameters( bool s);
-
- void SetEditWindow( HWND h );
- void StopEditing();
- void OnEditorClose();
- HWND EditorHandle() { return hwnd; }
-
- RECT GetEditorRect();
- void EditorIdle();
-
- void edit(bool open);
- void visible(bool vis);
- bool replace( );
VSTPlugin();
~VSTPlugin();
+ int Instance(const char *dllname);
+// void Create(VSTPlugin *plug);
void Free();
- int Instance( const char *dllname);
- void Create(VSTPlugin *plug);
- void Init( float samplerate , float blocksize );
+ void DspInit(float samplerate,int blocksize);
- virtual int GetNumParams(void) { return _pEffect->numParams; }
- virtual void GetParamName(int numparam,char* name)
- {
- if ( numparam < _pEffect->numParams ) Dispatch(effGetParamName,numparam,0,name,0.0f);
- else strcpy(name,"Out of Range");
+ bool Is() const { return _pEffect != NULL; }
- }
- virtual void GetParamValue(int numparam,char* parval)
- {
- if ( numparam < _pEffect->numParams ) DescribeValue(numparam,parval);
- else strcpy(parval,"Out of Range");
- }
- virtual float GetParamValue(int numparam)
- {
- if ( numparam < _pEffect->numParams ) return (_pEffect->getParameter(_pEffect, numparam));
- else return -1.0;
- }
+ ULONG GetVersion() const { return _pEffect?_pEffect->version:0; }
- int getNumInputs( void );
- int getNumOutputs( void );
-
- virtual char* GetName(void) { return _sProductName; }
- unsigned long GetVersion() { return _version; }
- char* GetVendorName(void) { return _sVendorName; }
- char* GetDllName(void) { return _sDllName; }
-
- long NumParameters(void) { return _pEffect->numParams; }
- float GetParameter(long parameter) { return _pEffect->getParameter(_pEffect, parameter); }
- bool DescribeValue(int parameter,char* psTxt);
- bool SetParameter(int parameter, float value);
- bool SetParameter(int parameter, int value);
- void SetCurrentProgram(int prg);
- int GetCurrentProgram();
- int NumPrograms() { return _pEffect->numPrograms; }
- bool IsSynth() { return _isSynth; }
- bool HasEditor() const { return _editor; }
+ bool IsSynth() const { return HasFlags(effFlagsIsSynth); }
+ bool IsReplacing() const { return HasFlags(effFlagsCanReplacing); }
+ bool HasEditor() const { return HasFlags(effFlagsHasEditor); }
- bool AddMIDI(unsigned char data0,unsigned char data1=0,unsigned char data2=0);
- void SendMidi();
+ 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; }
- void processReplacing( float **inputs, float **outputs, long sampleframes );
- void process( float **inputs, float **outputs, long sampleframes );
+ int GetNumParams() const { return _pEffect?_pEffect->numParams:0; }
+ void GetParamName(int numparam,char *name) const;
+ void GetParamValue(int numparam,char *parval) const;
+ float GetParamValue(int numparam) const;
- AEffect *_pEffect;
- long Dispatch(long opCode, long index, long value, void *ptr, float opt)
- {
- return _pEffect->dispatcher(_pEffect, opCode, index, value, ptr, opt);
- }
+ bool SetParamFloat(int parameter, float value);
+ bool SetParamInt(int parameter, int value) { return SetParamFloat(parameter,value/65535.0f); }
+
+ 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;
- static long Master(AEffect *effect, long opcode, long index, long value, void *ptr, float opt);
+
+ 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 );
- char _midichannel;
- bool instantiated;
- int _instance; // Remove when Changing the FileFormat.
-
- void setPos(int x,int y) { posx = x; posy = y; }
- void setX(int x) { posx = x; }
- void setY(int y) { posy = y; }
- int getX() const { return posx; }
- int getY() const { return posy; }
+ void Edit(bool open);
+ void StartEditing(WHandle h );
+ void StopEditing();
bool IsEdited() const { return hwnd != NULL; }
+ WHandle EditorHandle() const { return hwnd; }
+
+ void GetEditorRect(ERect &er) const { ERect *r; Dispatch(effEditGetRect,0,0,&r); er = *r; }
+ void EditorIdle() { Dispatch(effEditIdle); }
+
+ void Visible(bool vis);
+ bool IsVisible() const;
+
+// 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 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; }
protected:
+#if FLEXT_OS == FLEXT_OS_WIN
HMODULE h_dll;
- HMODULE h_winddll;
- HWND hwnd;
+#else
+#error
+#endif
+
+ WHandle hwnd;
+
+ AEffect *_pEffect;
+ inline long GetFlags() const { return _pEffect?_pEffect->flags:0; }
+ inline bool HasFlags(long msk) const { return _pEffect && (_pEffect->flags&msk); }
char _sProductName[64];
char _sVendorName[64];
- char *_sDllName; // Contains dll name
- ULONG _version;
- bool _isSynth,_editor;
+ std::string _sDllName; // Contains dll name
- float * inputs[MAX_INOUTS];
- float * outputs[MAX_INOUTS];
- float junk[256];
+/*
+ float *inputs[MAX_INOUTS];
+ float *outputs[MAX_INOUTS];
+*/
- static VstTimeInfo _timeInfo;
+// static VstTimeInfo _timeInfo;
VstMidiEvent midievent[MAX_EVENTS];
VstEvents events;
int queue_size;
- bool overwrite;
-private:
+// float sample_rate;
+
+ void SendMidi();
+ char _midichannel;
+
int posx,posy;
- bool show_params;
- static float sample_rate;
};
-#endif // _VSTPLUGIN_HOST
+#endif