2 #include "IPlug_include_in_plug_src.h"
6 const int kNumPrograms
= 1;
24 void NSEEL_HOSTSTUB_EnterMutex()
29 void NSEEL_HOSTSTUB_LeaveMutex()
34 IPlugEEL::IPlugEEL(IPlugInstanceInfo instanceInfo
)
35 : IPLUG_CTOR(kNumParams
, kNumPrograms
, instanceInfo
), mGain(1.)
39 vm
= NSEEL_VM_alloc(); // create virtual machine
41 mVmOutput
= NSEEL_VM_regvar(vm
, "x"); // register a variable into vm to get a value out
43 memset(codetext
, 0, 65536);
44 strcpy(codetext
, "x=rand(2)-1.;");
46 codehandle
= NSEEL_code_compile(vm
, codetext
, 0); // compile code
48 //arguments are: name, defaultVal, minVal, maxVal, step, label
49 GetParam(kGain
)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%");
50 GetParam(kGain
)->SetShape(2.);
52 IGraphics
* pGraphics
= MakeGraphics(this, kWidth
, kHeight
);
53 pGraphics
->AttachPanelBackground(&COLOR_RED
);
55 IBitmap knob
= pGraphics
->LoadIBitmap(KNOB_ID
, KNOB_FN
, kKnobFrames
);
57 pGraphics
->AttachControl(new IKnobMultiControl(this, kGainX
, kGainY
, kGain
, &knob
));
59 IRECT
textRect(5, 70, kWidth
-5, kHeight
-5);
60 IText
textProps(15, &COLOR_BLACK
, "Arial", IText::kStyleNormal
, IText::kAlignNear
, 0, IText::kQualityDefault
);
62 mTextControl
= new AlgDisplay(this, textRect
, &textProps
, codetext
);
63 pGraphics
->AttachControl(mTextControl
);
65 AttachGraphics(pGraphics
);
67 //MakePreset("preset 1", ... );
68 MakeDefaultPreset((char *) "-", kNumPrograms
);
73 NSEEL_code_free(codehandle
);
77 void IPlugEEL::ProcessDoubleReplacing(double** inputs
, double** outputs
, int nFrames
)
79 // Mutex is already locked for us.
81 double* in1
= inputs
[0];
82 double* in2
= inputs
[1];
83 double* out1
= outputs
[0];
84 double* out2
= outputs
[1];
86 for (int s
= 0; s
< nFrames
; ++s
, ++in1
, ++in2
, ++out1
, ++out2
)
88 NSEEL_code_execute(codehandle
);
89 *out1
= *mVmOutput
* mGain
;
94 void IPlugEEL::Reset()
97 IMutexLock
lock(this);
99 //double sr = GetSampleRate();
102 void IPlugEEL::OnParamChange(int paramIdx
)
104 IMutexLock
lock(this);
109 mGain
= GetParam(kGain
)->Value() / 100.;