-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFindNLargestF.h
More file actions
71 lines (63 loc) · 1.92 KB
/
FindNLargestF.h
File metadata and controls
71 lines (63 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#ifndef FINDNLARGESTF_H_
#define FINDNLARGESTF_H_
/*
* FindNLargestF.h - Find the N largest magnitude frequencies in an FFT
*
* Copyright (C) 2022
* Mark Broihier
*
*/
/* ---------------------------------------------------------------------- */
#include <list>
#include <map>
#include <math.h>
#include <sys/types.h>
/* ---------------------------------------------------------------------- */
class FindNLargestF {
private:
void init(int size, int number);
void adjustThresholds(float centroid, int candidate);
void adjustTargets(float centroid, int candidate);
int findClosestTarget (float centroid, int candidate);
void logCentroid(float centroid, int candidate);
void logBase(float baseValue, int candidate);
void reportHistory(int numberOfCandidates);
int * binArray;
bool * used;
float * samples;
float * mag;
int * histogram;
int sampleBufferSize;
int size;
int number;
int tic;
const int FIRST = 0;
const int SECOND = 1;
const int THIRD = 2;
const int REF1 = 4;
const int REF2 = 5;
const float BW = 3.0;
const float BW_DELTA = BW / 3.0;
const float BW1 = BW / 6.0;
const float BW2 = BW1 + BW_DELTA;
const float BW3 = BW2 + BW_DELTA;
const float CF = BW / 2.0;
const float LOWER = CF - BW1;
const float HIGHER = CF + BW1;
const int TARGET0 = 0;
const int TARGET1 = 1;
const int TARGET2 = 2;
const int TARGET3 = 3;
std::map<int, std::map<int, float> *> thresholds;
std::map<int, std::map<int, float> *> targets;
struct SampleRecord { float centroid; int timeStamp; };
struct BaseRecord { float base; int timeStamp; };
std::map<int, float> candidates; // list of cadidates mapped to their centroid location
std::map<int, std::list<SampleRecord> *> centroidHistory;
std::map<int, std::list<BaseRecord> *> baseHistory;
public:
void doWork();
FindNLargestF(int size, int number);
~FindNLargestF(void);
};
#endif // FINDNLARGESTF_H_