/*------------ FrvChi2.c, By B. Mours Aug 15, 2000 --------------------------*/ #ifndef FRVCHI2 #define FRVCHI2 #ifndef _POSIX_SOURCE #define _POSIX_SOURCE #endif #include "FrameL.h" #include "FrvFFT.h" #include "FrvBuf.h" #ifdef __cplusplus extern "C" { #endif struct FrvChi2 { /*--------------------- input data -------------*/ double decay; /* decay time for averageing (could by changed) */ long nDecay; /* #of fft for the mean spectrum(could be reset)*/ int outSize; /* output size */ int window; /* flag. If = 0; no window used for the FFT */ double threshold; /* threshold used to stored loudest segment info*/ /* If = 0; no data are saved */ double freq0; /* min freq for the first frequency band */ double freq1; /* freq boundary for the first/second freq. band*/ double freq2; /* freq boundary for the second/third freq. band*/ /*------------------- internal data ------------*/ FrvRFFT *fft; /* fft object */ FrvBuf *buffer; /* interface buffer */ char *name; /* chi2 name; copy of vector name */ int ip0; /* start index for the first freq. band */ int ip1; /* end index for the first freq. band */ int ip2; /* end index for the second freq. band */ int ip3; /* end index for the third freq. band */ /* ------------output------------------------- */ FrVect *amplitude2; /* vector to hold the averaged power spectrum */ FrVect *amplitude; /* amplitude spectrum for the loudest segment */ FrVect *amplitudeA; /* average amplitude sp. for the loudest segment*/ FrVect *residual; /* residual for the loudest segment */ FrVect *rms2; /* rms**2 amplitude sp. at the loudest segment */ FrVect *dataIn; /* data for the loudest segment */ long nCall; /* number of fft computed */ double chi2; /* chi2 for the last frame processed */ double chi2Freq; /* mean frequency for the signal */ int chi2Time; /* segment number which trigger the data */ double power1; /* mean power in the first frequency band */ double power2; /* mean power in the second frequency band */ double power3; /* mean power in the third frequency band */ }; typedef struct FrvChi2 FrvChi2; int FrvChi2Ini(FrvChi2 *chi2, FrVect *vect); FrvChi2* FrvChi2New(int outsize, int window, double threshold); FrvChi2* FrvChi2Proc(FrvChi2 *chi2, FrVect *vect); #ifdef __cplusplus } #endif #endif