-
Notifications
You must be signed in to change notification settings - Fork 7
/
vst2wrapper.h
229 lines (188 loc) · 8.38 KB
/
vst2wrapper.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
//------------------------------------------------------------------------
// Project : VST SDK
//
// Category : Helpers
// Filename : public.sdk/source/vst/vst2wrapper/vst2wrapper.h
// Created by : Steinberg, 01/2009
// Description : VST 3 -> VST 2 Wrapper
//
//-----------------------------------------------------------------------------
// LICENSE
// (c) 2019, Steinberg Media Technologies GmbH, All Rights Reserved
//-----------------------------------------------------------------------------
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of the Steinberg Media Technologies nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//-----------------------------------------------------------------------------
#pragma once
#include "docvst2.h"
/// \cond ignore
#include "basewrapper.h"
// #include "public.sdk/source/vst2.x/audioeffectx.h"
//------------------------------------------------------------------------
namespace Steinberg {
namespace Vst {
class Vst2MidiEventQueue;
class Vst2EditorWrapper;
//------------------------------------------------------------------------
class Vst2Wrapper : public BaseWrapper,
public IVst3ToVst2Wrapper
// , public ::AudioEffectX, public IVst3ToVst2Wrapper
{
public:
Vst2EditorWrapper *editor;
// will owned factory
static Vst2Wrapper *create(IPluginFactory *factory,
const TUID vst3ComponentID, VstInt32 vst2ID,
audioMasterCallback audioMaster);
Vst2Wrapper(BaseWrapper::SVST3Config &config, audioMasterCallback audioMaster,
VstInt32 vst2ID);
virtual ~Vst2Wrapper();
//--- ------------------------------------------------------
//--- BaseWrapper ------------------------------------------
bool init(audioMasterCallback audioMaster);
void _canDoubleReplacing(bool val);
void _setInitialDelay(int32 delay);
void _noTail(bool val);
void setupProcessTimeInfo();
void setupParameters();
void setupBuses();
void _ioChanged();
void _updateDisplay();
void _setNumInputs(int32 inputs);
void _setNumOutputs(int32 outputs);
bool _sizeWindow(int32 width, int32 height);
//--- ---------------------------------------------------------------------
// VST 3 Interfaces ------------------------------------------------------
// IComponentHandler
tresult PLUGIN_API beginEdit(ParamID tag);
tresult PLUGIN_API performEdit(ParamID tag, ParamValue valueNormalized);
tresult PLUGIN_API endEdit(ParamID tag);
// IHostApplication
tresult PLUGIN_API getName(String128 name);
//--- ---------------------------------------------------------------------
// VST 2 AudioEffectX overrides
// -----------------------------------------------
void suspend(); // Called when Plug-in is switched to off
void resume(); // Called when Plug-in is switched to on
VstInt32 startProcess();
VstInt32 stopProcess();
// Called when the sample rate changes (always in a suspend state)
void setSampleRate(float newSamplerate);
// Called when the maximum block size changes
// (always in a suspend state). Note that the
// sampleFrames in Process Calls could be
// smaller than this block size, but NOT bigger.
void setBlockSize(VstInt32 newBlockSize);
float getParameter(VstInt32 index);
void setParameter(VstInt32 index, float value);
void setProgram(VstInt32 program);
void setProgramName(char *name);
VstInt32 getProgram();
void getProgramName(char *name);
bool getProgramNameIndexed(VstInt32 category, VstInt32 index, char *text);
void getParameterLabel(VstInt32 index, char *label);
void getParameterDisplay(VstInt32 index, char *text);
void getParameterName(VstInt32 index, char *text);
bool canParameterBeAutomated(VstInt32 index);
bool string2parameter(VstInt32 index, char *text);
VstInt32 getChunk(void **data, bool isPreset = false);
VstInt32 setChunk(void *data, VstInt32 byteSize, bool isPreset = false);
bool setBypass(bool onOff);
bool setProcessPrecision(VstInt32 precision);
VstInt32 getNumMidiInputChannels();
VstInt32 getNumMidiOutputChannels();
VstInt32 getGetTailSize();
bool getEffectName(char *name);
bool getVendorString(char *text);
VstInt32 getVendorVersion();
VstIntPtr vendorSpecific(VstInt32 lArg, VstIntPtr lArg2, void *ptrArg,
float floatArg);
VstInt32 canDo(char *text);
// finally process...
void processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames);
void processDoubleReplacing(double **inputs, double **outputs,
VstInt32 sampleFrames);
VstInt32 processEvents(VstEvents *events);
#ifndef VESTIGE
bool getInputProperties(VstInt32 index, VstPinProperties *properties);
bool getOutputProperties(VstInt32 index, VstPinProperties *properties);
bool getPinProperties(BusDirection dir, VstInt32 pinIndex,
VstPinProperties *properties);
bool pinIndexToBusChannel(BusDirection dir, VstInt32 pinIndex,
int32 &busIndex, int32 &busChannel);
static VstInt32 vst3ToVst2SpeakerArr(SpeakerArrangement vst3Arr);
static SpeakerArrangement vst2ToVst3SpeakerArr(VstInt32 vst2Arr);
static VstInt32 vst3ToVst2Speaker(Speaker vst3Speaker);
#endif
VstInt32 curProgram;
int32 initialdelay;
bool doublereplacing;
int32 numinputs;
int32 numoutputs;
int32 numparams;
int32 numprograms;
bool synth;
audioMasterCallback audioMaster = nullptr;
//--- ------------------------------------------------------
DEFINE_INTERFACES
DEF_INTERFACE(Vst::IVst3ToVst2Wrapper)
END_DEFINE_INTERFACES(BaseWrapper)
REFCOUNT_METHODS(
BaseWrapper) //------------------------------------------------------------------------
protected:
Vst2MidiEventQueue *mVst2OutputEvents{nullptr};
VstInt32 mCurrentProcessLevel{0};
void updateProcessLevel();
void processOutputEvents();
};
//------------------------------------------------------------------------
// Vst2EditorWrapper Declaration
//------------------------------------------------------------------------
class Vst2EditorWrapper : public BaseEditorWrapper {
public:
//------------------------------------------------------------------------
Vst2EditorWrapper(IEditController *controller,
audioMasterCallback audioMaster);
//--- from BaseEditorWrapper ---------------------
void _close();
//--- from AEffEditor-------------------
bool getRect(ERect **rect);
bool open(void *ptr);
void close() { _close(); }
bool setKnobMode(VstInt32 val) {
return BaseEditorWrapper::_setKnobMode(static_cast<Vst::KnobMode>(val));
}
//--- IPlugFrame ----------------------------
tresult PLUGIN_API resizeView(IPlugView *view, ViewRect *newSize);
audioMasterCallback audioMaster3 = nullptr;
//------------------------------------------------------------------------
protected:
ERect mERect;
};
//------------------------------------------------------------------------
} // namespace Vst
} // namespace Steinberg
/** Must be implemented externally. */
// extern ::AudioEffect* createEffectInstance (audioMasterCallback audioMaster);
/// \endcond