00001
00002
00004 #ifndef __Sample__
00005 #define __Sample__
00006
00007 #include "CUtils.h"
00008 #include "TMath.h"
00009
00010 #define NORDER 20
00011 #define NORDERHP 12
00012
00013 using namespace std;
00014
00021 class ZPGFilter {
00022
00023 public:
00024 friend class Sample;
00025 friend class IIRFilter;
00026
00027 private:
00028
00029 ZPGFilter(const unsigned int numZeros, const unsigned int numPoles);
00030 virtual ~ZPGFilter(void);
00031
00032 bool WToZ(void);
00033
00034 unsigned int nzeros;
00035 unsigned int npoles;
00036 double *zeros[2];
00037 double *poles[2];
00038 double gain[2];
00039 };
00040
00041
00048 class IIRFilter {
00049
00050 public:
00051 friend class Sample;
00052
00053 private:
00054
00055 IIRFilter(ZPGFilter *zpgFilter);
00056 virtual ~IIRFilter(void);
00057
00058 unsigned int nzeros;
00059 unsigned int npoles;
00060 double *zeros[2];
00061 double *poles[2];
00062 double gain[2];
00063 unsigned int numDirect;
00064 unsigned int numRecurs;
00065 double *directCoef;
00066 double *recursCoef;
00067 double *history;
00068 double *history_init;
00069
00070 };
00071
00072
00081 class Sample {
00082
00083 public:
00084
00093 Sample(const int aVerbosity=0);
00094
00098 virtual ~Sample(void);
00112 bool SetFrequencies(const int aNativeFrequency, const int aWorkingFrequency, const double aHighPassFrequency=0);
00113
00119 bool SetNativeFrequency(const int aNativeFrequency);
00120
00128 bool SetWorkingFrequency(const int aWorkingFrequency);
00129
00137 bool SetHighPassFrequency(const double aHighPassFrequency);
00138
00149 bool Transform(const int invectorsize, double *invector, const int outvectorsize, double *outvector);
00150
00154 inline bool GetNativeFrequency(void){ return fNativeFrequency; };
00155
00159 inline bool GetWorkingFrequency(void){ return fWorkingFrequency; };
00160
00164 inline bool GetHighPassFrequency(void){ return fHighPassFrequency; };
00165
00169 inline bool GetStatus(void){ return status_OK; };
00170
00171
00172 protected:
00173
00174 bool status_OK;
00175 int fWorkingFrequency;
00176 int fNativeFrequency;
00177 int fVerbosity;
00178 double fHighPassFrequency;
00179
00180 private:
00181
00182
00183 bool MakeSamplingFilters(void);
00184 bool Resample(int invectorsize, double *invector, double *outvector);
00185 bool presample;
00186 int fResampleFactor;
00187 int fIntermediateFrequency;
00188 int I,J;
00189 IIRFilter *iirFilter[NORDER];
00190 bool PreSample(int &datavectorsize, double *datavector);
00191
00192
00193
00194 bool MakeHighPassFilters(void);
00195 bool HighPass(const int invectorsize, double *invector);
00196 int IHP,JHP;
00197 IIRFilter *iirFilterHP[NORDERHP];
00198
00199
00200 bool ApplyFilter(const int datavectorsize, double *datavector, IIRFilter *filter);
00201
00202 ClassDef(Sample,0)
00203
00204 };
00205
00206 #endif
00207
00208