22 #ifndef EDSP_MOVING_RMS_FILTER_HPP 23 #define EDSP_MOVING_RMS_FILTER_HPP 28 namespace edsp {
namespace filter {
48 template <
typename T,
typename Allocator = std::allocator<T>>
85 template <
typename InputIt,
typename OutputIt>
86 void filter(InputIt first, InputIt last, OutputIt d_first);
89 edsp::ring_buffer<T, Allocator> window_;
93 template <
typename T,
typename Allocator>
96 template <
typename T,
typename Allocator>
98 return window_.capacity();
101 template <
typename T,
typename Allocator>
106 template <
typename T,
typename Allocator>
107 template <
typename InputIt,
typename OutputIt>
109 if (window_.full()) {
110 for (; first != last; ++d_first, ++first) {
111 const auto sqr = (*first) * (*first);
112 accumulated_ -= window_.front();
114 window_.push_back(sqr)* d_first = std::sqrt(accumulated_ / static_cast<T>(window_.size()));
117 for (; first != last; ++d_first, ++first) {
118 const auto sqr = (*first) * (*first);
120 window_.push_back(sqr)* d_first = std::sqrt(accumulated_ / static_cast<T>(window_.size()));
125 template <
typename T,
typename Allocator>
132 #endif // EDSP_MOVING_RMS_FILTER_HPP moving_rms(size_type N)
Creates a moving_rms with a window of length N.
Definition: moving_rms_filter.hpp:94
This class implement a cumulative moving rms (rolling rms or running rms) filter. ...
Definition: moving_rms_filter.hpp:49
void resize(size_type N)
Resizes the moving window to the specified number of elements.
Definition: moving_rms_filter.hpp:126
size_type size() const
Returns the size of the moving window.
Definition: moving_rms_filter.hpp:97
void reset()
Reset the moving window to the original state.
Definition: moving_rms_filter.hpp:102
void filter(InputIt first, InputIt last, OutputIt d_first)
Applies a moving average filter to the elements in the range [first, last) and stores the result in a...
Definition: moving_rms_filter.hpp:108
Definition: amplifier.hpp:29
T value_type
Definition: moving_rms_filter.hpp:52
std::size_t size_type
Definition: moving_rms_filter.hpp:51