ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
RunningAverageFilter< memory > Class Template Reference

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.
 

Detailed Description

template<size_t memory>
class RunningAverageFilter< memory >

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.

Template Parameters
memoryThe size of the memory buffer for storing recent values.

Definition at line 27 of file RunningAverageFilter.h.

Constructor & Destructor Documentation

◆ RunningAverageFilter() [1/2]

template<size_t memory>
RunningAverageFilter ( )

Default constructor for RunningAverageFilter.

Initializes the filter with default parameters and a memory buffer of zeros.

◆ RunningAverageFilter() [2/2]

template<size_t memory>
RunningAverageFilter ( float  gain)

Constructs a RunningAverageFilter with a specified gain.

Parameters
gainThe gain factor for the filter (typically between 0.0 and 1.0).

Member Function Documentation

◆ Filter()

template<size_t memory>
float Filter ( float  value)

Filters the input value using the running average.

Calculates the smoothed output based on the memory buffer and gain.

Parameters
valueThe new input value to filter.
Returns
The filtered output value.

Referenced by BouncePhysics::Calculate(), DerivativeFilter::Filter(), FFTFilter::Filter(), Project::GetFrameRate(), MicrophoneSimple::Update(), MMC56X3::Update(), SHARPGP2Y::Update(), ClockAnimation::Update(), and MicrophoneSimple::Update().

◆ SetGain()

template<size_t memory>
void SetGain ( float  gain)

Sets the gain for the filter.

Parameters
gainThe new gain value, controlling smoothing intensity.

Member Data Documentation

◆ currentAmount

template<size_t memory>
uint8_t currentAmount
private

The current number of valid entries in the buffer.

Definition at line 31 of file RunningAverageFilter.h.

◆ gain

template<size_t memory>
float gain
private

The gain factor for the filter, controlling smoothing intensity.

Definition at line 29 of file RunningAverageFilter.h.

◆ values

template<size_t memory>
float values[memory]
private

Buffer to store the recent values.

Definition at line 30 of file RunningAverageFilter.h.


The documentation for this class was generated from the following file: