00001 #ifndef DTMFFILTER_H_
00002 #define DTMFFILTER_H_
00003
00004 #include <qmap.h>
00005
00006
00007 class goertzel
00008 {
00009 public:
00010 goertzel(int N, float targetFreq, float sampleRate);
00011 ~goertzel();
00012 int process(short *samples, int length);
00013
00014 private:
00015 void checkMatch();
00016 void processOneSample(short sample);
00017 void reset();
00018 void initialise(int N, float targetFreq, float sampleRate);
00019
00020 float Q1, Q2, coeff, sine, cosine;
00021 int countToN, m_N;
00022 int Match;
00023 };
00024
00025
00026 class DtmfFilter
00027 {
00028 public:
00029 DtmfFilter();
00030 ~DtmfFilter();
00031 QChar process(short *samples, int length);
00032
00033 private:
00034 void HitCounter(int Frequency, int numHitsThisSample);
00035 QChar CheckAnyDTMF();
00036
00037 goertzel *filter_697;
00038 goertzel *filter_770;
00039 goertzel *filter_852;
00040 goertzel *filter_941;
00041 goertzel *filter_1209;
00042 goertzel *filter_1336;
00043 goertzel *filter_1477;
00044
00045 QMap<int,int> Hits;
00046 QMap<QChar, unsigned int> Debounce;
00047 };
00048
00049 #endif