/* * DTMF decoder. * * Copyright by Andreas Eversberg ([email protected]) * based on different decoders such as ISDN4Linux * * This software may be used and distributed according to the terms * of the GNU General Public License, incorporated herein by reference. * */ #include <linux/mISDNif.h> #include <linux/mISDNdsp.h> #include "core.h" #include "dsp.h" #define NCOEFF … /* For DTMF recognition: * 2 * cos(2 * PI * k / N) precalculated for all k */ static u64 cos2pik[NCOEFF] = …; /* digit matrix */ static char dtmf_matrix[4][4] = …; /* dtmf detection using goertzel algorithm * init function */ void dsp_dtmf_goertzel_init(struct dsp *dsp) { … } /* check for hardware or software features */ void dsp_dtmf_hardware(struct dsp *dsp) { … } /************************************************************* * calculate the coefficients of the given sample and decode * *************************************************************/ /* the given sample is decoded. if the sample is not long enough for a * complete frame, the decoding is finished and continued with the next * call of this function. * * the algorithm is very good for detection with a minimum of errors. i * tested it allot. it even works with very short tones (40ms). the only * disadvantage is, that it doesn't work good with different volumes of both * tones. this will happen, if accoustically coupled dialers are used. * it sometimes detects tones during speech, which is normal for decoders. * use sequences to given commands during calls. * * dtmf - points to a structure of the current dtmf state * spl and len - the sample * fmt - 0 = alaw, 1 = ulaw, 2 = coefficients from HFC DTMF hw-decoder */ u8 *dsp_dtmf_goertzel_decode(struct dsp *dsp, u8 *data, int len, int fmt) { … }