spandsp  3.0.0
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  /*! Optional callback funcion to get more digits. */
36  digits_tx_callback_t callback;
37  /*! An opaque pointer passed to the callback function. */
39  tone_gen_state_t tones;
40  float low_level;
41  float high_level;
42  int on_time;
43  int off_time;
44  union
45  {
46  queue_state_t queue;
47  uint8_t buf[QUEUE_STATE_T_SIZE(MAX_DTMF_DIGITS)];
48  } queue;
49 };
50 
51 /*!
52  DTMF digit detector descriptor.
53 */
55 {
56  /*! Optional callback funcion to deliver received digits. */
57  digits_rx_callback_t digits_callback;
58  /*! An opaque pointer passed to the callback function. */
60  /*! Optional callback funcion to deliver real time digit state changes. */
61  tone_report_func_t realtime_callback;
62  /*! An opaque pointer passed to the real time callback function. */
64  /*! True if dialtone should be filtered before processing */
66 #if defined(SPANDSP_USE_FIXED_POINT)
67  /*! 350Hz filter state for the optional dialtone filter. */
68  float z350[2];
69  /*! 440Hz filter state for the optional dialtone filter. */
70  float z440[2];
71  /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
72  float normal_twist;
73  /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
74  float reverse_twist;
75  /*! Minimum acceptable tone level for detection. */
76  int32_t threshold;
77  /*! The accumlating total energy on the same period over which the Goertzels work. */
78  int32_t energy;
79 #else
80  /*! 350Hz filter state for the optional dialtone filter. */
81  float z350[2];
82  /*! 440Hz filter state for the optional dialtone filter. */
83  float z440[2];
84  /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
85  float normal_twist;
86  /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
88  /*! Minimum acceptable tone level for detection. */
89  float threshold;
90  /*! The accumlating total energy on the same period over which the Goertzels work. */
91  float energy;
92 #endif
93  /*! Tone detector working states for the row tones. */
95  /*! Tone detector working states for the column tones. */
97  /*! The result of the last tone analysis. */
98  uint8_t last_hit;
99  /*! The confirmed digit we are currently receiving */
100  uint8_t in_digit;
101  /*! The current sample number within a processing block. */
103 
104  /*! Tone state duration */
105  int duration;
106 
107  /*! The number of digits which have been lost due to buffer overflows. */
109  /*! The number of digits currently in the digit buffer. */
111  /*! The received digits buffer. This is a NULL terminated string. */
112  char digits[MAX_DTMF_DIGITS + 1];
113 
114  /*! \brief Error and flow logging control */
116 };
117 
118 #endif
119 /*- End of file ------------------------------------------------------------*/
Definition: private/dtmf.h:55
float z350[2]
Definition: private/dtmf.h:81
float reverse_twist
Definition: private/dtmf.h:87
float threshold
Definition: private/dtmf.h:89
bool filter_dialtone
Definition: private/dtmf.h:65
tone_report_func_t realtime_callback
Definition: private/dtmf.h:61
goertzel_state_t row_out[4]
Definition: private/dtmf.h:94
void * digits_callback_data
Definition: private/dtmf.h:59
goertzel_state_t col_out[4]
Definition: private/dtmf.h:96
uint8_t last_hit
Definition: private/dtmf.h:98
int current_digits
Definition: private/dtmf.h:110
int current_sample
Definition: private/dtmf.h:102
logging_state_t logging
Error and flow logging control.
Definition: private/dtmf.h:115
int lost_digits
Definition: private/dtmf.h:108
float z440[2]
Definition: private/dtmf.h:83
float energy
Definition: private/dtmf.h:91
uint8_t in_digit
Definition: private/dtmf.h:100
float normal_twist
Definition: private/dtmf.h:85
void * realtime_callback_data
Definition: private/dtmf.h:63
int duration
Definition: private/dtmf.h:105
char digits[MAX_DTMF_DIGITS+1]
Definition: private/dtmf.h:112
digits_rx_callback_t digits_callback
Definition: private/dtmf.h:57
Definition: private/dtmf.h:34
digits_tx_callback_t callback
Definition: private/dtmf.h:36
void * callback_data
Definition: private/dtmf.h:38
Definition: tone_detect.h:46
Definition: private/logging.h:34
Definition: private/queue.h:34
Definition: private/tone_generate.h:54