5
|
1 /*
|
|
2 * SpanDSP - a series of DSP components for telephony
|
|
3 *
|
|
4 * modem_connect_tones.c - Generation and detection of tones
|
|
5 * associated with modems calling and answering calls.
|
|
6 *
|
|
7 * Written by Steve Underwood <steveu@coppice.org>
|
|
8 *
|
|
9 * Copyright (C) 2006 Steve Underwood
|
|
10 *
|
|
11 * All rights reserved.
|
|
12 *
|
|
13 * This program is free software; you can redistribute it and/or modify
|
|
14 * it under the terms of the GNU General Public License version 2, as
|
|
15 * published by the Free Software Foundation.
|
|
16 *
|
|
17 * This program is distributed in the hope that it will be useful,
|
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
20 * GNU General Public License for more details.
|
|
21 *
|
|
22 * You should have received a copy of the GNU General Public License
|
|
23 * along with this program; if not, write to the Free Software
|
|
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
25 *
|
|
26 * $Id: modem_connect_tones.h,v 1.4 2006/10/24 13:45:28 steveu Exp $
|
|
27 */
|
|
28
|
|
29 /*! \file */
|
|
30
|
|
31 #if !defined(_MODEM_CONNECT_TONES_H_)
|
|
32 #define _MODEM_CONNECT_TONES_H_
|
|
33
|
|
34 /*! \page modem_connect_tones_page Echo cancellor disable tone detection
|
|
35
|
|
36 \section modem_connect_tones_page_sec_1 What does it do?
|
|
37 Some telephony terminal equipment, such as modems, require a channel which is as
|
|
38 clear as possible. They use their own echo cancellation. If the network is also
|
|
39 performing echo cancellation the two cancellors can end of squabbling about the
|
|
40 nature of the channel, with bad results. A special tone is defined which should
|
|
41 cause the network to disable any echo cancellation processes.
|
|
42
|
|
43 \section modem_connect_tones_page_sec_2 How does it work?
|
|
44 A sharp notch filter is implemented as a single bi-quad section. The presence of
|
|
45 the 2100Hz disable tone is detected by comparing the notched filtered energy
|
|
46 with the unfiltered energy. If the notch filtered energy is much lower than the
|
|
47 unfiltered energy, then a large proportion of the energy must be at the notch
|
|
48 frequency. This type of detector may seem less intuitive than using a narrow
|
|
49 bandpass filter to isolate the energy at the notch freqency. However, a sharp
|
|
50 bandpass implemented as an IIR filter rings badly, The reciprocal notch filter
|
|
51 is very well behaved.
|
|
52 */
|
|
53
|
|
54 enum
|
|
55 {
|
|
56 MODEM_CONNECT_TONES_FAX_CNG,
|
|
57 MODEM_CONNECT_TONES_FAX_CED,
|
|
58 MODEM_CONNECT_TONES_EC_DISABLE,
|
|
59 /*! \brief The version of EC disable with some 15Hz AM content, as in V.8 */
|
|
60 MODEM_CONNECT_TONES_EC_DISABLE_MOD,
|
|
61 };
|
|
62
|
|
63 /*!
|
|
64 Modem connect tones generator descriptor. This defines the state
|
|
65 of a single working instance of the tone generator.
|
|
66 */
|
|
67 typedef struct
|
|
68 {
|
|
69 int tone_type;
|
|
70
|
|
71 tone_gen_state_t tone_tx;
|
|
72 uint32_t tone_phase;
|
|
73 int32_t tone_phase_rate;
|
|
74 int level;
|
|
75 /*! \brief Countdown to the next phase hop */
|
|
76 int hop_timer;
|
|
77 uint32_t mod_phase;
|
|
78 int32_t mod_phase_rate;
|
|
79 int mod_level;
|
|
80 } modem_connect_tones_tx_state_t;
|
|
81
|
|
82 /*!
|
|
83 Modem connect tones receiver descriptor. This defines the state
|
|
84 of a single working instance of the tone detector.
|
|
85 */
|
|
86 typedef struct
|
|
87 {
|
|
88 int tone_type;
|
|
89 tone_report_func_t tone_callback;
|
|
90 void *callback_data;
|
|
91
|
|
92 float z1;
|
|
93 float z2;
|
|
94 int notch_level;
|
|
95 int channel_level;
|
|
96 int tone_present;
|
|
97 int tone_cycle_duration;
|
|
98 int good_cycles;
|
|
99 int hit;
|
|
100 } modem_connect_tones_rx_state_t;
|
|
101
|
|
102 #ifdef __cplusplus
|
|
103 extern "C" {
|
|
104 #endif
|
|
105
|
|
106 /*! \brief Initialse an instance of the echo canceller disable tone generator.
|
|
107 \param s The context.
|
|
108 */
|
|
109 modem_connect_tones_tx_state_t *modem_connect_tones_tx_init(modem_connect_tones_tx_state_t *s,
|
|
110 int tone_type);
|
|
111
|
|
112 /*! \brief Generate a block of echo canceller disable tone samples.
|
|
113 \param s The context.
|
|
114 \param amp An array of signal samples.
|
|
115 \param len The number of samples to generate.
|
|
116 \return The number of samples generated.
|
|
117 */
|
|
118 int modem_connect_tones_tx(modem_connect_tones_tx_state_t *s,
|
|
119 int16_t amp[],
|
|
120 int len);
|
|
121
|
|
122 /*! \brief Process a block of samples through an instance of the modem_connect
|
|
123 tones detector.
|
|
124 \param s The context.
|
|
125 \param amp An array of signal samples.
|
|
126 \param len The number of samples in the array.
|
|
127 \return The number of unprocessed samples.
|
|
128 */
|
|
129 int modem_connect_tones_rx(modem_connect_tones_rx_state_t *s,
|
|
130 const int16_t amp[],
|
|
131 int len);
|
|
132
|
|
133 /*! \brief Test if a modem_connect tone has been detected.
|
|
134 \param s The context.
|
|
135 \return TRUE if tone is detected, else FALSE.
|
|
136 */
|
|
137 int modem_connect_tones_rx_get(modem_connect_tones_rx_state_t *s);
|
|
138
|
|
139 /*! \brief Initialise an instance of the modem_connect tones detector.
|
|
140 \param s The context.
|
|
141 \param tone_type The type of connect tone being tested for.
|
|
142 \param tone_callback An optional callback routine, used to report tones
|
|
143 \param user_data An opaque pointer passed to the callback routine,
|
|
144 \return A pointer to the context.
|
|
145 */
|
|
146 modem_connect_tones_rx_state_t *modem_connect_tones_rx_init(modem_connect_tones_rx_state_t *s,
|
|
147 int tone_type,
|
|
148 tone_report_func_t tone_callback,
|
|
149 void *user_data);
|
|
150
|
|
151 #ifdef __cplusplus
|
|
152 }
|
|
153 #endif
|
|
154
|
|
155 #endif
|
|
156 /*- End of file ------------------------------------------------------------*/
|