-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmultifxVSTeditor.cpp
265 lines (204 loc) · 6.53 KB
/
multifxVSTeditor.cpp
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
//------------------------------------------------------------------------
//-
//- Project : Use different Controls of VSTGUI
//- Filename : multifxVSTeditor.cpp
//- Created by : Yvan Grabit
//- Description :
//-
//- © 2000-1999, Steinberg Soft und Hardware GmbH, All Rights Reserved
//------------------------------------------------------------------------
#include "stdafx.h"
//#include "multifxVSTmain.h"
#ifndef __multifxVSTeditor__
#include "multifxVSTeditor.h"
#endif
#include "stockeffet.h"
#include "CCVSThost.h"
#ifndef __multifxVST__
#include "multifxVST.h"
#endif
#include "Chaindlg.h"
#include "MainDlg.h"
#include "controleurdlg.h"
#include "Controleurlst.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "effectWnd.h"
#include "EffectTxTdlg.h"
enum
{
// bitmaps
kBackgroundBitmap = 10001,
kKickBtn,
kSliderHBgBitmap,
kSliderHandleBitmap,
kDigitBitmap,
// others
kBackgroundW = 420,
kBackgroundH = 210
};
void stringConvert (float value, char* string);
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
multifxVSTEditor::multifxVSTEditor (AudioEffect *effect)
: AEffGUIEditor (effect)
{
UpdateType = 0;
frame = 0;
oldTicks = 0;
visible = false;
rect.left = 0;
rect.top = 0;
rect.right = kBackgroundW;
rect.bottom = kBackgroundH;
/*host = NULL;
chaine_eff = NULL;*/
// we decide in this plugin to open all bitmaps in the open function
}
//-----------------------------------------------------------------------------
multifxVSTEditor::~multifxVSTEditor ()
{
CString buf;buf.Format("DESTROY :: multifxVSTEditor(%d) \n", this); TRACE(buf);
WinRect.top = WinRect.left = WinRect.bottom = WinRect.right =0;
}
void multifxVSTEditor::SetAPP(CAppPointer * m_cheff)
{
APP = m_cheff;
}
long multifxVSTEditor::getRect(ERect **rect)
{
*rect = &WinRect;
return TRUE;
}
//-----------------------------------------------------------------------------
long multifxVSTEditor::open (void *ptr)
{
//obligatoire avant le premier appel au MFC dans une dll lié dynamique
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// always call this !!!
AEffGUIEditor::open (ptr);
// get version
int version = getVstGuiVersion ();
int verMaj = (version & 0xFF00) >> 16;
int verMin = (version & 0x00FF);
//--dialog MFC---------------------------------------------
frame = new CFrame (VSTGUI::CRect(0,0,100,100), ptr, this);
//on récupere le handle de la fenetre contenant notre plug-ins (la fenetre de l'host)
HWND vb= (HWND)frame->getSystemWindow();
CWnd dfk;
dfk.Attach(vb);
APP->pMainDlg = new CMainDlg(&dfk);
ASSERT(APP->pMainDlg);
//on crée la fenetre principale
BOOL b =APP->pMainDlg->Create((UINT)CMainDlg::IDD ,&dfk);
ASSERT(b);
dfk.Detach();
//TRACE("NOUVELLE FENETRE\n");
APP->pMainDlg->SetAPP(APP);
APP->pMainDlg->Init();
//dlg->SetWindowPos(NULL,WinRect.left,WinRect.top,WinRect.right,WinRect.bottom,0);
::CRect r;
APP->pMainDlg->GetWindowRect(&r);
WinRect.top = WinRect.left = 0;
WinRect.bottom =r.Height();
WinRect.right = r.Width();
frame->setSize(r.Width(), r.Height());
APP->pMainDlg->ShowWindow(SW_SHOW);
/*APP->pMainDlg->ChildNotify(dlg,0);
APP->pMainDlg->ChildNotify(dlg,1);*/
// here we can call a initialize () function to initalize all controls values
return true;
}
//-----------------------------------------------------------------------------
bool multifxVSTEditor::keysRequired ()
{
if (frame && frame->getEditView ())
return true;
else
return false;
}
//-----------------------------------------------------------------------------
long multifxVSTEditor::onKeyDown (VstKeyCode &keyCode)
{
return 1;
}
//-----------------------------------------------------------------------------
long multifxVSTEditor::onKeyUp (VstKeyCode &keyCode)
{
return 1;
}
//-----------------------------------------------------------------------------
void multifxVSTEditor::close () //AFFFF normalement plus besoin du if
{
//pour ttes les fonctions générants des appels a la bibli mfc
AFX_MANAGE_STATE(AfxGetStaticModuleState());
CString buf;buf.Format("DEBCLOSE :: multifxVSTEditor(%d) \n", this); TRACE(buf);
if(APP->pMainDlg)
{
//if((long(APP->pMainDlg->m_hWnd) != 0) && (long(APP->pMainDlg->m_hWnd) != 0xfeeefeee))
{
//supprime les childs
APP->pMainDlg->ShowWindow(SW_HIDE);
APP->pMainDlg->DestroyWindow();
}
}
// don't forget to remove the frame !!
if (frame)
delete frame;
// set to zero all pointer (security)
cKickButton = 0;
frame = 0;
//APP = 0;
buf.Format("CLOSE :: multifxVSTEditor(%d) \n", this); TRACE(buf);
}
//-----------------------------------------------------------------------------
void multifxVSTEditor::idle () //AFFAIREEEEEE
{
AEffGUIEditor::idle (); // always call this to ensure update
APP->pMainDlg->EnterIdle();
}
void multifxVSTEditor::update()
{
AEffEditor::update();
switch(UpdateType)
{
case 1: //changement de chaine
APP->pMainDlg->OnUpdate();
break;
case 2: //parametre de l'automation
break;
}
UpdateType = 0;
//APP->pMainDlg->OnUpdate();
OutputDebugString("Update\n");
}
//----------------------------------------------------------------------------- AFAFAFAFAAF
void multifxVSTEditor::setParameter (long index, float value)
{
//pour ttes les fonctions générants des appels a la bibli mfc
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// called from the Aeffect to update the control's value
// test if the plug is opened
if (!frame)
return;
if (index == kChainTag)
{
UpdateType = 1;
}else if((index >= kNumParams) && (index < kNumParams + APP->parameter->GetCount()))
{
UpdateType = 2;
}
// call this to be sure that the graphic will be updated
postUpdate ();
}
//-----------------------------------------------------------------------------
void multifxVSTEditor::valueChanged (CDrawContext* context, CControl* control)
{
control->update (context);
}
//-----------------------------------------------------------------------------
void stringConvert (float value, char* string)
{
sprintf (string, "p %.2f", value);
}