OpenWareLaboratory
ExponentialMovingAverage Class Reference

Exponential Moving Average EMA. More...

Inheritance diagram for ExponentialMovingAverage:
Collaboration diagram for ExponentialMovingAverage:

Public Member Functions

 ExponentialMovingAverage (float lambda=0.995, float y=0)
 
float getAverage ()
 
float getLambda ()
 
float getNextAverage (float x)
 RMS detection with smoothing coefficient (Moving RMS) as per: R. More...
 
float process (float in)
 
virtual float process (float input)
 
void process (FloatArray input)
 
virtual void process (FloatArray input, FloatArray output)
 
virtual void process (FloatArray input, FloatArray output)
 
void set (float value)
 
void setCutoff (float fc)
 Set lambda (time coefficient) as the -3dB cutoff frequency, in radians. More...
 
void setLambda (float value)
 Set the exponential decay time coefficient. More...
 
void setModifiedMovingAverage (size_t N)
 Set lambda (time coefficient) as 1/N. More...
 
void setSmoothing (size_t observations, float smoothing=2)
 Set lambda (time coefficient) as amount of smoothing over number of observations. More...
 

Static Public Member Functions

static ExponentialMovingAveragecreate (float lambda)
 
static void destroy (ExponentialMovingAverage *obj)
 

Detailed Description

Exponential Moving Average EMA.

Definition at line 9 of file MovingAverage.h.

Constructor & Destructor Documentation

◆ ExponentialMovingAverage()

ExponentialMovingAverage::ExponentialMovingAverage ( float  lambda = 0.995,
float  y = 0 
)
inline

Definition at line 14 of file MovingAverage.h.

Referenced by create().

Member Function Documentation

◆ create()

static ExponentialMovingAverage* ExponentialMovingAverage::create ( float  lambda)
inlinestatic

Definition at line 75 of file MovingAverage.h.

References ExponentialMovingAverage().

◆ destroy()

static void ExponentialMovingAverage::destroy ( ExponentialMovingAverage obj)
inlinestatic

Definition at line 78 of file MovingAverage.h.

◆ getAverage()

float ExponentialMovingAverage::getAverage ( )
inline

Definition at line 63 of file MovingAverage.h.

◆ getLambda()

float ExponentialMovingAverage::getLambda ( )
inline

Definition at line 26 of file MovingAverage.h.

◆ getNextAverage()

float ExponentialMovingAverage::getNextAverage ( float  x)
inline

RMS detection with smoothing coefficient (Moving RMS) as per: R.

J. Cassidy, “Level Detection Tunings and Techniques for the Dynamic Range Compression of Audio Signals,” presented at the 117th Convention of the Audio Engineering Society (2004 Oct.), convention paper 6235. Referenced in https://www.eecs.qmul.ac.uk/~josh/documents/2012/GiannoulisMassbergReiss-dynamicrangecompression-JAES2012.pdf

Definition at line 59 of file MovingAverage.h.

Referenced by process().

◆ process() [1/5]

float ExponentialMovingAverage::process ( float  in)
inlinevirtual

Reimplemented from SignalProcessor.

Definition at line 67 of file MovingAverage.h.

References getNextAverage().

◆ process() [2/5]

virtual float SignalProcessor::process
inline

Definition at line 13 of file SignalProcessor.h.

◆ process() [3/5]

void ExponentialMovingAverage::process ( FloatArray  input)
inline

Definition at line 70 of file MovingAverage.h.

References getNextAverage(), and SimpleArray< T >::getSize().

◆ process() [4/5]

virtual void SignalProcessor::process
inline

Definition at line 16 of file SignalProcessor.h.

◆ process() [5/5]

◆ set()

void ExponentialMovingAverage::set ( float  value)
inline

Definition at line 15 of file MovingAverage.h.

◆ setCutoff()

void ExponentialMovingAverage::setCutoff ( float  fc)
inline

Set lambda (time coefficient) as the -3dB cutoff frequency, in radians.

(i.e. radians = pi times frequency / sample rate). Ref: https://dsp.stackexchange.com/questions/28308/exponential-weighted-moving-average-time-constant

Definition at line 51 of file MovingAverage.h.

◆ setLambda()

void ExponentialMovingAverage::setLambda ( float  value)
inline

Set the exponential decay time coefficient.

Lambda should be a value between 0 and 1, typically greater than 0.9. Higher values gives more smoothing.

Definition at line 23 of file MovingAverage.h.

◆ setModifiedMovingAverage()

void ExponentialMovingAverage::setModifiedMovingAverage ( size_t  N)
inline

Set lambda (time coefficient) as 1/N.

Known as a Modified Moving Average MMA, Smoothed Moving Average SMMA, or Running Moving Average RMA.

Definition at line 43 of file MovingAverage.h.

◆ setSmoothing()

void ExponentialMovingAverage::setSmoothing ( size_t  observations,
float  smoothing = 2 
)
inline

Set lambda (time coefficient) as amount of smoothing over number of observations.

With smoothing = 2.0 and observations = N, this corresponds roughly to an N-point SMA.

Definition at line 35 of file MovingAverage.h.


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