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