feat: StepDetector
move StepDetector from lockstep android to libpasada
This commit is contained in:
@@ -52,6 +52,8 @@ public:
|
||||
SsfStepDetector(size_t len_refr);
|
||||
double filter(double val);
|
||||
double peek_threshold();
|
||||
|
||||
static size_t initial_samples();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
52
pasada-lib/include/step_detector.h
Normal file
52
pasada-lib/include/step_detector.h
Normal 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
|
||||
Reference in New Issue
Block a user