eDSP  0.0.1
A cross-platform DSP library written in C++.
spectral_irregularity.hpp
Go to the documentation of this file.
1 
27 #ifndef EDSP_SPECTRAL_IRREGULARITY_HPP
28 #define EDSP_SPECTRAL_IRREGULARITY_HPP
29 
30 #include <iterator>
31 namespace edsp { namespace feature { inline namespace spectral {
32 
50  template <typename ForwardIt>
51  constexpr auto spectral_irregularity(ForwardIt first, ForwardIt last) {
52  using value_type = typename std::iterator_traits<ForwardIt>::value_type;
53  value_type square_diff = 0, square_ampl = 0;
54  for (auto until = (last - 1); first != until; ++first) {
55  const value_type diff = (*first + 1) - (*first);
56  square_diff += diff * diff;
57  square_ampl += (*first) * (*first);
58  }
59  return square_diff / square_ampl;
60  }
61 
62 }}}
63 
64 
65 #endif //EDSP_SPECTRAL_IRREGULARITY_HPP
constexpr auto spectral_irregularity(ForwardIt first, ForwardIt last)
Computes the spectral irregularity of the of the magnitude spectrum represented by the elements in th...
Definition: spectral_irregularity.hpp:51
Definition: amplifier.hpp:29