-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathnorm.h
75 lines (66 loc) · 1.74 KB
/
norm.h
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
72
73
74
75
#ifndef _NORM_H
#define _NORM_H
#include <map>
// normalization kinds
#define NK_NONE 0
#define NK_MEAN 1
#define NK_VAR 2
#define NK_SCALEGVAR 4
class ChannelNormParams
{
public:
ChannelNormParams();
~ChannelNormParams();
void Alloc(int FrameLength);
void Null();
int GetFrameLength();
unsigned int GetAccFramesNum();
void Accum(int Length, float *pFrame);
void Norm(int Length, float *pFrame);
void Update();
void SetNorm(unsigned int Kind);
float *GetMeans();
float *GetInvStds();
void SetMeans(float *pVct);
void SetInvStds(float *pVct);
void SetGlobStds(float *pVct);
protected:
int mFrameLength;
float *mpX;
float *mpX2;
float *mpMeans;
float *mpInvStds;
float *mpGlobStds;
unsigned int mNFrames;
unsigned int mNormKind;
void Free();
};
class Normalization
{
public:
Normalization();
~Normalization();
void SetChannel(int Channel);
void ProcessFrame(int Length, float *pFrame);
void StartEstimation(int NFrames);
void SetFile(char *pFile);
void SetSignalEstimEnd(bool Signal);
void SetMeanNorm(bool Norm);
void SetVarNorm(bool Norm);
void SetScaleToGVar(bool Flag);
void Save(char *pFile);
void Load(char *pFile);
protected:
int mActualChannel;
ChannelNormParams *mpActualParams;
std::map<int, ChannelNormParams> mParams;
unsigned int mNFramesForEstim;
char mpFile[1024];
bool mSignalEstimEnd;
bool mMeanNorm;
bool mVarNorm;
bool mScaleToGVar;
void UpdateNormFlags();
void ParseFloatVector(char *pText, float **ppVct, int *pLength);
};
#endif