Files
libpasada/pasada-lib/include/step_detector.h
David Madl d88ac81345 feat: StepDetector
move StepDetector from lockstep android to libpasada
2026-03-15 23:07:05 +01:00

52 lines
1.2 KiB
C++

//
// Created by david on 15.03.2026.
//
#ifndef PASADASUPERPROJECT_STEP_DETECTOR_H
#define PASADASUPERPROJECT_STEP_DETECTOR_H
#include "iir_filter.h"
#include "ssf_filter.h"
#include <vector>
class StepListener {
public:
virtual ~StepListener() {}
virtual void playBeat() = 0;
};
/**
* Step detector from accelerometer signal.
*
* Settling time is 3.0 sec (defined in SsfStepDetector.LEN_INIT),
* no steps are detected before.
*/
class StepDetector {
protected:
StepListener *listener;
IirFilter f_highpass;
Filt f_neg;
SsfFilter f_ssf;
SsfStepDetector f_ssd;
RunningQualityFilter f_sqi;
bool debug;
std::vector<double> buf_ssd;
std::vector<double> buf_sqi;
std::vector<double> buf_out;
public:
StepDetector(StepListener *listener, bool debug = false);
void filter(std::vector<float> values);
std::vector<double> getBufSsd();
std::vector<double> getBufSqi();
std::vector<double> getBufOut();
/**
* Prime the filters using the given input signal.
* Used for debugging (non-realtime processing) to align the signal.
*/
void primeFilters(std::vector<double> sig);
};
#endif //PASADASUPERPROJECT_STEP_DETECTOR_H