refactor: move test_helpers, RunningQuality
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#define PASADASUPERPROJECT_SSF_FILTER_H
|
||||
|
||||
#include "iir_filter.h"
|
||||
#include <deque>
|
||||
|
||||
#define FPS 60
|
||||
#define MAX_BPM 300
|
||||
@@ -53,4 +54,52 @@ public:
|
||||
double peek_threshold();
|
||||
};
|
||||
|
||||
/**
|
||||
* Running signal quality indicator.
|
||||
*/
|
||||
class RunningQuality {
|
||||
protected:
|
||||
// TODO: make it a filter (output proper samples)
|
||||
|
||||
/** template beat is resampled to this #samples */
|
||||
const int BEAT_LEN = 120 /* 2*FPS for 30 bpm lower end */;
|
||||
|
||||
/** threshold for accepting initial beats */
|
||||
const double BEAT_CORR_THR_1 = 0.9;
|
||||
/** threshold for accepting subsequent beats */
|
||||
const double BEAT_CORR_THR_2 = 0.8;
|
||||
/** absolute SSF threshold for accepting any beat */
|
||||
const double SSF_THRESHOLD = 5.0;
|
||||
/** number of recent beats to use for beat template. must be even (alternating feet have different patterns; make it symmetric) */
|
||||
const int NUM_BEATS = 4;
|
||||
|
||||
std::deque<std::vector<double> > beatTemplates;
|
||||
std::vector<double> beatTemplate;
|
||||
//std::vector<std::pair<int, int> > badBeatRanges;
|
||||
double beatCorrThr2;
|
||||
bool justLocked;
|
||||
int idx;
|
||||
|
||||
/** for debugging only - disable SSF_THRESHOLD */
|
||||
bool disableSsf;
|
||||
|
||||
void addTemplate(std::vector<double>& x);
|
||||
|
||||
void replaceTemplate(std::vector<double>& x);
|
||||
|
||||
virtual void dispatchLocked();
|
||||
virtual void dispatchBeat(int idx, bool good, double posCorr);
|
||||
|
||||
public:
|
||||
RunningQuality();
|
||||
explicit RunningQuality(bool disableSsf);
|
||||
virtual ~RunningQuality();
|
||||
|
||||
// note: arg should be an iterator really, but can do later
|
||||
/**
|
||||
* @param beat individual beat accelero signal
|
||||
*/
|
||||
void append(std::vector<double> &rawBeat, std::vector<double> &rawSsf);
|
||||
};
|
||||
|
||||
#endif //PASADASUPERPROJECT_SSF_FILTER_H
|
||||
Reference in New Issue
Block a user