-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathVSTCollection.h
223 lines (201 loc) · 9.63 KB
/
VSTCollection.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#ifndef _VST_COLLECTION_
#define _VST_COLLECTION_
/*==================================================================================================
Module Name: VSTCollection.h
General Description: VSTCollection class declaration. This class represents abstract element
which behaves as a black box having input stream, output stream and
set of parameters/settings which can be manipulated by client app.
Changing of available characteristics of the plugin instance will
influence output stream.
====================================================================================================
Revision History:
Modification
Author Date Major Changes
---------------------- ------------ -------------
Holy Spirit 07/23/2008 Initial version
==================================================================================================*/
//=================================================================================================
// Include Section
//=================================================================================================
#include "windows.h"
#include "CVSTHost.h"
//#include "Awful.h"
#include "Awful_effects.h"
#include "Awful_objects.h"
#include "awful_jucewindows.h"
//=================================================================================================
// Definition Section
//=================================================================================================
#define VST_MAX_NAME_LENGTH (100)
#define VST_MAX_PARAM_LABEL_LENGTH (30)
#define VST_MAX_PARAM_VALUE_LENGTH (60)
#define IDLE_TIMER (USER_TIMER_MINIMUM + 6)
#define IDLE_TIMER_INTERVAL (100)
#define WM_VST_PLUGEDITOR_CLOSED (WM_USER + 1)
//=================================================================================================
//***************************** Class Declaration Section *****************************************
//=================================================================================================
class CChaoticEffect : public CEffect, public Object
{
public:
CChaoticEffect(CVSTHost *pHost) : CEffect(pHost), Object() { this->owner = NULL; };
virtual ~CChaoticEffect() {};
//long EffProcessEvents(VstEvents * ptr);
};
//-------------------------------------------------------------------------------------------------
// CChaoticVSTHost Class Declaration
//-------------------------------------------------------------------------------------------------
class CChaoticVSTHost : public CVSTHost
{
public:
CChaoticVSTHost();
bool OnSetParameterAutomated(int nEffect, long index, float value);
bool OnUpdateDisplay(int nEffect);
void SetSampleRate(float fSampleRate);
void SetTempo(float fBPM);
// virtual bool OnOpenFileSelector (int nEffect, VstFileSelect *ptr);
// virtual bool OnCloseFileSelector (int nEffect, VstFileSelect *ptr);
virtual CEffect * CreateEffect()
{
return new CChaoticEffect(this);
}
virtual long OnIdle(int nEffect=-1);
virtual bool OnGetVendorString(char *text) { strcpy(text, "Chaotic Systems"); return true; }
virtual long OnGetHostVendorVersion() { return 1; }
virtual bool OnGetProductString(char *text) { strcpy(text, "Chaotic Sound Producer"); return true; }
virtual bool OnCanDo(const char *ptr);
virtual long OnAudioMasterCallback(int nEffect, long opcode, long index, long value, void *ptr, float opt);
};
//When build with JUCE, we use juce's windows
#ifndef USE_JUCE
//-------------------------------------------------------------------------------------------------
// VST Editor Window Class Declaration
//-------------------------------------------------------------------------------------------------
class CVSTEffWnd: public Object
{
public:
CVSTEffWnd(CChaoticEffect* pEffect, void* ParentWnd, CVSTPlugin* pPlug);
~CVSTEffWnd(){};
void SetTitle();
void SetEffect(CChaoticEffect* pEffect){ this->pEffect = pEffect; };
void ShowWindow(){ ::ShowWindow(this->hWndHandle, SW_SHOWNORMAL); };
void UpdateWindow(){ ::UpdateWindow(this->hWndHandle); };
void SetFocus(){ ::SetFocus(this->hWndHandle); };
void Close(){ ::DestroyWindow(this->hWndHandle); };
CVSTPlugin* pPlugin;
void* hWndHandle; //window handle
unsigned short width;
unsigned short height;
static LRESULT CALLBACK VSTWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
protected:
CChaoticEffect *pEffect;
void* ParentHWND;
};
#endif // USE_JUCE
//-------------------------------------------------------------------------------------------------
// VST Parameters Window Class Declaration
//-------------------------------------------------------------------------------------------------
class CVSTEffParamWnd: public Object
{
CVSTEffParamWnd();
~CVSTEffParamWnd();
};
//-------------------------------------------------------------------------------------------------
// VST Plugin Class Declaration
//-------------------------------------------------------------------------------------------------
class CVSTPlugin : public Object
{
public:
CVSTPlugin(Object* owner, int index, CChaoticVSTHost* pHost, void* ParentWindow);
~CVSTPlugin();
/* Inherited from Eff parent class */
void ProcessData(float* in_buff, float* out_buff, int num_frames);
void ProcessEvents(VstEvents *pEvents);
bool ShowEditor();
bool CloseEditor();
void Open();
void Close();
void SetParam(long index, float Value);
float GetParam(long index);
unsigned int GetNumParams();
void GetDisplayValue(long index, char** ppValDisp);
void GetParamName(long index, char** ppName);
void GetParamLabel(long index, char **ppLabel);
void SetReplacing(bool fReplace) { this->isReplacing = fReplace; };
bool HasEditor() { return hasEditor; };
bool UsesChunks() { return usesChunks; };
void GetDisplayName(char *name, unsigned int length);
long GetNumPresets();
void GetProgramName(char *pName);
long GetProgram();
void SetProgram(long index);
void Idle();
void EditIdle();
void SetBPM(float bpm);
void SetSampleRate(float fSampleRate);
void SetBufferSize(unsigned int uiBufferSize);
void TurnOffProcessing();
void TurnOnProcessing();
// void GetPresetName(long index);
// long GetPresetIndex(char* name);
// bool SetPresetByName(char* name);
// bool SetPresetByIndex(long index);
// void RenamePreset(long index, char* new_name);
// void RenamePreset(char* old_name, char* new_name);
// void SavePresetAs(char *name);
void GetErrorText();
bool isWindowActive;
bool isGenerator;
HANDLE hMutex;
CChaoticEffect *pEffect;
int eff_index;
CChaoticVSTHost* pHost;
int nAllocatedInbufs;
int nAllocatedOutbufs;
Scope* scope;
#ifndef USE_JUCE
CVSTEffWnd *pWnd;
#else
PluginEditWindow *pWnd;
#endif
int dispatch( const int opcode,
const int index,
const int value,
void* const ptr,
float opt )
{
return this->pEffect->EffDispatch(opcode, index, value, ptr, opt);
}
private:
void* ParentHWND;
float **inBufs;
float **outBufs;
bool isReplacing;
bool hasEditor;
bool usesChunks;
};
//-------------------------------------------------------------------------------------------------
// VST Collection Class Declaration
//-------------------------------------------------------------------------------------------------
class VSTCollection
{
public:
VSTCollection(void* MainWindowHandle);
~VSTCollection();
CVSTPlugin* LoadPlugin(Object * owner, char* path);
CChaoticVSTHost* pMainHost;
void RemovePlugin(CVSTPlugin *pPlug);
bool CheckPlugin(char *path, bool *isGenerator, char* name);
void SetBufferSize(unsigned int uiBufferSize)
{
this->pMainHost->SetBlockSize(uiBufferSize);
}
void SetBPM(float bpm) { this->pMainHost->SetTempo(bpm);}
void SetSampleRate(float fSampleRate){this->pMainHost->SetSampleRate(fSampleRate);}
void AcquireSema();
void ReleaseSema();
protected:
void* ParentHWND;
HANDLE hMutex;
};
#endif // _VST_COLLECTION_