![]() |
ProtoTracer
1.0
Real-time 3D rendering and animation engine
|
Smooths data values using a weighted running average. More...
#include <RunningAverageFilter.h>
Public Member Functions | |
RunningAverageFilter () | |
Default constructor for RunningAverageFilter . | |
RunningAverageFilter (float gain) | |
Constructs a RunningAverageFilter with a specified gain. | |
void | SetGain (float gain) |
Sets the gain for the filter. | |
float | Filter (float value) |
Filters the input value using the running average. | |
Private Attributes | |
float | gain |
The gain factor for the filter, controlling smoothing intensity. | |
float | values [memory] |
Buffer to store the recent values. | |
uint8_t | currentAmount |
The current number of valid entries in the buffer. | |
Smooths data values using a weighted running average.
The RunningAverageFilter
class calculates a running average based on a fixed memory size, applying a gain to control the influence of new values.
memory | The size of the memory buffer for storing recent values. |
Definition at line 27 of file RunningAverageFilter.h.
RunningAverageFilter | ( | ) |
Default constructor for RunningAverageFilter
.
Initializes the filter with default parameters and a memory buffer of zeros.
RunningAverageFilter | ( | float | gain | ) |
Constructs a RunningAverageFilter
with a specified gain.
Filters the input value using the running average.
Calculates the smoothed output based on the memory buffer and gain.
value | The new input value to filter. |
Referenced by BouncePhysics::Calculate(), DerivativeFilter::Filter(), FFTFilter::Filter(), Project::GetFrameRate(), MicrophoneSimple::Update(), MMC56X3::Update(), SHARPGP2Y::Update(), ClockAnimation::Update(), and MicrophoneSimple::Update().
Sets the gain for the filter.
gain | The new gain value, controlling smoothing intensity. |
The current number of valid entries in the buffer.
Definition at line 31 of file RunningAverageFilter.h.
The gain factor for the filter, controlling smoothing intensity.
Definition at line 29 of file RunningAverageFilter.h.
Buffer to store the recent values.
Definition at line 30 of file RunningAverageFilter.h.