eDSP  0.0.1
A cross-platform DSP library written in C++.
leq.hpp
Go to the documentation of this file.
1 
27 #ifndef EDSP_LEQ_HPP
28 #define EDSP_LEQ_HPP
29 
33 
34 namespace edsp { namespace feature { inline namespace temporal {
35 
43  template <typename T>
44  struct leq {
45  using size_type = std::size_t;
46  using value_type = T;
47 
52  inline explicit leq(size_type number_frames);
53 
57  ~leq() = default;
58 
68  template <typename ForwardIt>
69  inline value_type extract(ForwardIt first, ForwardIt last);
70 
71  private:
73  };
74 
75  template<typename T>
76  inline leq<T>::leq(leq::size_type number_frames) :
77  filter(number_frames) {
78 
79  }
80 
81  template<typename T>
82  template<typename ForwardIt>
83  inline typename leq<T>::value_type leq<T>::extract(ForwardIt first, ForwardIt last) {
84  const auto e = energy(first, last);
85  const auto energy_mean = filter.tick(e);
86  return converter::pow2db(energy_mean);
87  }
88 
89 }}}
90 
91 #endif //EDSP_LEQ_HPP
~leq()=default
Default destructor.
value_type tick(value_type tick)
Applies a moving average filter to the single element.
Definition: moving_average_filter.hpp:136
std::size_t size_type
Definition: leq.hpp:45
leq(size_type number_frames)
Creates a leq estimator.
Definition: leq.hpp:76
T value_type
Definition: leq.hpp:46
value_type extract(ForwardIt first, ForwardIt last)
Definition: leq.hpp:83
constexpr auto energy(ForwardIt first, ForwardIt last)
Computes the energy of the elements in the range [first, last)
Definition: energy.hpp:46
This class estimates the Equivalent Continuous Sound Level over consecutive frames.
Definition: leq.hpp:44
Definition: amplifier.hpp:29
constexpr T pow2db(T power) noexcept
Convert power to decibels.
Definition: pow2db.hpp:41