forked from Snipet/StupidCompressor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStupidCompressor.h
113 lines (104 loc) · 2.27 KB
/
StupidCompressor.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
#pragma once
#include "IPlug_include_in_plug_hdr.h"
#include "IControls.h"
#include "IPlugPaths.h"
#include "src/dsp/SLFO.h"
#include "src/dsp/SCompressor.h"
#include "src/dsp/SFilter.h"
#include "src/dsp/SLightLimiter.h"
#include "src/dsp/SDistortion.h"
#include "src/dsp/STransients.h"
#include "common.h"
const int kNumPresets = 1;
enum EParams
{
kGainIn = 0,
kGainOut,
kParamLFORateTempo,
kLFODepth,
kFoo,
kLFOOffset,
kThreshold,
kRatio,
kAttack,
kRelease,
kLowpassFreq,
kHighpassFreq,
kBandpassCompress,
kClipPower,
kClipType,
kCompressMode,
kTransientPower,
kTransients,
kDrive,
kLimiterRelease,
kMasterInput,
kMasterOutput,
kNumParams
};
enum EControlTags {
kInfoText = 0,
kLFOWindow,
kCloseButton,
kAboutButton,
kCustomWindowSend,
kAdvancedSkin,
kCtrlTags
};
using namespace iplug;
using namespace igraphics;
class StupidCompressor final : public Plugin
{
public:
StupidCompressor(const InstanceInfo& info);
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override;
void OnIdle() override;
//void OnParamChange(int idx) override;
void OnParamChangeUI(int idx, EParamSource a) override;
void OnParamChange(int idx) override;
bool OnMessage(int msgTag, int ctrlTag, int dataSize, const void* pData) override;
void HideGroup(int group);
void ShowGroup(int group);
void ManageSpecialCases(int openGroup);
private:
IRECT b;
SLFO lfo;
std::vector<Point> points;
ISender<3> mDisplaySender;
float movingAverage;
float movingAverageInput;
SCompressor leftC;
SCompressor rightC;
float split[4];
std::vector<SControl> controls;
float left;
float right;
float bandLeft;
float bandRight;
float compressedLeft;
float compressedRight;
float outputLeft;
float outputRight;
SLightLimiter leftL;
SLightLimiter rightL;
bool clipPower;
bool bandpassPower;
bool transientsPower;
int clipOption;
int compressOption;
SDistortion leftD;
SDistortion rightD;
STransients leftT;
STransients rightT;
StereoFilter lowpass;
StereoFilter highpass;
int openGroup;
int uiLastChange;
float masterGainInput;
float masterGainOutput;
};
float clip(float n, float lower, float upper)
{
n = (n > lower) * n + !(n > lower) * lower;
return (n < upper) * n + !(n < upper) * upper;
}