[IPLUG/EXAMPLES] fix IPlugChunks example
[wdl/wdl-ol.git] / IPlugExamples / IPlugEffect / IPlugEffect.cpp
blob68bc20f049c621adae1aa765a74e02b5ae056dfb
1 #include "IPlugEffect.h"
2 #include "IPlug_include_in_plug_src.h"
3 #include "IControl.h"
4 #include "resource.h"
6 const int kNumPrograms = 1;
8 enum EParams
10 kGain = 0,
11 kNumParams
14 enum ELayout
16 kWidth = GUI_WIDTH,
17 kHeight = GUI_HEIGHT,
19 kGainX = 100,
20 kGainY = 100,
21 kKnobFrames = 60
24 IPlugEffect::IPlugEffect(IPlugInstanceInfo instanceInfo)
25 : IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mGain(1.)
27 TRACE;
29 //arguments are: name, defaultVal, minVal, maxVal, step, label
30 GetParam(kGain)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%");
31 GetParam(kGain)->SetShape(2.);
33 IGraphics* pGraphics = MakeGraphics(this, kWidth, kHeight);
34 pGraphics->AttachPanelBackground(&COLOR_RED);
36 IBitmap knob = pGraphics->LoadIBitmap(KNOB_ID, KNOB_FN, kKnobFrames);
38 pGraphics->AttachControl(new IKnobMultiControl(this, kGainX, kGainY, kGain, &knob));
40 AttachGraphics(pGraphics);
42 //MakePreset("preset 1", ... );
43 MakeDefaultPreset((char *) "-", kNumPrograms);
46 IPlugEffect::~IPlugEffect() {}
48 void IPlugEffect::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
50 // Mutex is already locked for us.
52 double* in1 = inputs[0];
53 double* in2 = inputs[1];
54 double* out1 = outputs[0];
55 double* out2 = outputs[1];
57 for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2)
59 *out1 = *in1 * mGain;
60 *out2 = *in2 * mGain;
64 void IPlugEffect::Reset()
66 TRACE;
67 IMutexLock lock(this);
70 void IPlugEffect::OnParamChange(int paramIdx)
72 IMutexLock lock(this);
74 switch (paramIdx)
76 case kGain:
77 mGain = GetParam(kGain)->Value() / 100.;
78 break;
80 default:
81 break;