spandsp  0.0.6
private/dtmf.h
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/dtmf.h - DTMF tone generation and detection
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2001, 2005 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 #if !defined(_SPANDSP_PRIVATE_DTMF_H_)
27 #define _SPANDSP_PRIVATE_DTMF_H_
28 
29 /*!
30  DTMF generator state descriptor. This defines the state of a single
31  working instance of a DTMF generator.
32 */
34 {
35  tone_gen_state_t tones;
36  float low_level;
37  float high_level;
38  int on_time;
39  int off_time;
40  union
41  {
42  queue_state_t queue;
43  uint8_t buf[QUEUE_STATE_T_SIZE(MAX_DTMF_DIGITS)];
44  } queue;
45 };
46 
47 /*!
48  DTMF digit detector descriptor.
49 */
51 {
52  /*! Optional callback funcion to deliver received digits. */
53  digits_rx_callback_t digits_callback;
54  /*! An opaque pointer passed to the callback function. */
56  /*! Optional callback funcion to deliver real time digit state changes. */
57  tone_report_func_t realtime_callback;
58  /*! An opaque pointer passed to the real time callback function. */
60  /*! TRUE if dialtone should be filtered before processing */
62 #if defined(SPANDSP_USE_FIXED_POINT)
63  /*! 350Hz filter state for the optional dialtone filter. */
64  float z350[2];
65  /*! 440Hz filter state for the optional dialtone filter. */
66  float z440[2];
67  /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
68  float normal_twist;
69  /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
70  float reverse_twist;
71  /*! Minimum acceptable tone level for detection. */
72  int32_t threshold;
73  /*! The accumlating total energy on the same period over which the Goertzels work. */
74  int32_t energy;
75 #else
76  /*! 350Hz filter state for the optional dialtone filter. */
77  float z350[2];
78  /*! 440Hz filter state for the optional dialtone filter. */
79  float z440[2];
80  /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
81  float normal_twist;
82  /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
84  /*! Minimum acceptable tone level for detection. */
85  float threshold;
86  /*! The accumlating total energy on the same period over which the Goertzels work. */
87  float energy;
88 #endif
89  /*! Tone detector working states for the row tones. */
90  goertzel_state_t row_out[4];
91  /*! Tone detector working states for the column tones. */
92  goertzel_state_t col_out[4];
93  /*! The result of the last tone analysis. */
94  uint8_t last_hit;
95  /*! The confirmed digit we are currently receiving */
96  uint8_t in_digit;
97  /*! The current sample number within a processing block. */
99 
100  /*! Tone state duration */
101  int duration;
102 
103  /*! The number of digits which have been lost due to buffer overflows. */
105  /*! The number of digits currently in the digit buffer. */
107  /*! The received digits buffer. This is a NULL terminated string. */
108  char digits[MAX_DTMF_DIGITS + 1];
109 
110  /*! \brief Error and flow logging control */
112 };
113 
114 #endif
115 /*- End of file ------------------------------------------------------------*/
Definition: private/queue.h:33
void * digits_callback_data
Definition: private/dtmf.h:55
Definition: private/dtmf.h:50
int current_sample
Definition: private/dtmf.h:98
int filter_dialtone
Definition: private/dtmf.h:61
Definition: private/tone_generate.h:53
void * realtime_callback_data
Definition: private/dtmf.h:59
Definition: private/dtmf.h:33
uint8_t in_digit
Definition: private/dtmf.h:96
float normal_twist
Definition: private/dtmf.h:81
int current_digits
Definition: private/dtmf.h:106
float threshold
Definition: private/dtmf.h:85
logging_state_t logging
Error and flow logging control.
Definition: private/dtmf.h:111
float energy
Definition: private/dtmf.h:87
uint8_t last_hit
Definition: private/dtmf.h:94
digits_rx_callback_t digits_callback
Definition: private/dtmf.h:53
float reverse_twist
Definition: private/dtmf.h:83
Definition: private/logging.h:33
Definition: tone_detect.h:45
tone_report_func_t realtime_callback
Definition: private/dtmf.h:57
int duration
Definition: private/dtmf.h:101
int lost_digits
Definition: private/dtmf.h:104