FE_common.h
上传用户:italyroyal
上传日期:2013-05-06
资源大小:473k
文件大小:5k
- ///////////////////////////////////////////////////////////////////////////////
- // This is a part of the Feature program.
- // Version: 1.0
- // Date: February 22, 2003
- // Programmer: Oh-Wook Kwon
- // Copyright(c) 2003 Oh-Wook Kwon. All rights reserved. owkwon@ucsd.edu
- ///////////////////////////////////////////////////////////////////////////////
- #ifndef _FE_COMMON_H_
- #define _FE_COMMON_H_
- #ifdef WIN32
- #include <windows.h>
- #endif
- #ifdef min
- #undef min
- #endif
- #ifdef max
- #undef max
- #endif
- #include <assert.h>
- #include <iostream>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <cmath>
- #include <climits>
- #include <vector>
- #include <valarray>
- #include <string>
- using namespace std;
- #pragma warning(disable:4786)
- // FE_vector.h should be placed after "using namespace std;"
- #include "FE_vector.h"
- #include "FE_matrix.h"
- // Include definition for kWaves interface
- #ifdef MAIN_PROGRAM
- #include "FE_wave_feature.h"
- #else
- #include "../kWaves-0.95/Sources/WaveFeature.h"
- #endif
- #ifndef FLT_MAX
- #define FLT_MAX 1E37
- #endif
- #define LOG(x) (((x)>0.) ? (float)log((double)(x)) : (float)(-FLT_MAX))
- #define EXP(x) (exp(x))
- #define LOG10(x) (((x)>0.) ? (float)log10((double)(x)) : (float)(-FLT_MAX))
- #define EXP10(x) ((float)pow((double)10.0,(double)(x)))
- #ifndef M_PI
- #define M_PI 3.14159265358979323846
- #endif
- #ifndef TRUE
- #define TRUE 1
- #endif
- #ifndef FALSE
- #define FALSE 0
- #endif
- /*----------------------------------*/
- /* Common macros */
- /*----------------------------------*/
- #ifndef my_max
- #define my_max(a,b) (((a)>(b)) ? (a) : (b))
- #endif
- #ifndef my_min
- #define my_min(a,b) (((a)<(b)) ? (a) : (b))
- #endif
- #ifndef my_abs
- #define my_abs(x) ((x>=0) ? (x) : (-(x)))
- #endif
- /*----------------------------------*/
- /* Definition for feature extractor */
- /*----------------------------------*/
- #define SAMPLING_FREQ_1 8 /* 8kHz */
- #define SAMPLING_FREQ_2 11 /* 11kHz */
- #define SAMPLING_FREQ_3 16 /* 16kHz */
- #define FRAME_LENGTH_1 200 /* 25ms */
- #define FRAME_LENGTH_2 256 /* 23.27ms */
- #define FRAME_LENGTH_3 400 /* 25ms */
- #define FRAME_SHIFT_1 80 /* 10ms */
- #define FRAME_SHIFT_2 110 /* 10ms */
- #define FRAME_SHIFT_3 160 /* 10ms */
- #define FFT_LENGTH_1 256
- #define FFT_LENGTH_2 256
- #define FFT_LENGTH_3 512
- /************************************************************************
- User-specific Constant Values
- ************************************************************************/
- #define DEFAULT_SAMPLING_RATE 16000 /* 16 kHz sampling */
- #define DEFAULT_SHIFT_SIZE_IN_MS 10 /* 10 ms */
- #define DEFAULT_WINDOW_SIZE_IN_MS 25 /* 25 ms */
- #define DEFAULT_FFT_SIZE 512 /* FFT size */
- /**************************************************************
- * default setting
- **************************************************************/
- // Preemphasis
- #define FE_PRE_EMPH_FAC 0.97 /* Preemphasis factor */
- // LPC
- #define FE_LPC_ORDER 14 /* default LPC order */
- #define FE_LPC_ORDER_1 12 /* LPC order for 8 kHz sampling rate */
- #define FE_LPC_ORDER_2 14 /* LPC order for 16 kHz sampling rate */
- // Cepstrum
- #define FE_CEP_ORDER 12 /* Number of cepstral coefficients is CEPORDER+1 including c0 */
- // Dynamic features
- #define FE_DELTA 5 /* Order of delta coefficients */
- #define FE_DDELTA 3 /* Order of acceleration (delta-delta) coefficients */
- // Filter bank
- #define FE_NUM_CHANNELS 23 /* Number of bands in filter bank */
- #define FE_FBANK_FLOOR (-50.0) /* Energy floor for filter bank coefficients */
- // Energy
- #define FE_MIN_ENERGY (1)
- #define FE_MIN_LOG_ENERGY (0)
- /*----------------------------------*/
- /* Data structures */
- /*----------------------------------*/
- #ifdef FeReturnCode
- #define FeReturnCode __FeReturnCode
- #endif
- enum FeReturnCode { /* A starting number was added to avoid overlap with other enumerators. */
- FE_NULL=100, /* for null transition. non-speech or non-silence */
- FE_OK, /* successful, no error */
- FE_WAITING, /* waiting for speech start */
- FE_SPEECH, /* in the middle of speech */
- FE_PAUSE, /* pause */
- FE_END_POINT, /* endpoint detected */
- FE_NO_SPEECH, /* no speech found */
- FE_EARLY_END, /* end-of-file detected before endpoint detection */
- FE_EOF, /* end-of-file detected */
- FE_AUDIO_OPEN_ERROR, /* error in opening audio device */
- FE_WAVE_OPEN_ERROR, /* error in opening wave file */
- FE_STOP, /* stopped */
- FE_UNK_ERROR /* unknown error */
- };
- #endif