Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/super_tone_rx.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 15:50:58 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
---|---|
1 /* | |
2 * SpanDSP - a series of DSP components for telephony | |
3 * | |
4 * super_tone_rx.h - Flexible telephony supervisory tone detection. | |
5 * | |
6 * Written by Steve Underwood <steveu@coppice.org> | |
7 * | |
8 * Copyright (C) 2003 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 * $Id: super_tone_rx.h,v 1.21 2009/02/10 13:06:47 steveu Exp $ | |
26 */ | |
27 | |
28 #if !defined(_SPANDSP_SUPER_TONE_RX_H_) | |
29 #define _SPANDSP_SUPER_TONE_RX_H_ | |
30 | |
31 /*! \page super_tone_rx_page Supervisory tone detection | |
32 | |
33 \section super_tone_rx_page_sec_1 What does it do? | |
34 | |
35 The supervisory tone detector may be configured to detect most of the world's | |
36 telephone supervisory tones - things like ringback, busy, number unobtainable, | |
37 and so on. | |
38 | |
39 \section super_tone_rx_page_sec_2 How does it work? | |
40 | |
41 The supervisory tone detector is passed a series of data structures describing | |
42 the tone patterns - the frequencies and cadencing - of the tones to be searched | |
43 for. It constructs one or more Goertzel filters to monitor the required tones. | |
44 If tones are close in frequency a single Goertzel set to the centre of the | |
45 frequency range will be used. This optimises the efficiency of the detector. The | |
46 Goertzel filters are applied without applying any special window functional | |
47 (i.e. they use a rectangular window), so they have a sinc like response. | |
48 However, for most tone patterns their rejection qualities are adequate. | |
49 | |
50 The detector aims to meet the need of the standard call progress tones, to | |
51 ITU-T E.180/Q.35 (busy, dial, ringback, reorder). Also, the extended tones, | |
52 to ITU-T E.180, Supplement 2 and EIA/TIA-464-A (recall dial tone, special | |
53 ringback tone, intercept tone, call waiting tone, busy verification tone, | |
54 executive override tone, confirmation tone). | |
55 */ | |
56 | |
57 /*! Tone detection indication callback routine */ | |
58 typedef void (*tone_report_func_t)(void *user_data, int code, int level, int delay); | |
59 | |
60 typedef struct super_tone_rx_segment_s super_tone_rx_segment_t; | |
61 | |
62 typedef struct super_tone_rx_descriptor_s super_tone_rx_descriptor_t; | |
63 | |
64 typedef struct super_tone_rx_state_s super_tone_rx_state_t; | |
65 | |
66 #if defined(__cplusplus) | |
67 extern "C" | |
68 { | |
69 #endif | |
70 | |
71 /*! Create a new supervisory tone detector descriptor. | |
72 \param desc The supervisory tone set desciptor. If NULL, the routine will allocate space for a | |
73 descriptor. | |
74 \return The supervisory tone set descriptor. | |
75 */ | |
76 SPAN_DECLARE(super_tone_rx_descriptor_t *) super_tone_rx_make_descriptor(super_tone_rx_descriptor_t *desc); | |
77 | |
78 /*! Free a supervisory tone detector descriptor. | |
79 \param desc The supervisory tone set desciptor. | |
80 \return 0 for OK, -1 for fail. | |
81 */ | |
82 SPAN_DECLARE(int) super_tone_rx_free_descriptor(super_tone_rx_descriptor_t *desc); | |
83 | |
84 /*! Add a new tone pattern to a supervisory tone detector set. | |
85 \param desc The supervisory tone set descriptor. | |
86 \return The new tone ID. */ | |
87 SPAN_DECLARE(int) super_tone_rx_add_tone(super_tone_rx_descriptor_t *desc); | |
88 | |
89 /*! Add a new tone pattern element to a tone pattern in a supervisory tone detector. | |
90 \param desc The supervisory tone set desciptor. | |
91 \param tone The tone ID within the descriptor. | |
92 \param f1 Frequency 1 (-1 for a silent period). | |
93 \param f2 Frequency 2 (-1 for a silent period, or only one frequency). | |
94 \param min The minimum duration, in ms. | |
95 \param max The maximum duration, in ms. | |
96 \return The new number of elements in the tone description. | |
97 */ | |
98 SPAN_DECLARE(int) super_tone_rx_add_element(super_tone_rx_descriptor_t *desc, | |
99 int tone, | |
100 int f1, | |
101 int f2, | |
102 int min, | |
103 int max); | |
104 | |
105 /*! Initialise a supervisory tone detector. | |
106 \param s The supervisory tone detector context. | |
107 \param desc The tone descriptor. | |
108 \param callback The callback routine called to report the valid detection or termination of | |
109 one of the monitored tones. | |
110 \param user_data An opaque pointer passed when calling the callback routine. | |
111 \return The supervisory tone detector context. | |
112 */ | |
113 SPAN_DECLARE(super_tone_rx_state_t *) super_tone_rx_init(super_tone_rx_state_t *s, | |
114 super_tone_rx_descriptor_t *desc, | |
115 tone_report_func_t callback, | |
116 void *user_data); | |
117 | |
118 /*! Release a supervisory tone detector. | |
119 \param s The supervisory tone context. | |
120 \return 0 for OK, -1 for fail. | |
121 */ | |
122 SPAN_DECLARE(int) super_tone_rx_release(super_tone_rx_state_t *s); | |
123 | |
124 /*! Free a supervisory tone detector. | |
125 \param s The supervisory tone context. | |
126 \return 0 for OK, -1 for fail. | |
127 */ | |
128 SPAN_DECLARE(int) super_tone_rx_free(super_tone_rx_state_t *s); | |
129 | |
130 /*! Define a callback routine to be called each time a tone pattern element is complete. This is | |
131 mostly used when analysing a tone. | |
132 \param s The supervisory tone context. | |
133 \param callback The callback routine. | |
134 */ | |
135 SPAN_DECLARE(void) super_tone_rx_segment_callback(super_tone_rx_state_t *s, | |
136 void (*callback)(void *data, int f1, int f2, int duration)); | |
137 | |
138 /*! Apply supervisory tone detection processing to a block of audio samples. | |
139 \brief Apply supervisory tone detection processing to a block of audio samples. | |
140 \param super The supervisory tone context. | |
141 \param amp The audio sample buffer. | |
142 \param samples The number of samples in the buffer. | |
143 \return The number of samples processed. | |
144 */ | |
145 SPAN_DECLARE(int) super_tone_rx(super_tone_rx_state_t *super, const int16_t amp[], int samples); | |
146 | |
147 #if defined(__cplusplus) | |
148 } | |
149 #endif | |
150 | |
151 #endif | |
152 /*- End of file ------------------------------------------------------------*/ |