Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/tone_generate.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 * tone_generate.h - General telephony tone generation. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2001 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: tone_generate.h,v 1.39 2009/06/02 16:03:56 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if !defined(_SPANDSP_TONE_GENERATE_H_) | |
| 31 #define _SPANDSP_TONE_GENERATE_H_ | |
| 32 | |
| 33 /*! \page tone_generation_page Tone generation | |
| 34 \section tone_generation_page_sec_1 What does it do? | |
| 35 The tone generation module provides for the generation of cadenced tones, | |
| 36 suitable for a wide range of telephony applications. | |
| 37 | |
| 38 \section tone_generation_page_sec_2 How does it work? | |
| 39 Oscillators are a problem. They oscillate due to instability, and yet we need | |
| 40 them to behave in a stable manner. A look around the web will reveal many papers | |
| 41 on this subject. Many describe rather complex solutions to the problem. However, | |
| 42 we are only concerned with telephony applications. It is possible to generate | |
| 43 the tones we need with a very simple efficient scheme. It is also practical to | |
| 44 use an exhaustive test to prove the oscillator is stable under all the | |
| 45 conditions in which we will use it. | |
| 46 */ | |
| 47 | |
| 48 typedef struct tone_gen_tone_descriptor_s tone_gen_tone_descriptor_t; | |
| 49 | |
| 50 /*! | |
| 51 Cadenced multi-tone generator descriptor. | |
| 52 */ | |
| 53 typedef struct tone_gen_descriptor_s tone_gen_descriptor_t; | |
| 54 | |
| 55 /*! | |
| 56 Cadenced multi-tone generator state descriptor. This defines the state of | |
| 57 a single working instance of a generator. | |
| 58 */ | |
| 59 typedef struct tone_gen_state_s tone_gen_state_t; | |
| 60 | |
| 61 #if defined(__cplusplus) | |
| 62 extern "C" | |
| 63 { | |
| 64 #endif | |
| 65 | |
| 66 /*! Create a tone generator descriptor | |
| 67 \brief Create a tone generator descriptor | |
| 68 \param s The descriptor | |
| 69 \param f1 The first frequency, in Hz | |
| 70 \param l1 The level of the first frequency, in dBm0 | |
| 71 \param f2 0 for no second frequency, a positive number for the second frequency, | |
| 72 in Hz, or a negative number for an AM modulation frequency, in Hz | |
| 73 \param l2 The level of the second frequency, in dBm0, or the percentage modulation depth | |
| 74 for an AM modulated tone. | |
| 75 \param d1 x | |
| 76 \param d2 x | |
| 77 \param d3 x | |
| 78 \param d4 x | |
| 79 \param repeat x */ | |
| 80 SPAN_DECLARE(void) make_tone_gen_descriptor(tone_gen_descriptor_t *s, | |
| 81 int f1, | |
| 82 int l1, | |
| 83 int f2, | |
| 84 int l2, | |
| 85 int d1, | |
| 86 int d2, | |
| 87 int d3, | |
| 88 int d4, | |
| 89 int repeat); | |
| 90 | |
| 91 SPAN_DECLARE_NONSTD(int) tone_gen(tone_gen_state_t *s, int16_t amp[], int max_samples); | |
| 92 | |
| 93 SPAN_DECLARE(tone_gen_state_t *) tone_gen_init(tone_gen_state_t *s, tone_gen_descriptor_t *t); | |
| 94 | |
| 95 SPAN_DECLARE(int) tone_gen_release(tone_gen_state_t *s); | |
| 96 | |
| 97 SPAN_DECLARE(int) tone_gen_free(tone_gen_state_t *s); | |
| 98 | |
| 99 #if defined(__cplusplus) | |
| 100 } | |
| 101 #endif | |
| 102 | |
| 103 #endif | |
| 104 /*- End of file ------------------------------------------------------------*/ |
