18#include "DistrhoPlugin3BandEQ.hpp"
24static const float kPI = 3.141592654f;
30DistrhoPlugin3BandEQ::DistrhoPlugin3BandEQ()
43void DistrhoPlugin3BandEQ::initParameter(
uint32_t index, Parameter& parameter)
48 parameter.hints = kParameterIsAutomatable;
49 parameter.name =
"Low";
50 parameter.symbol =
"low";
51 parameter.unit =
"dB";
52 parameter.ranges.def = 0.0f;
53 parameter.ranges.min = -24.0f;
54 parameter.ranges.max = 24.0f;
58 parameter.hints = kParameterIsAutomatable;
59 parameter.name =
"Mid";
60 parameter.symbol =
"mid";
61 parameter.unit =
"dB";
62 parameter.ranges.def = 0.0f;
63 parameter.ranges.min = -24.0f;
64 parameter.ranges.max = 24.0f;
68 parameter.hints = kParameterIsAutomatable;
69 parameter.name =
"High";
70 parameter.symbol =
"high";
71 parameter.unit =
"dB";
72 parameter.ranges.def = 0.0f;
73 parameter.ranges.min = -24.0f;
74 parameter.ranges.max = 24.0f;
78 parameter.hints = kParameterIsAutomatable;
79 parameter.name =
"Master";
80 parameter.symbol =
"master";
81 parameter.unit =
"dB";
82 parameter.ranges.def = 0.0f;
83 parameter.ranges.min = -24.0f;
84 parameter.ranges.max = 24.0f;
88 parameter.hints = kParameterIsAutomatable;
89 parameter.name =
"Low-Mid Freq";
90 parameter.symbol =
"low_mid";
91 parameter.unit =
"Hz";
92 parameter.ranges.def = 440.0f;
93 parameter.ranges.min = 0.0f;
94 parameter.ranges.max = 1000.0f;
97 case paramMidHighFreq:
98 parameter.hints = kParameterIsAutomatable;
99 parameter.name =
"Mid-High Freq";
100 parameter.symbol =
"mid_high";
101 parameter.unit =
"Hz";
102 parameter.ranges.def = 1000.0f;
103 parameter.ranges.min = 1000.0f;
104 parameter.ranges.max = 20000.0f;
109void DistrhoPlugin3BandEQ::initProgramName(
uint32_t index,
String& programName)
114 programName =
"Default";
120float DistrhoPlugin3BandEQ::getParameterValue(
uint32_t index)
const
132 case paramLowMidFreq:
134 case paramMidHighFreq:
141void DistrhoPlugin3BandEQ::setParameterValue(
uint32_t index,
float value)
150 lowVol = std::exp( (fLow/48.0f) * 48.0f /
kAMP_DB);
154 midVol = std::exp( (fMid/48.0f) * 48.0f /
kAMP_DB);
158 highVol = std::exp( (fHigh/48.0f) * 48.0f /
kAMP_DB);
162 outVol = std::exp( (fMaster/48.0f) * 48.0f /
kAMP_DB);
164 case paramLowMidFreq:
165 fLowMidFreq = std::fmin(
value, fMidHighFreq);
166 freqLP = fLowMidFreq;
171 case paramMidHighFreq:
172 fMidHighFreq = std::fmax(
value, fLowMidFreq);
173 freqHP = fMidHighFreq;
181void DistrhoPlugin3BandEQ::loadProgram(
uint32_t index)
191 fLowMidFreq = 220.0f;
192 fMidHighFreq = 2000.0f;
195 lowVol = midVol = highVol = outVol = 1.0f;
206void DistrhoPlugin3BandEQ::activate()
210 xLP = std::exp(-2.0f *
kPI * freqLP / sr);
215 xHP = std::exp(-2.0f *
kPI * freqHP / sr);
220void DistrhoPlugin3BandEQ::deactivate()
222 out1LP = out2LP = out1HP = out2HP = 0.0f;
223 tmp1LP = tmp2LP = tmp1HP = tmp2HP = 0.0f;
226void DistrhoPlugin3BandEQ::run(
const float** inputs,
float** outputs,
uint32_t frames)
228 const float* in1 = inputs[0];
229 const float* in2 = inputs[1];
230 float* out1 = outputs[0];
231 float* out2 = outputs[1];
235 tmp1LP = a0LP * in1[
i] - b1LP * tmp1LP +
kDC_ADD;
236 tmp2LP = a0LP * in2[
i] - b1LP * tmp2LP +
kDC_ADD;
240 tmp1HP = a0HP * in1[
i] - b1HP * tmp1HP +
kDC_ADD;
241 tmp2HP = a0HP * in2[
i] - b1HP * tmp2HP +
kDC_ADD;
245 out1[
i] = (out1LP*lowVol + (in1[
i] - out1LP - out1HP)*midVol + out1HP*highVol) * outVol;
246 out2[
i] = (out2LP*lowVol + (in2[
i] - out2LP - out2HP)*midVol + out2HP*highVol) * outVol;
254 return new DistrhoPlugin3BandEQ();
#define END_NAMESPACE_DISTRHO
Definition DistrhoDefines.h:191
#define START_NAMESPACE_DISTRHO
Definition DistrhoDefines.h:190
static const float kAMP_DB
Definition DistrhoPlugin3BandEQ.cpp:22
Plugin * createPlugin()
Definition DistrhoPlugin3BandEQ.cpp:252
static const float kPI
Definition DistrhoPlugin3BandEQ.cpp:24
static const float kDC_ADD
Definition DistrhoPlugin3BandEQ.cpp:23
static void deactivate(LV2_Handle instance)
Definition bindings_test_plugin.c:128
register unsigned i
Definition inflate.c:1575
static PuglViewHint int value
Definition pugl.h:1708
virtual ASIOError getSampleRate(ASIOSampleRate *sampleRate)=0
unsigned int uint32_t
Definition mid.cpp:100