133 if(
Change(smoothedValue, value) < 0.04)
159 const int vote = (value >=
m_history[i])? 1 : -1;
162 return abs(sum) == (int)m_historySize;
165 static double Change(
double from,
double to)
167 return fabs(from - to) / from;
175 if(((h2-h1) * (h1-h0)) > 0)
bool operator()(double time, double &frequency)
double m_smoothedFrequency
virtual double SmoothedFrequency() const
FrequencyFilter(double resolution, double expectedFrequency)
regulate IIR gain for rapid but smooth tracking of a function.
static const size_t m_historySize
bool WasOnSameSide(double value) const
double operator()(double x, int bias)
NONCOPYABLE(FrequencyFilter)
Controller(double initialValue)
shared_ptr< IFrequencyFilter > PIFrequencyFilter
FrequencyEstimator m_frequencyEstimator
#define ENSURE(expr)
ensure the expression <expr> evaluates to non-zero.
IirFilter(double sensitivity, double initialValue)
const double m_minDeltaTime
static const double sensitivity
NONCOPYABLE(FrequencyEstimator)
double m_history[m_historySize]
double m_averagedFrequency
static double ComputeExponent(int bias)
PIFrequencyFilter CreateFrequencyFilter(double resolution, double expectedFrequency)
virtual void Update(double time)
virtual int StableFrequency() const
static double Change(double from, double to)
FrequencyEstimator(double resolution)
int ComputeBias(double smoothedValue, double value)
variable-width window for frequency determination
static const double errorTolerance
#define cassert(expr)
Compile-time assertion.
static const double sampleTime