39 #ifndef __VMML__LOWPASS_FILTER__HPP__
40 #define __VMML__LOWPASS_FILTER__HPP__
54 const T&
get()
const {
return _value; }
63 const T&
add(
const T& value );
66 std::deque< T > _data;
72 template<
size_t M,
typename T >
75 _data.push_front( value );
77 while( _data.size() > M )
81 typename std::deque< T >::const_iterator i = _data.begin();
83 double weight = _smoothFactor;
85 for( ++i ; i != _data.end(); ++i )
87 _value = _value * (1 - weight) + (*i) * weight;
88 weight *= _smoothFactor;
LowpassFilter(const float F)
Construct a new lowpass filter with the given smoothing.
const T * operator->() const
Access the filtered value.
heavily inspired by boost::enable_if http://www.boost.org, file: boost/utility/enable_if.hpp, Copyright 2003 Jaakko Järvi, Jeremiah Willcock, Andrew Lumsdaine
const T & operator*() const
Access the filtered value.
const T & add(const T &value)
Add a value to the data set and return the filtered output.