Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

mfcc.h

Go to the documentation of this file.
00001 
00034 /************************************************************************/
00035 /*    mfcc.h                                                            */
00036 /*                                                                      */
00037 /*    Author    : Yuichiro Nakano                                       */
00038 /************************************************************************/
00039 
00040 #ifndef __MFCC_H__
00041 #define __MFCC_H__
00042 
00044 #undef MFCC_TABLE_DEBUG
00045 
00046 #include <sent/stddefs.h>
00047 #include <ctype.h>
00048 
00049 #define DEF_SMPPERIOD   625     
00050 #define DEF_FRAMESIZE   400     
00051 #define DEF_FFTNUM      512     
00052 #define DEF_FRAMESHIFT  160     
00053 #define DEF_PREENPH     0.97    
00054 #define DEF_MFCCDIM     12      
00055 #define DEF_CEPLIF      22      
00056 #define DEF_FBANK       24      
00057 #define DEF_DELWIN      2       
00058 #define DEF_ACCWIN      2       
00059 #define DEF_SILFLOOR    50.0    
00060 #define DEF_ESCALE      0.1     
00061 #define DEF_SSALPHA     2.0     
00062 #define DEF_SSFLOOR     0.5     
00063 
00064 
00065 typedef struct {
00066   long smp_period;      
00067   int framesize;        
00068   int frameshift;       
00069   float preEmph;        
00070   int mfcc_dim;         
00071   int lifter;           
00072   int fbank_num;        
00073   int delWin;           
00074   int accWin;           
00075   float silFloor;       
00076   float escale;         
00077   int hipass;           
00078   int lopass;           
00079   int cmn;              
00080   int enormal;          
00081   int raw_e;            
00082   int c0;               
00083   float ss_alpha;       
00084   float ss_floor;       
00085   int zmeanframe;       
00086   int delta;            
00087   int acc;              
00088   int energy;           
00089   int absesup;          
00090   int baselen;          
00091   int vecbuflen;        
00092   int veclen;           
00093 }Value;
00094 
00096 typedef struct {
00097    int fftN;            
00098    int n;               
00099    int klo;             
00100    int khi;             
00101    float fres;          
00102    float *cf;           
00103    short *loChan;       
00104    float *loWt;         
00105    float *Re;           
00106    float *Im;           
00107 } FBankInfo;
00108 
00110 typedef struct {
00111   float **mfcc;                 
00112   int veclen;                   
00113   float *vec;                   
00114   int win;                      
00115   int len;                      
00116   int store;                    
00117   boolean *is_on;               
00118   int B;                        
00119 } DeltaBuf;
00120 
00121 #ifdef MFCC_SINCOS_TABLE
00122 /* functions for making tables */
00123 void make_costbl_hamming(int framesize);
00124 void make_fft_table(int n);
00125 void make_costbl_makemfcc(int fbank_num, int mfcc_dim);
00126 void make_sintbl_wcep(int lifter, int mfcc_dim);
00127 #endif
00128 
00129 /* Apply hamming window */
00130 void Hamming (float *wave, int framesize);
00131 
00132 /* Apply pre-emphasis filter */
00133 void PreEmphasise (float *wave, Value para);
00134 
00135 /* Return mel-frequency */
00136 float Mel(int k, float fres);
00137 
00138 /* Get filterbank information */
00139 FBankInfo InitFBank(Value para);
00140 void FreeFBank(FBankInfo fb);
00141 
00142 /* Apply FFT */
00143 void FFT(float *xRe, float *xIm, int p);
00144 
00145 /* Convert wave -> mel-frequency filterbank */
00146 void MakeFBank(float *wave, double *fbank, FBankInfo info, Value para, float *ssbuf);
00147 
00148 /* Apply the DCT to filterbank */ 
00149 void MakeMFCC(double *fbank, float *mfcc, Value para);
00150 
00151 /* Calculate 0'th Cepstral parameter*/
00152 float CalcC0(double *fbank, Value para);
00153 
00154 /* Calculate Log Raw Energy */
00155 float CalcLogRawE(float *wave, int framesize);
00156 
00157 /* Zero Mean Souce by frame */
00158 void ZMeanFrame(float *wave, int framesize);
00159 
00160 /* Re-scale cepstral coefficients */
00161 void WeightCepstrum (float *mfcc, Value para);
00162 
00163 /* Calculate delta coefficients */
00164 void Delta(float **c, int frame, Value para);
00165 
00166 /* Calculate acceleration coefficients */
00167 void Accel(float **c, int frame, Value para);
00168 
00169 /* Normalise log energy */
00170 void NormaliseLogE(float **c, int frame_num, Value para);
00171 
00172 /* Convert wave -> MFCC_E_D_(Z) */
00173 int Wav2MFCC(SP16 *wave, float **mfcc, Value para, int nSamples, float *ssbuf, int ssbuflen);
00174 
00175 /* Cepstrum Mean Normalization */
00176 void CMN(float **mfcc, int frame_num, int dim);
00177 
00178 /* for wav2mfcc-pipe.c */
00179 void WMP_init(Value para, float **bf, float *ssbuf, int ssbuflen);
00180 void WMP_calc(float *mfcc, float *bf, Value para, float *ssbuf);
00181 DeltaBuf *WMP_deltabuf_new(int veclen, int windowlen);
00182 void WMP_deltabuf_free(DeltaBuf *db);
00183 void WMP_deltabuf_prepare(DeltaBuf *db);
00184 boolean WMP_deltabuf_proceed(DeltaBuf *db, float *new_mfcc);
00185 boolean WMP_deltabuf_flush(DeltaBuf *db);
00186 
00187 void CMN_realtime_init(int dimension, float weight);
00188 void CMN_realtime_prepare();
00189 void CMN_realtime(float *mfcc, int dim);
00190 void CMN_realtime_update();
00191 boolean CMN_load_from_file(char *filename, int dim);
00192 boolean CMN_save_to_file(char *filename);
00193 
00194 /* spectral subtraction */
00195 float *new_SS_load_from_file(char *filename, int *slen);
00196 float *new_SS_calculate(SP16 *wave, int wavelen, Value para, int *slen);
00197 
00198 #endif /* __MFCC_H__ */

Generated on Tue Mar 28 16:17:42 2006 for Julius by  doxygen 1.4.2