17template<
typename T,
int NC = 1>
27 for (
auto i = 0; i < NC; i++)
29 mOutM1[i] = initialValue;
32 SetSmoothTime(timeMs, DEFAULT_SAMPLE_RATE);
36 inline T Process(T input)
38 mOutM1[0] = (input * mB) + (mOutM1[0] * mA);
40 denormal_fix(&mOutM1[0]);
45 inline void SetValue(T value)
47 for (
auto i = 0; i < NC; i++)
53 inline void SetValues(T values[NC])
55 for (
auto i = 0; i < NC; i++)
57 mOutM1[i] = values[i];
61 void SetSmoothTime(
double timeMs,
double sampleRate)
63 static constexpr double TWO_PI = 6.283185307179586476925286766559;
65 mA = exp(-TWO_PI / (timeMs * 0.001 * sampleRate));
69 void ProcessBlock(T inputs[NC], T** outputs,
int nFrames,
int channelOffset = 0)
74 for (
auto s = 0; s < nFrames; ++s)
76 for (
auto c = 0; c < NC; c++)
78 T output = (inputs[channelOffset + c] * b) + (mOutM1[c] * a);
80 denormal_fix(&output);
83 outputs[channelOffset + c][s] = output;
95 : mSmoothingTime(smoothingTime)
99 void ProcessBlock(T** inputs, T** outputs,
int nChans,
int nFrames,
double gainValue)
101 for (
auto s = 0; s < nFrames; ++s)
103 const T smoothedGain =
static_cast<T
>(mSmoother.Process(gainValue));
105 for (
auto c = 0; c < nChans; c++)
107 outputs[c][s] = inputs[c][s] * smoothedGain;
112 void SetSampleRate(
double sampleRate)
114 mSmoother.SetSmoothTime(mSmoothingTime, sampleRate);
118 const double mSmoothingTime;
IPlug Constant definitions, Types, magic numbers.