eDSP  0.0.1
A cross-platform DSP library written in C++.
asdf.hpp
Go to the documentation of this file.
1 
27 #ifndef EDSP_ASDF_HPP
28 #define EDSP_ASDF_HPP
29 
30 #include <iterator>
31 
32 namespace edsp { namespace feature { inline namespace temporal {
33 
63  template <typename InputIt, typename OutputIt>
64  constexpr void amdf(InputIt first, InputIt last, OutputIt d_first) {
65  using value_type = typename std::iterator_traits<OutputIt>::value_type;
66  const auto N = std::distance(first, last);
67  auto * array = &(*first);
68  for (auto i = 0; i < N; ++i, ++d_first) {
69  for (auto j = 0; j < (N - i); ++j) {
70  *d_first += std::abs(array[j] - array[j + i]);
71  }
72  *d_first /= static_cast<value_type>(N);
73  }
74  }
75 }}}
76 #endif //EDSP_ASDF_HPP
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
constexpr void amdf(InputIt first, InputIt last, OutputIt d_first)
Computes the AMDF (Average Magnitude Difference Function) of the contiguous elements in the range [fi...
Definition: amdf.hpp:51
Definition: amplifier.hpp:29