-
Notifications
You must be signed in to change notification settings - Fork 2
/
Compressor.cpp
83 lines (64 loc) · 1.62 KB
/
Compressor.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
#include "Compressor.h"
#include "IPlug_include_in_plug_src.h"
#include "IControl.h"
#include "resource.h"
const int kNumPrograms = 1;
enum EParams
{
kGain = 0,
kNumParams
};
enum ELayout
{
kWidth = GUI_WIDTH,
kHeight = GUI_HEIGHT,
kGainX = 100,
kGainY = 100,
kKnobFrames = 60
};
Compressor::Compressor(IPlugInstanceInfo instanceInfo)
: IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mGain(1.)
{
TRACE;
//arguments are: name, defaultVal, minVal, maxVal, step, label
GetParam(kGain)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%");
GetParam(kGain)->SetShape(2.);
IGraphics* pGraphics = MakeGraphics(this, kWidth, kHeight);
pGraphics->AttachPanelBackground(&COLOR_RED);
IBitmap knob = pGraphics->LoadIBitmap(KNOB_ID, KNOB_FN, kKnobFrames);
pGraphics->AttachControl(new IKnobMultiControl(this, kGainX, kGainY, kGain, &knob));
AttachGraphics(pGraphics);
//MakePreset("preset 1", ... );
MakeDefaultPreset((char *) "-", kNumPrograms);
}
Compressor::~Compressor() {}
void Compressor::ProcessDoubleReplacing(double** inputs, double** outputs, int nFrames)
{
// Mutex is already locked for us.
double* in1 = inputs[0];
double* in2 = inputs[1];
double* out1 = outputs[0];
double* out2 = outputs[1];
for (int s = 0; s < nFrames; ++s, ++in1, ++in2, ++out1, ++out2)
{
*out1 = *in1 * mGain;
*out2 = *in2 * mGain;
}
}
void Compressor::Reset()
{
TRACE;
IMutexLock lock(this);
}
void Compressor::OnParamChange(int paramIdx)
{
IMutexLock lock(this);
switch (paramIdx)
{
case kGain:
mGain = GetParam(kGain)->Value() / 100.;
break;
default:
break;
}
}