~ubuntu-branches/ubuntu/natty/iaxmodem/natty

« back to all changes in this revision

Viewing changes to lib/spandsp/src/spandsp/dtmf.h

  • Committer: Bazaar Package Importer
  • Author(s): Julien BLACHE
  • Date: 2009-02-22 11:56:35 UTC
  • mfrom: (1.1.10 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090222115635-kq7jy99yu2r8wtzv
Tags: 1.2.0~dfsg-1
* New upstream release.

* debian/rules:
  + Check that lib/spandsp/src/spandsp/mmx.h does not exist prior to build;
    just in case the header would reappear in the future.

* debian/patches/01_seteuid_setegid_ordering.dpatch:
  + Removed; merged upstream.
* debian/patches/11_build_configure-stamp.dpatch:
  + Updated; do not link unneeded libraries.
* debian/patches/10_replacement_spandsp_mmx_h.dpatch:
  + Removed; not needed as the header is not shipped anymore and is not
    needed for a successful build.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 * All rights reserved.
11
11
 *
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.
15
15
 *
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.
20
20
 *
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.
24
24
 *
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 $
26
26
 */
27
27
 
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.
46
46
 
 
47
The DTMF receiver's design assumes the channel is free of any DC component.
 
48
 
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
73
75
 
74
76
#define MAX_DTMF_DIGITS 128
75
77
 
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);
77
79
 
78
80
/*!
79
81
    DTMF generator state descriptor. This defines the state of a single
82
84
typedef struct
83
85
{
84
86
    tone_gen_state_t tones;
85
 
    int current_sample;
86
 
    /* The queue structure MUST be followed immediately by the buffer */
87
 
    queue_state_t queue;
88
 
    char digits[MAX_DTMF_DIGITS + 1];
 
87
    float low_level;
 
88
    float high_level;
 
89
    int on_time;
 
90
    int off_time;
 
91
    union
 
92
    {
 
93
        queue_state_t queue;
 
94
        uint8_t buf[QUEUE_STATE_T_SIZE(MAX_DTMF_DIGITS)];
 
95
    } queue;
89
96
} dtmf_tx_state_t;
90
97
 
91
98
/*!
94
101
typedef struct
95
102
{
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. */
99
 
    void *callback_data;
 
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 */
107
 
    float normal_twist;
108
 
    /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio */
109
 
    float reverse_twist;
110
 
 
111
 
    /*! 350Hz filter state for the optional dialtone filter */
112
 
    float z350[2];
113
 
    /*! 440Hz filter state for the optional dialtone filter */
114
 
    float z440[2];
115
 
 
 
113
#if defined(SPANDSP_USE_FIXED_POINT)
 
114
    /*! 350Hz filter state for the optional dialtone filter. */
 
115
    float z350[2];
 
116
    /*! 440Hz filter state for the optional dialtone filter. */
 
117
    float z440[2];
 
118
    /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
 
119
    float normal_twist;
 
120
    /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
 
121
    float reverse_twist;
 
122
    /*! Minimum acceptable tone level for detection. */
 
123
    int32_t threshold;
 
124
    /*! The accumlating total energy on the same period over which the Goertzels work. */
 
125
    int32_t energy;
 
126
#else
 
127
    /*! 350Hz filter state for the optional dialtone filter. */
 
128
    float z350[2];
 
129
    /*! 440Hz filter state for the optional dialtone filter. */
 
130
    float z440[2];
 
131
    /*! Maximum acceptable "normal" (lower bigger than higher) twist ratio. */
 
132
    float normal_twist;
 
133
    /*! Maximum acceptable "reverse" (higher bigger than lower) twist ratio. */
 
134
    float reverse_twist;
 
135
    /*! Minimum acceptable tone level for detection. */
 
136
    float threshold;
 
137
    /*! The accumlating total energy on the same period over which the Goertzels work. */
 
138
    float energy;
 
139
#endif
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. */
121
 
    float energy;
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);
158
180
 
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);
164
186
 
 
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);
 
192
 
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,
 
225
                   int filter_dialtone,
 
226
                   int twist,
 
227
                   int reverse_twist,
 
228
                   int threshold);
195
229
 
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);
231
265
 
232
266
/*! \brief Free a DTMF receiver context.