Commit d9ab86c9 authored by Steffen Vogel's avatar Steffen Vogel 🎅🏼

dsp: simplified moving average window

parent ce443713
/** A moving average filter.
/** A moving average window.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
......@@ -23,13 +23,13 @@
#pragma once
#include <villas/window.hpp>
#include <villas/dsp/window.hpp>
namespace villas {
namespace dsp {
template<typename T>
class MovingAverage {
class MovingAverageWindow {
public:
typedef typename Window<T>::size_type size_type;
......@@ -37,14 +37,11 @@ public:
protected:
Window<T> window;
size_type length;
T state;
public:
MovingAverage(size_type len, T i) :
MovingAverageWindow(size_type len, T i = 0) :
window(len, i),
length(len),
state(i)
{ }
......@@ -55,7 +52,7 @@ public:
state += in;
state -= out;
return state / len;
return state / window.getSteps();
}
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment