Control Surface  1.1.0
MIDI Control Surface library for Arduino
Public Member Functions | Private Attributes | List of all members
EMA_f Class Reference

A class for single-pole infinite impulse response filters or exponential moving average filters. More...

#include <EMA.hpp>

Collaboration diagram for EMA_f:

Public Member Functions

 EMA_f (float pole)
 Create an exponential moving average filter with a pole at the given location. More...
 
float filter (float value)
 Filter the input: Given \( x[n] \), calculate \( y[n] \). More...
 
float operator() (float value)
 Filter the input: Given \( x[n] \), calculate \( y[n] \). More...
 

Private Attributes

float alpha
 
float filtered = 0
 

Detailed Description

A class for single-pole infinite impulse response filters or exponential moving average filters.

This version uses floating point maths.

Difference equation: \( y[n] = \alpha·x[n]+(1-\alpha)·y[n-1] \) \( x \) is the input sequence, and \( y \) is the output sequence.

An in-depth explanation of the EMA filter

Definition at line 93 of file EMA.hpp.

Constructor & Destructor Documentation

◆ EMA_f()

EMA_f::EMA_f ( float  pole)
inline

Create an exponential moving average filter with a pole at the given location.

Parameters
poleThe pole of the filter ( \(1-\alpha\)).
Should be a value in the range \( \left[0,1\right) \).
Zero means no filtering, and closer to one means more filtering.

Definition at line 105 of file EMA.hpp.

Member Function Documentation

◆ filter()

float EMA_f::filter ( float  value)
inline

Filter the input: Given \( x[n] \), calculate \( y[n] \).

Parameters
valueThe new raw input value.
Returns
The new filtered output value.

Definition at line 114 of file EMA.hpp.

◆ operator()()

float EMA_f::operator() ( float  value)
inline

Filter the input: Given \( x[n] \), calculate \( y[n] \).

Parameters
valueThe new raw input value.
Returns
The new filtered output value.

Definition at line 126 of file EMA.hpp.

Member Data Documentation

◆ alpha

float EMA_f::alpha
private

Definition at line 129 of file EMA.hpp.

◆ filtered

float EMA_f::filtered = 0
private

Definition at line 130 of file EMA.hpp.


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