eDSP  0.0.1
A cross-platform DSP library written in C++.
spectral_decrease.hpp
Go to the documentation of this file.
1 
27 #ifndef EDSP_SPECTRAL_DECREASE_HPP
28 #define EDSP_SPECTRAL_DECREASE_HPP
29 
30 #include <edsp/meta/expects.hpp>
31 
32 namespace edsp { namespace feature { inline namespace spectral {
33 
34 
49  template <typename ForwardIt>
50  constexpr auto spectral_decrease(ForwardIt first, ForwardIt last) {
51  using input_t = typename std::iterator_traits<ForwardIt>::value_type;
52  auto weighted_sum = static_cast<input_t>(0);
53  auto unweighted_sum = static_cast<input_t>(0);
54  for (input_t i = 0, initial = *first; first != last; ++first, ++i) {
55  weighted_sum += ((*first) - initial) / i;
56  unweighted_sum += *first;
57  }
58  return weighted_sum / unweighted_sum;
59 
60  }
61 
62 }}}
63 
64 
65 #endif //EDSP_SPECTRAL_DECREASE_HPP
constexpr auto spectral_decrease(ForwardIt first, ForwardIt last)
Computes the spectral decrease of the of the magnitude spectrum represented by the elements in the ra...
Definition: spectral_decrease.hpp:50
Definition: amplifier.hpp:29