34 namespace edsp {
namespace feature {
inline namespace temporal {
57 template <
typename ForwardIt,
typename Numeric>
58 constexpr
auto lat(ForwardIt first, ForwardIt last, Numeric samplerate,
59 Numeric start_threshold, Numeric stop_threshold) {
60 using value_type =
typename std::iterator_traits<ForwardIt>::value_type;
61 const auto max_value = *std::max_element(first, last);
62 const auto cutoff_start_attack = max_value * start_threshold;
63 const auto cutoff_stop_attack = max_value * stop_threshold;
64 const auto start_iter = std::find_if(first, last,
65 std::bind(std::greater_equal<value_type>(), std::placeholders::_1, cutoff_start_attack));
66 const auto stop_iter = std::find_if(first, last,
67 std::bind(std::greater_equal<value_type >(), std::placeholders::_1, cutoff_stop_attack));
70 const auto attack_time =
static_cast<value_type
>(stop_attack - start_attack)
71 / static_cast<value_type>(samplerate);
72 constexpr
auto threshold =
static_cast<value_type
>(10e-5);
73 return (attack_time > threshold) ?
static_cast<T
>(std::log10(attack_time)) : -5;
constexpr auto lat(ForwardIt first, ForwardIt last, Numeric samplerate, Numeric start_threshold, Numeric stop_threshold)
The laq class estimates the logarithmic attack time of an envelope signal.
Definition: lat.hpp:58
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
Definition: amplifier.hpp:29