39 virtual bool reset(
double _sampleRate)
49 void setLPF_g(
double _lpf_g) { lpf_g = _lpf_g; }
58 double yn = (1.0 - lpf_g)*xn + lpf_g*state;
91 virtual bool reset(
double _sampleRate)
94 sampleRate = _sampleRate;
95 samplePeriod_T = 1.0 / sampleRate;
101 lpf.
reset(sampleRate);
114 double input = fabs(xn);
117 double rn = peakStore;
126 double attackValue = 0.0;
127 double releaseValue = 0.0;
130 double diff = input - peakStore;
132 attackValue = attackTime;
135 attackValue += peakStore;
138 releaseValue = rn * releaseTime;
141 peakStore = attackValue - releaseValue;
151 return 20.0 * log10(yn);
163 setAttackTime(attack_in_ms);
164 setReleaseTime(release_in_ms);
167 const double kSmallestPositiveFloatValue = 1.175494351e-38;
168 const double kSmallestNegativeFloatValue = -1.175494351e-38;
176 bool retValue =
false;
177 if (value > 0.0 && value < kSmallestPositiveFloatValue)
182 else if (value < 0.0 && value > kSmallestNegativeFloatValue)
191 double attackTime = 0.0;
192 double releaseTime = 0.0;
193 double sampleRate = 44100;
194 double samplePeriod_T = 1.0;
195 double lastEnvelope = 0.0;
196 double peakStore = 0.0;
200 void setAttackTime(
double attack_in_ms)
203 attackTime = 1.0 - exp((-2.2*samplePeriod_T) / (attack_in_ms * 0.001));
208 void setReleaseTime(
double release_in_ms)
211 releaseTime = 1.0 - exp((-2.2*samplePeriod_T) / (release_in_ms * 0.001));
239 virtual bool reset(
double _sampleRate)
242 sampleRate = _sampleRate;
243 samplePeriod_T = 1.0 / sampleRate;
249 lpf.
reset(sampleRate);
262 double input = fabs(xn);
265 double rn = peakStore;
274 double attackValue = 0.0;
275 double releaseValue = 0.0;
278 double diff = input - peakStore;
280 attackValue = attackTime;
283 attackValue += peakStore;
286 releaseValue = rn * releaseTime;
289 peakStore = attackValue - releaseValue;
306 setAttackTime(attack_in_ms);
307 setReleaseTime(release_in_ms);
310 const double kSmallestPositiveFloatValue = 1.175494351e-38;
311 const double kSmallestNegativeFloatValue = -1.175494351e-38;
319 bool retValue =
false;
320 if (value > 0.0 && value < kSmallestPositiveFloatValue)
325 else if (value < 0.0 && value > kSmallestNegativeFloatValue)
334 double attackTime = 0.0;
335 double releaseTime = 0.0;
336 double sampleRate = 44100;
337 double samplePeriod_T = 1.0;
338 double lastEnvelope = 0.0;
339 double peakStore = 0.0;
343 void setAttackTime(
double attack_in_ms)
346 attackTime = 1.0 - exp((-2.2*samplePeriod_T) / (attack_in_ms * 0.001));
351 void setReleaseTime(
double release_in_ms)
354 releaseTime = 1.0 - exp((-2.2*samplePeriod_T) / (release_in_ms * 0.001));
417 double yG = CS*(fThreshold - fDetectorValue);
423 return pow(10.0, yG / 20.0);
439 double yG = (fThreshold - fDetectorValue);
442 yG = yG > 0.0 ? 1.0 : CS*(fThreshold / fDetectorValue);
Encapsulates McNally's peak detector with added LPF smoothing (optional)
Definition: limiter.h:82
LogPeakDetector logDetector
the peak detector
Definition: limiter.h:463
double threshold_dB
hardcoded threshold in dB
Definition: limiter.h:464
Encapsulates a tiny first order, all-pole LPF object.
Definition: limiter.h:31
virtual double processAudioSample(double xn)
Definition: limiter.h:56
void setThreshold(double _threshold)
set threshold in dB
Definition: limiter.h:402
void setLPF_g(double _lpf_g)
Definition: limiter.h:49
double process(double input)
process one sample through limiter
Definition: limiter.h:453
bool checkFloatUnderflow(double &value)
set check for underflow
Definition: limiter.h:317
LinPeakDetector linDetector
the peak detector
Definition: limiter.h:466
Definition: addosccore.cpp:4
virtual bool reset(double _sampleRate)
reset members to initialized state
Definition: limiter.h:239
void setAttackReleaseTimes(double attack_in_ms, double release_in_ms)
set attack/release times
Definition: limiter.h:160
void reset(double _sampleRate)
reset internal detector
Definition: limiter.h:381
double calcLimiterGain(float fDetectorValue, float fThreshold)
calculate limiter gain using dB values for threshold and detection
Definition: limiter.h:432
virtual double processAudioSample(double xn)
process MONO input
Definition: limiter.h:259
bool checkFloatUnderflow(double &value)
set check for underflow
Definition: limiter.h:174
virtual bool reset(double _sampleRate)
reset members to initialized state
Definition: limiter.h:91
Encapsulates McNally's peak detector with added LPF smoothing (optional)
Definition: limiter.h:230
Implements a custom peak limiter designed especially for self oscillating filters whose outputs are >...
Definition: limiter.h:373
double threshold
hardcoded threshold for -1.5dB
Definition: limiter.h:467
virtual bool reset(double _sampleRate)
Definition: limiter.h:39
virtual double processAudioSample(double xn)
process MONO input
Definition: limiter.h:111
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.
double calcLimiterGaindB(float fDetectorValue, float fThreshold)
calculate limiter gain using dB values for threshold and detection
Definition: limiter.h:410
void setThreshold_dB(double _threshold_dB)
set threshold in dB
Definition: limiter.h:398
void setAttackReleaseTimes(double attack_in_ms, double release_in_ms)
set attack/release times
Definition: limiter.h:303
See also Designing Software Synthesizers in C++ 2nd Ed. by Will Pirkle.