2023-08-28 12:31:18 +02:00
|
|
|
/* An exponential window.
|
2019-04-16 07:58:37 +02:00
|
|
|
*
|
2023-08-31 11:17:07 +02:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-08-28 12:31:18 +02:00
|
|
|
*/
|
2019-04-16 07:58:37 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <villas/dsp/window.hpp>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace dsp {
|
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
template <typename T> class ExponentialWindow {
|
2019-04-16 07:58:37 +02:00
|
|
|
|
|
|
|
protected:
|
2023-09-07 13:19:19 +02:00
|
|
|
T a;
|
|
|
|
T last;
|
2019-04-16 07:58:37 +02:00
|
|
|
|
|
|
|
public:
|
2023-09-07 13:19:19 +02:00
|
|
|
ExponentialWindow(T _a, T i = 0) : a(a), last(i) {}
|
2019-04-16 07:58:37 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
T update(T in) {
|
|
|
|
last = a * in + (1 - a) * last;
|
2019-04-16 07:58:37 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
return last;
|
|
|
|
}
|
2019-04-16 07:58:37 +02:00
|
|
|
};
|
|
|
|
|
2022-12-02 17:16:44 +01:00
|
|
|
} // namespace dsp
|
|
|
|
} // namespace villas
|