dtmf.h

来自「DTMF检测程序。定点计算」· C头文件 代码 · 共 63 行

H
63
字号
#define FRAME_SIZE	160
#define MAX_LOOPS	160 		//max count for DFT loops

#define THR_SIG 	2000	//	2800	//threshold for tone (-23dB) :YDN-065
#define THR_PAU		600	//	400		//threshold for pause energy

#define THR_TWI1	(800*32768/10000)	//threshold for twist (-10dB) : <<YDN-065(-6dB)>>
#define THR_TWI2	(800*32768/10000)	//threshold for twist (-10dB) : <<YDN-065(-6dB)>>

#define THR_ROWREL	(5000*32768/10000)	//threshold for row's relative peak ratio
#define THR_COLREL	(5000*32768/10000)	//threshold for col's relative peak ratio

//#define THR_ROW2nd	(200*32768/10000)	//threshold for row's 2nd harmonic ratio
//#define THR_COL2nd	(200*32768/10000)	//threshold for col's 2nd harmonic ratio

#define PAUSE_TIME	1

#define GAIN_THR	0x0060*FRAME_SIZE	//gain control threshold

#define GAINBUF_LEN	(32)
#define TAPS_LEN		(8*2)
#define ENERGY_LEN	(8)
#define DTMF_NUMBERS	(16)

#define ALAW
//#define DEBUG

#ifndef bool
#define bool int
#endif

#ifndef true
#define true 1
#endif

#ifndef false
#define false 0
#endif

typedef struct
{
	int goertzelCnt;
	unsigned short digitLast;
	int pauseCnt;
//	short *pOldSample;
//	short gainBuf[GAINBUF_LEN];
	short taps[TAPS_LEN];
	short energy[ENERGY_LEN];
} DTMFDet_t;

bool dtmfDet(short *linearCode, unsigned short* pNum);
static inline short MUL_S16_S16(short x, short y);
static short DIV_S16_S16(short x, short y);
static void init(DTMFDet_t *pTab);
static void gaincrtl(short *pSample);
static void goertzel(short x, DTMFDet_t *pTab);
static void getEnergy(DTMFDet_t *pTab);
static void maxSearch(short *rowMax, short *colMax, short *rowMax2, short *colMax2, unsigned short *row, unsigned short *col, DTMFDet_t *pTab);
static bool strengthCheck(short rowMax, short colMax, DTMFDet_t *pTab);
static bool twistCheck(short rowMax, short colMax);
static bool relCheck(short rowMax, short colMax, short rowMax2, short colMax2);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?