OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
ossia::one_euro_filter< T > Struct Template Reference

One-euro filter: a low-pass whose cutoff rises with the speed of the signal. More...

Detailed Description

template<typename T = float>
struct ossia::one_euro_filter< T >

One-euro filter: a low-pass whose cutoff rises with the speed of the signal.

Casiez, Roussel and Vogel, "1 euro filter: a simple speed-based low-pass filter for noisy input in interactive systems", CHI 2012.

The point is the jitter/lag tradeoff: at rest the cutoff drops to min_cutoff and the output is very smooth, while a fast movement raises the cutoff so the output stays responsive. Per the authors: if lag during fast motion is the problem, raise beta ; if jitter at rest is the problem, lower min_cutoff.

The derivative is taken against the previous raw input, as in the reference implementation.

Public Types

using value_type = T
 

Public Member Functions

OSSIA_INLINE void reset () noexcept
 Forget the history: the next sample restarts the filter.
 
OSSIA_INLINE void assign_parameters (const one_euro_filter &p) noexcept
 Adopt p's tuning, keeping the history.
 
OSSIA_INLINE T operator() (T x, T dt) noexcept
 

Public Attributes

min_cutoff {1}
 Cutoff at zero speed, in Hz. Lower is smoother, and laggier.
 
beta {0}
 How much the speed raises the cutoff. 0 degrades to a plain low-pass.
 
d_cutoff {1}
 Cutoff of the low-pass applied to the derivative itself, in Hz.
 
one_pole_filter< T > x_filter {}
 Smoother for the value.
 
one_pole_filter< T > dx_filter {}
 Smoother for the derivative.
 
x_prev {}
 Previous raw input.
 

Member Function Documentation

◆ operator()()

template<typename T = float>
OSSIA_INLINE T ossia::one_euro_filter< T >::operator() ( x,
dt 
)
inlinenoexcept
Parameters
xInput sample.
dtTime since the previous sample, in seconds.

A dt <= 0 returns the previous output unchanged rather than dividing by zero, so that a duplicated timestamp cannot poison the state.