22 #ifndef EDSP_SPECTROGRAM_HPP 23 #define EDSP_SPECTROGRAM_HPP 30 namespace edsp {
inline namespace spectral {
60 template <
typename InputIt,
typename OutputIt,
61 typename Allocator = std::allocator<std::complex<meta::value_type_t<OutputIt>>>>
63 meta::expects(
std::distance(first, last) > 0,
"Not expecting empty input");
64 using value_type = meta::value_type_t<InputIt>;
66 fft_impl<value_type> fft_{size};
67 std::vector<std::complex<value_type>, Allocator> fft_data_(
make_fft_size(size));
68 fft_.dft(&(*first), meta::data(fft_data_));
70 std::transform(std::cbegin(fft_data_), std::cend(fft_data_), d_first,
71 [](
const std::complex<value_type>& val) -> meta::value_type_t<OutputIt> {
75 std::transform(std::cbegin(fft_data_), std::cend(fft_data_), d_first,
76 [](
const std::complex<value_type>& val) -> meta::value_type_t<OutputIt> {
84 #endif // EDSP_SPECTROGRAM_HPP
constexpr T mag2db(T magnitude) noexcept
Convert magnitude to decibels (dB)
Definition: mag2db.hpp:41
constexpr Integer make_fft_size(Integer real_size) noexcept
Computes the expected DFT size for a real-to-complex DFT transform.
Definition: dft.hpp:35
SpectralScale
The SpectralScale enum represent the scale used to represent the power spectral density.
Definition: periodogram.hpp:36
void periodogram(InputIt first, InputIt last, OutputIt d_first, SpectralScale scale)
Computes the periodogram of the range [first, last) and stores the result in another range...
Definition: periodogram.hpp:62
constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
constexpr T square(T x)
Computes the square value of the input number.
Definition: numeric.hpp:188
Definition: amplifier.hpp:29