-
Notifications
You must be signed in to change notification settings - Fork 2
/
plugin.h
237 lines (194 loc) · 5.29 KB
/
plugin.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
#ifndef __VST_PLUGIN_H__
#define __VST_PLUGIN_H__
#include <vector>
#include <public.sdk/source/vst2.x/audioeffectx.h>
#include "lock.h"
//#define dprintf(...) {}
//#include "../DebugMsg/Debug.h"
#define PLUGIN_EFFECT_NAME "None"
#define PLUGIN_VENDOR_NAME "FSM"
#define PLUGIN_PRODUCT_NAME "FSM Kick XP"
#define LOG_SCALE_GAIN (0.3f)
#define SCALE_GAIN_OVERHEAD (1.3f)
#define NOTE_OFF 255
#define VOICE_HOLD 0
#define VOICE_DECAY 1
#define VOICE_KILLED 2
typedef unsigned char byte;
typedef unsigned short word;
typedef unsigned long dword;
class FSM_VST_Plugin;
enum
{
// Global
kNumPrograms = 100,
kNumOutputs = 2,
};
enum
{
kVolume,
kStartFrq,
kEndFrq,
kBuzzAmt,
kClickAmt,
kPunchAmt,
kToneDecay,
kToneShape,
kBDecay,
kCDecay,
kDecSlope,
kDecTime,
kRelSlope,
kNumParams
};
class SynthParameter
{
public:
char const *Name; // Short name: "Cutoff"
char const *Description;// Longer description: "Cutoff Frequency (0-7f)"
int MinValue; // 0
int MaxValue; // 127
int DefValue; // default value for params that have MPF_STATE flag set
};
class ProgramParameters
{
public:
float bStartFrq;
float bEndFrq;
float bBuzzAmt;
float bClickAmt;
float bPunchAmt;
float bToneDecay;
float bToneShape;
float bBDecay;
float bCDecay;
float bDecSlope;
float bDecTime;
float bRelSlope;
};
class VoiceParameters
{
public:
float PitchLimit;
float ThisPitchLimit;
float StartFrq;
float ThisStartFrq;
float EndFrq;
float ThisEndFrq;
float TDecay;
float ThisTDecay;
float TShape;
float ThisTShape;
float DSlope;
float ThisDSlope;
float DTime;
float ThisDTime;
float RSlope;
float ThisRSlope;
float BDecay;
float ThisBDecay;
float CDecay;
float ThisCDecay;
float CurVolume;
float ThisCurVolume;
float ClickAmt;
float PunchAmt;
float BuzzAmt;
float Amp;
float DecAmp;
float BAmp;
float MulBAmp;
float CAmp;
float MulCAmp;
float Frequency;
double xSin, xCos, dxSin, dxCos;
int EnvPhase;
int LeftOver;
int Age;
double OscPhase;
};
class FSM_Voice : public VoiceParameters
{
public:
VstInt32 currentNote;
VstInt32 currentVelocity;
VstInt32 currentDelta;
VstInt32 releaseDelta;
int state;
FSM_Voice(VstInt32 note, VstInt32 velocity, VstInt32 delta);
void setNoteReleaseDeta(VstInt32 delta);
void setState(int newState);
void setParameters(ProgramParameters* vals, float sr);
void trigger();
float velocity()const
{
return currentVelocity / 127.0f;
}
};
//------------------------------------------------------------------------------------------
// FSM_VST_Program
//------------------------------------------------------------------------------------------
class FSM_VST_Program : public ProgramParameters
{
friend class FSM_VST_Plugin;
public:
FSM_VST_Program ();
~FSM_VST_Program() {}
void set(char* _name, int start, int end,
int buzz, int click, int punch, int tDecR, int tDecS,
int bDecR, int CPDecR, int ADecS, int ADecT, int ARelS);
private:
char name[kVstMaxProgNameLen+1];
};
//------------------------------------------------------------------------------------------
// FSM_VST_Plugin
//------------------------------------------------------------------------------------------
class FSM_VST_Plugin : public AudioEffectX {
public:
FSM_VST_Plugin (audioMasterCallback audioMaster);
~FSM_VST_Plugin ();
virtual void processReplacing (float** inputs, float** outputs, VstInt32 sampleFrames);
virtual VstInt32 processEvents (VstEvents* events);
virtual void setProgram(VstInt32 program);
virtual void setProgramName(char* name);
virtual void getProgramName(char* name);
virtual bool beginSetProgram() { this->issetprogram = true; return false; } ///< Called before a program is loaded
virtual bool endSetProgram() { this->issetprogram = false; return false; } ///< Called after a program was loaded
virtual bool getProgramNameIndexed (VstInt32 category, VstInt32 index, char* text);
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 void setSampleRate (float sampleRate);
virtual void setBlockSize (VstInt32 blockSize);
virtual bool getOutputProperties (VstInt32 index, VstPinProperties* properties);
virtual bool getEffectName (char* name);
virtual bool getVendorString (char* text);
virtual bool getProductString (char* text);
virtual VstInt32 getVendorVersion ();
virtual VstInt32 canDo (char* text);
virtual VstInt32 getNumMidiInputChannels ();
virtual VstInt32 getNumMidiOutputChannels ();
FSM_VST_Program* current() {
return &(curProgram >= 0 && curProgram < kNumPrograms ? programs[curProgram] : programs[0]);
}
#ifdef DEBUG_CONSOLE
VstIntPtr dispatcher(VstInt32 opcode, VstInt32 index, VstIntPtr value, void* ptr, float opt);
void startConsoleWin(int width, int height, char* fname);
HANDLE hout;
#endif // DEBUG_CONSOLE
private:
void noteOn(VstInt32 note, VstInt32 velocity, VstInt32 delta);
void noteOff(VstInt32 note, VstInt32 delta);
void allNotesOff(bool decay);
void initProcess();
bool processVoice(FSM_Voice *trk, float *pout, int c, float gain);
FSM_VST_Program* programs;
std::vector<FSM_Voice*> voices;
float fVolume;
bool issetprogram;
float thumpdata1[1024];
Lock* lock;
};
#endif