+ /* Low pass filter coefficient: 1.0 - e^(-2.0 * π * f / 48000) f in Hz.
+ * for f << SR, approx a ~= 6.2 * f / SR;
+ */
+ const double a = 156.825 / sample_rate; // 25 Hz LPF
+
+ for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
+ Sample* const buffer = i->data();
+ double lpf = initial;
+
+ for (pframes_t nx = 0; nx < nframes; ++nx) {
+ buffer[nx] *= lpf;
+ lpf += a * (target - lpf);
+ }
+ if (i == bufs.audio_begin()) {
+ rv = lpf;
+ }
+ }
+ if (fabsf (rv - target) < GAIN_COEFF_TINY) return target;
+ if (fabsf (rv) < GAIN_COEFF_TINY) return GAIN_COEFF_ZERO;
+ return rv;
+}
+
+void
+Amp::declick (BufferSet& bufs, framecnt_t nframes, int dir)
+{
+ if (nframes == 0 || bufs.count().n_total() == 0) {
+ return;
+ }
+
+ const framecnt_t declick = std::min ((framecnt_t) 512, nframes);
+ const double fractional_shift = 1.0 / declick ;
+ gain_t delta, initial;
+
+ if (dir < 0) {
+ /* fade out: remove more and more of delta from initial */
+ delta = -1.0;
+ initial = GAIN_COEFF_UNITY;
+ } else {
+ /* fade in: add more and more of delta from initial */
+ delta = 1.0;
+ initial = GAIN_COEFF_ZERO;
+ }
+
+ /* Audio Gain */