An exponential moving average class. More...
#include <MovingAverage.h>

Public Member Functions | |
| MovingAverage () | |
| Default constructor (infinite time window). | |
| MovingAverage (float timeWindow) | |
| Default constructor (finite time window). | |
| void | infiniteTimeWindow () |
| Sets to "infinite" smoothing window. | |
| void | timeWindow (float seconds) |
| Changes the smoothing window (expressed in seconds). | |
| float | timeWindow () const |
| Returns the smoothing window (expressed in seconds). | |
| bool | timeWindowIsInfinite () const |
| Returns true if time window is infinite. | |
| void | cutoff (float hz) |
| Changes the smoothing window cutoff frequency (expressed in Hz). | |
| float | cutoff () const |
| Returns the smoothing window cutoff frequency (expressed in Hz). | |
| float | alpha (float sampleRate) const |
| Returns the alpha value computed from given sample rate. | |
| void | reset () |
| Resets the moving average. | |
| virtual float | update (float v, float sampleRate=1, bool forceAlpha=false) |
| Updates the moving average with new value v# (also returns the current value). | |
| float | get () |
| Returns the value of the moving average. This is undefined if isValid() == false. | |
| float | constGet () const |
| unsigned int | nSamples () const |
| Returns the number of samples processed since reset(). | |
| void | amendUpdate (float previousValue, float newValue, float sampleRate=1, bool forceAlpha=false) |
| Performs an amendment of latest update (needs to be called with same sampleRate# and forceAlpha# parameters). | |
Static Public Member Functions | |
| static void | applyUpdate (float &runningValue, float newValue, float alpha) |
| Applies a single update on runningValue# with new sample newValue# and mixing factor alpha#. | |
| static void | applyAmendUpdate (float &runningValue, float previousValue, float newValue, float alpha) |
| Performs an amendment of latest update (needs to be called with same alpha# parameter). | |
| static float | computeUpdate (float runningValue, float newValue, float alpha) |
| Computes a single update on runningValue# with new sample newValue# and mixing factor alpha#. | |
| static float | alpha (float sampleRate, float timeWindow, unsigned int nSamples=UINT_MAX) |
| Returns the alpha value computed from given sample rate, time window, and number of samples. | |
Protected Attributes | |
| float | _smoothTime |
| float | _value |
| unsigned int | _nSamples |
An exponential moving average class.