1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 |
|
---|
3 | #ifndef SIMTOIPR_H
|
---|
4 | #define SIMTOIPR_H
|
---|
5 |
|
---|
6 | #include "toiprocessor.h"
|
---|
7 | #include "tvector.h"
|
---|
8 |
|
---|
9 | // --------- Un deglitcheur simple
|
---|
10 | // Dans chaque fenetre de largeur de wsz
|
---|
11 | // if (val > Mean(Window)+ns*Sigma(Window)) val = Mean(Window)
|
---|
12 | // Si Pas plus de maxnpt points remplissants cette condition
|
---|
13 |
|
---|
14 | class SimpleDeglitcher : public TOIProcessor {
|
---|
15 | public:
|
---|
16 | SimpleDeglitcher(int wsz=64, double ns=3, int maxnpt=5);
|
---|
17 | virtual ~SimpleDeglitcher();
|
---|
18 |
|
---|
19 | inline void SetRange(double min, double max)
|
---|
20 | { range_min = min; range_max = max; }
|
---|
21 | inline void GetRange(double& min, double& max) const
|
---|
22 | { min = range_min; max = range_max; }
|
---|
23 |
|
---|
24 | virtual void init();
|
---|
25 | virtual void run();
|
---|
26 |
|
---|
27 | inline int WSize() const { return wsize; }
|
---|
28 | inline double NbSigmas() const { return nsig; }
|
---|
29 | inline int MaxPoints() const { return maxpoints; }
|
---|
30 |
|
---|
31 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
32 | inline int_8 GlitchCount() const { return glcount; }
|
---|
33 | inline int_8 GlitchSampleCount() const { return glnscount; }
|
---|
34 | inline int_8 OutOfRangeSampleCount() const { return out_range_nscount; }
|
---|
35 |
|
---|
36 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
37 |
|
---|
38 | protected:
|
---|
39 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
40 | int_8 glnscount; // Nombre total de glitch
|
---|
41 | int_8 glcount; // Nombre de glitch detecte
|
---|
42 | int_8 out_range_nscount; // Nombre de sample Out Of Range
|
---|
43 | bool deglitchdone; // Deglitch effectue
|
---|
44 |
|
---|
45 | int wsize; // Taille de fenetre de travail
|
---|
46 | double nsig; // Seuil en nb de sigmas
|
---|
47 | int maxpoints; // Nb maxi de points > ns sigmas
|
---|
48 | double range_min, range_max; // Range acceptable pour in
|
---|
49 | };
|
---|
50 |
|
---|
51 |
|
---|
52 | // Un filtre simple, dans le domaine temporel
|
---|
53 | // remplace val -> Somme(val(i)*coeff(i)) ds Fenetre
|
---|
54 |
|
---|
55 | class SimpleFilter : public TOIProcessor {
|
---|
56 | public:
|
---|
57 | enum FilterKind {
|
---|
58 | UserFilter=0, // User defined filter function
|
---|
59 | MeanFilter=1, // Replace sample by the window mean value (lowpass)
|
---|
60 | SumFilter=2, // Replace sample by the window sum (lowpass)
|
---|
61 | GaussFilter=3, // Apply a gaussian to the window samples
|
---|
62 | DiffFilter=4, // value -= MeanValue
|
---|
63 | };
|
---|
64 |
|
---|
65 | static string FilterKind2String(FilterKind fk);
|
---|
66 | SimpleFilter(int wsz=128,
|
---|
67 | FilterKind fk=SimpleFilter::MeanFilter,
|
---|
68 | double a=1., double s=1.);
|
---|
69 | SimpleFilter(Vector const & vc);
|
---|
70 | ~SimpleFilter();
|
---|
71 |
|
---|
72 | inline FilterKind Type() { return fkind; }
|
---|
73 |
|
---|
74 | inline int WSize() const { return wsize; }
|
---|
75 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
76 | Vector FilterCoefficients() const;
|
---|
77 |
|
---|
78 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
79 |
|
---|
80 | virtual void init();
|
---|
81 | virtual void run();
|
---|
82 |
|
---|
83 | protected:
|
---|
84 | FilterKind fkind;
|
---|
85 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
86 | int wsize; // Taille de fenetre de travail
|
---|
87 | double* coef; // Coefficients du filtre
|
---|
88 |
|
---|
89 | };
|
---|
90 |
|
---|
91 | // Classe SimpleAdder
|
---|
92 | // Calcule la sortie = Somme_Entree [ coeff[num] * entree[num] ]
|
---|
93 |
|
---|
94 | class SimpleAdder : public TOIProcessor {
|
---|
95 | public:
|
---|
96 | SimpleAdder(int nbinput);
|
---|
97 | ~SimpleAdder();
|
---|
98 |
|
---|
99 | void SetGain(int num, double g);
|
---|
100 | double Gain(int num);
|
---|
101 |
|
---|
102 | inline int NbInput() const { return nb_input; }
|
---|
103 | inline int_8 ProcessedSampleCount() const { return totnscount; }
|
---|
104 |
|
---|
105 | virtual void PrintStatus(ostream & os) ; // const plus tard
|
---|
106 |
|
---|
107 | virtual void init();
|
---|
108 | virtual void run();
|
---|
109 |
|
---|
110 | protected:
|
---|
111 | int nb_input;
|
---|
112 | Vector gains;
|
---|
113 | int_8 totnscount; // Nombre total d'echantillon processe
|
---|
114 | };
|
---|
115 |
|
---|
116 |
|
---|
117 | #endif
|
---|