15 , wA_{std::exp(-std::log(real_t(9)) / (sample_rate *
attack_time))}
16 , wR_{std::exp(-std::log(real_t(9)) / (sample_rate *
release_time))}
18 DSPLIB_ASSERT(
threshold >= -140 &&
threshold <= 0,
"`threshold` must be in range [-140:0] db");
21 DSPLIB_ASSERT(
hold_time >= 0 &&
hold_time <= 4,
"`hold_time` must be in range [0:4] sec");
35 const int n =
x.size();
37 for (
int i = 0;
i <
n; ++
i) {
38 const auto gc = (dsplib::abs(
x[
i]) >= tlin_) ? 1 : 0;
39 lg_ = _smooth_gain(
gc);
46 Result operator()(
const arr_real& x) {
47 return this->process(x);
51 real_t _smooth_gain(real_t gc)
noexcept {
62 return (wA_ * lg_) + ((1 - wA_) * gc);
67 return (wR_ * lg_) + ((1 - wR_) * gc);