feat: StepDetector

move StepDetector from lockstep android to libpasada
This commit is contained in:
2026-03-15 23:07:05 +01:00
parent ba923c53bd
commit d88ac81345
9 changed files with 169 additions and 1 deletions

View File

@@ -0,0 +1,52 @@
//
// 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