comparison spandsp-0.0.3/spandsp-0.0.3/src/spandsp/tone_generate.h @ 5:f762bf195c4b

import spandsp-0.0.3
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 16:00:21 +0200
parents
children
comparison
equal deleted inserted replaced
4:26cd8f1ef0b1 5:f762bf195c4b
1 /*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * tone_generate.h - General telephony tone generation, and specific
5 * generation of Bell MF, MFC/R2 and network supervisory tones.
6 *
7 * Written by Steve Underwood <steveu@coppice.org>
8 *
9 * Copyright (C) 2001 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: tone_generate.h,v 1.24 2006/11/24 12:34:55 steveu Exp $
27 */
28
29 /*! \file */
30
31 #if !defined(_TONE_GENERATE_H_)
32 #define _TONE_GENERATE_H_
33
34 /*! \page tone_generation_page Tone generation
35 \section tone_generation_page_sec_1 What does it do?
36 The tone generation module provides for the generation of cadenced tones,
37 suitable for a wide range of telephony applications.
38
39 \section tone_generation_page_sec_2 How does it work?
40 Oscillators are a problem. They oscillate due to instability, and yet we need
41 them to behave in a stable manner. A look around the web will reveal many papers
42 on this subject. Many describe rather complex solutions to the problem. However,
43 we are only concerned with telephony applications. It is possible to generate
44 the tones we need with a very simple efficient scheme. It is also practical to
45 use an exhaustive test to prove the oscillator is stable under all the
46 conditions in which we will use it.
47 */
48
49 /*!
50 Cadenced dual tone generator descriptor.
51 */
52 typedef struct
53 {
54 int32_t phase_rate[2];
55 float gain[2];
56 int modulate;
57
58 int duration[4];
59
60 int repeat;
61 } tone_gen_descriptor_t;
62
63 /*!
64 Cadenced dual tone generator state descriptor. This defines the state of
65 a single working instance of a generator.
66 */
67 typedef struct
68 {
69 int32_t phase_rate[2];
70 float gain[2];
71 int modulate;
72
73 uint32_t phase[2];
74
75 int duration[4];
76
77 int repeat;
78
79 int current_section;
80 int current_position;
81 } tone_gen_state_t;
82
83 typedef struct
84 {
85 /*! First freq */
86 int f1;
87 /*! Second freq. 0 for none. Negative for an AM modulation tone. */
88 int f2;
89 /*! Level of the first freq (dBm0) */
90 int8_t level1;
91 /*! Level of the second freq (dBm0), or % modulation for AM */
92 int8_t level2;
93 /*! Tone on time (ms) */
94 uint16_t on_time1;
95 /*! Minimum post tone silence (ms) */
96 uint16_t off_time1;
97 /*! Tone on time (ms) */
98 uint16_t on_time2;
99 /*! Minimum post tone silence (ms) */
100 uint16_t off_time2;
101 /*! TRUE if cyclic tone, FALSE for one shot. */
102 int8_t repeat;
103 } cadenced_tone_t;
104
105 #ifdef __cplusplus
106 extern "C" {
107 #endif
108
109 void make_tone_descriptor(tone_gen_descriptor_t *desc, cadenced_tone_t *tone);
110
111 /*! Create a tone generator descriptor
112 \brief Create a tone generator descriptor
113 \param s The descriptor
114 \param f1 The first frequency, in Hz
115 \param l1 The level of the first frequency, in dBm0
116 \param f2 0 for no second frequency, a positive number for the second frequency,
117 in Hz, or a negative number for an AM modulation frequency, in Hz
118 \param l2 The level of the second frequency, in dBm0, or the percentage modulation depth
119 for an AM modulated tone.
120 \param d1 x
121 \param d2 x
122 \param d3 x
123 \param d4 x
124 \param repeat x */
125 void make_tone_gen_descriptor(tone_gen_descriptor_t *s,
126 int f1,
127 int l1,
128 int f2,
129 int l2,
130 int d1,
131 int d2,
132 int d3,
133 int d4,
134 int repeat);
135
136 void tone_gen_init(tone_gen_state_t *s, tone_gen_descriptor_t *t);
137
138 int tone_gen(tone_gen_state_t *s, int16_t amp[], int max_samples);
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif
145 /*- End of file ------------------------------------------------------------*/

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.