-
Notifications
You must be signed in to change notification settings - Fork 41
/
remotepluginserver.h
286 lines (231 loc) · 6.94 KB
/
remotepluginserver.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* dssi-vst: a DSSI plugin wrapper for VST effects and instruments
Copyright 2004-2007 Chris Cannam
*/
#ifndef REMOTE_PLUGIN_SERVER_H
#define REMOTE_PLUGIN_SERVER_H
#ifdef __WINE__
#else
#define __cdecl
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef DRAGWIN
#include <objidl.h>
#include <shellapi.h>
#endif
#undef min
#undef max
#ifdef VESTIGE
typedef int16_t VstInt16;
typedef int32_t VstInt32;
typedef int64_t VstInt64;
typedef intptr_t VstIntPtr;
#define VESTIGECALLBACK __cdecl
#include "vestige.h"
#else
#include "pluginterfaces/vst2.x/aeffectx.h"
#endif
#include "rdwrops.h"
#include "remoteplugin.h"
#include <string>
#include <atomic>
class RemotePluginServer {
public:
virtual ~RemotePluginServer();
virtual int getVersion() = 0;
virtual std::string getName() = 0;
virtual std::string getMaker() = 0;
virtual void setBufferSize(int) = 0;
virtual void setSampleRate(int) = 0;
virtual void reset() = 0;
virtual void terminate() = 0;
virtual int getInputCount() = 0;
virtual int getOutputCount() = 0;
virtual int getFlags() = 0;
virtual int getinitialDelay() = 0;
virtual int processVstEvents() = 0;
virtual void getChunk(ShmControl *m_shmControlptr) = 0;
virtual void setChunk(ShmControl *m_shmControlptr) = 0;
virtual void canBeAutomated(ShmControl *m_shmControlptr) = 0;
virtual void getProgram(ShmControl *m_shmControlptr) = 0;
virtual void EffectOpen(ShmControl *m_shmControlptr) = 0;
// virtual int getUniqueID() = 0;
// virtual int getVersion() = 0;
// virtual void eff_mainsChanged(int v) = 0;
virtual int getUID() { return 0; }
virtual int getParameterCount() { return 0; }
virtual std::string getParameterName(int) { return ""; }
virtual std::string getParameterLabel(int) { return ""; }
virtual std::string getParameterDisplay(int) { return ""; }
virtual void setParameter(int, float) { return; }
virtual float getParameter(int) { return 0.0f; }
virtual float getParameterDefault(int) { return 0.0f; }
virtual void getParameters(int p0, int pn, float *v) {
for (int i = p0; i <= pn; ++i)
v[i - p0] = 0.0f;
}
#ifdef WAVES
virtual int getShellName(char *name) { return 0; }
#endif
virtual int getProgramCount() { return 0; }
virtual int getProgramNameIndexed(int, char *name) { return 0; }
virtual std::string getProgramName() { return ""; }
virtual void setCurrentProgram(int) { return; }
virtual int getEffInt(int opcode, int value) { return 0; }
virtual std::string getEffString(int opcode, int index) { return ""; }
virtual void effDoVoid(int opcode) { return; }
virtual int effDoVoid2(int opcode, int index, int value, float opt) {
return 0;
}
virtual void process(float **inputs, float **outputs, int sampleFrames) = 0;
#ifdef DOUBLEP
virtual void processdouble(double **inputs, double **outputs,
int sampleFrames) = 0;
virtual bool setPrecision(int value) { return false; }
#ifndef INOUTMEM
double **m_inputsdouble;
double **m_outputsdouble;
#else
double *m_inputsdouble[1024];
double *m_outputsdouble[1024];
#endif
#endif
virtual bool getInProp(int index, ShmControl *m_shmControlptr) {
return false;
}
virtual bool getOutProp(int index, ShmControl *m_shmControlptr) {
return false;
}
#ifdef MIDIEFF
virtual bool getMidiKey(int index, ShmControl *m_shmControlptr) {
return false;
}
virtual bool getMidiProgName(int index, ShmControl *m_shmControlptr) {
return false;
}
virtual bool getMidiCurProg(int index, ShmControl *m_shmControlptr) {
return false;
}
virtual bool getMidiProgCat(int index, ShmControl *m_shmControlptr) {
return false;
}
virtual bool getMidiProgCh(int index, ShmControl *m_shmControlptr) {
return false;
}
virtual bool setSpeaker(ShmControl *m_shmControlptr) { return false; }
virtual bool getSpeaker(ShmControl *m_shmControlptr) { return false; }
#endif
#ifdef CANDOEFF
virtual bool getEffCanDo(std::string) = 0;
#endif
virtual void setDebugLevel(RemotePluginDebugLevel) { return; }
virtual bool warn(std::string) = 0;
virtual void showGUI(ShmControl *m_shmControlptr) {}
virtual void hideGUI() {}
virtual void hideGUI2() {}
#ifdef EMBED
virtual void openGUI() {}
#endif
virtual void guiUpdate() {}
virtual void finisherror() {}
void dispatch(int timeout = -1); // may throw RemotePluginClosedException
void dispatchControl(int timeout = -1); // may throw RemotePluginClosedException
void dispatchProcess(int timeout = -1); // may throw RemotePluginClosedException
void dispatchGetSet(int timeout = -1); // may throw RemotePluginClosedException
void dispatchPar(int timeout = -1); // may throw RemotePluginClosedException
void dispatchControl2(int timeout = -1); // may throw RemotePluginClosedException
int sizeShm();
char *m_shm;
char *m_shm2;
char *m_shm3;
char *m_shm4;
char *m_shm5;
#ifdef PCACHE
char *m_shm6;
struct alignas(64) ParamState {
float value;
float valueupdate;
char changed;
};
#endif
int m_shmControlFd;
int m_threadsfinish;
void waitForClient2exit();
void waitForClient3exit();
void waitForClient4exit();
void waitForClient5exit();
void waitForClient6exit();
protected:
RemotePluginServer(std::string fileIdentifiers);
void cleanup();
private:
void dispatchControlEvents(ShmControl *m_shmControlptr);
void dispatchProcessEvents();
void dispatchGetSetEvents();
void dispatchParEvents();
int m_flags;
int m_shmFd;
size_t m_shmSize;
char *m_shmFileName;
#ifndef INOUTMEM
float **m_inputs;
float **m_outputs;
#else
float *m_inputs[1024];
float *m_outputs[1024];
#endif
RemotePluginDebugLevel m_debugLevel;
public:
#ifdef CHUNKBUF
void *chunkptr;
char *chunkptr2;
#endif
int m_bufferSize;
int m_numInputs;
int m_numOutputs;
ShmControl *m_shmControl;
ShmControl *m_shmControl2;
ShmControl *m_shmControl3;
ShmControl *m_shmControl4;
ShmControl *m_shmControl5;
ShmControl *m_shmControl6;
void waitForServer(ShmControl *m_shmControlptr);
void waitForServerexit();
void waitForServerexcept();
void RemotePluginClosedException();
int m_inexcept;
int m_386run;
#ifdef EMBED
#ifdef TRACKTIONWM
int hosttracktion;
#endif
#endif
int starterror;
int initdone;
bool fwait(ShmControl *m_shmControlptr, std::atomic_int *fcount, int ms);
bool fpost(ShmControl *m_shmControlptr, std::atomic_int *fcount);
bool fwait2(ShmControl *m_shmControlptr, std::atomic_int *fcount, int ms);
bool fpost2(ShmControl *m_shmControlptr, std::atomic_int *fcount);
VstTimeInfo *timeinfo;
VstTimeInfo timeinfo2;
int bufferSize;
int sampleRate;
struct alignas(64) vinfo {
char a[64 + 8 + (sizeof(int32_t) * 2) + 48];
// char a[96];
};
struct alignas(64) winmessage {
int handle;
int width;
int height;
int winerror;
} winm2;
winmessage *winm;
HANDLE ThreadHandle[4];
ShmControl *m_shmControlptr;
int m_updateio;
int m_updatein;
int m_updateout;
int m_delay;
};
#endif