super_tone_tx.h

00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * super_tone_tx.h - Flexible telephony supervisory tone generation.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2001 Steve Underwood
00009  *
00010  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  *
00026  * $Id: super_tone_tx.h,v 1.5 2005/11/25 14:52:00 steveu Exp $
00027  */
00028 
00029 #if !defined(_SUPER_TONE_TX_H_)
00030 #define _SUPER_TONE_TX_H_
00031 
00032 /*! \page super_tone_tx_page Supervisory tone generation
00033 
00034 \section super_tone_tx_page_sec_1 What does it do?
00035 
00036 The supervisory tone generator may be configured to generate most of the world's
00037 telephone supervisory tones - things like ringback, busy, number unobtainable,
00038 and so on. It uses tree structure tone descriptions, which can deal with quite
00039 complex cadence patterns. 
00040 
00041 \section super_tone_tx_page_sec_2 How does it work?
00042 
00043 */
00044 
00045 typedef struct super_tone_tx_step_s super_tone_tx_step_t;
00046 
00047 typedef struct
00048 {
00049     int32_t phase_rate[2];
00050     int gain[2];
00051     uint32_t phase[2];
00052     int current_position;
00053     int level;
00054     super_tone_tx_step_t *levels[4];
00055     int cycles[4];
00056 } super_tone_tx_state_t;
00057 
00058 struct super_tone_tx_step_s
00059 {
00060     int32_t phase_rate[2];
00061     int gain[2];
00062     int tone;
00063     int length;
00064     int cycles;
00065     super_tone_tx_step_t *next;
00066     super_tone_tx_step_t *nest;
00067 };
00068 
00069 super_tone_tx_step_t *super_tone_tx_make_step(super_tone_tx_step_t *s,
00070                                               float f1,
00071                                               float l1,
00072                                               float f2,
00073                                               float l2,
00074                                               int length,
00075                                               int cycles);
00076 
00077 void super_tone_tx_free(super_tone_tx_step_t *s);
00078 
00079 /*! Initialise a supervisory tone generator.
00080     \brief Initialise a supervisory tone generator.
00081     \param s The supervisory tone generator context.
00082     \param tree The supervisory tone tree to be generated.
00083     \return The supervisory tone generator context. */
00084 super_tone_tx_state_t *super_tone_tx_init(super_tone_tx_state_t *s, super_tone_tx_step_t *tree);
00085 
00086 /*! Generate a block of audio samples for a supervisory tone pattern.
00087     \brief Generate a block of audio samples for a supervisory tone pattern.
00088     \param tone The supervisory tone context.
00089     \param amp The audio sample buffer.
00090     \param max_samples The maximum number of samples to be generated.
00091     \return The number of samples generated. */
00092 int super_tone_tx(super_tone_tx_state_t *s, int16_t amp[], int max_samples);
00093 
00094 #endif
00095 /*- End of file ------------------------------------------------------------*/

Generated on Fri Nov 10 09:40:24 2006 for libspandsp by  doxygen 1.5.1