sipxmedialib  Version 3.3
MpDTMFDetector.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2007 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2007 SIPez LLC.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 // Author: Keith Kyzivat <kkyzivat AT SIPez DOT com>
12 
13 #ifndef _MpDTMFDetector_h_
14 #define _MpDTMFDetector_h_
15 
16 // SYSTEM INCLUDES
17 // APPLICATION INCLUDES
18 #include <os/OsIntTypes.h>
19 #include <mp/MpTypes.h>
20 #include <utl/UtlDefs.h> // UtlBoolean
21 
22 // DEFINES
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 // MACROS
29 // FORWARD DECLARATIONS
30 
56 {
57 /* //////////////////////////// PUBLIC //////////////////////////////////// */
58 public:
59 /* ============================ CREATORS ================================== */
61 
62 
64  MpDtmfDetector(const unsigned samplesPerSec, const unsigned nProcessSamples);
65 
67  virtual ~MpDtmfDetector();
68 
70 
71 /* ============================ MANIPULATORS ============================== */
73 
74 
76  void reset();
81  void setSamplesPerSec(const unsigned samplesPerSec);
89  void setNumProcessSamples(const unsigned nProcessSamples);
103  UtlBoolean processSample(const MpAudioSample sample);
118 
119 /* ============================ ACCESSORS ================================= */
121 
122 
124  unsigned getSamplesPerSec() const;
125 
127  unsigned getNumProcessSamples() const;
128 
130  char getLastDetectedDTMF() const;
144 
145 /* ============================ INQUIRY =================================== */
147 
148 
150 
151 /* //////////////////////////// PROTECTED ///////////////////////////////// */
152 protected:
153 
154 /* //////////////////////////// PRIVATE /////////////////////////////////// */
155 private:
157  void calcCoeffs();
170  void dtmfValidation();
178 private:
179  unsigned mSamplesPerSec;
181  uint32_t mSampleCount;
182 
183  static double sFreqs_to_detect[];
184  static uint8_t snFreqsToDetect;
185 
186  double* mQ1;
187  double* mQ2;
188  double* mR;
189 
190  double* mCoefs;
191 
193 };
194 
195 /* ============================ INLINE METHODS ============================ */
196 
197 #endif // _MpDTMFDetector_h_
char mLastDetectedDTMF
Definition: MpDTMFDetector.h:192
unsigned getNumProcessSamples() const
Get the number of samples that this detector uses to determine frequencies on.
Definition: MpDTMFDetector.cpp:121
double * mQ2
Definition: MpDTMFDetector.h:187
double * mR
Definition: MpDTMFDetector.h:188
MpDtmfDetector(const unsigned samplesPerSec, const unsigned nProcessSamples)
Default constructor.
Definition: MpDTMFDetector.cpp:35
char getLastDetectedDTMF() const
Get the last DTMF tone that the detector detected.
Definition: MpDTMFDetector.cpp:126
void calcCoeffs()
Calculate coefficients needed for the goertzel algorithm.
Definition: MpDTMFDetector.cpp:137
double * mCoefs
Definition: MpDTMFDetector.h:190
UtlBoolean processSample(const MpAudioSample sample)
Process a sample through the detector.
Definition: MpDTMFDetector.cpp:85
unsigned getSamplesPerSec() const
Get the sample rate.
Definition: MpDTMFDetector.cpp:116
static uint8_t snFreqsToDetect
Definition: MpDTMFDetector.h:184
int16_t MpAudioSample
Definition: MpTypes.h:44
void dtmfValidation()
Validate the detected frequencies detected by processSample.
Definition: MpDTMFDetector.cpp:147
unsigned mSamplesPerSec
Definition: MpDTMFDetector.h:179
A simple DTMF detector class that uses the Goertzel algorithm.
Definition: MpDTMFDetector.h:55
static double sFreqs_to_detect[]
Definition: MpDTMFDetector.h:183
void reset()
Reset the state of the detector.
Definition: MpDTMFDetector.cpp:57
unsigned mNumProcessSamples
Definition: MpDTMFDetector.h:180
void setNumProcessSamples(const unsigned nProcessSamples)
Set the number of samples to use to detect frequencies on.
Definition: MpDTMFDetector.cpp:80
virtual ~MpDtmfDetector()
Destructor.
Definition: MpDTMFDetector.cpp:47
void setSamplesPerSec(const unsigned samplesPerSec)
Set the sample rate.
Definition: MpDTMFDetector.cpp:74
double * mQ1
Definition: MpDTMFDetector.h:186
uint32_t mSampleCount
Definition: MpDTMFDetector.h:181