10
10
* All rights reserved.
12
12
* This program is free software; you can redistribute it and/or modify
13
* it under the terms of the GNU General Public License version 2, as
14
* published by the Free Software Foundation.
13
* it under the terms of the GNU Lesser General Public License version 2.1,
14
* as published by the Free Software Foundation.
16
16
* This program is distributed in the hope that it will be useful,
17
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
19
* GNU Lesser General Public License for more details.
21
* You should have received a copy of the GNU General Public License
22
* along with this program; if not, write to the Free Software
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
23
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
* $Id: dtmf.h,v 1.18 2007/12/20 11:11:16 steveu Exp $
25
* $Id: dtmf.h,v 1.28 2008/06/13 14:46:52 steveu Exp $
28
28
#if !defined(_SPANDSP_DTMF_H_)
44
44
exist. If you do need good dial tone tolerance, a dial tone filter can be
45
45
enabled in the detector.
47
The DTMF receiver's design assumes the channel is free of any DC component.
47
49
\section dtmf_rx_page_sec_2 How does it work?
48
50
Like most other DSP based DTMF detector's, this one uses the Goertzel algorithm
49
51
to look for the DTMF tones. What makes each detector design different is just how
74
76
#define MAX_DTMF_DIGITS 128
76
typedef void (*dtmf_rx_callback_t)(void *user_data, const char *digits, int len);
78
typedef void (*digits_rx_callback_t)(void *user_data, const char *digits, int len);
79
81
DTMF generator state descriptor. This defines the state of a single
96
103
/*! Optional callback funcion to deliver received digits. */
97
dtmf_rx_callback_t callback;
104
digits_rx_callback_t digits_callback;
98
105
/*! An opaque pointer passed to the callback function. */
106
void *digits_callback_data;
100
107
/*! Optional callback funcion to deliver real time digit state changes. */
101
108
tone_report_func_t realtime_callback;
102
109
/*! An opaque pointer passed to the real time callback function. */
103
110
void *realtime_callback_data;
104
111
/*! TRUE if dialtone should be filtered before processing */
105
112
int filter_dialtone;
106
/*! Maximum acceptable "normal" (lower bigger than higher) twist ratio */
108
/*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio */
111
/*! 350Hz filter state for the optional dialtone filter */
113
/*! 440Hz filter state for the optional dialtone filter */
113
#if defined(SPANDSP_USE_FIXED_POINT)
114
/*! 350Hz filter state for the optional dialtone filter. */
116
/*! 440Hz filter state for the optional dialtone filter. */
118
/*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
120
/*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
122
/*! Minimum acceptable tone level for detection. */
124
/*! The accumlating total energy on the same period over which the Goertzels work. */
127
/*! 350Hz filter state for the optional dialtone filter. */
129
/*! 440Hz filter state for the optional dialtone filter. */
131
/*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
133
/*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
135
/*! Minimum acceptable tone level for detection. */
137
/*! The accumlating total energy on the same period over which the Goertzels work. */
116
140
/*! Tone detector working states for the row tones. */
117
141
goertzel_state_t row_out[4];
118
142
/*! Tone detector working states for the column tones. */
119
143
goertzel_state_t col_out[4];
120
/*! The accumlating total energy on the same period over which the Goertzels work. */
122
144
/*! The result of the last tone analysis. */
123
145
uint8_t last_hit;
124
146
/*! The confirmed digit we are currently receiving */
154
176
assumed to be a NULL terminated string.
155
177
\return The number of digits actually added. This may be less than the
156
178
length of the digit string, if the buffer fills up. */
157
size_t dtmf_tx_put(dtmf_tx_state_t *s, const char *digits, ssize_t len);
179
size_t dtmf_tx_put(dtmf_tx_state_t *s, const char *digits, int len);
159
181
/*! \brief Change the transmit level for a DTMF tone generator context.
160
182
\param s The DTMF generator context.
162
184
\param twist The twist, in dB. */
163
185
void dtmf_tx_set_level(dtmf_tx_state_t *s, int level, int twist);
187
/*! \brief Change the transmit on and off time for a DTMF tone generator context.
188
\param s The DTMF generator context.
189
\param on-time The on time, in ms.
190
\param off_time The off time, in ms. */
191
void dtmf_tx_set_timing(dtmf_tx_state_t *s, int on_time, int off_time);
165
193
/*! \brief Initialise a DTMF tone generator context.
166
194
\param s The DTMF generator context.
167
195
\return A pointer to the DTMF generator context. */
190
218
\param filter_dialtone TRUE to enable filtering of dialtone, FALSE
191
219
to disable, < 0 to leave unchanged.
192
220
\param twist Acceptable twist, in dB. < 0 to leave unchanged.
193
\param reverse_twist Acceptable reverse twist, in dB. < 0 to leave unchanged. */
194
void dtmf_rx_parms(dtmf_rx_state_t *s, int filter_dialtone, int twist, int reverse_twist);
221
\param reverse_twist Acceptable reverse twist, in dB. < 0 to leave unchanged.
222
\param threshold The minimum acceptable tone level for detection, in dBm0.
223
<= -99 to leave unchanged. */
224
void dtmf_rx_parms(dtmf_rx_state_t *s,
196
230
/*! Process a block of received DTMF audio samples.
197
231
\brief Process a block of received DTMF audio samples.
226
260
and supplied in callbacks.
227
261
\return A pointer to the DTMF receiver context. */
228
262
dtmf_rx_state_t *dtmf_rx_init(dtmf_rx_state_t *s,
229
dtmf_rx_callback_t callback,
263
digits_rx_callback_t callback,
230
264
void *user_data);
232
266
/*! \brief Free a DTMF receiver context.